Merge "DO NOT MERGE: Reduce shell power over user management." into lmp-mr1-dev
diff --git a/api/system-current.txt b/api/system-current.txt
index 4402a17..729f656 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -8934,7 +8934,6 @@
method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);
method public android.graphics.drawable.Drawable loadLogo(android.content.pm.PackageManager);
- method public java.lang.CharSequence loadSafeLabel(android.content.pm.PackageManager);
method public android.graphics.drawable.Drawable loadUnbadgedIcon(android.content.pm.PackageManager);
method public android.content.res.XmlResourceParser loadXmlMetaData(android.content.pm.PackageManager, java.lang.String);
method public void writeToParcel(android.os.Parcel, int);
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 8c57169..b4f6d10 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1529,9 +1529,10 @@
case START_BACKUP_AGENT_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
- ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
+ String packageName = data.readString();
int backupRestoreMode = data.readInt();
- boolean success = bindBackupAgent(info, backupRestoreMode);
+ int userId = data.readInt();
+ boolean success = bindBackupAgent(packageName, backupRestoreMode, userId);
reply.writeNoException();
reply.writeInt(success ? 1 : 0);
return true;
@@ -3591,13 +3592,14 @@
return binder;
}
- public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode)
+ public boolean bindBackupAgent(String packageName, int backupRestoreMode, int userId)
throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
- app.writeToParcel(data, 0);
+ data.writeString(packageName);
data.writeInt(backupRestoreMode);
+ data.writeInt(userId);
mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0);
reply.readException();
boolean success = reply.readInt() != 0;
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index dd3a38b..832ff5e 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -176,7 +176,7 @@
int res) throws RemoteException;
public IBinder peekService(Intent service, String resolvedType) throws RemoteException;
- public boolean bindBackupAgent(ApplicationInfo appInfo, int backupRestoreMode)
+ public boolean bindBackupAgent(String packageName, int backupRestoreMode, int userId)
throws RemoteException;
public void clearPendingBackup() throws RemoteException;
public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException;
diff --git a/core/java/android/content/pm/PackageItemInfo.java b/core/java/android/content/pm/PackageItemInfo.java
index 0d089d0..84474bb 100644
--- a/core/java/android/content/pm/PackageItemInfo.java
+++ b/core/java/android/content/pm/PackageItemInfo.java
@@ -16,8 +16,6 @@
package android.content.pm;
-import android.annotation.NonNull;
-import android.annotation.SystemApi;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
@@ -26,9 +24,6 @@
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Printer;
-import android.text.BidiFormatter;
-import android.text.TextPaint;
-import android.text.Html;
import java.text.Collator;
import java.util.Comparator;
@@ -42,7 +37,6 @@
* in the implementation of Parcelable in subclasses.
*/
public class PackageItemInfo {
- private static final float MAX_LABEL_SIZE_PX = 500f;
/**
* Public name of this item. From the "android:name" attribute.
*/
@@ -143,62 +137,7 @@
}
return packageName;
}
-
- /**
- * Same as {@link #loadLabel(PackageManager)} with the addition that
- * the returned label is safe for being presented in the UI since it
- * will not contain new lines and the length will be limited to a
- * reasonable amount. This prevents a malicious party to influence UI
- * layout via the app label misleading the user into performing a
- * detrimental for them action. If the label is too long it will be
- * truncated and ellipsized at the end.
- *
- * @param pm A PackageManager from which the label can be loaded; usually
- * the PackageManager from which you originally retrieved this item
- * @return Returns a CharSequence containing the item's label. If the
- * item does not have a label, its name is returned.
- *
- * @hide
- */
- @SystemApi
- public @NonNull CharSequence loadSafeLabel(@NonNull PackageManager pm) {
- // loadLabel() always returns non-null
- String label = loadLabel(pm).toString();
- // strip HTML tags to avoid <br> and other tags overwriting original message
- String labelStr = Html.fromHtml(label).toString();
-
- // If the label contains new line characters it may push the UI
- // down to hide a part of it. Labels shouldn't have new line
- // characters, so just truncate at the first time one is seen.
- final int labelLength = labelStr.length();
- int offset = 0;
- while (offset < labelLength) {
- final int codePoint = labelStr.codePointAt(offset);
- final int type = Character.getType(codePoint);
- if (type == Character.LINE_SEPARATOR
- || type == Character.CONTROL
- || type == Character.PARAGRAPH_SEPARATOR) {
- labelStr = labelStr.substring(0, offset);
- break;
- }
- // replace all non-break space to " " in order to be trimmed
- if (type == Character.SPACE_SEPARATOR) {
- labelStr = labelStr.substring(0, offset) + " " + labelStr.substring(offset +
- Character.charCount(codePoint));
- }
- offset += Character.charCount(codePoint);
- }
-
- labelStr = labelStr.trim();
- if (labelStr.isEmpty()) {
- return packageName;
- }
- TextPaint paint = new TextPaint();
- paint.setTextSize(42);
-
- return TextUtils.ellipsize(labelStr, paint, MAX_LABEL_SIZE_PX,
- TextUtils.TruncateAt.END);
- }
+
/**
* Retrieve the current graphical icon associated with this item. This
* will call back on the given PackageManager to load the icon from
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index c1e4994..b70ec52 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -2118,7 +2118,8 @@
mConnecting = true;
mConnectedAgent = null;
try {
- if (mActivityManager.bindBackupAgent(app, mode)) {
+ if (mActivityManager.bindBackupAgent(app.packageName, mode,
+ UserHandle.USER_OWNER)) {
Slog.d(TAG, "awaiting agent for " + app);
// success; wait for the agent to arrive
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 47f5318..f8c2f1e 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -15392,10 +15392,22 @@
// Cause the target app to be launched if necessary and its backup agent
// instantiated. The backup agent will invoke backupAgentCreated() on the
// activity manager to announce its creation.
- public boolean bindBackupAgent(ApplicationInfo app, int backupMode) {
- if (DEBUG_BACKUP) Slog.v(TAG, "bindBackupAgent: app=" + app + " mode=" + backupMode);
+ public boolean bindBackupAgent(String packageName, int backupMode, int userId) {
+ if (DEBUG_BACKUP) Slog.v(TAG, "bindBackupAgent: app=" + packageName + " mode=" + backupMode);
enforceCallingPermission("android.permission.CONFIRM_FULL_BACKUP", "bindBackupAgent");
+ IPackageManager pm = AppGlobals.getPackageManager();
+ ApplicationInfo app = null;
+ try {
+ app = pm.getApplicationInfo(packageName, 0, userId);
+ } catch (RemoteException e) {
+ // can't happen; package manager is process-local
+ }
+ if (app == null) {
+ Slog.w(TAG, "Unable to bind backup agent for " + packageName);
+ return false;
+ }
+
synchronized(this) {
// !!! TODO: currently no check here that we're already bound
BatteryStatsImpl.Uid.Pkg.Serv ss = null;