Merge "Remove special handling of wakeup alarm for car" into qt-dev
am: a47901806e
Change-Id: I5a69ba1832036afe1bea0c56bf41f8c718d90eed
This commit is contained in:
@@ -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) {
|
||||
@@ -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
|
||||
@@ -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();
|
||||
@@ -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() {
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -241,11 +238,6 @@ public class AlarmManagerServiceTest {
|
||||
PowerManager.WakeLock getAlarmWakeLock() {
|
||||
return mWakeLock;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isAutomotive() {
|
||||
return mIsAutomotiveOverride;
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -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);
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user