diff options
author | Billy Lau <billylau@google.com> | 2015-06-30 09:05:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-30 09:05:34 +0000 |
commit | f62f4c94a36f5c2f7ad3c70316dc585ea3fd721a (patch) | |
tree | bdbb639a54a06230eefc3679ac08f17bcb222ba0 | |
parent | fef8cbd6a643a621a97f8e5616977e1fb65d9a5f (diff) | |
parent | cbe540f94691b595ca2eaede2871d885c38a845c (diff) | |
download | frameworks_base-f62f4c94a36f5c2f7ad3c70316dc585ea3fd721a.zip frameworks_base-f62f4c94a36f5c2f7ad3c70316dc585ea3fd721a.tar.gz frameworks_base-f62f4c94a36f5c2f7ad3c70316dc585ea3fd721a.tar.bz2 |
Merge "Bug: 21589105 Rescoping the SYSTEM_ALERT_WINDOW permission to an explicit toggle to be manually enabled in Settings." into mnc-dev
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | api/system-current.txt | 1 | ||||
-rw-r--r-- | core/java/android/provider/Settings.java | 15 | ||||
-rw-r--r-- | core/java/com/android/internal/logging/MetricsLogger.java | 1 | ||||
-rw-r--r-- | core/res/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 23 |
6 files changed, 42 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt index 2802062..3cb38c4 100644 --- a/api/current.txt +++ b/api/current.txt @@ -26424,6 +26424,7 @@ package android.provider { field public static final java.lang.String ACTION_LOCATION_SOURCE_SETTINGS = "android.settings.LOCATION_SOURCE_SETTINGS"; field public static final java.lang.String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS = "android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS"; field public static final java.lang.String ACTION_MANAGE_APPLICATIONS_SETTINGS = "android.settings.MANAGE_APPLICATIONS_SETTINGS"; + field public static final java.lang.String ACTION_MANAGE_OVERLAY_PERMISSION = "android.settings.MANAGE_OVERLAY_PERMISSION"; field public static final java.lang.String ACTION_MEMORY_CARD_SETTINGS = "android.settings.MEMORY_CARD_SETTINGS"; field public static final java.lang.String ACTION_NETWORK_OPERATOR_SETTINGS = "android.settings.NETWORK_OPERATOR_SETTINGS"; field public static final java.lang.String ACTION_NFCSHARING_SETTINGS = "android.settings.NFCSHARING_SETTINGS"; diff --git a/api/system-current.txt b/api/system-current.txt index 5713af2..9e6ae81 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -28485,6 +28485,7 @@ package android.provider { field public static final java.lang.String ACTION_LOCATION_SOURCE_SETTINGS = "android.settings.LOCATION_SOURCE_SETTINGS"; field public static final java.lang.String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS = "android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS"; field public static final java.lang.String ACTION_MANAGE_APPLICATIONS_SETTINGS = "android.settings.MANAGE_APPLICATIONS_SETTINGS"; + field public static final java.lang.String ACTION_MANAGE_OVERLAY_PERMISSION = "android.settings.MANAGE_OVERLAY_PERMISSION"; field public static final java.lang.String ACTION_MEMORY_CARD_SETTINGS = "android.settings.MEMORY_CARD_SETTINGS"; field public static final java.lang.String ACTION_NETWORK_OPERATOR_SETTINGS = "android.settings.NETWORK_OPERATOR_SETTINGS"; field public static final java.lang.String ACTION_NFCSHARING_SETTINGS = "android.settings.NFCSHARING_SETTINGS"; diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index cc56969..e5afdde 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -562,6 +562,21 @@ public final class Settings { "android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS"; /** + * Activity Action: Show settings to toggle permission to draw on top of + * other apps. + * <p> + * In some cases, a matching Activity may not exist, so ensure you + * safeguard against this. + * <p> + * Input: Nothing. + * <p> + * Output: Nothing. + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_MANAGE_OVERLAY_PERMISSION = + "android.settings.MANAGE_OVERLAY_PERMISSION"; + + /** * Activity Action: Show screen of details about a particular application. * <p> * In some cases, a matching Activity may not exist, so ensure you diff --git a/core/java/com/android/internal/logging/MetricsLogger.java b/core/java/com/android/internal/logging/MetricsLogger.java index b78eca7..6dc66ea 100644 --- a/core/java/com/android/internal/logging/MetricsLogger.java +++ b/core/java/com/android/internal/logging/MetricsLogger.java @@ -40,6 +40,7 @@ public class MetricsLogger implements MetricsConstants { public static final int ACTION_BRIGHTNESS = 218; public static final int ACTION_BRIGHTNESS_AUTO = 219; public static final int BRIGHTNESS_DIALOG = 220; + public static final int SYSTEM_ALERT_WINDOW_APPS = 221; // Temporary constants go here, to await migration to MetricsConstants. public static void visible(Context context, int category) throws IllegalArgumentException { diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index bada791..bd9b014 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1414,7 +1414,7 @@ <permission android:name="android.permission.SYSTEM_ALERT_WINDOW" android:label="@string/permlab_systemAlertWindow" android:description="@string/permdesc_systemAlertWindow" - android:protectionLevel="dangerous" /> + android:protectionLevel="signature|system|appop" /> <!-- ================================== --> <!-- Permissions affecting the system wallpaper --> diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index d31c6e9..b41dd06 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -51,6 +51,7 @@ import android.media.IAudioService; import android.media.Ringtone; import android.media.RingtoneManager; import android.media.session.MediaSessionLegacyHelper; +import android.os.Binder; import android.os.Bundle; import android.os.Debug; import android.os.FactoryTest; @@ -61,6 +62,7 @@ import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.os.PowerManager; +import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; @@ -267,6 +269,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { SearchManager mSearchManager; AccessibilityManager mAccessibilityManager; BurnInProtectionHelper mBurnInProtectionHelper; + AppOpsManager mAppOpsManager; // Vibrator pattern for haptic feedback of a long press. long[] mLongPressVibePattern; @@ -1255,6 +1258,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); mDreamManagerInternal = LocalServices.getService(DreamManagerInternal.class); + mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); // Init display burn-in protection boolean burnInProtectionEnabled = context.getResources().getBoolean( @@ -1812,6 +1816,25 @@ public class PhoneWindowManager implements WindowManagerPolicy { permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; } if (permission != null) { + if (permission == android.Manifest.permission.SYSTEM_ALERT_WINDOW) { + final int callingUid = Binder.getCallingUid(); + // check if this is a system uid first before bothering with + // obtaining package name + if (callingUid == Process.SYSTEM_UID) { + return WindowManagerGlobal.ADD_OKAY; + } + + final int mode = mAppOpsManager.checkOp(outAppOp[0], callingUid, + attrs.packageName); + if (mode == AppOpsManager.MODE_DEFAULT) { + if (mContext.checkCallingPermission(permission) != + PackageManager.PERMISSION_GRANTED) { + return WindowManagerGlobal.ADD_PERMISSION_DENIED; + } + } + return WindowManagerGlobal.ADD_OKAY; + } + if (mContext.checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { return WindowManagerGlobal.ADD_PERMISSION_DENIED; |