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

Commit 1e50f473 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Trigger PowerManager setting update from DreamManager." into main

parents 8925cb8f d8099f60
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -71,8 +71,11 @@ public class DreamManager {
    @TestApi
    @RequiresPermission(WRITE_SECURE_SETTINGS)
    public void setScreensaverEnabled(boolean enabled) {
        Settings.Secure.putIntForUser(mContext.getContentResolver(),
                Settings.Secure.SCREENSAVER_ENABLED, enabled ? 1 : 0, UserHandle.USER_CURRENT);
        try {
            mService.setScreensaverEnabled(enabled);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /**
+5 −0
Original line number Diff line number Diff line
@@ -357,4 +357,9 @@ public abstract class PowerManagerInternal {
     * This may affect dream eligibility.
     */
    public abstract void setDevicePostured(boolean isPostured);

    /**
     * Notifies PowerManager that settings have changed and that it should refresh its state.
     */
    public abstract void updateSettings();
}
+2 −0
Original line number Diff line number Diff line
@@ -59,4 +59,6 @@ interface IDreamManager {
            float screenBrightnessFloat, int screenBrightnessInt,
            boolean useNormalBrightnessForDoze);
    oneway void finishSelfOneway(in IBinder token, boolean immediate);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)")
    void setScreensaverEnabled(boolean enabled);
}
+15 −0
Original line number Diff line number Diff line
@@ -1365,6 +1365,21 @@ public final class DreamManagerService extends SystemService {
            }
        }

        @Override
        public void setScreensaverEnabled(boolean enabled) {
            checkPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS);
            final UserHandle userHandle = getCallingUserHandle();
            final long ident = Binder.clearCallingIdentity();
            try {
                Settings.Secure.putIntForUser(mContext.getContentResolver(),
                        Settings.Secure.SCREENSAVER_ENABLED, enabled ? 1 : 0,
                        userHandle.getIdentifier());
                mPowerManagerInternal.updateSettings();
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }

        boolean canLaunchDreamActivity(String dreamPackageName, String packageName,
                int callingUid) {
            if (dreamPackageName == null || packageName == null) {
+7 −0
Original line number Diff line number Diff line
@@ -7445,6 +7445,13 @@ public final class PowerManagerService extends SystemService
        public void setDevicePostured(boolean isPostured) {
            setDevicePosturedInternal(isPostured);
        }

        @Override
        public void updateSettings() {
            synchronized (mLock) {
                updateSettingsLocked();
            }
        }
    }

    /**