Loading core/java/android/view/Window.java +6 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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) { Loading core/java/android/view/WindowManager.java +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading core/res/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -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" Loading core/res/res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -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. --> Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading
core/java/android/view/Window.java +6 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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) { Loading
core/java/android/view/WindowManager.java +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
core/res/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -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" Loading
core/res/res/values/strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -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. --> Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading