Snap for 8195043 from 3b3c6bc564 to tm-release

Change-Id: Id1eaa96c3cea05b66651b102c34d05f92615d33f
This commit is contained in:
Android Build Coastguard Worker
2022-02-18 02:09:15 +00:00
21 changed files with 112 additions and 48 deletions

View File

@@ -4349,6 +4349,7 @@
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.safetycenter.action.REFRESH_SAFETY_SOURCES"/> <action android:name="android.safetycenter.action.REFRESH_SAFETY_SOURCES"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter> </intent-filter>
</receiver> </receiver>

View File

@@ -21,13 +21,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@android:color/transparent"> android:background="@android:color/transparent">
<com.android.settingslib.widget.settingsspinner.SettingsSpinner <Spinner
android:id="@+id/filter_spinner" android:id="@+id/filter_spinner"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:theme="@style/Widget.PopupWindow.Settings"/> android:theme="@style/Widget.PopupWindow.Settings"/>
<ImageView <ImageView

View File

@@ -20,7 +20,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"> android:minHeight="?android:attr/listPreferredItemHeight">
<com.android.settingslib.widget.settingsspinner.SettingsSpinner <Spinner
android:id="@+id/cycles_spinner" android:id="@+id/cycles_spinner"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@@ -21,12 +21,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@android:color/transparent"> android:background="@android:color/transparent">
<com.android.settingslib.widget.settingsspinner.SettingsSpinner <Spinner
android:id="@+id/filter_spinner" android:id="@+id/filter_spinner"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_marginStart="24dp" android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:theme="@style/Widget.PopupWindow.Settings"/> android:theme="@style/Widget.PopupWindow.Settings"/>
</FrameLayout> </FrameLayout>

View File

@@ -6,15 +6,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".development.tare.DropdownActivity"> tools:context=".development.tare.DropdownActivity">
<com.android.settingslib.widget.settingsspinner.SettingsSpinner <Spinner
android:id="@+id/spinner" android:id="@+id/spinner"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:theme="@style/Widget.PopupWindow.Settings" android:theme="@style/Widget.PopupWindow.Settings" />
android:padding="10dp" />
<FrameLayout <FrameLayout
android:id="@+id/frame_layout" android:id="@+id/frame_layout"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -60,5 +60,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="20dp" android:layout_margin="20dp"
android:onClick="revertSettings" android:onClick="revertSettings"
android:text="@string/tare_revert" /> android:text="@string/tare_revert"
style="@style/ActionPrimaryButton" />
</LinearLayout> </LinearLayout>

View File

@@ -13332,7 +13332,7 @@
<!-- Wallet (formerly Cards and passes) toggle name [CHAR LIMIT=60] --> <!-- Wallet (formerly Cards and passes) toggle name [CHAR LIMIT=60] -->
<string name="lockscreen_privacy_wallet_setting_toggle">Show wallet</string> <string name="lockscreen_privacy_wallet_setting_toggle">Show wallet</string>
<!-- Wallet (formerly Cards and passes) summary [CHAR LIMIT=NONE] --> <!-- Wallet (formerly Cards and passes) summary [CHAR LIMIT=NONE] -->
<string name="lockscreen_privacy_wallet_summary">Allow access to wallet from lock screen and quick settings</string> <string name="lockscreen_privacy_wallet_summary">Allow access to wallet from lock screen</string>
<!-- QR Code Scanner toggle name [CHAR LIMIT=60] --> <!-- QR Code Scanner toggle name [CHAR LIMIT=60] -->
<string name="lockscreen_privacy_qr_code_scanner_setting_toggle">Show QR scanner</string> <string name="lockscreen_privacy_qr_code_scanner_setting_toggle">Show QR scanner</string>

View File

