Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5718f500 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Merge "Revert "Per-display group PowerManager APIs by default"" into main

parents db6e75f5 95daecab
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -92,10 +92,9 @@ public abstract class DisplayManagerInternal {
            boolean waitForNegativeProximity);

    /**
     * Returns {@code true} if the proximity sensor screen-off function is available for the given
     * display.
     * Returns {@code true} if the proximity sensor screen-off function is available.
     */
    public abstract boolean isProximitySensorAvailable(int displayId);
    public abstract boolean isProximitySensorAvailable();

    /**
     * Registers a display group listener which will be informed of the addition, removal, or change
+0 −2
Original line number Diff line number Diff line
@@ -42,9 +42,7 @@ 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);
+0 −10
Original line number Diff line number Diff line
@@ -1344,9 +1344,6 @@ 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);
@@ -1737,10 +1734,6 @@ 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();
@@ -1804,9 +1797,6 @@ 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);
    }

+3 −2
Original line number Diff line number Diff line
@@ -5233,9 +5233,10 @@ public final class DisplayManagerService extends SystemService {
        }

        @Override
        public boolean isProximitySensorAvailable(int displayId) {
        public boolean isProximitySensorAvailable() {
            synchronized (mSyncRoot) {
                return mDisplayPowerControllers.get(displayId).isProximitySensorAvailable();
                return mDisplayPowerControllers.get(Display.DEFAULT_DISPLAY)
                        .isProximitySensorAvailable();
            }
        }

+6 −19
Original line number Diff line number Diff line
@@ -743,7 +743,6 @@ 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,
@@ -2036,7 +2035,7 @@ public final class PowerManagerService extends SystemService
    }

    @SuppressWarnings("deprecation")
    private boolean isWakeLockLevelSupportedInternal(int level, int displayId) {
    private boolean isWakeLockLevelSupportedInternal(int level) {
        synchronized (mLock) {
            switch (level) {
                case PowerManager.PARTIAL_WAKE_LOCK:
@@ -2048,8 +2047,7 @@ public final class PowerManagerService extends SystemService
                    return true;

                case PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK:
                    return mSystemReady
                            && mDisplayManagerInternal.isProximitySensorAvailable(displayId);
                    return mSystemReady && mDisplayManagerInternal.isProximitySensorAvailable();
                case PowerManager.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK:
                    return mSystemReady && mFeatureFlags.isEarlyScreenTimeoutDetectorEnabled()
                            && mScreenTimeoutOverridePolicy != null;
@@ -2266,6 +2264,7 @@ 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")
@@ -2330,6 +2329,8 @@ 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;
@@ -2427,7 +2428,6 @@ 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);
@@ -3975,9 +3975,6 @@ 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);
@@ -5978,17 +5975,7 @@ public final class PowerManagerService extends SystemService
        public boolean isWakeLockLevelSupported(int level) {
            final long ident = Binder.clearCallingIdentity();
            try {
                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);
                return isWakeLockLevelSupportedInternal(level);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
Loading