Loading services/core/java/com/android/server/AlarmManagerService.java +0 −25 Original line number Diff line number Diff line Loading @@ -1698,8 +1698,6 @@ class AlarmManagerService extends SystemService { return; } type = fixTypeIfAuto(type); // Sanity check the window length. This will catch people mistakenly // trying to pass an end-of-window timestamp rather than a duration. if (windowLength > AlarmManager.INTERVAL_HALF_DAY) { Loading Loading @@ -1814,21 +1812,6 @@ class AlarmManagerService extends SystemService { return mConstants.APP_STANDBY_QUOTAS[index]; } /** * In case of cars, we need to avoid scheduling wakeup alarms, since we don't want the system * to wake up from suspend arbitrarily to perform app work. */ private int fixTypeIfAuto(int type) { if (mInjector.isAutomotive()) { if (type == AlarmManager.ELAPSED_REALTIME_WAKEUP) { type = AlarmManager.ELAPSED_REALTIME; } else if (type == AlarmManager.RTC_WAKEUP) { type = AlarmManager.RTC; } } return type; } /** * Return the minimum time that should elapse before an app in the specified bucket * can receive alarms again Loading Loading @@ -2232,7 +2215,6 @@ class AlarmManagerService extends SystemService { pw.print(" mLastTickSet="); pw.println(sdf.format(new Date(mLastTickSet))); pw.print(" mLastTickAdded="); pw.println(sdf.format(new Date(mLastTickAdded))); pw.print(" mLastTickRemoved="); pw.println(sdf.format(new Date(mLastTickRemoved))); pw.print(" mIsAutomotive="); pw.println(mInjector.isAutomotive()); if (RECORD_ALARMS_IN_HISTORY) { pw.println(); Loading Loading @@ -3899,12 +3881,9 @@ class AlarmManagerService extends SystemService { static class Injector { private long mNativeData; private Context mContext; private final boolean mIsAutomotive; Injector(Context context) { mContext = context; mIsAutomotive = context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_AUTOMOTIVE); } void init() { Loading Loading @@ -3993,10 +3972,6 @@ class AlarmManagerService extends SystemService { ClockReceiver getClockReceiver(AlarmManagerService service) { return service.new ClockReceiver(); } boolean isAutomotive() { return mIsAutomotive; } } private class AlarmThread extends Thread Loading services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java +0 −21 Original line number Diff line number Diff line Loading @@ -68,7 +68,6 @@ import android.app.usage.UsageStatsManagerInternal; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading Loading @@ -122,8 +121,6 @@ public class AlarmManagerServiceTest { private AlarmManagerService.ClockReceiver mClockReceiver; @Mock private PowerManager.WakeLock mWakeLock; @Mock private PackageManager mMockPackageManager; private MockitoSession mMockingSession; private Injector mInjector; Loading Loading @@ -241,11 +238,6 @@ public class AlarmManagerServiceTest { PowerManager.WakeLock getAlarmWakeLock() { return mWakeLock; } @Override boolean isAutomotive() { return mIsAutomotiveOverride; } } @Before Loading @@ -272,7 +264,6 @@ public class AlarmManagerServiceTest { when(mMockContext.getContentResolver()).thenReturn(mMockResolver); doReturn("min_futurity=0,min_interval=0").when(() -> Settings.Global.getString(mMockResolver, Settings.Global.ALARM_MANAGER_CONSTANTS)); when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager); mInjector = new Injector(mMockContext); mService = new AlarmManagerService(mMockContext, mInjector); Loading Loading @@ -1024,18 +1015,6 @@ public class AlarmManagerServiceTest { assertAlarmTypeConversion(typesToSet, typesExpected); } /** * Confirm that wakeup alarms are never set for automotive. */ @Test public void alarmTypesForAuto() throws Exception { mInjector.mIsAutomotiveOverride = true; final int[] typesToSet = {ELAPSED_REALTIME_WAKEUP, ELAPSED_REALTIME, RTC_WAKEUP, RTC}; final int[] typesExpected = {ELAPSED_REALTIME, ELAPSED_REALTIME, ELAPSED_REALTIME, ELAPSED_REALTIME}; assertAlarmTypeConversion(typesToSet, typesExpected); } private void assertAlarmTypeConversion(int[] typesToSet, int[] typesExpected) throws Exception { for (int i = 0; i < typesToSet.length; i++) { setTestAlarm(typesToSet[i], 1234, getNewMockPendingIntent()); Loading Loading
services/core/java/com/android/server/AlarmManagerService.java +0 −25 Original line number Diff line number Diff line Loading @@ -1698,8 +1698,6 @@ class AlarmManagerService extends SystemService { return; } type = fixTypeIfAuto(type); // Sanity check the window length. This will catch people mistakenly // trying to pass an end-of-window timestamp rather than a duration. if (windowLength > AlarmManager.INTERVAL_HALF_DAY) { Loading Loading @@ -1814,21 +1812,6 @@ class AlarmManagerService extends SystemService { return mConstants.APP_STANDBY_QUOTAS[index]; } /** * In case of cars, we need to avoid scheduling wakeup alarms, since we don't want the system * to wake up from suspend arbitrarily to perform app work. */ private int fixTypeIfAuto(int type) { if (mInjector.isAutomotive()) { if (type == AlarmManager.ELAPSED_REALTIME_WAKEUP) { type = AlarmManager.ELAPSED_REALTIME; } else if (type == AlarmManager.RTC_WAKEUP) { type = AlarmManager.RTC; } } return type; } /** * Return the minimum time that should elapse before an app in the specified bucket * can receive alarms again Loading Loading @@ -2232,7 +2215,6 @@ class AlarmManagerService extends SystemService { pw.print(" mLastTickSet="); pw.println(sdf.format(new Date(mLastTickSet))); pw.print(" mLastTickAdded="); pw.println(sdf.format(new Date(mLastTickAdded))); pw.print(" mLastTickRemoved="); pw.println(sdf.format(new Date(mLastTickRemoved))); pw.print(" mIsAutomotive="); pw.println(mInjector.isAutomotive()); if (RECORD_ALARMS_IN_HISTORY) { pw.println(); Loading Loading @@ -3899,12 +3881,9 @@ class AlarmManagerService extends SystemService { static class Injector { private long mNativeData; private Context mContext; private final boolean mIsAutomotive; Injector(Context context) { mContext = context; mIsAutomotive = context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_AUTOMOTIVE); } void init() { Loading Loading @@ -3993,10 +3972,6 @@ class AlarmManagerService extends SystemService { ClockReceiver getClockReceiver(AlarmManagerService service) { return service.new ClockReceiver(); } boolean isAutomotive() { return mIsAutomotive; } } private class AlarmThread extends Thread Loading
services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java +0 −21 Original line number Diff line number Diff line Loading @@ -68,7 +68,6 @@ import android.app.usage.UsageStatsManagerInternal; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Handler; import android.os.Looper; import android.os.Message; Loading Loading @@ -122,8 +121,6 @@ public class AlarmManagerServiceTest { private AlarmManagerService.ClockReceiver mClockReceiver; @Mock private PowerManager.WakeLock mWakeLock; @Mock private PackageManager mMockPackageManager; private MockitoSession mMockingSession; private Injector mInjector; Loading Loading @@ -241,11 +238,6 @@ public class AlarmManagerServiceTest { PowerManager.WakeLock getAlarmWakeLock() { return mWakeLock; } @Override boolean isAutomotive() { return mIsAutomotiveOverride; } } @Before Loading @@ -272,7 +264,6 @@ public class AlarmManagerServiceTest { when(mMockContext.getContentResolver()).thenReturn(mMockResolver); doReturn("min_futurity=0,min_interval=0").when(() -> Settings.Global.getString(mMockResolver, Settings.Global.ALARM_MANAGER_CONSTANTS)); when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager); mInjector = new Injector(mMockContext); mService = new AlarmManagerService(mMockContext, mInjector); Loading Loading @@ -1024,18 +1015,6 @@ public class AlarmManagerServiceTest { assertAlarmTypeConversion(typesToSet, typesExpected); } /** * Confirm that wakeup alarms are never set for automotive. */ @Test public void alarmTypesForAuto() throws Exception { mInjector.mIsAutomotiveOverride = true; final int[] typesToSet = {ELAPSED_REALTIME_WAKEUP, ELAPSED_REALTIME, RTC_WAKEUP, RTC}; final int[] typesExpected = {ELAPSED_REALTIME, ELAPSED_REALTIME, ELAPSED_REALTIME, ELAPSED_REALTIME}; assertAlarmTypeConversion(typesToSet, typesExpected); } private void assertAlarmTypeConversion(int[] typesToSet, int[] typesExpected) throws Exception { for (int i = 0; i < typesToSet.length; i++) { setTestAlarm(typesToSet[i], 1234, getNewMockPendingIntent()); Loading