diff options
| author | Steve Kondik <shade@chemlab.org> | 2013-06-12 00:47:55 -0700 |
|---|---|---|
| committer | Steve Kondik <shade@chemlab.org> | 2013-06-24 11:36:22 -0700 |
| commit | e48fce6da7bd839d70cbf69abb2780c6d30ea7f6 (patch) | |
| tree | 49dd160f5a5d10847fd446e0db7f31f2d800792f /services/java/com/android/server/am/ActivityManagerService.java | |
| parent | b429a08331e8ebea15113fe287f4e5c9478d7001 (diff) | |
| download | frameworks_base-e48fce6da7bd839d70cbf69abb2780c6d30ea7f6.zip frameworks_base-e48fce6da7bd839d70cbf69abb2780c6d30ea7f6.tar.gz frameworks_base-e48fce6da7bd839d70cbf69abb2780c6d30ea7f6.tar.bz2 | |
framework: Privacy Guard
* Introduce a new privacy feature which allows the user to run an
application with reduced visibility into his or her personal data.
* Adds a per-application flag and simple API to determine if this flag
is enabled for the current or calling process.
* This flag can be used by content providers to decide if they should
return a limited/empty dataset.
Change-Id: Id7c54d728e63acb2b02a2a9322930b54949f6c5d
Diffstat (limited to 'services/java/com/android/server/am/ActivityManagerService.java')
| -rw-r--r-- | services/java/com/android/server/am/ActivityManagerService.java | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index c068982..618f02c 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -120,6 +120,7 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; +import android.provider.Telephony.Sms.Intents; import android.text.format.Time; import android.util.EventLog; import android.util.Log; @@ -901,6 +902,9 @@ public final class ActivityManagerService extends ActivityManagerNative static final int CONTINUE_USER_SWITCH_MSG = 35; static final int USER_SWITCH_TIMEOUT_MSG = 36; + static final int POST_PRIVACY_NOTIFICATION_MSG = 40; + static final int CANCEL_PRIVACY_NOTIFICATION_MSG = 41; + static final int FIRST_ACTIVITY_STACK_MSG = 100; static final int FIRST_BROADCAST_QUEUE_MSG = 200; static final int FIRST_COMPAT_MODE_MSG = 300; @@ -1361,6 +1365,69 @@ public final class ActivityManagerService extends ActivityManagerNative timeoutUserSwitch((UserStartedState)msg.obj, msg.arg1, msg.arg2); break; } + case POST_PRIVACY_NOTIFICATION_MSG: { + INotificationManager inm = NotificationManager.getService(); + if (inm == null) { + return; + } + + ActivityRecord root = (ActivityRecord)msg.obj; + ProcessRecord process = root.app; + if (process == null) { + return; + } + + try { + Context context = mContext.createPackageContext(process.info.packageName, 0); + String text = mContext.getString(R.string.privacy_guard_notification_detail, + context.getApplicationInfo().loadLabel(context.getPackageManager())); + String title = mContext.getString(R.string.privacy_guard_notification); + + Intent infoIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, + Uri.fromParts("package", root.packageName, null)); + + Notification notification = new Notification(); + notification.icon = com.android.internal.R.drawable.stat_notify_privacy_guard; + notification.when = 0; + notification.flags = Notification.FLAG_ONGOING_EVENT; + notification.priority = Notification.PRIORITY_LOW; + notification.defaults = 0; + notification.sound = null; + notification.vibrate = null; + notification.setLatestEventInfo(getUiContext(), + title, text, + PendingIntent.getActivityAsUser(mContext, 0, infoIntent, + PendingIntent.FLAG_CANCEL_CURRENT, null, + new UserHandle(root.userId))); + + try { + int[] outId = new int[1]; + inm.enqueueNotificationWithTag("android", null, + R.string.privacy_guard_notification, + notification, outId, root.userId); + } catch (RuntimeException e) { + Slog.w(ActivityManagerService.TAG, + "Error showing notification for privacy guard", e); + } catch (RemoteException e) { + } + } catch (NameNotFoundException e) { + Slog.w(TAG, "Unable to create context for privacy guard notification", e); + } + } break; + case CANCEL_PRIVACY_NOTIFICATION_MSG: { + INotificationManager inm = NotificationManager.getService(); + if (inm == null) { + return; + } + try { + inm.cancelNotificationWithTag("android", null, + R.string.privacy_guard_notification, msg.arg1); + } catch (RuntimeException e) { + Slog.w(ActivityManagerService.TAG, + "Error canceling notification for service", e); + } catch (RemoteException e) { + } + } break; } } }; @@ -7426,6 +7493,30 @@ public final class ActivityManagerService extends ActivityManagerNative return KEY_DISPATCHING_TIMEOUT; } + public boolean isPrivacyGuardEnabledForProcess(int pid) { + ProcessRecord proc; + synchronized (mPidsSelfLocked) { + proc = mPidsSelfLocked.get(pid); + } + if (proc == null) { + return false; + } + try { + return AppGlobals.getPackageManager().getPrivacyGuardSetting( + proc.info.packageName, proc.userId); + } catch (RemoteException e) { + Log.e(TAG, e.getMessage(), e); + } + return false; + } + + public boolean isFilteredByPrivacyGuard(String intent) { + return Intents.SMS_RECEIVED_ACTION.equals(intent) || + Intents.DATA_SMS_RECEIVED_ACTION.equals(intent) || + Intents.SMS_EMERGENCY_CB_RECEIVED_ACTION.equals(intent) || + Intents.SMS_CB_RECEIVED_ACTION.equals(intent); + } + public void registerProcessObserver(IProcessObserver observer) { enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER, "registerProcessObserver()"); |
