summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorBilly Lau <billylau@google.com>2015-07-18 00:26:58 +0100
committerBilly Lau <billylau@google.com>2015-07-29 23:21:26 +0100
commit6ad2d66072795dd9836350b273dcde52910ab4c3 (patch)
tree407b5f32d915c561baded2f6eb7ed7e9d2e61ad5 /services
parent771d210ab2d0df9d6748eb56e3f7250377df1fc4 (diff)
downloadframeworks_base-6ad2d66072795dd9836350b273dcde52910ab4c3.zip
frameworks_base-6ad2d66072795dd9836350b273dcde52910ab4c3.tar.gz
frameworks_base-6ad2d66072795dd9836350b273dcde52910ab4c3.tar.bz2
Bug: 21589105 Rescope WRITE_SETTINGS permission (framework services perm check
changes) AppOpsManager: Changed the default operating mode for WRITE_SETTINGS to MODE_DEFAULT from MODE_ALLOWED. packages/SettingsProvider: We no longer do static permission checks for WRITE_SETTINGS in early checks and defer that to app op when MODE_DEFAULT is returned. For some operations, checking against WRITE_SECURE_SETTINGS is sufficient. ActivityManagerService & PowerManagerService: Incorporated app op checks and handled the MODE_DEFAULT case. provider/Settings: Added helper function to do checks on whether app ops protected operations can be performed by a caller. This includes checks for WRITE_SETTINGS and SYSTEM_ALERT_WINDOW. Also added a public API (with javadocs) for apps to query if they can modify system settings. Changed the javadocs description for ACTION_MANAGE_WRITE_SETTINGS and ACTION_MANAGE_OVERLAY_PERMISSION. Added public API (with javadocs) for apps to query whether they can draw overlays or not, and also javadocs description on how to use that check. Change-Id: I7b651fe8af836c2074defdbd6acfec3f32acdbe9
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java22
-rw-r--r--services/core/java/com/android/server/power/PowerManagerService.java11
2 files changed, 29 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 89e500e..783dea5 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -17201,8 +17201,7 @@ public final class ActivityManagerService extends ActivityManagerNative
public void updatePersistentConfiguration(Configuration values) {
enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION,
"updateConfiguration()");
- enforceCallingPermission(android.Manifest.permission.WRITE_SETTINGS,
- "updateConfiguration()");
+ enforceWriteSettingsPermission("updateConfiguration()");
if (values == null) {
throw new NullPointerException("Configuration must not be null");
}
@@ -17214,6 +17213,25 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ private void enforceWriteSettingsPermission(String func) {
+ int uid = Binder.getCallingUid();
+ if (uid == Process.ROOT_UID) {
+ return;
+ }
+
+ if (Settings.checkAndNoteWriteSettingsOperation(mContext, uid,
+ Settings.getPackageNameForUid(mContext, uid), false)) {
+ return;
+ }
+
+ String msg = "Permission Denial: " + func + " from pid="
+ + Binder.getCallingPid()
+ + ", uid=" + uid
+ + " requires " + android.Manifest.permission.WRITE_SETTINGS;
+ Slog.w(TAG, msg);
+ throw new SecurityException(msg);
+ }
+
public void updateConfiguration(Configuration values) {
enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION,
"updateConfiguration()");
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 88476ce..b920f97 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -30,6 +30,7 @@ import com.android.server.lights.LightsManager;
import com.android.server.Watchdog;
import android.Manifest;
+import android.app.AppOpsManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -3319,8 +3320,14 @@ public final class PowerManagerService extends SystemService
*/
@Override // Binder call
public void setStayOnSetting(int val) {
- mContext.enforceCallingOrSelfPermission(
- android.Manifest.permission.WRITE_SETTINGS, null);
+ int uid = Binder.getCallingUid();
+ // if uid is of root's, we permit this operation straight away
+ if (uid != Process.ROOT_UID) {
+ if (!Settings.checkAndNoteWriteSettingsOperation(mContext, uid,
+ Settings.getPackageNameForUid(mContext, uid), true)) {
+ return;
+ }
+ }
final long ident = Binder.clearCallingIdentity();
try {