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

Commit f4506c00 authored by Danesh M's avatar Danesh M
Browse files

Camera : Powerkey shutter (1/3)

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

Patchset 2 : Add mask to setFlags
Patchset 3 : Rebased

Change-Id: Ic54cae422d7cf66c28d9ca778eca7931cc62c851
parent b91c5c0e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -751,6 +751,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) {
@@ -790,6 +793,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
@@ -704,6 +704,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
@@ -588,6 +588,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
@@ -916,6 +916,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 the app to move app 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
@@ -3628,6 +3628,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