Loading core/java/android/hardware/display/DisplayManagerInternal.java +3 −2 Original line number Diff line number Diff line Loading @@ -92,9 +92,10 @@ public abstract class DisplayManagerInternal { boolean waitForNegativeProximity); /** * Returns {@code true} if the proximity sensor screen-off function is available. * Returns {@code true} if the proximity sensor screen-off function is available for the given * display. */ public abstract boolean isProximitySensorAvailable(); public abstract boolean isProximitySensorAvailable(int displayId); /** * Registers a display group listener which will be informed of the addition, removal, or change Loading core/java/android/os/IPowerManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -42,7 +42,9 @@ interface IPowerManager void updateWakeLockWorkSource(IBinder lock, in WorkSource ws, String historyTag); void updateWakeLockCallback(IBinder lock, IWakeLockCallback callback); @UnsupportedAppUsage boolean isWakeLockLevelSupported(int level); boolean isWakeLockLevelSupportedWithDisplayId(int level, int displayId); void userActivity(int displayId, long time, int event, int flags); void wakeUp(long time, int reason, String details, String opPackageName); Loading core/java/android/os/PowerManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -1344,6 +1344,9 @@ public final class PowerManager { * @see #ON_AFTER_RELEASE */ public WakeLock newWakeLock(int levelAndFlags, String tag) { if (android.companion.virtualdevice.flags.Flags.displayPowerManagerApis()) { return newWakeLock(levelAndFlags, tag, mContext.getDisplayId()); } validateWakeLockParameters(levelAndFlags, tag); return new WakeLock(levelAndFlags, tag, mContext.getOpPackageName(), Display.INVALID_DISPLAY); Loading Loading @@ -1734,6 +1737,10 @@ public final class PowerManager { */ public boolean isWakeLockLevelSupported(int level) { try { if (android.companion.virtualdevice.flags.Flags.displayPowerManagerApis()) { return mService.isWakeLockLevelSupportedWithDisplayId( level, mContext.getDisplayId()); } return mService.isWakeLockLevelSupported(level); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading Loading @@ -1797,6 +1804,9 @@ public final class PowerManager { * @see android.content.Intent#ACTION_SCREEN_OFF */ public boolean isInteractive() { if (android.companion.virtualdevice.flags.Flags.displayPowerManagerApis()) { return isInteractive(mContext.getDisplayId()); } return mInteractiveCache.query(null); } Loading services/core/java/com/android/server/display/DisplayManagerService.java +2 −3 Original line number Diff line number Diff line Loading @@ -5233,10 +5233,9 @@ public final class DisplayManagerService extends SystemService { } @Override public boolean isProximitySensorAvailable() { public boolean isProximitySensorAvailable(int displayId) { synchronized (mSyncRoot) { return mDisplayPowerControllers.get(Display.DEFAULT_DISPLAY) .isProximitySensorAvailable(); return mDisplayPowerControllers.get(displayId).isProximitySensorAvailable(); } } Loading services/core/java/com/android/server/power/PowerManagerService.java +19 −6 Original line number Diff line number Diff line Loading @@ -743,6 +743,7 @@ public final class PowerManagerService extends SystemService int reason, int uid, int opUid, String opPackageName, String details) { mWakefulnessChanging = true; mDirty |= DIRTY_WAKEFULNESS; mInjector.invalidateIsInteractiveCaches(); if (wakefulness == WAKEFULNESS_AWAKE) { // Kick user activity to prevent newly awake group from timing out instantly. // The dream may end without user activity if the dream app crashes / is updated, Loading Loading @@ -2035,7 +2036,7 @@ public final class PowerManagerService extends SystemService } @SuppressWarnings("deprecation") private boolean isWakeLockLevelSupportedInternal(int level) { private boolean isWakeLockLevelSupportedInternal(int level, int displayId) { synchronized (mLock) { switch (level) { case PowerManager.PARTIAL_WAKE_LOCK: Loading @@ -2047,7 +2048,8 @@ public final class PowerManagerService extends SystemService return true; case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK: return mSystemReady && mDisplayManagerInternal.isProximitySensorAvailable(); return mSystemReady && mDisplayManagerInternal.isProximitySensorAvailable(displayId); case PowerManager.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK: return mSystemReady && mFeatureFlags.isEarlyScreenTimeoutDetectorEnabled() && mScreenTimeoutOverridePolicy != null; Loading Loading @@ -2264,7 +2266,6 @@ public final class PowerManagerService extends SystemService int opUid, String opPackageName, String details) { mPowerGroups.get(groupId).setWakefulnessLocked(wakefulness, eventTime, uid, reason, opUid, opPackageName, details); mInjector.invalidateIsInteractiveCaches(); } @SuppressWarnings("deprecation") Loading Loading @@ -2329,8 +2330,6 @@ public final class PowerManagerService extends SystemService Trace.traceBegin(Trace.TRACE_TAG_POWER, traceMethodName); try { // Phase 2: Handle wakefulness change and bookkeeping. // Under lock, invalidate before set ensures caches won't return stale values. mInjector.invalidateIsInteractiveCaches(); mWakefulnessRaw = newWakefulness; mWakefulnessChanging = true; mDirty |= DIRTY_WAKEFULNESS; Loading Loading @@ -2428,6 +2427,7 @@ public final class PowerManagerService extends SystemService void onPowerGroupEventLocked(int event, PowerGroup powerGroup) { mWakefulnessChanging = true; mDirty |= DIRTY_WAKEFULNESS; mInjector.invalidateIsInteractiveCaches(); final int groupId = powerGroup.getGroupId(); if (event == DisplayGroupPowerChangeListener.DISPLAY_GROUP_REMOVED) { mPowerGroups.delete(groupId); Loading Loading @@ -3975,6 +3975,9 @@ public final class PowerManagerService extends SystemService private boolean isInteractiveInternal(int displayId, int uid) { synchronized (mLock) { if (!mSystemReady) { return isGloballyInteractiveInternal(); } DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(displayId); if (displayInfo == null) { Slog.w(TAG, "Did not find DisplayInfo for displayId " + displayId); Loading Loading @@ -5975,7 +5978,17 @@ public final class PowerManagerService extends SystemService public boolean isWakeLockLevelSupported(int level) { final long ident = Binder.clearCallingIdentity(); try { return isWakeLockLevelSupportedInternal(level); return isWakeLockLevelSupportedInternal(level, Display.DEFAULT_DISPLAY); } finally { Binder.restoreCallingIdentity(ident); } } @Override // Binder call public boolean isWakeLockLevelSupportedWithDisplayId(int level, int displayId) { final long ident = Binder.clearCallingIdentity(); try { return isWakeLockLevelSupportedInternal(level, displayId); } finally { Binder.restoreCallingIdentity(ident); } Loading Loading
core/java/android/hardware/display/DisplayManagerInternal.java +3 −2 Original line number Diff line number Diff line Loading @@ -92,9 +92,10 @@ public abstract class DisplayManagerInternal { boolean waitForNegativeProximity); /** * Returns {@code true} if the proximity sensor screen-off function is available. * Returns {@code true} if the proximity sensor screen-off function is available for the given * display. */ public abstract boolean isProximitySensorAvailable(); public abstract boolean isProximitySensorAvailable(int displayId); /** * Registers a display group listener which will be informed of the addition, removal, or change Loading
core/java/android/os/IPowerManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -42,7 +42,9 @@ interface IPowerManager void updateWakeLockWorkSource(IBinder lock, in WorkSource ws, String historyTag); void updateWakeLockCallback(IBinder lock, IWakeLockCallback callback); @UnsupportedAppUsage boolean isWakeLockLevelSupported(int level); boolean isWakeLockLevelSupportedWithDisplayId(int level, int displayId); void userActivity(int displayId, long time, int event, int flags); void wakeUp(long time, int reason, String details, String opPackageName); Loading
core/java/android/os/PowerManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -1344,6 +1344,9 @@ public final class PowerManager { * @see #ON_AFTER_RELEASE */ public WakeLock newWakeLock(int levelAndFlags, String tag) { if (android.companion.virtualdevice.flags.Flags.displayPowerManagerApis()) { return newWakeLock(levelAndFlags, tag, mContext.getDisplayId()); } validateWakeLockParameters(levelAndFlags, tag); return new WakeLock(levelAndFlags, tag, mContext.getOpPackageName(), Display.INVALID_DISPLAY); Loading Loading @@ -1734,6 +1737,10 @@ public final class PowerManager { */ public boolean isWakeLockLevelSupported(int level) { try { if (android.companion.virtualdevice.flags.Flags.displayPowerManagerApis()) { return mService.isWakeLockLevelSupportedWithDisplayId( level, mContext.getDisplayId()); } return mService.isWakeLockLevelSupported(level); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading Loading @@ -1797,6 +1804,9 @@ public final class PowerManager { * @see android.content.Intent#ACTION_SCREEN_OFF */ public boolean isInteractive() { if (android.companion.virtualdevice.flags.Flags.displayPowerManagerApis()) { return isInteractive(mContext.getDisplayId()); } return mInteractiveCache.query(null); } Loading
services/core/java/com/android/server/display/DisplayManagerService.java +2 −3 Original line number Diff line number Diff line Loading @@ -5233,10 +5233,9 @@ public final class DisplayManagerService extends SystemService { } @Override public boolean isProximitySensorAvailable() { public boolean isProximitySensorAvailable(int displayId) { synchronized (mSyncRoot) { return mDisplayPowerControllers.get(Display.DEFAULT_DISPLAY) .isProximitySensorAvailable(); return mDisplayPowerControllers.get(displayId).isProximitySensorAvailable(); } } Loading
services/core/java/com/android/server/power/PowerManagerService.java +19 −6 Original line number Diff line number Diff line Loading @@ -743,6 +743,7 @@ public final class PowerManagerService extends SystemService int reason, int uid, int opUid, String opPackageName, String details) { mWakefulnessChanging = true; mDirty |= DIRTY_WAKEFULNESS; mInjector.invalidateIsInteractiveCaches(); if (wakefulness == WAKEFULNESS_AWAKE) { // Kick user activity to prevent newly awake group from timing out instantly. // The dream may end without user activity if the dream app crashes / is updated, Loading Loading @@ -2035,7 +2036,7 @@ public final class PowerManagerService extends SystemService } @SuppressWarnings("deprecation") private boolean isWakeLockLevelSupportedInternal(int level) { private boolean isWakeLockLevelSupportedInternal(int level, int displayId) { synchronized (mLock) { switch (level) { case PowerManager.PARTIAL_WAKE_LOCK: Loading @@ -2047,7 +2048,8 @@ public final class PowerManagerService extends SystemService return true; case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK: return mSystemReady && mDisplayManagerInternal.isProximitySensorAvailable(); return mSystemReady && mDisplayManagerInternal.isProximitySensorAvailable(displayId); case PowerManager.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK: return mSystemReady && mFeatureFlags.isEarlyScreenTimeoutDetectorEnabled() && mScreenTimeoutOverridePolicy != null; Loading Loading @@ -2264,7 +2266,6 @@ public final class PowerManagerService extends SystemService int opUid, String opPackageName, String details) { mPowerGroups.get(groupId).setWakefulnessLocked(wakefulness, eventTime, uid, reason, opUid, opPackageName, details); mInjector.invalidateIsInteractiveCaches(); } @SuppressWarnings("deprecation") Loading Loading @@ -2329,8 +2330,6 @@ public final class PowerManagerService extends SystemService Trace.traceBegin(Trace.TRACE_TAG_POWER, traceMethodName); try { // Phase 2: Handle wakefulness change and bookkeeping. // Under lock, invalidate before set ensures caches won't return stale values. mInjector.invalidateIsInteractiveCaches(); mWakefulnessRaw = newWakefulness; mWakefulnessChanging = true; mDirty |= DIRTY_WAKEFULNESS; Loading Loading @@ -2428,6 +2427,7 @@ public final class PowerManagerService extends SystemService void onPowerGroupEventLocked(int event, PowerGroup powerGroup) { mWakefulnessChanging = true; mDirty |= DIRTY_WAKEFULNESS; mInjector.invalidateIsInteractiveCaches(); final int groupId = powerGroup.getGroupId(); if (event == DisplayGroupPowerChangeListener.DISPLAY_GROUP_REMOVED) { mPowerGroups.delete(groupId); Loading Loading @@ -3975,6 +3975,9 @@ public final class PowerManagerService extends SystemService private boolean isInteractiveInternal(int displayId, int uid) { synchronized (mLock) { if (!mSystemReady) { return isGloballyInteractiveInternal(); } DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(displayId); if (displayInfo == null) { Slog.w(TAG, "Did not find DisplayInfo for displayId " + displayId); Loading Loading @@ -5975,7 +5978,17 @@ public final class PowerManagerService extends SystemService public boolean isWakeLockLevelSupported(int level) { final long ident = Binder.clearCallingIdentity(); try { return isWakeLockLevelSupportedInternal(level); return isWakeLockLevelSupportedInternal(level, Display.DEFAULT_DISPLAY); } finally { Binder.restoreCallingIdentity(ident); } } @Override // Binder call public boolean isWakeLockLevelSupportedWithDisplayId(int level, int displayId) { final long ident = Binder.clearCallingIdentity(); try { return isWakeLockLevelSupportedInternal(level, displayId); } finally { Binder.restoreCallingIdentity(ident); } Loading