Loading apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +4 −4 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ import com.android.internal.util.DumpUtils; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.Preconditions; import com.android.server.AppStateTracker; import com.android.server.DeviceIdleController; import com.android.server.DeviceIdleInternal; import com.android.server.FgThread; import com.android.server.LocalServices; import com.android.server.job.JobSchedulerServiceDumpProto.ActiveJob; Loading Loading @@ -207,7 +207,7 @@ public class JobSchedulerService extends com.android.server.SystemService PackageManagerInternal mLocalPM; ActivityManagerInternal mActivityManagerInternal; IBatteryStats mBatteryStats; DeviceIdleController.LocalService mLocalDeviceIdleController; DeviceIdleInternal mLocalDeviceIdleController; AppStateTracker mAppStateTracker; final UsageStatsManagerInternal mUsageStats; Loading Loading @@ -1399,8 +1399,8 @@ public class JobSchedulerService extends com.android.server.SystemService mReadyToRock = true; mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService( BatteryStats.SERVICE_NAME)); mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class); mLocalDeviceIdleController = LocalServices.getService(DeviceIdleInternal.class); // Create the "runners". for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) { mActiveServices.add( Loading apex/jobscheduler/service/java/com/android/server/job/controllers/DeviceIdleJobsController.java +3 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.util.ArrayUtils; import com.android.internal.util.IndentingPrintWriter; import com.android.server.DeviceIdleController; import com.android.server.DeviceIdleInternal; import com.android.server.LocalServices; import com.android.server.job.JobSchedulerService; import com.android.server.job.StateControllerProto; Loading Loading @@ -66,7 +66,7 @@ public final class DeviceIdleJobsController extends StateController { private final DeviceIdleUpdateFunctor mDeviceIdleUpdateFunctor; private final DeviceIdleJobsDelayHandler mHandler; private final PowerManager mPowerManager; private final DeviceIdleController.LocalService mLocalDeviceIdleController; private final DeviceIdleInternal mLocalDeviceIdleController; /** * True when in device idle mode, so we don't want to schedule any jobs. Loading Loading @@ -123,7 +123,7 @@ public final class DeviceIdleJobsController extends StateController { // Register for device idle mode changes mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class); LocalServices.getService(DeviceIdleInternal.class); mDeviceIdleWhitelistAppIds = mLocalDeviceIdleController.getPowerSaveWhitelistUserAppIds(); mPowerSaveTempWhitelistAppIds = mLocalDeviceIdleController.getPowerSaveTempWhitelistAppIds(); Loading services/core/java/com/android/server/AlarmManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ class AlarmManagerService extends SystemService { final LocalLog mLog = new LocalLog(TAG); AppOpsManager mAppOps; DeviceIdleController.LocalService mLocalDeviceIdleController; DeviceIdleInternal mLocalDeviceIdleController; private UsageStatsManagerInternal mUsageStatsManagerInternal; final Object mLock = new Object(); Loading Loading @@ -1594,7 +1594,7 @@ class AlarmManagerService extends SystemService { mConstants.start(getContext().getContentResolver()); mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE); mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class); LocalServices.getService(DeviceIdleInternal.class); mUsageStatsManagerInternal = LocalServices.getService(UsageStatsManagerInternal.class); mUsageStatsManagerInternal.addAppIdleStateChangeListener(new AppStandbyTracker()); Loading services/core/java/com/android/server/DeviceIdleController.java +16 −3 Original line number Diff line number Diff line Loading @@ -1636,27 +1636,32 @@ public class DeviceIdleController extends SystemService } } public class LocalService { private class LocalService implements DeviceIdleInternal { @Override public void onConstraintStateChanged(IDeviceIdleConstraint constraint, boolean active) { synchronized (DeviceIdleController.this) { onConstraintStateChangedLocked(constraint, active); } } @Override public void registerDeviceIdleConstraint(IDeviceIdleConstraint constraint, String name, @IDeviceIdleConstraint.MinimumState int minState) { registerDeviceIdleConstraintInternal(constraint, name, minState); } @Override public void unregisterDeviceIdleConstraint(IDeviceIdleConstraint constraint) { unregisterDeviceIdleConstraintInternal(constraint); } @Override public void exitIdle(String reason) { exitIdleInternal(reason); } // duration in milliseconds @Override public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, String reason) { addPowerSaveTempWhitelistAppInternal(callingUid, packageName, duration, Loading @@ -1664,26 +1669,31 @@ public class DeviceIdleController extends SystemService } // duration in milliseconds @Override public void addPowerSaveTempWhitelistAppDirect(int uid, long duration, boolean sync, String reason) { addPowerSaveTempWhitelistAppDirectInternal(0, uid, duration, sync, reason); } // duration in milliseconds @Override public long getNotificationWhitelistDuration() { return mConstants.NOTIFICATION_WHITELIST_DURATION; } @Override public void setJobsActive(boolean active) { DeviceIdleController.this.setJobsActive(active); } // Up-call from alarm manager. @Override public void setAlarmsActive(boolean active) { DeviceIdleController.this.setAlarmsActive(active); } /** Is the app on any of the power save whitelists, whether system or user? */ @Override public boolean isAppOnWhitelist(int appid) { return DeviceIdleController.this.isAppOnWhitelistInternal(appid); } Loading @@ -1694,10 +1704,12 @@ public class DeviceIdleController extends SystemService * can change when the list changes, so it needs to be re-acquired when * {@link PowerManager#ACTION_POWER_SAVE_WHITELIST_CHANGED} is sent. */ @Override public int[] getPowerSaveWhitelistUserAppIds() { return DeviceIdleController.this.getPowerSaveWhitelistUserAppIds(); } @Override public int[] getPowerSaveTempWhitelistAppIds() { return DeviceIdleController.this.getAppIdTempWhitelistInternal(); } Loading Loading @@ -1767,7 +1779,8 @@ public class DeviceIdleController extends SystemService return mContext.getSystemService(SensorManager.class); } ConstraintController getConstraintController(Handler handler, LocalService localService) { ConstraintController getConstraintController(Handler handler, DeviceIdleInternal localService) { if (mContext.getPackageManager() .hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY)) { return new TvConstraintController(mContext, handler); Loading Loading @@ -1884,7 +1897,7 @@ public class DeviceIdleController extends SystemService mBinderService = new BinderService(); publishBinderService(Context.DEVICE_IDLE_CONTROLLER, mBinderService); publishLocalService(LocalService.class, new LocalService()); publishLocalService(DeviceIdleInternal.class, new LocalService()); } @Override Loading services/core/java/com/android/server/DeviceIdleInternal.java 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server; import com.android.server.deviceidle.IDeviceIdleConstraint; public interface DeviceIdleInternal { void onConstraintStateChanged(IDeviceIdleConstraint constraint, boolean active); void registerDeviceIdleConstraint(IDeviceIdleConstraint constraint, String name, @IDeviceIdleConstraint.MinimumState int minState); void unregisterDeviceIdleConstraint(IDeviceIdleConstraint constraint); void exitIdle(String reason); // duration in milliseconds void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, String reason); // duration in milliseconds void addPowerSaveTempWhitelistAppDirect(int uid, long duration, boolean sync, String reason); // duration in milliseconds long getNotificationWhitelistDuration(); void setJobsActive(boolean active); // Up-call from alarm manager. void setAlarmsActive(boolean active); boolean isAppOnWhitelist(int appid); int[] getPowerSaveWhitelistUserAppIds(); int[] getPowerSaveTempWhitelistAppIds(); } Loading
apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +4 −4 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ import com.android.internal.util.DumpUtils; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.Preconditions; import com.android.server.AppStateTracker; import com.android.server.DeviceIdleController; import com.android.server.DeviceIdleInternal; import com.android.server.FgThread; import com.android.server.LocalServices; import com.android.server.job.JobSchedulerServiceDumpProto.ActiveJob; Loading Loading @@ -207,7 +207,7 @@ public class JobSchedulerService extends com.android.server.SystemService PackageManagerInternal mLocalPM; ActivityManagerInternal mActivityManagerInternal; IBatteryStats mBatteryStats; DeviceIdleController.LocalService mLocalDeviceIdleController; DeviceIdleInternal mLocalDeviceIdleController; AppStateTracker mAppStateTracker; final UsageStatsManagerInternal mUsageStats; Loading Loading @@ -1399,8 +1399,8 @@ public class JobSchedulerService extends com.android.server.SystemService mReadyToRock = true; mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService( BatteryStats.SERVICE_NAME)); mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class); mLocalDeviceIdleController = LocalServices.getService(DeviceIdleInternal.class); // Create the "runners". for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) { mActiveServices.add( Loading
apex/jobscheduler/service/java/com/android/server/job/controllers/DeviceIdleJobsController.java +3 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.util.ArrayUtils; import com.android.internal.util.IndentingPrintWriter; import com.android.server.DeviceIdleController; import com.android.server.DeviceIdleInternal; import com.android.server.LocalServices; import com.android.server.job.JobSchedulerService; import com.android.server.job.StateControllerProto; Loading Loading @@ -66,7 +66,7 @@ public final class DeviceIdleJobsController extends StateController { private final DeviceIdleUpdateFunctor mDeviceIdleUpdateFunctor; private final DeviceIdleJobsDelayHandler mHandler; private final PowerManager mPowerManager; private final DeviceIdleController.LocalService mLocalDeviceIdleController; private final DeviceIdleInternal mLocalDeviceIdleController; /** * True when in device idle mode, so we don't want to schedule any jobs. Loading Loading @@ -123,7 +123,7 @@ public final class DeviceIdleJobsController extends StateController { // Register for device idle mode changes mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class); LocalServices.getService(DeviceIdleInternal.class); mDeviceIdleWhitelistAppIds = mLocalDeviceIdleController.getPowerSaveWhitelistUserAppIds(); mPowerSaveTempWhitelistAppIds = mLocalDeviceIdleController.getPowerSaveTempWhitelistAppIds(); Loading
services/core/java/com/android/server/AlarmManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ class AlarmManagerService extends SystemService { final LocalLog mLog = new LocalLog(TAG); AppOpsManager mAppOps; DeviceIdleController.LocalService mLocalDeviceIdleController; DeviceIdleInternal mLocalDeviceIdleController; private UsageStatsManagerInternal mUsageStatsManagerInternal; final Object mLock = new Object(); Loading Loading @@ -1594,7 +1594,7 @@ class AlarmManagerService extends SystemService { mConstants.start(getContext().getContentResolver()); mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE); mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class); LocalServices.getService(DeviceIdleInternal.class); mUsageStatsManagerInternal = LocalServices.getService(UsageStatsManagerInternal.class); mUsageStatsManagerInternal.addAppIdleStateChangeListener(new AppStandbyTracker()); Loading
services/core/java/com/android/server/DeviceIdleController.java +16 −3 Original line number Diff line number Diff line Loading @@ -1636,27 +1636,32 @@ public class DeviceIdleController extends SystemService } } public class LocalService { private class LocalService implements DeviceIdleInternal { @Override public void onConstraintStateChanged(IDeviceIdleConstraint constraint, boolean active) { synchronized (DeviceIdleController.this) { onConstraintStateChangedLocked(constraint, active); } } @Override public void registerDeviceIdleConstraint(IDeviceIdleConstraint constraint, String name, @IDeviceIdleConstraint.MinimumState int minState) { registerDeviceIdleConstraintInternal(constraint, name, minState); } @Override public void unregisterDeviceIdleConstraint(IDeviceIdleConstraint constraint) { unregisterDeviceIdleConstraintInternal(constraint); } @Override public void exitIdle(String reason) { exitIdleInternal(reason); } // duration in milliseconds @Override public void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, String reason) { addPowerSaveTempWhitelistAppInternal(callingUid, packageName, duration, Loading @@ -1664,26 +1669,31 @@ public class DeviceIdleController extends SystemService } // duration in milliseconds @Override public void addPowerSaveTempWhitelistAppDirect(int uid, long duration, boolean sync, String reason) { addPowerSaveTempWhitelistAppDirectInternal(0, uid, duration, sync, reason); } // duration in milliseconds @Override public long getNotificationWhitelistDuration() { return mConstants.NOTIFICATION_WHITELIST_DURATION; } @Override public void setJobsActive(boolean active) { DeviceIdleController.this.setJobsActive(active); } // Up-call from alarm manager. @Override public void setAlarmsActive(boolean active) { DeviceIdleController.this.setAlarmsActive(active); } /** Is the app on any of the power save whitelists, whether system or user? */ @Override public boolean isAppOnWhitelist(int appid) { return DeviceIdleController.this.isAppOnWhitelistInternal(appid); } Loading @@ -1694,10 +1704,12 @@ public class DeviceIdleController extends SystemService * can change when the list changes, so it needs to be re-acquired when * {@link PowerManager#ACTION_POWER_SAVE_WHITELIST_CHANGED} is sent. */ @Override public int[] getPowerSaveWhitelistUserAppIds() { return DeviceIdleController.this.getPowerSaveWhitelistUserAppIds(); } @Override public int[] getPowerSaveTempWhitelistAppIds() { return DeviceIdleController.this.getAppIdTempWhitelistInternal(); } Loading Loading @@ -1767,7 +1779,8 @@ public class DeviceIdleController extends SystemService return mContext.getSystemService(SensorManager.class); } ConstraintController getConstraintController(Handler handler, LocalService localService) { ConstraintController getConstraintController(Handler handler, DeviceIdleInternal localService) { if (mContext.getPackageManager() .hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY)) { return new TvConstraintController(mContext, handler); Loading Loading @@ -1884,7 +1897,7 @@ public class DeviceIdleController extends SystemService mBinderService = new BinderService(); publishBinderService(Context.DEVICE_IDLE_CONTROLLER, mBinderService); publishLocalService(LocalService.class, new LocalService()); publishLocalService(DeviceIdleInternal.class, new LocalService()); } @Override Loading
services/core/java/com/android/server/DeviceIdleInternal.java 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server; import com.android.server.deviceidle.IDeviceIdleConstraint; public interface DeviceIdleInternal { void onConstraintStateChanged(IDeviceIdleConstraint constraint, boolean active); void registerDeviceIdleConstraint(IDeviceIdleConstraint constraint, String name, @IDeviceIdleConstraint.MinimumState int minState); void unregisterDeviceIdleConstraint(IDeviceIdleConstraint constraint); void exitIdle(String reason); // duration in milliseconds void addPowerSaveTempWhitelistApp(int callingUid, String packageName, long duration, int userId, boolean sync, String reason); // duration in milliseconds void addPowerSaveTempWhitelistAppDirect(int uid, long duration, boolean sync, String reason); // duration in milliseconds long getNotificationWhitelistDuration(); void setJobsActive(boolean active); // Up-call from alarm manager. void setAlarmsActive(boolean active); boolean isAppOnWhitelist(int appid); int[] getPowerSaveWhitelistUserAppIds(); int[] getPowerSaveTempWhitelistAppIds(); }