summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2014-07-16 17:14:40 (GMT)
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-16 00:46:50 (GMT)
commitbb474f6df0d737dba4081e7cb1bd5b5d9b7f4f57 (patch)
treec4e3f6b6f6cb3cd4e2bf067bd8f727229bb86b43
parentca424c67f3deeb34a870e37a5743f66091961112 (diff)
parentd31df54073fbd80a9db9d277dde8c0e7421ffa14 (diff)
downloadandroid_packages_apps_Trebuchet-bb474f6df0d737dba4081e7cb1bd5b5d9b7f4f57.zip
android_packages_apps_Trebuchet-bb474f6df0d737dba4081e7cb1bd5b5d9b7f4f57.tar.gz
android_packages_apps_Trebuchet-bb474f6df0d737dba4081e7cb1bd5b5d9b7f4f57.tar.bz2
Merge "Include user handle for uninstall intents." into ub-now-master
-rw-r--r--src/com/android/launcher3/DeleteDropTarget.java22
-rw-r--r--src/com/android/launcher3/Launcher.java6
-rw-r--r--src/com/android/launcher3/compat/UserHandleCompat.java13
3 files changed, 25 insertions, 16 deletions
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 20546b8..3d45432 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -187,11 +187,6 @@ public class DeleteDropTarget extends ButtonDropTarget {
if (!willAcceptDrop(info) || isAllAppsWidget(source, info)) {
isVisible = false;
}
- if (useUninstallLabel &&
- !(((ItemInfo) info).user.equals(UserHandleCompat.myUserHandle()))) {
- // Don't support uninstall for apps from other profiles.
- isVisible = false;
- }
if (useUninstallLabel) {
setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null);
@@ -287,19 +282,16 @@ public class DeleteDropTarget extends ButtonDropTarget {
if (isAllAppsApplication(d.dragSource, item)) {
// Uninstall the application if it is being dragged from AppsCustomize
AppInfo appInfo = (AppInfo) item;
- // We don't support uninstalling apps from other profiles.
- if (item.user.equals(UserHandleCompat.myUserHandle())) {
- mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags);
- }
+ mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags,
+ appInfo.user);
} else if (isUninstallFromWorkspace(d)) {
ShortcutInfo shortcut = (ShortcutInfo) item;
- // We don't support uninstalling apps from other profiles.
- if (shortcut.intent != null && shortcut.intent.getComponent() != null &&
- shortcut.user.equals(UserHandleCompat.myUserHandle())) {
+ if (shortcut.intent != null && shortcut.intent.getComponent() != null) {
final ComponentName componentName = shortcut.intent.getComponent();
final DragSource dragSource = d.dragSource;
- mWaitingForUninstall =
- mLauncher.startApplicationUninstallActivity(componentName, shortcut.flags);
+ final UserHandleCompat user = shortcut.user;
+ mWaitingForUninstall = mLauncher.startApplicationUninstallActivity(
+ componentName, shortcut.flags, user);
if (mWaitingForUninstall) {
final Runnable checkIfUninstallWasSuccess = new Runnable() {
@Override
@@ -307,7 +299,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
mWaitingForUninstall = false;
String packageName = componentName.getPackageName();
boolean uninstallSuccessful = !AllAppsList.packageHasActivities(
- getContext(), packageName, UserHandleCompat.myUserHandle());
+ getContext(), packageName, user);
if (dragSource instanceof Folder) {
((Folder) dragSource).
onUninstallActivityReturned(uninstallSuccessful);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 400cd24..951b5d4 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2721,7 +2721,8 @@ public class Launcher extends Activity
}
// returns true if the activity was started
- boolean startApplicationUninstallActivity(ComponentName componentName, int flags) {
+ boolean startApplicationUninstallActivity(ComponentName componentName, int flags,
+ UserHandleCompat user) {
if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) {
// System applications cannot be installed. For now, show a toast explaining that.
// We may give them the option of disabling apps this way.
@@ -2735,6 +2736,9 @@ public class Launcher extends Activity
Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ if (user != null) {
+ user.addToIntent(intent, Intent.EXTRA_USER);
+ }
startActivity(intent);
return true;
}
diff --git a/src/com/android/launcher3/compat/UserHandleCompat.java b/src/com/android/launcher3/compat/UserHandleCompat.java
index 8f5dda2..4baf052 100644
--- a/src/com/android/launcher3/compat/UserHandleCompat.java
+++ b/src/com/android/launcher3/compat/UserHandleCompat.java
@@ -16,6 +16,7 @@
package com.android.launcher3.compat;
+import android.content.Intent;
import android.os.Build;
import android.os.UserHandle;
@@ -78,4 +79,16 @@ public class UserHandleCompat {
return 0;
}
}
+
+ /**
+ * Adds {@link UserHandle} to the intent in for L or above.
+ * Pre-L the launcher doesn't support showing apps for multiple
+ * profiles so this is a no-op.
+ */
+ public void addToIntent(Intent intent, String name) {
+ // TODO change this to use api version once L gets an API number.
+ if ("L".equals(Build.VERSION.CODENAME) && mUser != null) {
+ intent.putExtra(name, mUser);
+ }
+ }
} \ No newline at end of file