summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2013-01-31 15:00:51 -0800
committerDianne Hackborn <hackbod@google.com>2013-02-01 15:14:29 -0800
commitf265ea9d8307282ff1da3915978625a94fc2859e (patch)
tree4e92b5de30239c1808a395cb49c9b17fe28ccffb /services
parent7a4ecc957d437ad4914988edc7593570f1e43f79 (diff)
downloadframeworks_base-f265ea9d8307282ff1da3915978625a94fc2859e.zip
frameworks_base-f265ea9d8307282ff1da3915978625a94fc2859e.tar.gz
frameworks_base-f265ea9d8307282ff1da3915978625a94fc2859e.tar.bz2
App ops: vibration, neighboring cells, dialing, etc.
Improve handling of vibration op, so that apps are better blamed (there is now a hidden vibrator API that supplies the app to blame, and the system now uses this when vibrating on behalf of an app). Add operation for retrieving neighboring cell information. Add a new op for calling a phone number. This required plumbing information about the launching package name through the activity manager, which required changing the internal startActivity class, which required hitting a ton of code that uses those internal APIs. Change-Id: I3f8015634fdb296558f07fe654fb8d53e5c94d07
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/AppOpsService.java55
-rw-r--r--services/java/com/android/server/NotificationManagerService.java23
-rw-r--r--services/java/com/android/server/UiModeManagerService.java2
-rw-r--r--services/java/com/android/server/VibratorService.java22
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java66
-rw-r--r--services/java/com/android/server/am/ActivityRecord.java5
-rw-r--r--services/java/com/android/server/am/ActivityStack.java12
-rw-r--r--services/java/com/android/server/am/PendingIntentRecord.java7
-rw-r--r--services/java/com/android/server/am/ServiceRecord.java5
-rw-r--r--services/java/com/android/server/net/NetworkPolicyManagerService.java4
-rw-r--r--services/java/com/android/server/wm/WindowState.java10
-rw-r--r--services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java3
12 files changed, 125 insertions, 89 deletions
diff --git a/services/java/com/android/server/AppOpsService.java b/services/java/com/android/server/AppOpsService.java
index bf2a5ae..335917e 100644
--- a/services/java/com/android/server/AppOpsService.java
+++ b/services/java/com/android/server/AppOpsService.java
@@ -203,9 +203,9 @@ public class AppOpsService extends IAppOpsService.Stub {
@Override
public void setMode(int code, int uid, String packageName, int mode) {
- uid = handleIncomingUid(uid);
+ verifyIncomingUid(uid);
synchronized (this) {
- Op op = getOpLocked(code, uid, packageName, true);
+ Op op = getOpLocked(AppOpsManager.opToSwitch(code), uid, packageName, true);
if (op != null) {
if (op.mode != mode) {
op.mode = mode;
@@ -217,9 +217,9 @@ public class AppOpsService extends IAppOpsService.Stub {
@Override
public int checkOperation(int code, int uid, String packageName) {
- uid = handleIncomingUid(uid);
+ verifyIncomingUid(uid);
synchronized (this) {
- Op op = getOpLocked(code, uid, packageName, false);
+ Op op = getOpLocked(AppOpsManager.opToSwitch(code), uid, packageName, false);
if (op == null) {
return AppOpsManager.MODE_ALLOWED;
}
@@ -229,24 +229,27 @@ public class AppOpsService extends IAppOpsService.Stub {
@Override
public int noteOperation(int code, int uid, String packageName) {
- uid = handleIncomingUid(uid);
+ verifyIncomingUid(uid);
synchronized (this) {
- Op op = getOpLocked(code, uid, packageName, true);
- if (op == null) {
+ Ops ops = getOpsLocked(uid, packageName, true);
+ if (ops == null) {
if (DEBUG) Log.d(TAG, "noteOperation: no op for code " + code + " uid " + uid
+ " package " + packageName);
return AppOpsManager.MODE_IGNORED;
}
+ Op op = getOpLocked(ops, code, true);
if (op.duration == -1) {
Slog.w(TAG, "Noting op not finished: uid " + uid + " pkg " + packageName
+ " code " + code + " time=" + op.time + " duration=" + op.duration);
}
op.duration = 0;
- if (op.mode != AppOpsManager.MODE_ALLOWED) {
- if (DEBUG) Log.d(TAG, "noteOperation: reject #" + op.mode + " for code " + code
- + " uid " + uid + " package " + packageName);
+ final int switchCode = AppOpsManager.opToSwitch(code);
+ final Op switchOp = switchCode != code ? getOpLocked(ops, switchCode, true) : op;
+ if (switchOp.mode != AppOpsManager.MODE_ALLOWED) {
+ if (DEBUG) Log.d(TAG, "noteOperation: reject #" + op.mode + " for code "
+ + switchCode + " (" + code + ") uid " + uid + " package " + packageName);
op.rejectTime = System.currentTimeMillis();
- return op.mode;
+ return switchOp.mode;
}
if (DEBUG) Log.d(TAG, "noteOperation: allowing code " + code + " uid " + uid
+ " package " + packageName);
@@ -257,19 +260,22 @@ public class AppOpsService extends IAppOpsService.Stub {
@Override
public int startOperation(int code, int uid, String packageName) {
- uid = handleIncomingUid(uid);
+ verifyIncomingUid(uid);
synchronized (this) {
- Op op = getOpLocked(code, uid, packageName, true);
- if (op == null) {
+ Ops ops = getOpsLocked(uid, packageName, true);
+ if (ops == null) {
if (DEBUG) Log.d(TAG, "startOperation: no op for code " + code + " uid " + uid
+ " package " + packageName);
return AppOpsManager.MODE_IGNORED;
}
- if (op.mode != AppOpsManager.MODE_ALLOWED) {
- if (DEBUG) Log.d(TAG, "startOperation: reject #" + op.mode + " for code " + code
- + " uid " + uid + " package " + packageName);
+ Op op = getOpLocked(ops, code, true);
+ final int switchCode = AppOpsManager.opToSwitch(code);
+ final Op switchOp = switchCode != code ? getOpLocked(ops, switchCode, true) : op;
+ if (switchOp.mode != AppOpsManager.MODE_ALLOWED) {
+ if (DEBUG) Log.d(TAG, "startOperation: reject #" + op.mode + " for code "
+ + switchCode + " (" + code + ") uid " + uid + " package " + packageName);
op.rejectTime = System.currentTimeMillis();
- return op.mode;
+ return switchOp.mode;
}
if (DEBUG) Log.d(TAG, "startOperation: allowing code " + code + " uid " + uid
+ " package " + packageName);
@@ -284,7 +290,7 @@ public class AppOpsService extends IAppOpsService.Stub {
@Override
public void finishOperation(int code, int uid, String packageName) {
- uid = handleIncomingUid(uid);
+ verifyIncomingUid(uid);
synchronized (this) {
Op op = getOpLocked(code, uid, packageName, true);
if (op == null) {
@@ -305,16 +311,15 @@ public class AppOpsService extends IAppOpsService.Stub {
}
}
- private int handleIncomingUid(int uid) {
+ private void verifyIncomingUid(int uid) {
if (uid == Binder.getCallingUid()) {
- return uid;
+ return;
}
if (Binder.getCallingPid() == Process.myPid()) {
- return uid;
+ return;
}
mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,
Binder.getCallingPid(), Binder.getCallingUid(), null);
- return uid;
}
private Ops getOpsLocked(int uid, String packageName, boolean edit) {
@@ -377,6 +382,10 @@ public class AppOpsService extends IAppOpsService.Stub {
if (ops == null) {
return null;
}
+ return getOpLocked(ops, code, edit);
+ }
+
+ private Op getOpLocked(Ops ops, int code, boolean edit) {
Op op = ops.get(code);
if (op == null) {
if (!edit) {
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index adcc6ad..d121653 100644
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -278,6 +278,7 @@ public class NotificationManagerService extends INotificationManager.Stub
private static final class NotificationRecord
{
final String pkg;
+ final String basePkg;
final String tag;
final int id;
final int uid;
@@ -287,10 +288,11 @@ public class NotificationManagerService extends INotificationManager.Stub
final int score;
IBinder statusBarKey;
- NotificationRecord(String pkg, String tag, int id, int uid, int initialPid,
+ NotificationRecord(String pkg, String basePkg, String tag, int id, int uid, int initialPid,
int userId, int score, Notification notification)
{
this.pkg = pkg;
+ this.basePkg = basePkg;
this.tag = tag;
this.id = id;
this.uid = uid;
@@ -880,10 +882,10 @@ public class NotificationManagerService extends INotificationManager.Stub
// Notifications
// ============================================================================
- public void enqueueNotificationWithTag(String pkg, String tag, int id, Notification notification,
- int[] idOut, int userId)
+ public void enqueueNotificationWithTag(String pkg, String basePkg, String tag, int id,
+ Notification notification, int[] idOut, int userId)
{
- enqueueNotificationInternal(pkg, Binder.getCallingUid(), Binder.getCallingPid(),
+ enqueueNotificationInternal(pkg, basePkg, Binder.getCallingUid(), Binder.getCallingPid(),
tag, id, notification, idOut, userId);
}
@@ -893,8 +895,8 @@ public class NotificationManagerService extends INotificationManager.Stub
// Not exposed via Binder; for system use only (otherwise malicious apps could spoof the
// uid/pid of another application)
- public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid,
- String tag, int id, Notification notification, int[] idOut, int userId)
+ public void enqueueNotificationInternal(String pkg, String basePkg, int callingUid,
+ int callingPid, String tag, int id, Notification notification, int[] idOut, int userId)
{
if (DBG) {
Slog.v(TAG, "enqueueNotificationInternal: pkg=" + pkg + " id=" + id + " notification=" + notification);
@@ -984,7 +986,7 @@ public class NotificationManagerService extends INotificationManager.Stub
final boolean canInterrupt = (score >= SCORE_INTERRUPTION_THRESHOLD);
synchronized (mNotificationList) {
- NotificationRecord r = new NotificationRecord(pkg, tag, id,
+ NotificationRecord r = new NotificationRecord(pkg, basePkg, tag, id,
callingUid, callingPid, userId,
score,
notification);
@@ -1141,15 +1143,16 @@ public class NotificationManagerService extends INotificationManager.Stub
// does not have the VIBRATE permission.
long identity = Binder.clearCallingIdentity();
try {
- mVibrator.vibrate(useDefaultVibrate ? mDefaultVibrationPattern
- : mFallbackVibrationPattern,
+ mVibrator.vibrate(r.uid, r.basePkg,
+ useDefaultVibrate ? mDefaultVibrationPattern
+ : mFallbackVibrationPattern,
((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);
} finally {
Binder.restoreCallingIdentity(identity);
}
} else if (notification.vibrate.length > 1) {
// If you want your own vibration pattern, you need the VIBRATE permission
- mVibrator.vibrate(notification.vibrate,
+ mVibrator.vibrate(r.uid, r.basePkg, notification.vibrate,
((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);
}
}
diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java
index 0e456f1..062be01 100644
--- a/services/java/com/android/server/UiModeManagerService.java
+++ b/services/java/com/android/server/UiModeManagerService.java
@@ -494,7 +494,7 @@ final class UiModeManagerService extends IUiModeManager.Stub {
if (Sandman.shouldStartDockApp(mContext, homeIntent)) {
try {
int result = ActivityManagerNative.getDefault().startActivityWithConfig(
- null, homeIntent, null, null, null, 0, 0,
+ null, null, homeIntent, null, null, null, 0, 0,
mConfiguration, null, UserHandle.USER_CURRENT);
if (result >= ActivityManager.START_SUCCESS) {
dockAppStarted = true;
diff --git a/services/java/com/android/server/VibratorService.java b/services/java/com/android/server/VibratorService.java
index 69379f1..9065525 100644
--- a/services/java/com/android/server/VibratorService.java
+++ b/services/java/com/android/server/VibratorService.java
@@ -178,12 +178,23 @@ public class VibratorService extends IVibratorService.Stub
return doVibratorExists();
}
- public void vibrate(String packageName, long milliseconds, IBinder token) {
+ private void verifyIncomingUid(int uid) {
+ if (uid == Binder.getCallingUid()) {
+ return;
+ }
+ if (Binder.getCallingPid() == Process.myPid()) {
+ return;
+ }
+ mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,
+ Binder.getCallingPid(), Binder.getCallingUid(), null);
+ }
+
+ public void vibrate(int uid, String packageName, long milliseconds, IBinder token) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires VIBRATE permission");
}
- int uid = Binder.getCallingUid();
+ verifyIncomingUid(uid);
// We're running in the system server so we cannot crash. Check for a
// timeout of 0 or negative. This will ensure that a vibration has
// either a timeout of > 0 or a non-null pattern.
@@ -219,12 +230,13 @@ public class VibratorService extends IVibratorService.Stub
return true;
}
- public void vibratePattern(String packageName, long[] pattern, int repeat, IBinder token) {
+ public void vibratePattern(int uid, String packageName, long[] pattern, int repeat,
+ IBinder token) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires VIBRATE permission");
}
- int uid = Binder.getCallingUid();
+ verifyIncomingUid(uid);
// so wakelock calls will succeed
long identity = Binder.clearCallingIdentity();
try {
@@ -454,7 +466,7 @@ public class VibratorService extends IVibratorService.Stub
//synchronized (mInputDeviceVibrators) {
// return !mInputDeviceVibrators.isEmpty() || vibratorExists();
//}
- return vibratorExists();
+ return true || vibratorExists();
}
private void doVibratorOn(long millis, int uid) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index ca60a93..252cae2 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -624,7 +624,6 @@ public final class ActivityManagerService extends ActivityManagerNative
/**
* Thread-local storage used to carry caller permissions over through
* indirect content-provider access.
- * @see #ActivityManagerService.openContentUri()
*/
private class Identity {
public int pid;
@@ -831,18 +830,6 @@ public final class ActivityManagerService extends ActivityManagerNative
= new ArrayList<ProcessChangeItem>();
/**
- * Callback of last caller to {@link #requestPss}.
- */
- Runnable mRequestPssCallback;
-
- /**
- * Remaining processes for which we are waiting results from the last
- * call to {@link #requestPss}.
- */
- final ArrayList<ProcessRecord> mRequestPssList
- = new ArrayList<ProcessRecord>();
-
- /**
* Runtime statistics collection thread. This object's lock is used to
* protect all related state.
*/
@@ -1231,7 +1218,7 @@ public final class ActivityManagerService extends ActivityManagerNative
try {
int[] outId = new int[1];
- inm.enqueueNotificationWithTag("android", null,
+ inm.enqueueNotificationWithTag("android", "android", null,
R.string.heavy_weight_notification,
notification, outId, root.userId);
} catch (RuntimeException e) {
@@ -2309,7 +2296,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (app == null || app.instrumentationClass == null) {
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
mMainStack.startActivityLocked(null, intent, null, aInfo,
- null, null, 0, 0, 0, 0, null, false, null);
+ null, null, 0, 0, 0, null, 0, null, false, null);
}
}
@@ -2387,7 +2374,7 @@ public final class ActivityManagerService extends ActivityManagerNative
intent.setComponent(new ComponentName(
ri.activityInfo.packageName, ri.activityInfo.name));
mMainStack.startActivityLocked(null, intent, null, ri.activityInfo,
- null, null, 0, 0, 0, 0, null, false, null);
+ null, null, 0, 0, 0, null, 0, null, false, null);
}
}
}
@@ -2522,27 +2509,28 @@ public final class ActivityManagerService extends ActivityManagerNative
mPendingActivityLaunches.clear();
}
- public final int startActivity(IApplicationThread caller,
+ public final int startActivity(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags,
String profileFile, ParcelFileDescriptor profileFd, Bundle options) {
- return startActivityAsUser(caller, intent, resolvedType, resultTo, resultWho, requestCode,
+ return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
+ resultWho, requestCode,
startFlags, profileFile, profileFd, options, UserHandle.getCallingUserId());
}
- public final int startActivityAsUser(IApplicationThread caller,
+ public final int startActivityAsUser(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags,
String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId) {
enforceNotIsolatedCaller("startActivity");
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivity", null);
- return mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
+ return mMainStack.startActivityMayWait(caller, -1, callingPackage, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags, profileFile, profileFd,
null, null, options, userId);
}
- public final WaitResult startActivityAndWait(IApplicationThread caller,
+ public final WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options, int userId) {
@@ -2550,20 +2538,20 @@ public final class ActivityManagerService extends ActivityManagerNative
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityAndWait", null);
WaitResult res = new WaitResult();
- mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
+ mMainStack.startActivityMayWait(caller, -1, callingPackage, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags, profileFile, profileFd,
res, null, options, UserHandle.getCallingUserId());
return res;
}
- public final int startActivityWithConfig(IApplicationThread caller,
+ public final int startActivityWithConfig(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, Configuration config,
Bundle options, int userId) {
enforceNotIsolatedCaller("startActivityWithConfig");
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityWithConfig", null);
- int ret = mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
+ int ret = mMainStack.startActivityMayWait(caller, -1, callingPackage, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags,
null, null, null, config, options, userId);
return ret;
@@ -2684,7 +2672,7 @@ public final class ActivityManagerService extends ActivityManagerNative
final long origId = Binder.clearCallingIdentity();
int res = mMainStack.startActivityLocked(r.app.thread, intent,
r.resolvedType, aInfo, resultTo != null ? resultTo.appToken : null,
- resultWho, requestCode, -1, r.launchedFromUid, 0,
+ resultWho, requestCode, -1, r.launchedFromUid, r.launchedFromPackage, 0,
options, false, null);
Binder.restoreCallingIdentity(origId);
@@ -2696,38 +2684,38 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
- final int startActivityInPackage(int uid,
+ final int startActivityInPackage(int uid, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, Bundle options, int userId) {
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityInPackage", null);
- int ret = mMainStack.startActivityMayWait(null, uid, intent, resolvedType,
+ int ret = mMainStack.startActivityMayWait(null, uid, callingPackage, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags,
null, null, null, null, options, userId);
return ret;
}
- public final int startActivities(IApplicationThread caller,
+ public final int startActivities(IApplicationThread caller, String callingPackage,
Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle options,
int userId) {
enforceNotIsolatedCaller("startActivities");
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivity", null);
- int ret = mMainStack.startActivities(caller, -1, intents, resolvedTypes, resultTo,
- options, userId);
+ int ret = mMainStack.startActivities(caller, -1, callingPackage, intents,
+ resolvedTypes, resultTo, options, userId);
return ret;
}
- final int startActivitiesInPackage(int uid,
+ final int startActivitiesInPackage(int uid, String callingPackage,
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options, int userId) {
userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityInPackage", null);
- int ret = mMainStack.startActivities(null, uid, intents, resolvedTypes, resultTo,
- options, userId);
+ int ret = mMainStack.startActivities(null, uid, callingPackage, intents, resolvedTypes,
+ resultTo, options, userId);
return ret;
}
@@ -6743,7 +6731,6 @@ public final class ActivityManagerService extends ActivityManagerNative
/**
* Drop a content provider from a ProcessRecord's bookkeeping
- * @param cpr
*/
public void removeContentProvider(IBinder connection, boolean stable) {
enforceNotIsolatedCaller("removeContentProvider");
@@ -12665,7 +12652,8 @@ public final class ActivityManagerService extends ActivityManagerNative
destIntent.getComponent(), 0, srec.userId);
int res = mMainStack.startActivityLocked(srec.app.thread, destIntent,
null, aInfo, parent.appToken, null,
- 0, -1, parent.launchedFromUid, 0, null, true, null);
+ 0, -1, parent.launchedFromUid, parent.launchedFromPackage,
+ 0, null, true, null);
foundParentInTask = res == ActivityManager.START_SUCCESS;
} catch (RemoteException e) {
foundParentInTask = false;
@@ -12687,6 +12675,14 @@ public final class ActivityManagerService extends ActivityManagerNative
return srec.launchedFromUid;
}
+ public String getLaunchedFromPackage(IBinder activityToken) {
+ ActivityRecord srec = ActivityRecord.forToken(activityToken);
+ if (srec == null) {
+ return null;
+ }
+ return srec.launchedFromPackage;
+ }
+
// =========================================================
// LIFETIME MANAGEMENT
// =========================================================
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java
index 3af2287..ba2e47a 100644
--- a/services/java/com/android/server/am/ActivityRecord.java
+++ b/services/java/com/android/server/am/ActivityRecord.java
@@ -59,6 +59,7 @@ final class ActivityRecord {
final IApplicationToken.Stub appToken; // window manager token
final ActivityInfo info; // all about me
final int launchedFromUid; // always the uid who started the activity.
+ final String launchedFromPackage; // always the package who started the activity.
final int userId; // Which user is this running for?
final Intent intent; // the original intent that generated us
final ComponentName realActivity; // the intent component, or target of an alias.
@@ -135,6 +136,7 @@ final class ActivityRecord {
pw.print(prefix); pw.print("packageName="); pw.print(packageName);
pw.print(" processName="); pw.println(processName);
pw.print(prefix); pw.print("launchedFromUid="); pw.print(launchedFromUid);
+ pw.print(" launchedFromPackage="); pw.println(launchedFromPackage);
pw.print(" userId="); pw.println(userId);
pw.print(prefix); pw.print("app="); pw.println(app);
pw.print(prefix); pw.println(intent.toInsecureStringWithClip());
@@ -325,7 +327,7 @@ final class ActivityRecord {
}
ActivityRecord(ActivityManagerService _service, ActivityStack _stack, ProcessRecord _caller,
- int _launchedFromUid, Intent _intent, String _resolvedType,
+ int _launchedFromUid, String _launchedFromPackage, Intent _intent, String _resolvedType,
ActivityInfo aInfo, Configuration _configuration,
ActivityRecord _resultTo, String _resultWho, int _reqCode,
boolean _componentSpecified) {
@@ -334,6 +336,7 @@ final class ActivityRecord {
appToken = new Token(this);
info = aInfo;
launchedFromUid = _launchedFromUid;
+ launchedFromPackage = _launchedFromPackage;
userId = UserHandle.getUserId(aInfo.applicationInfo.uid);
intent = _intent;
shortComponentName = _intent.getComponent().flattenToShortString();
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index de9dda4..526b24f 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -2483,7 +2483,7 @@ final class ActivityStack {
final int startActivityLocked(IApplicationThread caller,
Intent intent, String resolvedType, ActivityInfo aInfo, IBinder resultTo,
String resultWho, int requestCode,
- int callingPid, int callingUid, int startFlags, Bundle options,
+ int callingPid, int callingUid, String callingPackage, int startFlags, Bundle options,
boolean componentSpecified, ActivityRecord[] outActivity) {
int err = ActivityManager.START_SUCCESS;
@@ -2620,7 +2620,7 @@ final class ActivityStack {
}
}
- ActivityRecord r = new ActivityRecord(mService, this, callerApp, callingUid,
+ ActivityRecord r = new ActivityRecord(mService, this, callerApp, callingUid, callingPackage,
intent, resolvedType, aInfo, mService.mConfiguration,
resultRecord, resultWho, requestCode, componentSpecified);
if (outActivity != null) {
@@ -3095,7 +3095,7 @@ final class ActivityStack {
}
final int startActivityMayWait(IApplicationThread caller, int callingUid,
- Intent intent, String resolvedType, IBinder resultTo,
+ String callingPackage, Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, String profileFile,
ParcelFileDescriptor profileFd, WaitResult outResult, Configuration config,
Bundle options, int userId) {
@@ -3202,7 +3202,7 @@ final class ActivityStack {
int res = startActivityLocked(caller, intent, resolvedType,
aInfo, resultTo, resultWho, requestCode, callingPid, callingUid,
- startFlags, options, componentSpecified, null);
+ callingPackage, startFlags, options, componentSpecified, null);
if (mConfigWillChange && mMainStack) {
// If the caller also wants to switch to a new configuration,
@@ -3253,7 +3253,7 @@ final class ActivityStack {
}
}
- final int startActivities(IApplicationThread caller, int callingUid,
+ final int startActivities(IApplicationThread caller, int callingUid, String callingPackage,
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options, int userId) {
if (intents == null) {
@@ -3316,7 +3316,7 @@ final class ActivityStack {
theseOptions = null;
}
int res = startActivityLocked(caller, intent, resolvedTypes[i],
- aInfo, resultTo, null, -1, callingPid, callingUid,
+ aInfo, resultTo, null, -1, callingPid, callingUid, callingPackage,
0, theseOptions, componentSpecified, outActivity);
if (res < 0) {
return res;
diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java
index 8ee303f..8ab71dd 100644
--- a/services/java/com/android/server/am/PendingIntentRecord.java
+++ b/services/java/com/android/server/am/PendingIntentRecord.java
@@ -246,11 +246,12 @@ class PendingIntentRecord extends IIntentSender.Stub {
}
allIntents[allIntents.length-1] = finalIntent;
allResolvedTypes[allResolvedTypes.length-1] = resolvedType;
- owner.startActivitiesInPackage(uid, allIntents,
+ owner.startActivitiesInPackage(uid, key.packageName, allIntents,
allResolvedTypes, resultTo, options, userId);
} else {
- owner.startActivityInPackage(uid, finalIntent, resolvedType,
- resultTo, resultWho, requestCode, 0, options, userId);
+ owner.startActivityInPackage(uid, key.packageName, finalIntent,
+ resolvedType, resultTo, resultWho, requestCode, 0,
+ options, userId);
}
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java
index 84e824a..b06c60a 100644
--- a/services/java/com/android/server/am/ServiceRecord.java
+++ b/services/java/com/android/server/am/ServiceRecord.java
@@ -369,8 +369,9 @@ class ServiceRecord extends Binder {
}
try {
int[] outId = new int[1];
- nm.enqueueNotificationInternal(localPackageName, appUid, appPid,
- null, localForegroundId, localForegroundNoti, outId, userId);
+ nm.enqueueNotificationInternal(localPackageName, localPackageName,
+ appUid, appPid, null, localForegroundId, localForegroundNoti,
+ outId, userId);
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
"Error showing notification for service", e);
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java
index cbd2a0f..3ae652a 100644
--- a/services/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -828,7 +828,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
final String packageName = mContext.getPackageName();
final int[] idReceived = new int[1];
mNotifManager.enqueueNotificationWithTag(
- packageName, tag, 0x0, builder.getNotification(), idReceived,
+ packageName, packageName, tag, 0x0, builder.getNotification(), idReceived,
UserHandle.USER_OWNER);
mActiveNotifs.add(tag);
} catch (RemoteException e) {
@@ -863,7 +863,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
try {
final String packageName = mContext.getPackageName();
final int[] idReceived = new int[1];
- mNotifManager.enqueueNotificationWithTag(packageName, tag,
+ mNotifManager.enqueueNotificationWithTag(packageName, packageName, tag,
0x0, builder.getNotification(), idReceived, UserHandle.USER_OWNER);
mActiveNotifs.add(tag);
} catch (RemoteException e) {
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index cb11be3..a335958 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -382,6 +382,16 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
@Override
+ public int getOwningUid() {
+ return mSession.mUid;
+ }
+
+ @Override
+ public String getOwningPackage() {
+ return mAttrs.packageName;
+ }
+
+ @Override
public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) {
mHaveFrame = true;
diff --git a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
index 47ce130..8b9f718 100644
--- a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
@@ -864,7 +864,8 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase {
private Future<String> expectEnqueueNotification() throws Exception {
final FutureCapture<String> tag = new FutureCapture<String>();
- mNotifManager.enqueueNotificationWithTag(isA(String.class), capture(tag.capture), anyInt(),
+ mNotifManager.enqueueNotificationWithTag(isA(String.class), isA(String.class),
+ capture(tag.capture), anyInt(),
isA(Notification.class), isA(int[].class), UserHandle.myUserId());
return tag;
}