diff --git a/aosp/frameworks/base/services/core/java/com/android/server/job/JobSchedulerInternal.java b/aosp/frameworks/base/services/core/java/com/android/server/job/JobSchedulerInternal.java index 425ec473bc8e19278b0d0d78dbbc49be0690a4b7..19bd3fd996eb4cea3854243b7e95f041829e46c2 100644 --- a/aosp/frameworks/base/services/core/java/com/android/server/job/JobSchedulerInternal.java +++ b/aosp/frameworks/base/services/core/java/com/android/server/job/JobSchedulerInternal.java @@ -74,6 +74,8 @@ public interface JobSchedulerInternal { */ void reportAppUsage(String packageName, int userId); + void onInteraciveChange(boolean isInteractive); + /** * Report a snapshot of sync-related jobs back to the sync manager */ diff --git a/aosp/frameworks/base/services/core/java/com/android/server/job/JobSchedulerService.java b/aosp/frameworks/base/services/core/java/com/android/server/job/JobSchedulerService.java index bd7afde37c71bd92ddb42782c6aaae6713abda3d..e68f32140633c6d263b9e3fc76e13e49594a175e 100644 --- a/aosp/frameworks/base/services/core/java/com/android/server/job/JobSchedulerService.java +++ b/aosp/frameworks/base/services/core/java/com/android/server/job/JobSchedulerService.java @@ -165,6 +165,7 @@ public class JobSchedulerService extends com.android.server.SystemService static final int MSG_UID_GONE = 5; static final int MSG_UID_ACTIVE = 6; static final int MSG_UID_IDLE = 7; + static final int MSG_INTERACTIVE_CHANGED = 8; /** * Track Services that have currently active or pending jobs. The index is provided by @@ -196,6 +197,8 @@ public class JobSchedulerService extends com.android.server.SystemService ActivityManagerInternal mActivityManagerInternal; IBatteryStats mBatteryStats; DeviceIdleController.LocalService mLocalDeviceIdleController; + HwInteractiveController mHwInteractiveController; + AppStateTracker mAppStateTracker; final UsageStatsManagerInternal mUsageStats; @@ -1148,7 +1151,8 @@ public class JobSchedulerService extends com.android.server.SystemService mControllers.add(new ContentObserverController(this)); mDeviceIdleJobsController = new DeviceIdleJobsController(this); mControllers.add(mDeviceIdleJobsController); - mControllers.add(new HwInteractiveController(this)); + mHwInteractiveController = new HwInteractiveController(this); + mControllers.add(mHwInteractiveController); // If the job store determined that it can't yet reschedule persisted jobs, // we need to start watching the clock. @@ -1650,7 +1654,11 @@ public class JobSchedulerService extends com.android.server.SystemService } break; } - + case MSG_INTERACTIVE_CHANGED: { + int interactive = message.arg1; + mHwInteractiveController.onInteraciveChange(interactive == 1); + break; + } } maybeRunPendingJobsLocked(); // Don't remove JOB_EXPIRED in case one came along while processing the queue. @@ -2344,6 +2352,12 @@ public class JobSchedulerService extends com.android.server.SystemService return new JobStorePersistStats(mJobs.getPersistStats()); } } + @Override + public void onInteraciveChange(boolean isInteractive) { + Message msg = mHandler.obtainMessage(MSG_INTERACTIVE_CHANGED); + msg.arg1 = isInteractive ? 1 : 0; + mHandler.sendMessage(msg); + } } /** diff --git a/aosp/frameworks/base/services/core/java/com/android/server/power/Notifier.java b/aosp/frameworks/base/services/core/java/com/android/server/power/Notifier.java index ed607ef170ba09aba34f43dc4707310b6e75d28c..eecf17acba3f3e3be78d6616d9ca77b53661716a 100644 --- a/aosp/frameworks/base/services/core/java/com/android/server/power/Notifier.java +++ b/aosp/frameworks/base/services/core/java/com/android/server/power/Notifier.java @@ -90,8 +90,6 @@ final class Notifier { private static final int MSG_PROFILE_TIMED_OUT = 5; private static final int MSG_WIRED_CHARGING_STARTED = 6; - private static final int MSG_INTERACTIVE = 7; - private static final long[] WIRELESS_VIBRATION_TIME = { 40, 40, 40, 40, 40, 40, 40, 40, 40, // ramp-up sampling rate = 40ms 40, 40, 40, 40, 40, 40, 40 // ramp-down sampling rate = 40ms @@ -126,8 +124,6 @@ final class Notifier { private final Intent mScreenOffIntent; private final Intent mScreenBrightnessBoostIntent; - private final IHwNotifier mHwNotifier; - // True if the device should suspend when the screen is off due to proximity. private final boolean mSuspendWhenScreenOffDueToProximityConfig; @@ -179,7 +175,6 @@ final class Notifier { mScreenOffIntent.addFlags( Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND | Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS); - mHwNotifier = new HwNotifier(mContext, mHandler); mScreenBrightnessBoostIntent = new Intent(PowerManager.ACTION_SCREEN_BRIGHTNESS_BOOST_CHANGED); mScreenBrightnessBoostIntent.addFlags( @@ -416,18 +411,6 @@ final class Notifier { } } - public void onInteraciveChange(boolean isInteractive) { - mHwNotifier.onInteraciveChange(isInteractive); - } - - private void sendNoInteractiveIntent(boolean isInteractive) { - synchronized (mLock) { - if (mActivityManagerInternal.isSystemReady()) { - mHwNotifier.sendNoInteractiveIntent(isInteractive); - } - } - } - /** * Handle early interactive state changes such as getting applications or the lock * screen running and ready for the user to see (such as when turning on the screen). @@ -830,8 +813,6 @@ final class Notifier { case MSG_WIRED_CHARGING_STARTED: showWiredChargingStarted(); break; - case MSG_INTERACTIVE: - sendNoInteractiveIntent(msg.arg1 == 1); } } } diff --git a/aosp/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java b/aosp/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java index 767b15817db38d152f728ebc79b7dafb3b8be74c..d290555ca7e07c9d2526f12dd7954b10450ad5f7 100644 --- a/aosp/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java +++ b/aosp/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java @@ -2063,7 +2063,7 @@ public final class PowerManagerService extends SystemService || (mUserActivitySummary & (USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM)) != 0 || mScreenBrightnessBoostInProgress); - mHwPowerManagerService.checkInteractiveStatusAndNotify(nowKeepInteractive, mNotifier); + mHwPowerManagerService.checkInteractiveStatusAndNotify(nowKeepInteractive); } private void scheduleUserInactivityTimeout(long timeMs) {