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

Commit 45cf7031 authored by Danesh M's avatar Danesh M Committed by Steve Kondik
Browse files

Camera : Powerkey shutter (1/2)

Allows user to take use power key to take pictures/videos

Patchset 2 : Add mask to setFlags
Patchset 3 : Rebased

Change-Id: I19f7829a49b43dc04bbf73efc0a3d3f7b0d24987
parent 0710fdc2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -741,6 +741,9 @@ public abstract class Window {
     * @param mask Which of the window flag bits to modify.
     */
    public void setFlags(int flags, int mask) {
        if ((flags & mask & WindowManager.LayoutParams.PREVENT_POWER_KEY) != 0){
            mContext.enforceCallingOrSelfPermission("android.permission.PREVENT_POWER_KEY", "No permission to prevent power key");
        }
        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.flags = (attrs.flags&~mask) | (flags&mask);
        if ((mask&WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0) {
@@ -780,6 +783,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");
        }
        mWindowAttributes.copyFrom(a);
        if (mCallback != null) {
            mCallback.onWindowAttributesChanged(mWindowAttributes);
+3 −0
Original line number Diff line number Diff line
@@ -699,6 +699,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;

        /**
         * Various behavioral options/flags.  Default is none.
         * 
+7 −0
Original line number Diff line number Diff line
@@ -541,6 +541,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
@@ -852,6 +852,11 @@
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_movePackage">Allows an application to move application resources from internal to external media and vice versa.</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_readLogs">read sensitive log data</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
@@ -2926,6 +2926,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) {
                    if (isScreenOn && !mPowerKeyTriggered