From 20814592ea95c41459acb6ff26587204106ddd3f Mon Sep 17 00:00:00 2001 From: yuanruibin Date: Wed, 15 Jan 2025 09:26:46 +0800 Subject: [PATCH] =?UTF-8?q?A11=E6=9B=B4=E6=96=B0=E5=BC=80=E6=BA=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/job/JobSchedulerInternal.java | 2 ++ .../server/job/JobSchedulerService.java | 18 ++++++++++++++++-- .../com/android/server/power/Notifier.java | 19 ------------------- .../server/power/PowerManagerService.java | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/aosp/frameworks/base/apex/jobscheduler/framework/java/com/android/server/job/JobSchedulerInternal.java b/aosp/frameworks/base/apex/jobscheduler/framework/java/com/android/server/job/JobSchedulerInternal.java index 7833a0374..d9e56c463 100644 --- a/aosp/frameworks/base/apex/jobscheduler/framework/java/com/android/server/job/JobSchedulerInternal.java +++ b/aosp/frameworks/base/apex/jobscheduler/framework/java/com/android/server/job/JobSchedulerInternal.java @@ -54,6 +54,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/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/aosp/frameworks/base/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java index 1e470ce50..e36b35516 100644 --- a/aosp/frameworks/base/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +++ b/aosp/frameworks/base/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java @@ -222,6 +222,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 @@ -284,6 +285,7 @@ public class JobSchedulerService extends com.android.server.SystemService ActivityManagerInternal mActivityManagerInternal; IBatteryStats mBatteryStats; DeviceIdleInternal mLocalDeviceIdleController; + HwInteractiveController mHwInteractiveController; @VisibleForTesting AppStateTracker mAppStateTracker; final UsageStatsManagerInternal mUsageStats; @@ -1448,7 +1450,8 @@ public class JobSchedulerService extends com.android.server.SystemService mControllers.add(mDeviceIdleJobsController); mQuotaController = new QuotaController(this); mControllers.add(mQuotaController); - mControllers.add(new HwInteractiveController(this)); + mHwInteractiveController = new HwInteractiveController(this); + mControllers.add(mHwInteractiveController); mRestrictiveControllers = new ArrayList<>(); mRestrictiveControllers.add(mBatteryController); @@ -1976,7 +1979,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. @@ -2455,6 +2462,13 @@ 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 b6a700740..8f0fd607f 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 @@ -96,7 +96,6 @@ public class Notifier { private static final int MSG_WIRELESS_CHARGING_STARTED = 3; 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[] CHARGING_VIBRATION_TIME = { 40, 40, 40, 40, 40, 40, 40, 40, 40, // ramp-up sampling rate = 40ms @@ -132,8 +131,6 @@ public class Notifier { private final Intent mScreenOnIntent; private final Intent mScreenOffIntent; - private final IHwNotifier mHwNotifier; - // True if the device should suspend when the screen is off due to proximity. private final boolean mSuspendWhenScreenOffDueToProximityConfig; @@ -191,8 +188,6 @@ public class Notifier { Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND | Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS); - mHwNotifier = new HwNotifier(mContext, mHandler); - mSuspendWhenScreenOffDueToProximityConfig = context.getResources().getBoolean( com.android.internal.R.bool.config_suspendWhenScreenOffDueToProximity); mShowWirelessChargingAnimationConfig = context.getResources().getBoolean( @@ -451,18 +446,6 @@ public 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). @@ -895,8 +878,6 @@ public class Notifier { case MSG_WIRED_CHARGING_STARTED: showWiredChargingStarted(msg.arg1); 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 8c2984418..8d98f7eaa 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 @@ -2382,7 +2382,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) { -- Gitee