@@ -30,7 +30,7 @@ import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.ProcStatsData.MemInfo; import com.android.settings.applications.ProcStatsData.MemInfo;
import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.core.instrumentation.Instrumentable; 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 public abstract class ProcessStatsBase extends SettingsPreferenceFragment
implements OnItemSelectedListener { implements OnItemSelectedListener {

View File

@@ -135,7 +135,7 @@ import com.android.settingslib.applications.ApplicationsState.CompoundFilter;
import com.android.settingslib.applications.ApplicationsState.VolumeFilter; import com.android.settingslib.applications.ApplicationsState.VolumeFilter;
import com.android.settingslib.fuelgauge.PowerAllowlistBackend; import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
import com.android.settingslib.utils.ThreadUtils; 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; import com.google.android.material.appbar.AppBarLayout;

View File

@@ -27,7 +27,7 @@ import com.android.net.module.util.NetworkStatsUtils;
import com.android.settings.Utils; import com.android.settings.Utils;
import com.android.settingslib.net.ChartData; import com.android.settingslib.net.ChartData;
import com.android.settingslib.net.NetworkCycleData; 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.time.ZonedDateTime;
import java.util.Iterator; import java.util.Iterator;

View File

@@ -18,12 +18,12 @@ import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.Spinner;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder; import androidx.preference.PreferenceViewHolder;
import com.android.settings.R; import com.android.settings.R;
import com.android.settingslib.widget.settingsspinner.SettingsSpinner;
public class SpinnerPreference extends Preference implements CycleAdapter.SpinnerInterface { public class SpinnerPreference extends Preference implements CycleAdapter.SpinnerInterface {
@@ -63,7 +63,7 @@ public class SpinnerPreference extends Preference implements CycleAdapter.Spinne
@Override @Override
public void onBindViewHolder(PreferenceViewHolder holder) { public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(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.setAdapter(mAdapter);
spinner.setSelection(mPosition); spinner.setSelection(mPosition);
spinner.setOnItemSelectedListener(mOnSelectedListener); spinner.setOnItemSelectedListener(mOnSelectedListener);

View File

@@ -26,6 +26,7 @@ import android.widget.ArrayAdapter;
import android.widget.Spinner; import android.widget.Spinner;
import com.android.settings.R; 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 * 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); String[] policies = getResources().getStringArray(R.array.tare_policies);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(DropdownActivity.this, ArrayAdapter<String> arrayAdapter = new SettingsSpinnerAdapter<String>(this);
android.R.layout.simple_list_item_1, policies); arrayAdapter.addAll(policies);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(arrayAdapter); mSpinner.setAdapter(arrayAdapter);
mSpinner.setSelection(policy); mSpinner.setSelection(policy);

View File

@@ -26,8 +26,8 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController; import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.widget.SettingsSpinnerAdapter;
import com.android.settingslib.widget.SettingsSpinnerPreference; import com.android.settingslib.widget.SettingsSpinnerPreference;
import com.android.settingslib.widget.settingsspinner.SettingsSpinnerAdapter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

View File

@@ -16,6 +16,8 @@
package com.android.settings.safetycenter; 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 static android.safetycenter.SafetyCenterManager.EXTRA_REFRESH_SAFETY_SOURCE_IDS;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@@ -24,6 +26,8 @@ import android.content.Intent;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.List;
/** Broadcast receiver for handling requests from Safety Center for fresh data. */ /** Broadcast receiver for handling requests from Safety Center for fresh data. */
public class SafetySourceBroadcastReceiver extends BroadcastReceiver { public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
@@ -33,10 +37,22 @@ public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
return; return;
} }
String[] sourceIdsExtra = intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS); if (ACTION_REFRESH_SAFETY_SOURCES.equals(intent.getAction())) {
String[] sourceIdsExtra =
intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS);
if (sourceIdsExtra != null && sourceIdsExtra.length > 0) { if (sourceIdsExtra != null && sourceIdsExtra.length > 0) {
ImmutableList<String> sourceIds = ImmutableList.copyOf(sourceIdsExtra); refreshSafetySources(context, ImmutableList.copyOf(sourceIdsExtra));
}
return;
}
if (ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
refreshAllSafetySources(context);
}
}
private static void refreshSafetySources(Context context, List<String> sourceIds) {
if (sourceIds.contains(LockScreenSafetySource.SAFETY_SOURCE_ID)) { if (sourceIds.contains(LockScreenSafetySource.SAFETY_SOURCE_ID)) {
LockScreenSafetySource.sendSafetyData(context); LockScreenSafetySource.sendSafetyData(context);
} }
@@ -45,5 +61,9 @@ public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
BiometricsSafetySource.sendSafetyData(context); BiometricsSafetySource.sendSafetyData(context);
} }
} }
private static void refreshAllSafetySources(Context context) {
LockScreenSafetySource.sendSafetyData(context);
BiometricsSafetySource.sendSafetyData(context);
} }
} }

View File

@@ -195,7 +195,7 @@ public class AccessibilityHearingAidPreferenceControllerTest {
private void setupBluetoothEnvironment() { private void setupBluetoothEnvironment() {
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager; ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
mLocalBluetoothManager = Utils.getLocalBtManager(mContext); mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
mBluetoothManager = new BluetoothManager(mContext); mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter(); mBluetoothAdapter = mBluetoothManager.getAdapter();
when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager); when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager); when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);

View File

@@ -76,7 +76,7 @@ public abstract class BluetoothDetailsControllerTestBase {
when(mFragment.getPreferenceScreen()).thenReturn(mScreen); when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
mLifecycleOwner = () -> mLifecycle; mLifecycleOwner = () -> mLifecycle;
mLifecycle = spy(new Lifecycle(mLifecycleOwner)); mLifecycle = spy(new Lifecycle(mLifecycleOwner));
mBluetoothManager = new BluetoothManager(mContext); mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter(); mBluetoothAdapter = mBluetoothManager.getAdapter();
} }

View File

