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

Commit 79a8bd0a authored by Danesh M's avatar Danesh M Committed by Danesh Mondegarian
Browse files

PowerKey Shutter Button (1/2)

Adds an option to make the power key act as the shutter button.

Change-Id: I9d4957601125d0a8ecc1ad3ee0ae285e17df6bd3
parent e2bf4809
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -687,8 +687,10 @@ public abstract class Window {
     * @param mask Which of the window flag bits to modify.
     */
    public void setFlags(int flags, int mask) {
        if ((flags & WindowManager.LayoutParams.PREVENT_POWER_KEY) != 0){
            mContext.enforceCallingOrSelfPermission("android.permission.PREVENT_POWER_KEY", "No permission to prevent power key");
        }
        final WindowManager.LayoutParams attrs = getAttributes();

        flags=interceptFsRequest(flags);

        attrs.flags = (attrs.flags&~mask) | (flags&mask);
@@ -709,6 +711,9 @@ public abstract class Window {
     *          current values.
     */
    public void setAttributes(WindowManager.LayoutParams a) {
        if ((a.flags & WindowManager.LayoutParams.PREVENT_POWER_KEY) != 0){
            mContext.enforceCallingOrSelfPermission("android.permission.PREVENT_POWER_KEY", "No permission to prevent power key");
        }
        a.flags=interceptFsRequest(a.flags);
        mWindowAttributes.copyFrom(a);
        if (mCallback != null) {
+4 −1
Original line number Diff line number Diff line
@@ -630,6 +630,9 @@ public interface WindowManager extends ViewManager {
         * {@hide} */
        public static final int FLAG_SYSTEM_ERROR = 0x40000000;

        /** Window flag: Overrides default power key behavior */
        public static final int PREVENT_POWER_KEY = 0x80000000;

        /**
         * Given a particular set of window manager flags, determine whether
         * such a window may be a target for an input method when it has
+7 −0
Original line number Diff line number Diff line
@@ -452,6 +452,13 @@
        android:label="@string/permlab_camera"
        android:description="@string/permdesc_camera" />

    <!-- Allows an application to override the power key action -->
    <permission android:name="android.permission.PREVENT_POWER_KEY"
        android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
        android:protectionLevel="dangerous"
        android:label="@string/permlab_preventpower"
        android:description="@string/permdesc_preventpower" />

    <!-- Allows access to the vibrator -->
    <permission android:name="android.permission.VIBRATE"
        android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
+5 −0
Original line number Diff line number Diff line
@@ -756,6 +756,11 @@
        information about what you are doing with the phone, potentially
        including personal or private information.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_preventpower">prevent power key</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_preventpower">Allows an application to override the power key</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_diagnostic">read/write to resources owned by diag</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+3 −0
Original line number Diff line number Diff line
@@ -2185,6 +2185,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            }

            case KeyEvent.KEYCODE_POWER: {
                if ((mTopFullscreenOpaqueWindowState.getAttrs().flags & WindowManager.LayoutParams.PREVENT_POWER_KEY) != 0){
                    return result;
                }
                result &= ~ACTION_PASS_TO_USER;
                if (down) {
                    ITelephony telephonyService = getTelephonyService();