diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 290f84e2030..0279eec6987 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -4349,6 +4349,7 @@
android:exported="true">
+
diff --git a/res/layout/apps_filter_spinner.xml b/res/layout/apps_filter_spinner.xml
index 1de570528be..fcdcb5e8756 100644
--- a/res/layout/apps_filter_spinner.xml
+++ b/res/layout/apps_filter_spinner.xml
@@ -21,13 +21,11 @@
android:layout_height="wrap_content"
android:background="@android:color/transparent">
-
-
-
diff --git a/res/layout/tare_dropdown_page.xml b/res/layout/tare_dropdown_page.xml
index 79931e88938..674b189912d 100644
--- a/res/layout/tare_dropdown_page.xml
+++ b/res/layout/tare_dropdown_page.xml
@@ -6,15 +6,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".development.tare.DropdownActivity">
-
+ android:theme="@style/Widget.PopupWindow.Settings" />
+ android:text="@string/tare_revert"
+ style="@style/ActionPrimaryButton" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bf76bb87211..9d868cbe4ea 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -13332,7 +13332,7 @@
Show wallet
- Allow access to wallet from lock screen and quick settings
+ Allow access to wallet from lock screen
Show QR scanner
diff --git a/src/com/android/settings/applications/ProcessStatsBase.java b/src/com/android/settings/applications/ProcessStatsBase.java
index 67fc4c1eb3f..ce1453ff635 100644
--- a/src/com/android/settings/applications/ProcessStatsBase.java
+++ b/src/com/android/settings/applications/ProcessStatsBase.java
@@ -30,7 +30,7 @@ import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.ProcStatsData.MemInfo;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.core.instrumentation.Instrumentable;
-import com.android.settingslib.widget.settingsspinner.SettingsSpinnerAdapter;
+import com.android.settingslib.widget.SettingsSpinnerAdapter;
public abstract class ProcessStatsBase extends SettingsPreferenceFragment
implements OnItemSelectedListener {
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 0c1270621c1..a6ce6fbeb84 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -135,7 +135,7 @@ import com.android.settingslib.applications.ApplicationsState.CompoundFilter;
import com.android.settingslib.applications.ApplicationsState.VolumeFilter;
import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
import com.android.settingslib.utils.ThreadUtils;
-import com.android.settingslib.widget.settingsspinner.SettingsSpinnerAdapter;
+import com.android.settingslib.widget.SettingsSpinnerAdapter;
import com.google.android.material.appbar.AppBarLayout;
diff --git a/src/com/android/settings/datausage/CycleAdapter.java b/src/com/android/settings/datausage/CycleAdapter.java
index 1292d001435..2cabd8de452 100644
--- a/src/com/android/settings/datausage/CycleAdapter.java
+++ b/src/com/android/settings/datausage/CycleAdapter.java
@@ -27,7 +27,7 @@ import com.android.net.module.util.NetworkStatsUtils;
import com.android.settings.Utils;
import com.android.settingslib.net.ChartData;
import com.android.settingslib.net.NetworkCycleData;
-import com.android.settingslib.widget.settingsspinner.SettingsSpinnerAdapter;
+import com.android.settingslib.widget.SettingsSpinnerAdapter;
import java.time.ZonedDateTime;
import java.util.Iterator;
diff --git a/src/com/android/settings/datausage/SpinnerPreference.java b/src/com/android/settings/datausage/SpinnerPreference.java
index 67298a14bb6..867930baa97 100644
--- a/src/com/android/settings/datausage/SpinnerPreference.java
+++ b/src/com/android/settings/datausage/SpinnerPreference.java
@@ -18,12 +18,12 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
+import android.widget.Spinner;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
-import com.android.settingslib.widget.settingsspinner.SettingsSpinner;
public class SpinnerPreference extends Preference implements CycleAdapter.SpinnerInterface {
@@ -63,7 +63,7 @@ public class SpinnerPreference extends Preference implements CycleAdapter.Spinne
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- SettingsSpinner spinner = (SettingsSpinner) holder.findViewById(R.id.cycles_spinner);
+ Spinner spinner = (Spinner) holder.findViewById(R.id.cycles_spinner);
spinner.setAdapter(mAdapter);
spinner.setSelection(mPosition);
spinner.setOnItemSelectedListener(mOnSelectedListener);
diff --git a/src/com/android/settings/development/tare/DropdownActivity.java b/src/com/android/settings/development/tare/DropdownActivity.java
index c1a11fa7e3e..55f1fec0585 100644
--- a/src/com/android/settings/development/tare/DropdownActivity.java
+++ b/src/com/android/settings/development/tare/DropdownActivity.java
@@ -26,6 +26,7 @@ import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.android.settings.R;
+import com.android.settingslib.widget.SettingsSpinnerAdapter;
/**
* Dropdown activity to allow for the user to easily switch between the different TARE
@@ -58,9 +59,8 @@ public class DropdownActivity extends Activity {
String[] policies = getResources().getStringArray(R.array.tare_policies);
- ArrayAdapter arrayAdapter = new ArrayAdapter<>(DropdownActivity.this,
- android.R.layout.simple_list_item_1, policies);
- arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ ArrayAdapter arrayAdapter = new SettingsSpinnerAdapter(this);
+ arrayAdapter.addAll(policies);
mSpinner.setAdapter(arrayAdapter);
mSpinner.setSelection(policy);
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
index 5d5a2a58194..d972575983a 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSelectionPreferenceController.java
@@ -26,8 +26,8 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.widget.SettingsSpinnerAdapter;
import com.android.settingslib.widget.SettingsSpinnerPreference;
-import com.android.settingslib.widget.settingsspinner.SettingsSpinnerAdapter;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiver.java b/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiver.java
index 0fd0c0dee22..bdc52ad59ca 100644
--- a/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiver.java
+++ b/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiver.java
@@ -16,6 +16,8 @@
package com.android.settings.safetycenter;
+import static android.content.Intent.ACTION_BOOT_COMPLETED;
+import static android.safetycenter.SafetyCenterManager.ACTION_REFRESH_SAFETY_SOURCES;
import static android.safetycenter.SafetyCenterManager.EXTRA_REFRESH_SAFETY_SOURCE_IDS;
import android.content.BroadcastReceiver;
@@ -24,6 +26,8 @@ import android.content.Intent;
import com.google.common.collect.ImmutableList;
+import java.util.List;
+
/** Broadcast receiver for handling requests from Safety Center for fresh data. */
public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
@@ -33,17 +37,33 @@ public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
return;
}
- String[] sourceIdsExtra = intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS);
- if (sourceIdsExtra != null && sourceIdsExtra.length > 0) {
- ImmutableList sourceIds = ImmutableList.copyOf(sourceIdsExtra);
-
- if (sourceIds.contains(LockScreenSafetySource.SAFETY_SOURCE_ID)) {
- LockScreenSafetySource.sendSafetyData(context);
+ if (ACTION_REFRESH_SAFETY_SOURCES.equals(intent.getAction())) {
+ String[] sourceIdsExtra =
+ intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS);
+ if (sourceIdsExtra != null && sourceIdsExtra.length > 0) {
+ refreshSafetySources(context, ImmutableList.copyOf(sourceIdsExtra));
}
+ return;
+ }
- if (sourceIds.contains(BiometricsSafetySource.SAFETY_SOURCE_ID)) {
- BiometricsSafetySource.sendSafetyData(context);
- }
+
+ if (ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
+ refreshAllSafetySources(context);
}
}
+
+ private static void refreshSafetySources(Context context, List sourceIds) {
+ if (sourceIds.contains(LockScreenSafetySource.SAFETY_SOURCE_ID)) {
+ LockScreenSafetySource.sendSafetyData(context);
+ }
+
+ if (sourceIds.contains(BiometricsSafetySource.SAFETY_SOURCE_ID)) {
+ BiometricsSafetySource.sendSafetyData(context);
+ }
+ }
+
+ private static void refreshAllSafetySources(Context context) {
+ LockScreenSafetySource.sendSafetyData(context);
+ BiometricsSafetySource.sendSafetyData(context);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
index f59545236fa..a45564812e2 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
@@ -195,7 +195,7 @@ public class AccessibilityHearingAidPreferenceControllerTest {
private void setupBluetoothEnvironment() {
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
- mBluetoothManager = new BluetoothManager(mContext);
+ mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java
index 6ecbf2edc9f..08f708440fa 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java
@@ -76,7 +76,7 @@ public abstract class BluetoothDetailsControllerTestBase {
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = spy(new Lifecycle(mLifecycleOwner));
- mBluetoothManager = new BluetoothManager(mContext);
+ mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingControllerTest.java
index 6da9bf471f7..88e15ebc13e 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingControllerTest.java
@@ -24,6 +24,7 @@ import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
+import android.os.Parcel;
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
@@ -40,12 +41,22 @@ import org.robolectric.annotation.Config;
@Config(shadows = {ShadowBluetoothAdapter.class})
public class BluetoothPairingControllerTest {
private final BluetoothClass mBluetoothClass =
- new BluetoothClass(BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE);
+ createBtClass(BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE);
@Mock
private BluetoothDevice mBluetoothDevice;
private Context mContext;
private BluetoothPairingController mBluetoothPairingController;
+ private BluetoothClass createBtClass(int deviceClass) {
+ Parcel p = Parcel.obtain();
+ p.writeInt(deviceClass);
+ p.setDataPosition(0); // reset position of parcel before passing to constructor
+
+ BluetoothClass bluetoothClass = BluetoothClass.CREATOR.createFromParcel(p);
+ p.recycle();
+ return bluetoothClass;
+ }
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
diff --git a/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
index b73e1c9ae4c..b04a2cd21bf 100644
--- a/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
@@ -139,7 +139,7 @@ public class AudioOutputSwitchPreferenceControllerTest {
mPackageManager = Shadow.extract(mContext.getPackageManager());
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
- mBluetoothManager = new BluetoothManager(mContext);
+ mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
diff --git a/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
index 39109065b80..2580bfd8786 100644
--- a/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
@@ -130,7 +130,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
- mBluetoothManager = new BluetoothManager(mContext);
+ mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
diff --git a/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
index 306c4c1a4da..10471cb405b 100644
--- a/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
@@ -171,7 +171,7 @@ public class MediaOutputPreferenceControllerTest {
when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
- mBluetoothManager = new BluetoothManager(mContext);
+ mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
diff --git a/tests/unit/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiverTest.java b/tests/unit/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiverTest.java
index 8806e509a94..6c9addd6a3e 100644
--- a/tests/unit/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiverTest.java
+++ b/tests/unit/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiverTest.java
@@ -16,6 +16,7 @@
package com.android.settings.safetycenter;
+import static android.safetycenter.SafetyCenterManager.ACTION_REFRESH_SAFETY_SOURCES;
import static android.safetycenter.SafetyCenterManager.EXTRA_REFRESH_SAFETY_SOURCE_IDS;
import static com.google.common.truth.Truth.assertThat;
@@ -66,13 +67,25 @@ public class SafetySourceBroadcastReceiverTest {
SafetyCenterStatusHolder.sInstance = null;
}
+ @Test
+ public void sendSafetyData_whenSafetyCenterIsEnabled_withNoIntentAction_sendsNoData() {
+ when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
+ Intent intent = new Intent().putExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS, new String[]{});
+
+ new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
+
+ verify(mSafetyCenterManagerWrapper, never()).sendSafetyCenterUpdate(any(), any());
+ }
+
@Test
public void sendSafetyData_whenSafetyCenterIsDisabled_sendsNoData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(false);
Intent intent =
- new Intent().putExtra(
- EXTRA_REFRESH_SAFETY_SOURCE_IDS,
- new String[]{ LockScreenSafetySource.SAFETY_SOURCE_ID });
+ new Intent()
+ .setAction(ACTION_REFRESH_SAFETY_SOURCES)
+ .putExtra(
+ EXTRA_REFRESH_SAFETY_SOURCE_IDS,
+ new String[]{ LockScreenSafetySource.SAFETY_SOURCE_ID });
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
@@ -82,7 +95,7 @@ public class SafetySourceBroadcastReceiverTest {
@Test
public void sendSafetyData_whenSafetyCenterIsEnabled_withNullSourceIds_sendsNoData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
- Intent intent = new Intent();
+ Intent intent = new Intent().setAction(ACTION_REFRESH_SAFETY_SOURCES);
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
@@ -92,7 +105,10 @@ public class SafetySourceBroadcastReceiverTest {
@Test
public void sendSafetyData_whenSafetyCenterIsEnabled_withNoSourceIds_sendsNoData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
- Intent intent = new Intent().putExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS, new String[]{});
+ Intent intent =
+ new Intent()
+ .setAction(ACTION_REFRESH_SAFETY_SOURCES)
+ .putExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS, new String[]{});
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
@@ -103,9 +119,11 @@ public class SafetySourceBroadcastReceiverTest {
public void sendSafetyData_withLockscreenSourceId_sendsLockscreenData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
Intent intent =
- new Intent().putExtra(
- EXTRA_REFRESH_SAFETY_SOURCE_IDS,
- new String[]{ LockScreenSafetySource.SAFETY_SOURCE_ID });
+ new Intent()
+ .setAction(ACTION_REFRESH_SAFETY_SOURCES)
+ .putExtra(
+ EXTRA_REFRESH_SAFETY_SOURCE_IDS,
+ new String[]{ LockScreenSafetySource.SAFETY_SOURCE_ID });
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
ArgumentCaptor captor = ArgumentCaptor.forClass(SafetySourceData.class);
@@ -120,13 +138,31 @@ public class SafetySourceBroadcastReceiverTest {
public void sendSafetyData_withBiometricsSourceId_sendsBiometricData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
Intent intent =
- new Intent().putExtra(
- EXTRA_REFRESH_SAFETY_SOURCE_IDS,
- new String[]{ BiometricsSafetySource.SAFETY_SOURCE_ID });
+ new Intent()
+ .setAction(ACTION_REFRESH_SAFETY_SOURCES)
+ .putExtra(
+ EXTRA_REFRESH_SAFETY_SOURCE_IDS,
+ new String[]{ BiometricsSafetySource.SAFETY_SOURCE_ID });
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
// TODO(b/215517420): Update this test when BiometricSafetySource is implemented.
verify(mSafetyCenterManagerWrapper, never()).sendSafetyCenterUpdate(any(), any());
}
+
+ @Test
+ public void sendSafetyData_onBootCompleted_sendsBiometricAndLockscreenData() {
+ when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
+ Intent intent = new Intent().setAction(Intent.ACTION_BOOT_COMPLETED);
+
+ // TODO(b/215517420): Update this test when BiometricSafetySource is implemented to test
+ // that biometrics data is also sent.
+ new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
+ ArgumentCaptor captor = ArgumentCaptor.forClass(SafetySourceData.class);
+ verify(mSafetyCenterManagerWrapper, times(1))
+ .sendSafetyCenterUpdate(any(), captor.capture());
+ SafetySourceData safetySourceData = captor.getValue();
+
+ assertThat(safetySourceData.getId()).isEqualTo(LockScreenSafetySource.SAFETY_SOURCE_ID);
+ }
}