Merge "Add test for setLowPowerStandbyActiveDuringMaintenance" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
363473deab
@@ -68,7 +68,7 @@ import java.util.Arrays;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class LowPowerStandbyController {
|
||||
public class LowPowerStandbyController {
|
||||
private static final String TAG = "LowPowerStandbyController";
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean DEFAULT_ACTIVE_DURING_MAINTENANCE = false;
|
||||
@@ -173,7 +173,9 @@ public final class LowPowerStandbyController {
|
||||
mSettingsObserver = new SettingsObserver(mHandler);
|
||||
}
|
||||
|
||||
void systemReady() {
|
||||
/** Call when system services are ready */
|
||||
@VisibleForTesting
|
||||
public void systemReady() {
|
||||
final Resources resources = mContext.getResources();
|
||||
synchronized (mLock) {
|
||||
mSupportedConfig = resources.getBoolean(
|
||||
@@ -435,7 +437,9 @@ public final class LowPowerStandbyController {
|
||||
}
|
||||
}
|
||||
|
||||
void setActiveDuringMaintenance(boolean activeDuringMaintenance) {
|
||||
/** Set whether Low Power Standby should be active during doze maintenance mode. */
|
||||
@VisibleForTesting
|
||||
public void setActiveDuringMaintenance(boolean activeDuringMaintenance) {
|
||||
synchronized (mLock) {
|
||||
if (!mSupportedConfig) {
|
||||
Slog.w(TAG, "Low Power Standby settings cannot be changed "
|
||||
|
||||
@@ -71,7 +71,6 @@ import android.os.IWakeLockCallback;
|
||||
import android.os.Looper;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerSaveState;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.os.test.TestLooper;
|
||||
import android.provider.Settings;
|
||||
@@ -144,6 +143,7 @@ public class PowerManagerServiceTest {
|
||||
@Mock private AmbientDisplayConfiguration mAmbientDisplayConfigurationMock;
|
||||
@Mock private SystemPropertiesWrapper mSystemPropertiesMock;
|
||||
@Mock private AppOpsManager mAppOpsManagerMock;
|
||||
@Mock private LowPowerStandbyController mLowPowerStandbyControllerMock;
|
||||
|
||||
@Mock
|
||||
private InattentiveSleepWarningController mInattentiveSleepWarningControllerMock;
|
||||
@@ -298,8 +298,7 @@ public class PowerManagerServiceTest {
|
||||
@Override
|
||||
LowPowerStandbyController createLowPowerStandbyController(Context context,
|
||||
Looper looper) {
|
||||
return new LowPowerStandbyController(context, mTestLooper.getLooper(),
|
||||
SystemClock::elapsedRealtime);
|
||||
return mLowPowerStandbyControllerMock;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -316,7 +315,6 @@ public class PowerManagerServiceTest {
|
||||
LocalServices.removeServiceForTest(DisplayManagerInternal.class);
|
||||
LocalServices.removeServiceForTest(BatteryManagerInternal.class);
|
||||
LocalServices.removeServiceForTest(ActivityManagerInternal.class);
|
||||
LocalServices.removeServiceForTest(LowPowerStandbyControllerInternal.class);
|
||||
FakeSettingsProvider.clearSettingsProvider();
|
||||
}
|
||||
|
||||
@@ -1888,6 +1886,18 @@ public class PowerManagerServiceTest {
|
||||
assertThat(wakeLock.mDisabled).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetLowPowerStandbyActiveDuringMaintenance_redirectsCallToNativeWrapper() {
|
||||
createService();
|
||||
startSystem();
|
||||
|
||||
mService.getBinderServiceInstance().setLowPowerStandbyActiveDuringMaintenance(true);
|
||||
verify(mLowPowerStandbyControllerMock).setActiveDuringMaintenance(true);
|
||||
|
||||
mService.getBinderServiceInstance().setLowPowerStandbyActiveDuringMaintenance(false);
|
||||
verify(mLowPowerStandbyControllerMock).setActiveDuringMaintenance(false);
|
||||
}
|
||||
|
||||
private WakeLock acquireWakeLock(String tag, int flags) {
|
||||
IBinder token = new Binder();
|
||||
String packageName = "pkg.name";
|
||||
|
||||
Reference in New Issue
Block a user