Hides screen attention when attention service is not avaliable.
If a wrong attention package is pushed to users devices, the screen attention won't work. In this case, we should also hide the settings as well. Test: atest AdaptiveSleepPreferenceControllerTest Bug: 148099790 Change-Id: Ieb4fd1008856024c23624f0eab3dfbfc3fc4ee3b
This commit is contained in:
@@ -16,17 +16,22 @@
|
||||
|
||||
package com.android.settings.display;
|
||||
|
||||
import static android.provider.Settings.System.ADAPTIVE_SLEEP;
|
||||
import static android.provider.Settings.Secure.ADAPTIVE_SLEEP;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
@@ -75,6 +80,14 @@ public class AdaptiveSleepPreferenceControllerTest {
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isControllerAvailable_ServiceUnavailable_returnUnsupported() {
|
||||
doReturn(null).when(mPackageManager).resolveService(isA(Intent.class), anyInt());
|
||||
|
||||
assertThat(AdaptiveSleepPreferenceController.isControllerAvailable(mContext)).isEqualTo(
|
||||
UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_turnOn_returnOn() {
|
||||
mController.onPreferenceChange(null, true);
|
||||
|
Reference in New Issue
Block a user