@@ -24,6 +24,7 @@ import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Parcel;
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
@@ -40,12 +41,22 @@ import org.robolectric.annotation.Config;
@Config(shadows = {ShadowBluetoothAdapter.class}) @Config(shadows = {ShadowBluetoothAdapter.class})
public class BluetoothPairingControllerTest { public class BluetoothPairingControllerTest {
private final BluetoothClass mBluetoothClass = private final BluetoothClass mBluetoothClass =
new BluetoothClass(BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE); createBtClass(BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE);
@Mock @Mock
private BluetoothDevice mBluetoothDevice; private BluetoothDevice mBluetoothDevice;
private Context mContext; private Context mContext;
private BluetoothPairingController mBluetoothPairingController; 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 @Before
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);

View File

@@ -139,7 +139,7 @@ public class AudioOutputSwitchPreferenceControllerTest {
mPackageManager = Shadow.extract(mContext.getPackageManager()); mPackageManager = Shadow.extract(mContext.getPackageManager());
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true); mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
mBluetoothManager = new BluetoothManager(mContext); mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter(); mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1)); mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));

View File

@@ -130,7 +130,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile); when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile); when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
mBluetoothManager = new BluetoothManager(mContext); mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter(); mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1)); mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));

View File

@@ -171,7 +171,7 @@ public class MediaOutputPreferenceControllerTest {
when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile); when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile); when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
mBluetoothManager = new BluetoothManager(mContext); mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter(); mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1)); mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));

View File

@@ -16,6 +16,7 @@
package com.android.settings.safetycenter; 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 android.safetycenter.SafetyCenterManager.EXTRA_REFRESH_SAFETY_SOURCE_IDS;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -66,11 +67,23 @@ public class SafetySourceBroadcastReceiverTest {
SafetyCenterStatusHolder.sInstance = null; 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 @Test
public void sendSafetyData_whenSafetyCenterIsDisabled_sendsNoData() { public void sendSafetyData_whenSafetyCenterIsDisabled_sendsNoData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(false); when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(false);
Intent intent = Intent intent =
new Intent().putExtra( new Intent()
.setAction(ACTION_REFRESH_SAFETY_SOURCES)
.putExtra(
EXTRA_REFRESH_SAFETY_SOURCE_IDS, EXTRA_REFRESH_SAFETY_SOURCE_IDS,
new String[]{ LockScreenSafetySource.SAFETY_SOURCE_ID }); new String[]{ LockScreenSafetySource.SAFETY_SOURCE_ID });
@@ -82,7 +95,7 @@ public class SafetySourceBroadcastReceiverTest {
@Test @Test
public void sendSafetyData_whenSafetyCenterIsEnabled_withNullSourceIds_sendsNoData() { public void sendSafetyData_whenSafetyCenterIsEnabled_withNullSourceIds_sendsNoData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true); when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
Intent intent = new Intent(); Intent intent = new Intent().setAction(ACTION_REFRESH_SAFETY_SOURCES);
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent); new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
@@ -92,7 +105,10 @@ public class SafetySourceBroadcastReceiverTest {
@Test @Test
public void sendSafetyData_whenSafetyCenterIsEnabled_withNoSourceIds_sendsNoData() { public void sendSafetyData_whenSafetyCenterIsEnabled_withNoSourceIds_sendsNoData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true); 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); new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
@@ -103,7 +119,9 @@ public class SafetySourceBroadcastReceiverTest {
public void sendSafetyData_withLockscreenSourceId_sendsLockscreenData() { public void sendSafetyData_withLockscreenSourceId_sendsLockscreenData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true); when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
Intent intent = Intent intent =
new Intent().putExtra( new Intent()
.setAction(ACTION_REFRESH_SAFETY_SOURCES)
.putExtra(
EXTRA_REFRESH_SAFETY_SOURCE_IDS, EXTRA_REFRESH_SAFETY_SOURCE_IDS,
new String[]{ LockScreenSafetySource.SAFETY_SOURCE_ID }); new String[]{ LockScreenSafetySource.SAFETY_SOURCE_ID });
@@ -120,7 +138,9 @@ public class SafetySourceBroadcastReceiverTest {
public void sendSafetyData_withBiometricsSourceId_sendsBiometricData() { public void sendSafetyData_withBiometricsSourceId_sendsBiometricData() {
when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true); when(mSafetyCenterStatusHolder.isEnabled(mApplicationContext)).thenReturn(true);
Intent intent = Intent intent =
new Intent().putExtra( new Intent()
.setAction(ACTION_REFRESH_SAFETY_SOURCES)
.putExtra(
EXTRA_REFRESH_SAFETY_SOURCE_IDS, EXTRA_REFRESH_SAFETY_SOURCE_IDS,
new String[]{ BiometricsSafetySource.SAFETY_SOURCE_ID }); new String[]{ BiometricsSafetySource.SAFETY_SOURCE_ID });
@@ -129,4 +149,20 @@ public class SafetySourceBroadcastReceiverTest {
// TODO(b/215517420): Update this test when BiometricSafetySource is implemented. // TODO(b/215517420): Update this test when BiometricSafetySource is implemented.
verify(mSafetyCenterManagerWrapper, never()).sendSafetyCenterUpdate(any(), any()); 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<SafetySourceData> 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);
}
} }