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

Commit 77f342c3 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Add app ops for wake locks."

parents 2e46b60d 713df150
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -104,8 +104,9 @@ public class AppOpsManager {
    public static final int OP_AUDIO_ALARM_VOLUME = 37;
    public static final int OP_AUDIO_NOTIFICATION_VOLUME = 38;
    public static final int OP_AUDIO_BLUETOOTH_VOLUME = 39;
    public static final int OP_WAKE_LOCK = 40;
    /** @hide */
    public static final int _NUM_OP = 40;
    public static final int _NUM_OP = 41;

    /**
     * This maps each operation to the operation that serves as the
@@ -156,6 +157,7 @@ public class AppOpsManager {
            OP_AUDIO_ALARM_VOLUME,
            OP_AUDIO_NOTIFICATION_VOLUME,
            OP_AUDIO_BLUETOOTH_VOLUME,
            OP_WAKE_LOCK,
    };

    /**
@@ -203,6 +205,7 @@ public class AppOpsManager {
            "AUDIO_ALARM_VOLUME",
            "AUDIO_NOTIFICATION_VOLUME",
            "AUDIO_BLUETOOTH_VOLUME",
            "WAKE_LOCK",
    };

    /**
@@ -250,6 +253,7 @@ public class AppOpsManager {
            null, // no permission for changing alarm volume
            null, // no permission for changing notification volume
            null, // no permission for changing bluetooth volume
            android.Manifest.permission.WAKE_LOCK,
    };

    /**
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ interface IPowerManager
{
    // WARNING: The first two methods must remain the first two methods because their
    // transaction numbers must not change unless IPowerManager.cpp is also updated.
    void acquireWakeLock(IBinder lock, int flags, String tag, in WorkSource ws);
    void acquireWakeLock(IBinder lock, int flags, String tag, String packageName, in WorkSource ws);
    void releaseWakeLock(IBinder lock, int flags);

    void updateWakeLockWorkSource(IBinder lock, in WorkSource ws);
+6 −4
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ public final class PowerManager {

    /**
     * Flag for {@link WakeLock#release release(int)} to defer releasing a
     * {@link #WAKE_BIT_PROXIMITY_SCREEN_OFF} wake lock until the proximity sensor returns
     * {@link #PROXIMITY_SCREEN_OFF_WAKE_LOCK} wake lock until the proximity sensor returns
     * a negative value.
     *
     * {@hide}
@@ -407,7 +407,7 @@ public final class PowerManager {
     */
    public WakeLock newWakeLock(int levelAndFlags, String tag) {
        validateWakeLockParameters(levelAndFlags, tag);
        return new WakeLock(levelAndFlags, tag);
        return new WakeLock(levelAndFlags, tag, mContext.getBasePackageName());
    }

    /** @hide */
@@ -624,6 +624,7 @@ public final class PowerManager {
    public final class WakeLock {
        private final int mFlags;
        private final String mTag;
        private final String mPackageName;
        private final IBinder mToken;
        private int mCount;
        private boolean mRefCounted = true;
@@ -636,9 +637,10 @@ public final class PowerManager {
            }
        };

        WakeLock(int flags, String tag) {
        WakeLock(int flags, String tag, String packageName) {
            mFlags = flags;
            mTag = tag;
            mPackageName = packageName;
            mToken = new Binder();
        }

@@ -714,7 +716,7 @@ public final class PowerManager {
                // been explicitly released by the keyguard.
                mHandler.removeCallbacks(mReleaser);
                try {
                    mService.acquireWakeLock(mToken, mFlags, mTag, mWorkSource);
                    mService.acquireWakeLock(mToken, mFlags, mTag, mPackageName, mWorkSource);
                } catch (RemoteException e) {
                }
                mHeld = true;
+3 −0
Original line number Diff line number Diff line
@@ -551,6 +551,9 @@ public class AppOpsService extends IAppOpsService.Stub {
                        pkgUid = mContext.getPackageManager().getPackageUid(packageName,
                                UserHandle.getUserId(uid));
                    } catch (NameNotFoundException e) {
                        if ("media".equals(packageName)) {
                            pkgUid = Process.MEDIA_UID;
                        }
                    }
                    if (pkgUid != uid) {
                        // Oops!  The package name is not valid for the uid they are calling
+2 −1
Original line number Diff line number Diff line
@@ -286,7 +286,8 @@ class ServerThread {
            // only initialize the power service after we have started the
            // lights service, content providers and the battery service.
            power.init(context, lights, ActivityManagerService.self(), battery,
                    BatteryStatsService.getService(), display);
                    BatteryStatsService.getService(),
                    ActivityManagerService.self().getAppOpsService(), display);

            Slog.i(TAG, "Alarm Manager");
            alarm = new AlarmManagerService(context);
Loading