No more UserHandleCompat
Bug: 32745285
Change-Id: I762fb4e268c1afe48a1860ab12a4ccb3f626aa95
diff --git a/src/com/android/launcher3/AllAppsList.java b/src/com/android/launcher3/AllAppsList.java
index bbc8650..34a44fc 100644
--- a/src/com/android/launcher3/AllAppsList.java
+++ b/src/com/android/launcher3/AllAppsList.java
@@ -18,10 +18,10 @@
import android.content.ComponentName;
import android.content.Context;
+import android.os.UserHandle;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.ItemInfoMatcher;
@@ -95,7 +95,7 @@
/**
* Add the icons for the supplied apk called packageName.
*/
- public void addPackage(Context context, String packageName, UserHandleCompat user) {
+ public void addPackage(Context context, String packageName, UserHandle user) {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
final List<LauncherActivityInfoCompat> matches = launcherApps.getActivityList(packageName,
user);
@@ -108,7 +108,7 @@
/**
* Remove the apps for the given apk identified by packageName.
*/
- public void removePackage(String packageName, UserHandleCompat user) {
+ public void removePackage(String packageName, UserHandle user) {
final List<AppInfo> data = this.data;
for (int i = data.size() - 1; i >= 0; i--) {
AppInfo info = data.get(i);
@@ -133,7 +133,7 @@
}
}
- public void updateIconsAndLabels(HashSet<String> packages, UserHandleCompat user,
+ public void updateIconsAndLabels(HashSet<String> packages, UserHandle user,
ArrayList<AppInfo> outUpdates) {
for (AppInfo info : data) {
if (info.user.equals(user) && packages.contains(info.componentName.getPackageName())) {
@@ -146,7 +146,7 @@
/**
* Add and remove icons for this package which has been updated.
*/
- public void updatePackage(Context context, String packageName, UserHandleCompat user) {
+ public void updatePackage(Context context, String packageName, UserHandle user) {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
final List<LauncherActivityInfoCompat> matches = launcherApps.getActivityList(packageName,
user);
@@ -210,7 +210,7 @@
* MAIN/LAUNCHER activities in the supplied package.
*/
static boolean packageHasActivities(Context context, String packageName,
- UserHandleCompat user) {
+ UserHandle user) {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
return launcherApps.getActivityList(packageName, user).size() > 0;
}
@@ -219,7 +219,7 @@
* Returns whether <em>apps</em> contains <em>component</em>.
*/
private static boolean findActivity(ArrayList<AppInfo> apps, ComponentName component,
- UserHandleCompat user) {
+ UserHandle user) {
final int N = apps.size();
for (int i = 0; i < N; i++) {
final AppInfo info = apps.get(i);
@@ -233,7 +233,7 @@
/**
* Find an ApplicationInfo object for the given packageName and className.
*/
- private AppInfo findApplicationInfoLocked(String packageName, UserHandleCompat user,
+ private AppInfo findApplicationInfoLocked(String packageName, UserHandle user,
String className) {
for (AppInfo info: data) {
if (user.equals(info.user) && packageName.equals(info.componentName.getPackageName())
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index 23e2882..f7c5184 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -20,10 +20,10 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.os.UserHandle;
import android.util.Log;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.PackageManagerHelper;
@@ -73,18 +73,18 @@
/**
* Must not hold the Context.
*/
- public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandleCompat user,
+ public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandle user,
IconCache iconCache) {
this(context, info, user, iconCache,
UserManagerCompat.getInstance(context).isQuietModeEnabled(user));
}
- public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandleCompat user,
+ public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandle user,
IconCache iconCache, boolean quietModeEnabled) {
this(context, info, user, iconCache, quietModeEnabled, true /* useLowResIcon */);
}
- public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandleCompat user,
+ public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandle user,
IconCache iconCache, boolean quietModeEnabled, boolean useLowResIcon) {
this.componentName = info.getComponentName();
this.container = ItemInfo.NO_ID;
@@ -134,7 +134,7 @@
}
public static Intent makeLaunchIntent(Context context, LauncherActivityInfoCompat info,
- UserHandleCompat user) {
+ UserHandle user) {
long serialNumber = UserManagerCompat.getInstance(context).getSerialNumberForUser(user);
return new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_LAUNCHER)
diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java
index c244235..4c88e7e 100644
--- a/src/com/android/launcher3/FolderInfo.java
+++ b/src/com/android/launcher3/FolderInfo.java
@@ -17,8 +17,8 @@
package com.android.launcher3;
import android.content.Context;
+import android.os.Process;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.ContentWriter;
import java.util.ArrayList;
@@ -56,7 +56,7 @@
public FolderInfo() {
itemType = LauncherSettings.Favorites.ITEM_TYPE_FOLDER;
- user = UserHandleCompat.myUserHandle();
+ user = Process.myUserHandle();
}
/**
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 9f332a4..3557447 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -38,13 +38,14 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
+import android.os.Process;
import android.os.SystemClock;
+import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.LauncherIcons;
@@ -86,7 +87,7 @@
public boolean isLowResIcon;
}
- private final HashMap<UserHandleCompat, Bitmap> mDefaultIcons = new HashMap<>();
+ private final HashMap<UserHandle, Bitmap> mDefaultIcons = new HashMap<>();
@Thunk final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
private final Context mContext;
@@ -185,7 +186,7 @@
return getFullResDefaultActivityIcon();
}
- private Bitmap makeDefaultIcon(UserHandleCompat user) {
+ private Bitmap makeDefaultIcon(UserHandle user) {
Drawable unbadged = getFullResDefaultActivityIcon();
return LauncherIcons.createBadgedIconBitmap(unbadged, user, mContext);
}
@@ -193,14 +194,14 @@
/**
* Remove any records for the supplied ComponentName.
*/
- public synchronized void remove(ComponentName componentName, UserHandleCompat user) {
+ public synchronized void remove(ComponentName componentName, UserHandle user) {
mCache.remove(new ComponentKey(componentName, user));
}
/**
* Remove any records for the supplied package name from memory.
*/
- private void removeFromMemCacheLocked(String packageName, UserHandleCompat user) {
+ private void removeFromMemCacheLocked(String packageName, UserHandle user) {
HashSet<ComponentKey> forDeletion = new HashSet<ComponentKey>();
for (ComponentKey key: mCache.keySet()) {
if (key.componentName.getPackageName().equals(packageName)
@@ -216,7 +217,7 @@
/**
* Updates the entries related to the given package in memory and persistent DB.
*/
- public synchronized void updateIconsForPkg(String packageName, UserHandleCompat user) {
+ public synchronized void updateIconsForPkg(String packageName, UserHandle user) {
removeIconsForPkg(packageName, user);
try {
PackageInfo info = mPackageManager.getPackageInfo(packageName,
@@ -234,7 +235,7 @@
/**
* Removes the entries related to the given package in memory and persistent DB.
*/
- public synchronized void removeIconsForPkg(String packageName, UserHandleCompat user) {
+ public synchronized void removeIconsForPkg(String packageName, UserHandle user) {
removeFromMemCacheLocked(packageName, user);
long userSerial = mUserManager.getSerialNumberForUser(user);
mIconDb.delete(
@@ -247,7 +248,7 @@
mWorkerHandler.removeCallbacksAndMessages(ICON_UPDATE_TOKEN);
mIconProvider.updateSystemStateString();
- for (UserHandleCompat user : mUserManager.getUserProfiles()) {
+ for (UserHandle user : mUserManager.getUserProfiles()) {
// Query for the set of apps
final List<LauncherActivityInfoCompat> apps = mLauncherApps.getActivityList(null, user);
// Fail if we don't have any apps
@@ -258,7 +259,7 @@
// Update icon cache. This happens in segments and {@link #onPackageIconsUpdated}
// is called by the icon cache when the job is complete.
- updateDBIcons(user, apps, UserHandleCompat.myUserHandle().equals(user)
+ updateDBIcons(user, apps, Process.myUserHandle().equals(user)
? ignorePackagesForMainUser : Collections.<String>emptySet());
}
}
@@ -268,7 +269,7 @@
* the DB and are updated.
* @return The set of packages for which icons have updated.
*/
- private void updateDBIcons(UserHandleCompat user, List<LauncherActivityInfoCompat> apps,
+ private void updateDBIcons(UserHandle user, List<LauncherActivityInfoCompat> apps,
Set<String> ignorePackages) {
long userSerial = mUserManager.getSerialNumberForUser(user);
PackageManager pm = mContext.getPackageManager();
@@ -432,7 +433,7 @@
return new IconLoadRequest(request, mWorkerHandler);
}
- private Bitmap getNonNullIcon(CacheEntry entry, UserHandleCompat user) {
+ private Bitmap getNonNullIcon(CacheEntry entry, UserHandle user) {
return entry.icon == null ? getDefaultIcon(user) : entry.icon;
}
@@ -441,7 +442,7 @@
*/
public synchronized void getTitleAndIcon(AppInfo application,
LauncherActivityInfoCompat info, boolean useLowResIcon) {
- UserHandleCompat user = info == null ? application.user : info.getUser();
+ UserHandle user = info == null ? application.user : info.getUser();
CacheEntry entry = cacheLocked(application.componentName, info, user,
false, useLowResIcon);
application.title = Utilities.trim(entry.title);
@@ -467,7 +468,7 @@
/**
* Returns a high res icon for the given intent and user
*/
- public synchronized Bitmap getIcon(Intent intent, UserHandleCompat user) {
+ public synchronized Bitmap getIcon(Intent intent, UserHandle user) {
ComponentName component = intent.getComponent();
// null info means not installed, but if we have a component from the intent then
// we should still look in the cache for restored app icons.
@@ -485,7 +486,7 @@
* corresponding activity is not found, it reverts to the package icon.
*/
public synchronized void getTitleAndIcon(ShortcutInfo shortcutInfo, Intent intent,
- UserHandleCompat user, boolean useLowResIcon) {
+ UserHandle user, boolean useLowResIcon) {
ComponentName component = intent.getComponent();
// null info means not installed, but if we have a component from the intent then
// we should still look in the cache for restored app icons.
@@ -505,7 +506,7 @@
*/
public synchronized void getTitleAndIcon(
ShortcutInfo shortcutInfo, ComponentName component, LauncherActivityInfoCompat info,
- UserHandleCompat user, boolean usePkgIcon, boolean useLowResIcon) {
+ UserHandle user, boolean usePkgIcon, boolean useLowResIcon) {
CacheEntry entry = cacheLocked(component, info, user, usePkgIcon, useLowResIcon);
shortcutInfo.iconBitmap = getNonNullIcon(entry, user);
shortcutInfo.title = Utilities.trim(entry.title);
@@ -526,14 +527,14 @@
infoInOut.usingLowResIcon = entry.isLowResIcon;
}
- public synchronized Bitmap getDefaultIcon(UserHandleCompat user) {
+ public synchronized Bitmap getDefaultIcon(UserHandle user) {
if (!mDefaultIcons.containsKey(user)) {
mDefaultIcons.put(user, makeDefaultIcon(user));
}
return mDefaultIcons.get(user);
}
- public boolean isDefaultIcon(Bitmap icon, UserHandleCompat user) {
+ public boolean isDefaultIcon(Bitmap icon, UserHandle user) {
return mDefaultIcons.get(user) == icon;
}
@@ -542,7 +543,7 @@
* This method is not thread safe, it must be called from a synchronized method.
*/
protected CacheEntry cacheLocked(ComponentName componentName, LauncherActivityInfoCompat info,
- UserHandleCompat user, boolean usePackageIcon, boolean useLowResIcon) {
+ UserHandle user, boolean usePackageIcon, boolean useLowResIcon) {
ComponentKey cacheKey = new ComponentKey(componentName, user);
CacheEntry entry = mCache.get(cacheKey);
if (entry == null || (entry.isLowResIcon && !useLowResIcon)) {
@@ -587,7 +588,7 @@
* Adds a default package entry in the cache. This entry is not persisted and will be removed
* when the cache is flushed.
*/
- public synchronized void cachePackageInstallInfo(String packageName, UserHandleCompat user,
+ public synchronized void cachePackageInstallInfo(String packageName, UserHandle user,
Bitmap icon, CharSequence title) {
removeFromMemCacheLocked(packageName, user);
@@ -607,7 +608,7 @@
}
}
- private static ComponentKey getPackageKey(String packageName, UserHandleCompat user) {
+ private static ComponentKey getPackageKey(String packageName, UserHandle user) {
ComponentName cn = new ComponentName(packageName, packageName + EMPTY_CLASS_NAME);
return new ComponentKey(cn, user);
}
@@ -616,7 +617,7 @@
* Gets an entry for the package, which can be used as a fallback entry for various components.
* This method is not thread safe, it must be called from a synchronized method.
*/
- private CacheEntry getEntryForPackageLocked(String packageName, UserHandleCompat user,
+ private CacheEntry getEntryForPackageLocked(String packageName, UserHandle user,
boolean useLowResIcon) {
ComponentKey cacheKey = getPackageKey(packageName, user);
CacheEntry entry = mCache.get(cacheKey);
@@ -628,7 +629,7 @@
// Check the DB first.
if (!getEntryFromDB(cacheKey, entry, useLowResIcon)) {
try {
- int flags = UserHandleCompat.myUserHandle().equals(user) ? 0 :
+ int flags = Process.myUserHandle().equals(user) ? 0 :
PackageManager.GET_UNINSTALLED_PACKAGES;
PackageInfo info = mPackageManager.getPackageInfo(packageName, flags);
ApplicationInfo appInfo = info.applicationInfo;
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 2f92201..df2deb8 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -26,13 +26,14 @@
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.os.Process;
+import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
@@ -94,7 +95,7 @@
}
public static void removeFromInstallQueue(Context context, HashSet<String> packageNames,
- UserHandleCompat user) {
+ UserHandle user) {
if (packageNames.isEmpty()) {
return;
}
@@ -192,7 +193,7 @@
}
PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(
- data, UserHandleCompat.myUserHandle(), context);
+ data, Process.myUserHandle(), context);
if (info.launchIntent == null || info.label == null) {
if (DBG) Log.e(TAG, "Invalid install shortcut intent");
return null;
@@ -289,12 +290,12 @@
final Context mContext;
final Intent launchIntent;
final String label;
- final UserHandleCompat user;
+ final UserHandle user;
/**
* Initializes a PendingInstallShortcutInfo received from a different app.
*/
- public PendingInstallShortcutInfo(Intent data, UserHandleCompat user, Context context) {
+ public PendingInstallShortcutInfo(Intent data, UserHandle user, Context context) {
activityInfo = null;
shortcutInfo = null;
providerInfo = null;
@@ -351,7 +352,7 @@
data = null;
mContext = context;
- user = UserHandleCompat.fromUser(info.getProfile());
+ user = info.getProfile();
launchIntent = new Intent().setComponent(info.provider)
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
@@ -490,7 +491,7 @@
AppWidgetProviderInfo info = AppWidgetManager.getInstance(context)
.getAppWidgetInfo(widgetId);
if (info == null || !info.provider.equals(decoder.launcherIntent.getComponent()) ||
- !info.getProfile().equals(decoder.user.getUser())) {
+ !info.getProfile().equals(decoder.user)) {
return null;
}
return new PendingInstallShortcutInfo(info, widgetId, context);
@@ -524,14 +525,14 @@
private static class Decoder extends JSONObject {
public final Intent launcherIntent;
- public final UserHandleCompat user;
+ public final UserHandle user;
private Decoder(String encoded, Context context) throws JSONException, URISyntaxException {
super(encoded);
launcherIntent = Intent.parseUri(getString(LAUNCH_INTENT_KEY), 0);
user = has(USER_HANDLE_KEY) ? UserManagerCompat.getInstance(context)
.getUserForSerialNumber(getLong(USER_HANDLE_KEY))
- : UserHandleCompat.myUserHandle();
+ : Process.myUserHandle();
if (user == null) {
throw new JSONException("Invalid user");
}
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index 3e0ae4f..82c7ab8 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -19,8 +19,9 @@
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Intent;
+import android.os.Process;
+import android.os.UserHandle;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.ContentWriter;
/**
@@ -106,10 +107,10 @@
*/
public CharSequence contentDescription;
- public UserHandleCompat user;
+ public UserHandle user;
public ItemInfo() {
- user = UserHandleCompat.myUserHandle();
+ user = Process.myUserHandle();
}
ItemInfo(ItemInfo info) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 85e6a77..8aa4158 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -52,6 +52,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Process;
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.Trace;
@@ -90,7 +91,6 @@
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
@@ -2089,8 +2089,8 @@
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
- mAppWidgetManager.getUser(info.info)
- .addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE,
+ mAppWidgetManager.getUser(info.info));
// TODO: we need to make sure that this accounts for the options bundle.
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
@@ -2323,8 +2323,8 @@
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, info.appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, appWidgetInfo.provider);
- mAppWidgetManager.getUser(appWidgetInfo)
- .addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE,
+ mAppWidgetManager.getUser(appWidgetInfo));
startActivityForResult(intent, REQUEST_BIND_PENDING_APPWIDGET);
}
} else {
@@ -2392,7 +2392,7 @@
.setNeutralButton(R.string.abandoned_clean_this,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- final UserHandleCompat user = UserHandleCompat.myUserHandle();
+ final UserHandle user = Process.myUserHandle();
mWorkspace.removeAbandonedPromise(packageName, user);
}
})
@@ -2702,7 +2702,7 @@
!intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;
- UserHandleCompat user = null;
+ UserHandle user = null;
if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) {
long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1);
user = UserManagerCompat.getInstance(this).getUserForSerialNumber(serialNumber);
@@ -2720,7 +2720,7 @@
&& ((ShortcutInfo) item).promisedIntent == null) {
// Shortcuts need some special checks due to legacy reasons.
startShortcutIntentSafely(intent, optsBundle, item);
- } else if (user == null || user.equals(UserHandleCompat.myUserHandle())) {
+ } else if (user == null || user.equals(Process.myUserHandle())) {
// Could be launching some bookkeeping activity
startActivity(intent, optsBundle);
} else {
@@ -3782,7 +3782,7 @@
*/
@Override
public void bindShortcutsChanged(final ArrayList<ShortcutInfo> updated,
- final ArrayList<ShortcutInfo> removed, final UserHandleCompat user) {
+ final ArrayList<ShortcutInfo> removed, final UserHandle user) {
Runnable r = new Runnable() {
public void run() {
bindShortcutsChanged(updated, removed, user);
@@ -3851,7 +3851,7 @@
@Override
public void bindWorkspaceComponentsRemoved(
final HashSet<String> packageNames, final HashSet<ComponentName> components,
- final UserHandleCompat user) {
+ final UserHandle user) {
Runnable r = new Runnable() {
public void run() {
bindWorkspaceComponentsRemoved(packageNames, components, user);
@@ -3997,36 +3997,6 @@
return true;
}
- // TODO: These method should be a part of LauncherSearchCallback
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public ItemInfo createAppDragInfo(Intent appLaunchIntent) {
- // Called from search suggestion
- UserHandleCompat user = null;
- if (Utilities.ATLEAST_LOLLIPOP) {
- UserHandle userHandle = appLaunchIntent.getParcelableExtra(Intent.EXTRA_USER);
- if (userHandle != null) {
- user = UserHandleCompat.fromUser(userHandle);
- }
- }
- return createAppDragInfo(appLaunchIntent, user);
- }
-
- // TODO: This method should be a part of LauncherSearchCallback
- public ItemInfo createAppDragInfo(Intent intent, UserHandleCompat user) {
- if (user == null) {
- user = UserHandleCompat.myUserHandle();
- }
-
- // Called from search suggestion, add the profile extra to the intent to ensure that we
- // can launch it correctly
- LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this);
- LauncherActivityInfoCompat activityInfo = launcherApps.resolveActivity(intent, user);
- if (activityInfo == null) {
- return null;
- }
- return new AppInfo(this, activityInfo, user, mIconCache);
- }
-
protected void moveWorkspaceToDefaultScreen() {
mWorkspace.moveToDefaultScreen(false);
}
diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java
index 2218767..b68a64b 100644
--- a/src/com/android/launcher3/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java
@@ -19,8 +19,8 @@
import android.appwidget.AppWidgetHostView;
import android.content.ComponentName;
import android.content.Intent;
+import android.os.Process;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.ContentWriter;
/**
@@ -112,7 +112,7 @@
spanX = -1;
spanY = -1;
// We only support app widgets on current user.
- user = UserHandleCompat.myUserHandle();
+ user = Process.myUserHandle();
restoreStatus = RESTORE_COMPLETED;
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 2a6f56b..0dc91e3 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -37,6 +37,7 @@
import android.os.Process;
import android.os.SystemClock;
import android.os.Trace;
+import android.os.UserHandle;
import android.provider.BaseColumns;
import android.text.TextUtils;
import android.util.Log;
@@ -48,7 +49,6 @@
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
@@ -58,17 +58,17 @@
import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.model.AddWorkspaceItemsTask;
-import com.android.launcher3.model.ExtendedModelTask;
import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.CacheDataUpdatedTask;
+import com.android.launcher3.model.ExtendedModelTask;
import com.android.launcher3.model.GridSizeMigrationTask;
-import com.android.launcher3.model.PackageItemInfo;
-import com.android.launcher3.model.SdCardAvailableReceiver;
-import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.model.PackageInstallStateChangedTask;
+import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.model.PackageUpdatedTask;
+import com.android.launcher3.model.SdCardAvailableReceiver;
import com.android.launcher3.model.ShortcutsChangedTask;
import com.android.launcher3.model.UserLockStateChangedTask;
+import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.provider.ImportDataTask;
import com.android.launcher3.provider.LauncherDbUtils;
@@ -197,12 +197,12 @@
ArrayList<AppInfo> addedApps);
public void bindAppsUpdated(ArrayList<AppInfo> apps);
public void bindShortcutsChanged(ArrayList<ShortcutInfo> updated,
- ArrayList<ShortcutInfo> removed, UserHandleCompat user);
+ ArrayList<ShortcutInfo> removed, UserHandle user);
public void bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets);
public void bindRestoreItemsChange(HashSet<ItemInfo> updates);
public void bindWorkspaceComponentsRemoved(
HashSet<String> packageNames, HashSet<ComponentName> components,
- UserHandleCompat user);
+ UserHandle user);
public void bindAppInfosRemoved(ArrayList<AppInfo> appInfos);
public void notifyWidgetProvidersChanged();
public void bindAllWidgets(MultiHashMap<PackageItemInfo, WidgetItem> widgets);
@@ -255,7 +255,7 @@
HashSet<String> packages = new HashSet<>();
packages.add(packageName);
enqueueModelUpdateTask(new CacheDataUpdatedTask(
- CacheDataUpdatedTask.OP_SESSION_UPDATE, UserHandleCompat.myUserHandle(), packages));
+ CacheDataUpdatedTask.OP_SESSION_UPDATE, Process.myUserHandle(), packages));
}
/**
@@ -692,36 +692,36 @@
}
@Override
- public void onPackageChanged(String packageName, UserHandleCompat user) {
+ public void onPackageChanged(String packageName, UserHandle user) {
int op = PackageUpdatedTask.OP_UPDATE;
enqueueModelUpdateTask(new PackageUpdatedTask(op, user, packageName));
}
@Override
- public void onPackageRemoved(String packageName, UserHandleCompat user) {
+ public void onPackageRemoved(String packageName, UserHandle user) {
onPackagesRemoved(user, packageName);
}
- public void onPackagesRemoved(UserHandleCompat user, String... packages) {
+ public void onPackagesRemoved(UserHandle user, String... packages) {
int op = PackageUpdatedTask.OP_REMOVE;
enqueueModelUpdateTask(new PackageUpdatedTask(op, user, packages));
}
@Override
- public void onPackageAdded(String packageName, UserHandleCompat user) {
+ public void onPackageAdded(String packageName, UserHandle user) {
int op = PackageUpdatedTask.OP_ADD;
enqueueModelUpdateTask(new PackageUpdatedTask(op, user, packageName));
}
@Override
- public void onPackagesAvailable(String[] packageNames, UserHandleCompat user,
+ public void onPackagesAvailable(String[] packageNames, UserHandle user,
boolean replacing) {
enqueueModelUpdateTask(
new PackageUpdatedTask(PackageUpdatedTask.OP_UPDATE, user, packageNames));
}
@Override
- public void onPackagesUnavailable(String[] packageNames, UserHandleCompat user,
+ public void onPackagesUnavailable(String[] packageNames, UserHandle user,
boolean replacing) {
if (!replacing) {
enqueueModelUpdateTask(new PackageUpdatedTask(
@@ -730,25 +730,25 @@
}
@Override
- public void onPackagesSuspended(String[] packageNames, UserHandleCompat user) {
+ public void onPackagesSuspended(String[] packageNames, UserHandle user) {
enqueueModelUpdateTask(new PackageUpdatedTask(
PackageUpdatedTask.OP_SUSPEND, user, packageNames));
}
@Override
- public void onPackagesUnsuspended(String[] packageNames, UserHandleCompat user) {
+ public void onPackagesUnsuspended(String[] packageNames, UserHandle user) {
enqueueModelUpdateTask(new PackageUpdatedTask(
PackageUpdatedTask.OP_UNSUSPEND, user, packageNames));
}
@Override
public void onShortcutsChanged(String packageName, List<ShortcutInfoCompat> shortcuts,
- UserHandleCompat user) {
+ UserHandle user) {
enqueueModelUpdateTask(new ShortcutsChangedTask(packageName, shortcuts, user, true));
}
public void updatePinnedShortcuts(String packageName, List<ShortcutInfoCompat> shortcuts,
- UserHandleCompat user) {
+ UserHandle user) {
enqueueModelUpdateTask(new ShortcutsChangedTask(packageName, shortcuts, user, false));
}
@@ -771,7 +771,7 @@
} else if (Intent.ACTION_MANAGED_PROFILE_AVAILABLE.equals(action) ||
Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE.equals(action) ||
Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action)) {
- UserHandleCompat user = UserHandleCompat.fromIntent(intent);
+ UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER);
if (user != null) {
if (Intent.ACTION_MANAGED_PROFILE_AVAILABLE.equals(action) ||
Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE.equals(action)) {
@@ -1199,7 +1199,7 @@
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
final DeepShortcutManager shortcutManager = DeepShortcutManager.getInstance(context);
final boolean isSdCardReady = Utilities.isBootCompleted();
- final MultiHashMap<UserHandleCompat, String> pendingPackages = new MultiHashMap<>();
+ final MultiHashMap<UserHandle, String> pendingPackages = new MultiHashMap<>();
LauncherAppState app = LauncherAppState.getInstance();
InvariantDeviceProfile profile = app.getInvariantDeviceProfile();
@@ -1282,10 +1282,10 @@
LauncherSettings.Favorites.OPTIONS);
final CursorIconInfo cursorIconInfo = new CursorIconInfo(mContext, c);
- final LongSparseArray<UserHandleCompat> allUsers = new LongSparseArray<>();
+ final LongSparseArray<UserHandle> allUsers = new LongSparseArray<>();
final LongSparseArray<Boolean> quietMode = new LongSparseArray<>();
final LongSparseArray<Boolean> unlockedUsers = new LongSparseArray<>();
- for (UserHandleCompat user : mUserManager.getUserProfiles()) {
+ for (UserHandle user : mUserManager.getUserProfiles()) {
long serialNo = mUserManager.getSerialNumberForUser(user);
allUsers.put(serialNo, user);
quietMode.put(serialNo, mUserManager.isQuietModeEnabled(user));
@@ -1318,7 +1318,7 @@
long id;
long serialNumber;
Intent intent;
- UserHandleCompat user;
+ UserHandle user;
String targetPackage;
while (!mStopped && c.moveToNext()) {
@@ -1465,7 +1465,7 @@
c.getInt(rankIndex) >= FolderIcon.NUM_ITEMS_IN_PREVIEW;
if (itemReplaced) {
- if (user.equals(UserHandleCompat.myUserHandle())) {
+ if (user.equals(Process.myUserHandle())) {
info = getAppShortcutInfo(intent, user, null,
cursorIconInfo, false, useLowResIcon);
} else {
@@ -1474,7 +1474,7 @@
continue;
}
} else if (restored) {
- if (user.equals(UserHandleCompat.myUserHandle())) {
+ if (user.equals(Process.myUserHandle())) {
info = getRestoredItemInfo(c, intent,
promiseType, itemType, cursorIconInfo);
intent = getRestoredItemIntent(c, context, intent);
@@ -2251,11 +2251,11 @@
return;
}
- final List<UserHandleCompat> profiles = mUserManager.getUserProfiles();
+ final List<UserHandle> profiles = mUserManager.getUserProfiles();
// Clear the list of apps
mBgAllAppsList.clear();
- for (UserHandleCompat user : profiles) {
+ for (UserHandle user : profiles) {
// Query for the set of apps
final long qiaTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
final List<LauncherActivityInfoCompat> apps = mLauncherApps.getActivityList(null, user);
@@ -2341,7 +2341,7 @@
DeepShortcutManager shortcutManager = DeepShortcutManager.getInstance(mContext);
mHasShortcutHostPermission = shortcutManager.hasHostPermission();
if (mHasShortcutHostPermission) {
- for (UserHandleCompat user : mUserManager.getUserProfiles()) {
+ for (UserHandle user : mUserManager.getUserProfiles()) {
if (mUserManager.isUserUnlocked(user)) {
List<ShortcutInfoCompat> shortcuts =
shortcutManager.queryForAllShortcuts(user);
@@ -2399,7 +2399,7 @@
/**
* Called when the icons for packages have been updated in the icon cache.
*/
- public void onPackageIconsUpdated(HashSet<String> updatedPackages, UserHandleCompat user) {
+ public void onPackageIconsUpdated(HashSet<String> updatedPackages, UserHandle user) {
// If any package icon has changed (app was updated while launcher was dead),
// update the corresponding shortcuts.
enqueueModelUpdateTask(new CacheDataUpdatedTask(
@@ -2519,7 +2519,7 @@
public ShortcutInfo getRestoredItemInfo(Cursor c, Intent intent,
int promiseType, int itemType, CursorIconInfo iconInfo) {
final ShortcutInfo info = new ShortcutInfo();
- info.user = UserHandleCompat.myUserHandle();
+ info.user = Process.myUserHandle();
info.iconBitmap = iconInfo.loadIcon(c, info);
// the fallback icon
if (info.iconBitmap == null) {
@@ -2569,9 +2569,8 @@
*
* If c is not null, then it will be used to fill in missing data like the title and icon.
*/
- public ShortcutInfo getAppShortcutInfo(Intent intent,
- UserHandleCompat user, Cursor c, CursorIconInfo iconInfo,
- boolean allowMissingTarget, boolean useLowResIcon) {
+ public ShortcutInfo getAppShortcutInfo(Intent intent, UserHandle user, Cursor c,
+ CursorIconInfo iconInfo, boolean allowMissingTarget, boolean useLowResIcon) {
if (user == null) {
Log.d(TAG, "Null user found in getShortcutInfo");
return null;
@@ -2625,7 +2624,7 @@
@Thunk ShortcutInfo getShortcutInfo(Cursor c, CursorIconInfo iconInfo) {
final ShortcutInfo info = new ShortcutInfo();
// Non-app shortcuts are only supported for current user.
- info.user = UserHandleCompat.myUserHandle();
+ info.user = Process.myUserHandle();
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
// TODO: If there's an explicit component and we can't install that, delete it.
@@ -2661,7 +2660,7 @@
// Only support intents for current user for now. Intents sent from other
// users wouldn't get here without intent forwarding anyway.
- info.user = UserHandleCompat.myUserHandle();
+ info.user = Process.myUserHandle();
if (bitmap instanceof Bitmap) {
info.iconBitmap = LauncherIcons.createIconBitmap((Bitmap) bitmap, context);
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index b30c3f3..c6edae9 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -45,6 +45,7 @@
import android.os.Message;
import android.os.Process;
import android.os.Trace;
+import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;
@@ -52,7 +53,6 @@
import com.android.launcher3.AutoInstallsLayout.LayoutParserCallback;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.LauncherSettings.WorkspaceScreens;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
@@ -657,13 +657,13 @@
Utilities.getPrefs(mContext).edit().putBoolean(EMPTY_DATABASE_CREATED, true).commit();
// When a new DB is created, remove all previously stored managed profile information.
- ManagedProfileHeuristic.processAllUsers(Collections.<UserHandleCompat>emptyList(),
+ ManagedProfileHeuristic.processAllUsers(Collections.<UserHandle>emptyList(),
mContext);
}
public long getDefaultUserSerial() {
return UserManagerCompat.getInstance(mContext).getSerialNumberForUser(
- UserHandleCompat.myUserHandle());
+ Process.myUserHandle());
}
private void addFavoritesTable(SQLiteDatabase db, boolean optional) {
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index fd65337..b9010c7 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -23,10 +23,11 @@
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Build;
+import android.os.Process;
+import android.os.UserHandle;
import android.text.TextUtils;
import com.android.launcher3.LauncherSettings.Favorites;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.shortcuts.DeepShortcutManager;
@@ -257,7 +258,7 @@
IconCache cache = launcherAppState.getIconCache();
Bitmap unbadgedBitmap = unbadgedDrawable == null
- ? cache.getDefaultIcon(UserHandleCompat.myUserHandle())
+ ? cache.getDefaultIcon(Process.myUserHandle())
: LauncherIcons.createScaledBitmapWithoutShadow(unbadgedDrawable, context);
iconBitmap = getBadgedIcon(unbadgedBitmap, shortcutInfo, cache, context);
}
diff --git a/src/com/android/launcher3/UninstallDropTarget.java b/src/com/android/launcher3/UninstallDropTarget.java
index 00c613a..a7839ec 100644
--- a/src/com/android/launcher3/UninstallDropTarget.java
+++ b/src/com/android/launcher3/UninstallDropTarget.java
@@ -8,14 +8,13 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.os.UserHandle;
import android.os.UserManager;
import android.util.AttributeSet;
-import android.util.Pair;
import android.widget.Toast;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
-import com.android.launcher3.compat.UserHandleCompat;
public class UninstallDropTarget extends ButtonDropTarget {
@@ -60,7 +59,7 @@
*/
private static ComponentName getUninstallTarget(Context context, Object item) {
Intent intent = null;
- UserHandleCompat user = null;
+ UserHandle user = null;
if (item instanceof AppInfo) {
AppInfo info = (AppInfo) item;
intent = info.intent;
@@ -120,7 +119,7 @@
Uri.fromParts("package", cn.getPackageName(), cn.getClassName()))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
- info.user.addToIntent(intent, Intent.EXTRA_USER);
+ intent.putExtra(Intent.EXTRA_USER, info.user);
launcher.startActivity(intent);
isUninstallable = true;
}
@@ -139,7 +138,7 @@
*/
protected static void sendUninstallResult(
final Launcher launcher, boolean activityStarted,
- final ComponentName cn, final UserHandleCompat user,
+ final ComponentName cn, final UserHandle user,
final DropTargetResultCallback callback) {
if (activityStarted) {
final Runnable checkIfUninstallWasSuccess = new Runnable() {
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java
index 354b8ec..399920e 100644
--- a/src/com/android/launcher3/WidgetPreviewLoader.java
+++ b/src/com/android/launcher3/WidgetPreviewLoader.java
@@ -25,11 +25,11 @@
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Handler;
+import android.os.UserHandle;
import android.util.Log;
import android.util.LongSparseArray;
import com.android.launcher3.compat.AppWidgetManagerCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.util.ComponentKey;
@@ -149,11 +149,11 @@
mDb.insertOrReplace(values);
}
- public void removePackage(String packageName, UserHandleCompat user) {
+ public void removePackage(String packageName, UserHandle user) {
removePackage(packageName, user, mUserManager.getSerialNumberForUser(user));
}
- private void removePackage(String packageName, UserHandleCompat user, long userSerial) {
+ private void removePackage(String packageName, UserHandle user, long userSerial) {
synchronized(mPackageVersions) {
mPackageVersions.remove(packageName);
}
@@ -217,7 +217,7 @@
for (int i = 0; i < packagesToDelete.size(); i++) {
long userId = packagesToDelete.keyAt(i);
- UserHandleCompat user = mUserManager.getUserForSerialNumber(userId);
+ UserHandle user = mUserManager.getUserForSerialNumber(userId);
for (String pkg : packagesToDelete.valueAt(i)) {
removePackage(pkg, user, userId);
}
@@ -652,7 +652,7 @@
// TODO: remove dependency on size
@Thunk final String size;
- public WidgetCacheKey(ComponentName componentName, UserHandleCompat user, String size) {
+ public WidgetCacheKey(ComponentName componentName, UserHandle user, String size) {
super(componentName, user);
this.size = size;
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index ab98367..cbea7e0 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -38,6 +38,7 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Parcelable;
+import android.os.UserHandle;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Property;
@@ -61,7 +62,6 @@
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.compat.AppWidgetManagerCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.dragndrop.DragController;
@@ -4016,7 +4016,7 @@
});
}
- public void removeAbandonedPromise(String packageName, UserHandleCompat user) {
+ public void removeAbandonedPromise(String packageName, UserHandle user) {
HashSet<String> packages = new HashSet<>(1);
packages.add(packageName);
ItemInfoMatcher matcher = ItemInfoMatcher.ofPackages(packages, user);
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 8b7a6ba..0bfbd3e 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -16,12 +16,12 @@
package com.android.launcher3.allapps;
import android.content.Context;
+import android.os.Process;
import android.util.Log;
import com.android.launcher3.AppInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.compat.AlphabeticIndexCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.LabelComparator;
@@ -363,13 +363,13 @@
if (DEBUG_PREDICTIONS) {
if (mPredictedAppComponents.isEmpty() && !mApps.isEmpty()) {
mPredictedAppComponents.add(new ComponentKey(mApps.get(0).componentName,
- UserHandleCompat.myUserHandle()));
+ Process.myUserHandle()));
mPredictedAppComponents.add(new ComponentKey(mApps.get(0).componentName,
- UserHandleCompat.myUserHandle()));
+ Process.myUserHandle()));
mPredictedAppComponents.add(new ComponentKey(mApps.get(0).componentName,
- UserHandleCompat.myUserHandle()));
+ Process.myUserHandle()));
mPredictedAppComponents.add(new ComponentKey(mApps.get(0).componentName,
- UserHandleCompat.myUserHandle()));
+ Process.myUserHandle()));
}
}
diff --git a/src/com/android/launcher3/allapps/AppInfoComparator.java b/src/com/android/launcher3/allapps/AppInfoComparator.java
index 1f5fece..80577a7 100644
--- a/src/com/android/launcher3/allapps/AppInfoComparator.java
+++ b/src/com/android/launcher3/allapps/AppInfoComparator.java
@@ -16,9 +16,10 @@
package com.android.launcher3.allapps;
import android.content.Context;
+import android.os.Process;
+import android.os.UserHandle;
import com.android.launcher3.AppInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.util.LabelComparator;
@@ -30,12 +31,12 @@
public class AppInfoComparator implements Comparator<AppInfo> {
private final UserManagerCompat mUserManager;
- private final UserHandleCompat mMyUser;
+ private final UserHandle mMyUser;
private final LabelComparator mLabelComparator;
public AppInfoComparator(Context context) {
mUserManager = UserManagerCompat.getInstance(context);
- mMyUser = UserHandleCompat.myUserHandle();
+ mMyUser = Process.myUserHandle();
mLabelComparator = new LabelComparator();
}
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompat.java b/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
index 811cacf..5388f2a 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
@@ -25,6 +25,7 @@
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.UserHandle;
import com.android.launcher3.IconCache;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
@@ -77,7 +78,7 @@
public abstract boolean bindAppWidgetIdIfAllowed(
int appWidgetId, AppWidgetProviderInfo info, Bundle options);
- public abstract UserHandleCompat getUser(LauncherAppWidgetProviderInfo info);
+ public abstract UserHandle getUser(LauncherAppWidgetProviderInfo info);
public abstract void startConfigActivity(AppWidgetProviderInfo info, int widgetId,
Activity activity, AppWidgetHost host, int requestCode);
@@ -90,7 +91,7 @@
int imageWidth, int imageHeight);
public abstract LauncherAppWidgetProviderInfo findProvider(
- ComponentName provider, UserHandleCompat user);
+ ComponentName provider, UserHandle user);
public abstract HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap();
}
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
index de9414e..e7d8e29 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
@@ -28,6 +28,8 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
+import android.os.Process;
+import android.os.UserHandle;
import com.android.launcher3.IconCache;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
@@ -65,8 +67,8 @@
}
@Override
- public UserHandleCompat getUser(LauncherAppWidgetProviderInfo info) {
- return UserHandleCompat.myUserHandle();
+ public UserHandle getUser(LauncherAppWidgetProviderInfo info) {
+ return Process.myUserHandle();
}
@Override
@@ -97,7 +99,7 @@
@Override
public LauncherAppWidgetProviderInfo findProvider(
- ComponentName provider, UserHandleCompat user) {
+ ComponentName provider, UserHandle user) {
for (AppWidgetProviderInfo info : mAppWidgetManager.getInstalledProviders()) {
if (info.provider.equals(provider)) {
return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
@@ -109,7 +111,7 @@
@Override
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
- UserHandleCompat user = UserHandleCompat.myUserHandle();
+ UserHandle user = Process.myUserHandle();
for (AppWidgetProviderInfo info : mAppWidgetManager.getInstalledProviders()) {
result.put(new ComponentKey(info.provider, user), info);
}
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
index a1570e6..0acf753 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
@@ -33,6 +33,7 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
+import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.view.View;
@@ -81,11 +82,11 @@
}
@Override
- public UserHandleCompat getUser(LauncherAppWidgetProviderInfo info) {
+ public UserHandle getUser(LauncherAppWidgetProviderInfo info) {
if (info.isCustomWidget) {
- return UserHandleCompat.myUserHandle();
+ return Process.myUserHandle();
}
- return UserHandleCompat.fromUser(info.getProfile());
+ return info.getProfile();
}
@Override
@@ -150,9 +151,9 @@
}
@Override
- public LauncherAppWidgetProviderInfo findProvider(ComponentName provider, UserHandleCompat user) {
+ public LauncherAppWidgetProviderInfo findProvider(ComponentName provider, UserHandle user) {
for (AppWidgetProviderInfo info : mAppWidgetManager
- .getInstalledProvidersForProfile(user.getUser())) {
+ .getInstalledProvidersForProfile(user)) {
if (info.provider.equals(provider)) {
return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
}
@@ -164,10 +165,9 @@
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
for (UserHandle user : mUserManager.getUserProfiles()) {
- UserHandleCompat userHandle = UserHandleCompat.fromUser(user);
for (AppWidgetProviderInfo info :
mAppWidgetManager.getInstalledProvidersForProfile(user)) {
- result.put(new ComponentKey(info.provider, userHandle), info);
+ result.put(new ComponentKey(info.provider, user), info);
}
}
return result;
diff --git a/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java b/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java
index 46d36d1..4dd05bb 100644
--- a/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java
+++ b/src/com/android/launcher3/compat/DeferredLauncherActivityInfo.java
@@ -21,7 +21,7 @@
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.graphics.drawable.Drawable;
-import android.util.Log;
+import android.os.UserHandle;
/**
* {@link LauncherActivityInfoCompat} which loads its data only when needed.
@@ -29,13 +29,13 @@
public class DeferredLauncherActivityInfo extends LauncherActivityInfoCompat {
private final ComponentName mComponent;
- private final UserHandleCompat mUser;
+ private final UserHandle mUser;
private final Context mContext;
private LauncherActivityInfoCompat mActualInfo;
public DeferredLauncherActivityInfo(
- ComponentName component, UserHandleCompat user, Context context) {
+ ComponentName component, UserHandle user, Context context) {
mComponent = component;
mUser = user;
mContext = context;
@@ -47,7 +47,7 @@
}
@Override
- public UserHandleCompat getUser() {
+ public UserHandle getUser() {
return mUser;
}
diff --git a/src/com/android/launcher3/compat/LauncherActivityInfoCompat.java b/src/com/android/launcher3/compat/LauncherActivityInfoCompat.java
index 65af4ea..830b60a 100644
--- a/src/com/android/launcher3/compat/LauncherActivityInfoCompat.java
+++ b/src/com/android/launcher3/compat/LauncherActivityInfoCompat.java
@@ -19,6 +19,7 @@
import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
import android.graphics.drawable.Drawable;
+import android.os.UserHandle;
public abstract class LauncherActivityInfoCompat {
@@ -26,7 +27,7 @@
}
public abstract ComponentName getComponentName();
- public abstract UserHandleCompat getUser();
+ public abstract UserHandle getUser();
public abstract CharSequence getLabel();
public abstract Drawable getIcon(int density);
public abstract ApplicationInfo getApplicationInfo();
diff --git a/src/com/android/launcher3/compat/LauncherActivityInfoCompatV16.java b/src/com/android/launcher3/compat/LauncherActivityInfoCompatV16.java
index fee0376..d697803 100644
--- a/src/com/android/launcher3/compat/LauncherActivityInfoCompatV16.java
+++ b/src/com/android/launcher3/compat/LauncherActivityInfoCompatV16.java
@@ -18,14 +18,16 @@
import android.content.ComponentName;
import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
+import android.os.Process;
+import android.os.UserHandle;
public class LauncherActivityInfoCompatV16 extends LauncherActivityInfoCompat {
@@ -46,8 +48,8 @@
return mComponentName;
}
- public UserHandleCompat getUser() {
- return UserHandleCompat.myUserHandle();
+ public UserHandle getUser() {
+ return Process.myUserHandle();
}
public CharSequence getLabel() {
diff --git a/src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java b/src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java
index 67c5c27..874b3c3 100644
--- a/src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java
+++ b/src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java
@@ -22,6 +22,7 @@
import android.content.pm.LauncherActivityInfo;
import android.graphics.drawable.Drawable;
import android.os.Build;
+import android.os.UserHandle;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class LauncherActivityInfoCompatVL extends LauncherActivityInfoCompat {
@@ -36,8 +37,8 @@
return mLauncherActivityInfo.getComponentName();
}
- public UserHandleCompat getUser() {
- return UserHandleCompat.fromUser(mLauncherActivityInfo.getUser());
+ public UserHandle getUser() {
+ return mLauncherActivityInfo.getUser();
}
public CharSequence getLabel() {
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java
index 645e68a..c75298b 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompat.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java
@@ -19,10 +19,9 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.LauncherApps;
import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.UserHandle;
import com.android.launcher3.Utilities;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
@@ -32,15 +31,15 @@
public abstract class LauncherAppsCompat {
public interface OnAppsChangedCallbackCompat {
- void onPackageRemoved(String packageName, UserHandleCompat user);
- void onPackageAdded(String packageName, UserHandleCompat user);
- void onPackageChanged(String packageName, UserHandleCompat user);
- void onPackagesAvailable(String[] packageNames, UserHandleCompat user, boolean replacing);
- void onPackagesUnavailable(String[] packageNames, UserHandleCompat user, boolean replacing);
- void onPackagesSuspended(String[] packageNames, UserHandleCompat user);
- void onPackagesUnsuspended(String[] packageNames, UserHandleCompat user);
+ void onPackageRemoved(String packageName, UserHandle user);
+ void onPackageAdded(String packageName, UserHandle user);
+ void onPackageChanged(String packageName, UserHandle user);
+ void onPackagesAvailable(String[] packageNames, UserHandle user, boolean replacing);
+ void onPackagesUnavailable(String[] packageNames, UserHandle user, boolean replacing);
+ void onPackagesSuspended(String[] packageNames, UserHandle user);
+ void onPackagesUnsuspended(String[] packageNames, UserHandle user);
void onShortcutsChanged(String packageName, List<ShortcutInfoCompat> shortcuts,
- UserHandleCompat user);
+ UserHandle user);
}
protected LauncherAppsCompat() {
@@ -63,16 +62,16 @@
}
public abstract List<LauncherActivityInfoCompat> getActivityList(String packageName,
- UserHandleCompat user);
+ UserHandle user);
public abstract LauncherActivityInfoCompat resolveActivity(Intent intent,
- UserHandleCompat user);
- public abstract void startActivityForProfile(ComponentName component, UserHandleCompat user,
+ UserHandle user);
+ public abstract void startActivityForProfile(ComponentName component, UserHandle user,
Rect sourceBounds, Bundle opts);
- public abstract void showAppDetailsForProfile(ComponentName component, UserHandleCompat user);
+ public abstract void showAppDetailsForProfile(ComponentName component, UserHandle user);
public abstract void addOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
public abstract void removeOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
- public abstract boolean isPackageEnabledForProfile(String packageName, UserHandleCompat user);
+ public abstract boolean isPackageEnabledForProfile(String packageName, UserHandle user);
public abstract boolean isActivityEnabledForProfile(ComponentName component,
- UserHandleCompat user);
- public abstract boolean isPackageSuspendedForProfile(String packageName, UserHandleCompat user);
+ UserHandle user);
+ public abstract boolean isPackageSuspendedForProfile(String packageName, UserHandle user);
}
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
index 49a0df6..0d1efa8 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
@@ -22,18 +22,17 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
-import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Process;
+import android.os.UserHandle;
import android.provider.Settings;
import com.android.launcher3.Utilities;
-import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Thunk;
@@ -60,7 +59,7 @@
}
public List<LauncherActivityInfoCompat> getActivityList(String packageName,
- UserHandleCompat user) {
+ UserHandle user) {
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
mainIntent.setPackage(packageName);
@@ -73,7 +72,7 @@
return list;
}
- public LauncherActivityInfoCompat resolveActivity(Intent intent, UserHandleCompat user) {
+ public LauncherActivityInfoCompat resolveActivity(Intent intent, UserHandle user) {
ResolveInfo info = mPm.resolveActivity(intent, 0);
if (info != null) {
return new LauncherActivityInfoCompatV16(mContext, info);
@@ -81,7 +80,7 @@
return null;
}
- public void startActivityForProfile(ComponentName component, UserHandleCompat user,
+ public void startActivityForProfile(ComponentName component, UserHandle user,
Rect sourceBounds, Bundle opts) {
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
@@ -91,7 +90,7 @@
mContext.startActivity(launchIntent, opts);
}
- public void showAppDetailsForProfile(ComponentName component, UserHandleCompat user) {
+ public void showAppDetailsForProfile(ComponentName component, UserHandle user) {
String packageName = component.getPackageName();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", packageName, null));
@@ -116,11 +115,11 @@
}
}
- public boolean isPackageEnabledForProfile(String packageName, UserHandleCompat user) {
+ public boolean isPackageEnabledForProfile(String packageName, UserHandle user) {
return PackageManagerHelper.isAppEnabled(mPm, packageName);
}
- public boolean isActivityEnabledForProfile(ComponentName component, UserHandleCompat user) {
+ public boolean isActivityEnabledForProfile(ComponentName component, UserHandle user) {
try {
ActivityInfo info = mPm.getActivityInfo(component, 0);
return info != null && info.isEnabled();
@@ -129,7 +128,7 @@
}
}
- public boolean isPackageSuspendedForProfile(String packageName, UserHandleCompat user) {
+ public boolean isPackageSuspendedForProfile(String packageName, UserHandle user) {
return false;
}
@@ -156,7 +155,7 @@
@Thunk class PackageMonitor extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
- final UserHandleCompat user = UserHandleCompat.myUserHandle();
+ final UserHandle user = Process.myUserHandle();
if (Intent.ACTION_PACKAGE_CHANGED.equals(action)
|| Intent.ACTION_PACKAGE_REMOVED.equals(action)
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
index d97bf2f..f408da0 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
@@ -49,10 +49,8 @@
mLauncherApps = (LauncherApps) context.getSystemService("launcherapps");
}
- public List<LauncherActivityInfoCompat> getActivityList(String packageName,
- UserHandleCompat user) {
- List<LauncherActivityInfo> list = mLauncherApps.getActivityList(packageName,
- user.getUser());
+ public List<LauncherActivityInfoCompat> getActivityList(String packageName, UserHandle user) {
+ List<LauncherActivityInfo> list = mLauncherApps.getActivityList(packageName, user);
if (list.size() == 0) {
return Collections.emptyList();
}
@@ -64,8 +62,8 @@
return compatList;
}
- public LauncherActivityInfoCompat resolveActivity(Intent intent, UserHandleCompat user) {
- LauncherActivityInfo activity = mLauncherApps.resolveActivity(intent, user.getUser());
+ public LauncherActivityInfoCompat resolveActivity(Intent intent, UserHandle user) {
+ LauncherActivityInfo activity = mLauncherApps.resolveActivity(intent, user);
if (activity != null) {
return new LauncherActivityInfoCompatVL(activity);
} else {
@@ -73,13 +71,13 @@
}
}
- public void startActivityForProfile(ComponentName component, UserHandleCompat user,
+ public void startActivityForProfile(ComponentName component, UserHandle user,
Rect sourceBounds, Bundle opts) {
- mLauncherApps.startMainActivity(component, user.getUser(), sourceBounds, opts);
+ mLauncherApps.startMainActivity(component, user, sourceBounds, opts);
}
- public void showAppDetailsForProfile(ComponentName component, UserHandleCompat user) {
- mLauncherApps.startAppDetailsActivity(component, user.getUser(), null, null);
+ public void showAppDetailsForProfile(ComponentName component, UserHandle user) {
+ mLauncherApps.startAppDetailsActivity(component, user, null, null);
}
public void addOnAppsChangedCallback(LauncherAppsCompat.OnAppsChangedCallbackCompat callback) {
@@ -101,15 +99,15 @@
}
}
- public boolean isPackageEnabledForProfile(String packageName, UserHandleCompat user) {
- return mLauncherApps.isPackageEnabled(packageName, user.getUser());
+ public boolean isPackageEnabledForProfile(String packageName, UserHandle user) {
+ return mLauncherApps.isPackageEnabled(packageName, user);
}
- public boolean isActivityEnabledForProfile(ComponentName component, UserHandleCompat user) {
- return mLauncherApps.isActivityEnabled(component, user.getUser());
+ public boolean isActivityEnabledForProfile(ComponentName component, UserHandle user) {
+ return mLauncherApps.isActivityEnabled(component, user);
}
- public boolean isPackageSuspendedForProfile(String packageName, UserHandleCompat user) {
+ public boolean isPackageSuspendedForProfile(String packageName, UserHandle user) {
return false;
}
@@ -121,33 +119,32 @@
}
public void onPackageRemoved(String packageName, UserHandle user) {
- mCallback.onPackageRemoved(packageName, UserHandleCompat.fromUser(user));
+ mCallback.onPackageRemoved(packageName, user);
}
public void onPackageAdded(String packageName, UserHandle user) {
- mCallback.onPackageAdded(packageName, UserHandleCompat.fromUser(user));
+ mCallback.onPackageAdded(packageName, user);
}
public void onPackageChanged(String packageName, UserHandle user) {
- mCallback.onPackageChanged(packageName, UserHandleCompat.fromUser(user));
+ mCallback.onPackageChanged(packageName, user);
}
public void onPackagesAvailable(String[] packageNames, UserHandle user, boolean replacing) {
- mCallback.onPackagesAvailable(packageNames, UserHandleCompat.fromUser(user), replacing);
+ mCallback.onPackagesAvailable(packageNames, user, replacing);
}
public void onPackagesUnavailable(String[] packageNames, UserHandle user,
boolean replacing) {
- mCallback.onPackagesUnavailable(packageNames, UserHandleCompat.fromUser(user),
- replacing);
+ mCallback.onPackagesUnavailable(packageNames, user, replacing);
}
public void onPackagesSuspended(String[] packageNames, UserHandle user) {
- mCallback.onPackagesSuspended(packageNames, UserHandleCompat.fromUser(user));
+ mCallback.onPackagesSuspended(packageNames, user);
}
public void onPackagesUnsuspended(String[] packageNames, UserHandle user) {
- mCallback.onPackagesUnsuspended(packageNames, UserHandleCompat.fromUser(user));
+ mCallback.onPackagesUnsuspended(packageNames, user);
}
@Override
@@ -158,8 +155,7 @@
shortcutInfoCompats.add(new ShortcutInfoCompat(shortcutInfo));
}
- mCallback.onShortcutsChanged(packageName, shortcutInfoCompats,
- UserHandleCompat.fromUser(user));
+ mCallback.onShortcutsChanged(packageName, shortcutInfoCompats, user);
}
}
}
diff --git a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
index 948471c..192cb0c 100644
--- a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
+++ b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
@@ -23,6 +23,8 @@
import android.content.pm.PackageInstaller.SessionInfo;
import android.os.Build;
import android.os.Handler;
+import android.os.Process;
+import android.os.UserHandle;
import android.util.SparseArray;
import com.android.launcher3.IconCache;
@@ -52,7 +54,7 @@
@Override
public HashMap<String, Integer> updateAndGetActiveSessionCache() {
HashMap<String, Integer> activePackages = new HashMap<>();
- UserHandleCompat user = UserHandleCompat.myUserHandle();
+ UserHandle user = Process.myUserHandle();
for (SessionInfo info : mInstaller.getAllSessions()) {
addSessionInfoToCache(info, user);
if (info.getAppPackageName() != null) {
@@ -63,7 +65,7 @@
return activePackages;
}
- @Thunk void addSessionInfoToCache(SessionInfo info, UserHandleCompat user) {
+ @Thunk void addSessionInfoToCache(SessionInfo info, UserHandle user) {
String packageName = info.getAppPackageName();
if (packageName != null) {
mCache.cachePackageInstallInfo(packageName, user, info.getAppIcon(),
@@ -124,7 +126,7 @@
private void pushSessionDisplayToLauncher(int sessionId) {
SessionInfo session = mInstaller.getSessionInfo(sessionId);
if (session != null && session.getAppPackageName() != null) {
- addSessionInfoToCache(session, UserHandleCompat.myUserHandle());
+ addSessionInfoToCache(session, Process.myUserHandle());
LauncherAppState app = LauncherAppState.getInstanceNoCreate();
if (app != null) {
diff --git a/src/com/android/launcher3/compat/UserHandleCompat.java b/src/com/android/launcher3/compat/UserHandleCompat.java
deleted file mode 100644
index 50af21b..0000000
--- a/src/com/android/launcher3/compat/UserHandleCompat.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.compat;
-
-import android.annotation.TargetApi;
-import android.content.Intent;
-import android.os.Build;
-import android.os.UserHandle;
-import com.android.launcher3.Utilities;
-
-public class UserHandleCompat {
- private UserHandle mUser;
-
- private UserHandleCompat(UserHandle user) {
- mUser = user;
- }
-
- private UserHandleCompat() {
- }
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
- public static UserHandleCompat myUserHandle() {
- if (Utilities.ATLEAST_JB_MR1) {
- return new UserHandleCompat(android.os.Process.myUserHandle());
- } else {
- return new UserHandleCompat();
- }
- }
-
- public static UserHandleCompat fromUser(UserHandle user) {
- if (user == null) {
- return null;
- } else {
- return new UserHandleCompat(user);
- }
- }
-
- public UserHandle getUser() {
- return mUser;
- }
-
- @Override
- public String toString() {
- if (Utilities.ATLEAST_JB_MR1) {
- return mUser.toString();
- } else {
- return "";
- }
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof UserHandleCompat)) {
- return false;
- }
- if (Utilities.ATLEAST_JB_MR1) {
- return mUser.equals(((UserHandleCompat) other).mUser);
- } else {
- return true;
- }
- }
-
- @Override
- public int hashCode() {
- if (Utilities.ATLEAST_JB_MR1) {
- return mUser.hashCode();
- } else {
- 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) {
- if (Utilities.ATLEAST_LOLLIPOP && mUser != null) {
- intent.putExtra(name, mUser);
- }
- }
-
- public static UserHandleCompat fromIntent(Intent intent) {
- if (Utilities.ATLEAST_LOLLIPOP) {
- UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER);
- if (user != null) {
- return UserHandleCompat.fromUser(user);
- }
- }
- return null;
- }
-}
diff --git a/src/com/android/launcher3/compat/UserManagerCompat.java b/src/com/android/launcher3/compat/UserManagerCompat.java
index b40eaa2..24c95b1 100644
--- a/src/com/android/launcher3/compat/UserManagerCompat.java
+++ b/src/com/android/launcher3/compat/UserManagerCompat.java
@@ -17,6 +17,7 @@
package com.android.launcher3.compat;
import android.content.Context;
+import android.os.UserHandle;
import com.android.launcher3.Utilities;
@@ -55,13 +56,13 @@
*/
public abstract void enableAndResetCache();
- public abstract List<UserHandleCompat> getUserProfiles();
- public abstract long getSerialNumberForUser(UserHandleCompat user);
- public abstract UserHandleCompat getUserForSerialNumber(long serialNumber);
- public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user);
- public abstract long getUserCreationTime(UserHandleCompat user);
- public abstract boolean isQuietModeEnabled(UserHandleCompat user);
- public abstract boolean isUserUnlocked(UserHandleCompat user);
+ public abstract List<UserHandle> getUserProfiles();
+ public abstract long getSerialNumberForUser(UserHandle user);
+ public abstract UserHandle getUserForSerialNumber(long serialNumber);
+ public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user);
+ public abstract long getUserCreationTime(UserHandle user);
+ public abstract boolean isQuietModeEnabled(UserHandle user);
+ public abstract boolean isUserUnlocked(UserHandle user);
public abstract boolean isDemoUser();
}
diff --git a/src/com/android/launcher3/compat/UserManagerCompatV16.java b/src/com/android/launcher3/compat/UserManagerCompatV16.java
index 9bd4567..60374aa 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatV16.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatV16.java
@@ -16,6 +16,9 @@
package com.android.launcher3.compat;
+import android.os.Process;
+import android.os.UserHandle;
+
import java.util.ArrayList;
import java.util.List;
@@ -24,26 +27,26 @@
UserManagerCompatV16() {
}
- public List<UserHandleCompat> getUserProfiles() {
- List<UserHandleCompat> profiles = new ArrayList<UserHandleCompat>(1);
- profiles.add(UserHandleCompat.myUserHandle());
+ public List<UserHandle> getUserProfiles() {
+ List<UserHandle> profiles = new ArrayList<UserHandle>(1);
+ profiles.add(Process.myUserHandle());
return profiles;
}
- public UserHandleCompat getUserForSerialNumber(long serialNumber) {
- return UserHandleCompat.myUserHandle();
+ public UserHandle getUserForSerialNumber(long serialNumber) {
+ return Process.myUserHandle();
}
- public long getSerialNumberForUser(UserHandleCompat user) {
+ public long getSerialNumberForUser(UserHandle user) {
return 0;
}
- public CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user) {
+ public CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user) {
return label;
}
@Override
- public long getUserCreationTime(UserHandleCompat user) {
+ public long getUserCreationTime(UserHandle user) {
return 0;
}
@@ -52,12 +55,12 @@
}
@Override
- public boolean isQuietModeEnabled(UserHandleCompat user) {
+ public boolean isQuietModeEnabled(UserHandle user) {
return false;
}
@Override
- public boolean isUserUnlocked(UserHandleCompat user) {
+ public boolean isUserUnlocked(UserHandle user) {
return true;
}
diff --git a/src/com/android/launcher3/compat/UserManagerCompatV17.java b/src/com/android/launcher3/compat/UserManagerCompatV17.java
index 75203b7..08e8947 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatV17.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatV17.java
@@ -19,6 +19,8 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
+import android.os.Process;
+import android.os.UserHandle;
import android.os.UserManager;
import com.android.launcher3.util.LongArrayMap;
@@ -28,10 +30,10 @@
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class UserManagerCompatV17 extends UserManagerCompatV16 {
- protected LongArrayMap<UserHandleCompat> mUsers;
+ protected LongArrayMap<UserHandle> mUsers;
// Create a separate reverse map as LongArrayMap.indexOfValue checks if objects are same
// and not {@link Object#equals}
- protected HashMap<UserHandleCompat, Long> mUserToSerialMap;
+ protected HashMap<UserHandle, Long> mUserToSerialMap;
protected UserManager mUserManager;
@@ -39,23 +41,23 @@
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
}
- public long getSerialNumberForUser(UserHandleCompat user) {
+ public long getSerialNumberForUser(UserHandle user) {
synchronized (this) {
if (mUserToSerialMap != null) {
Long serial = mUserToSerialMap.get(user);
return serial == null ? 0 : serial;
}
}
- return mUserManager.getSerialNumberForUser(user.getUser());
+ return mUserManager.getSerialNumberForUser(user);
}
- public UserHandleCompat getUserForSerialNumber(long serialNumber) {
+ public UserHandle getUserForSerialNumber(long serialNumber) {
synchronized (this) {
if (mUsers != null) {
return mUsers.get(serialNumber);
}
}
- return UserHandleCompat.fromUser(mUserManager.getUserForSerialNumber(serialNumber));
+ return mUserManager.getUserForSerialNumber(serialNumber);
}
@Override
@@ -63,8 +65,8 @@
synchronized (this) {
mUsers = new LongArrayMap<>();
mUserToSerialMap = new HashMap<>();
- UserHandleCompat myUser = UserHandleCompat.myUserHandle();
- long serial = mUserManager.getSerialNumberForUser(myUser.getUser());
+ UserHandle myUser = Process.myUserHandle();
+ long serial = mUserManager.getSerialNumberForUser(myUser);
mUsers.put(serial, myUser);
mUserToSerialMap.put(myUser, serial);
}
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVL.java b/src/com/android/launcher3/compat/UserManagerCompatVL.java
index 2552b0c..2774602 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVL.java
@@ -53,46 +53,35 @@
if (users != null) {
for (UserHandle user : users) {
long serial = mUserManager.getSerialNumberForUser(user);
- UserHandleCompat userCompat = UserHandleCompat.fromUser(user);
- mUsers.put(serial, userCompat);
- mUserToSerialMap.put(userCompat, serial);
+ mUsers.put(serial, user);
+ mUserToSerialMap.put(user, serial);
}
}
}
}
@Override
- public List<UserHandleCompat> getUserProfiles() {
+ public List<UserHandle> getUserProfiles() {
synchronized (this) {
if (mUsers != null) {
- List<UserHandleCompat> users = new ArrayList<>();
- users.addAll(mUserToSerialMap.keySet());
- return users;
+ return new ArrayList<>(mUserToSerialMap.keySet());
}
}
List<UserHandle> users = mUserManager.getUserProfiles();
- if (users == null) {
- return Collections.emptyList();
- }
- ArrayList<UserHandleCompat> compatUsers = new ArrayList<UserHandleCompat>(
- users.size());
- for (UserHandle user : users) {
- compatUsers.add(UserHandleCompat.fromUser(user));
- }
- return compatUsers;
+ return users == null ? Collections.<UserHandle>emptyList() : users;
}
@Override
- public CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user) {
+ public CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user) {
if (user == null) {
return label;
}
- return mPm.getUserBadgedLabel(label, user.getUser());
+ return mPm.getUserBadgedLabel(label, user);
}
@Override
- public long getUserCreationTime(UserHandleCompat user) {
+ public long getUserCreationTime(UserHandle user) {
SharedPreferences prefs = Utilities.getPrefs(mContext);
String key = USER_CREATION_TIME_KEY + getSerialNumberForUser(user);
if (!prefs.contains(key)) {
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVM.java b/src/com/android/launcher3/compat/UserManagerCompatVM.java
index 81d67ea..75c1877 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVM.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVM.java
@@ -19,6 +19,7 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
+import android.os.UserHandle;
@TargetApi(Build.VERSION_CODES.M)
public class UserManagerCompatVM extends UserManagerCompatVL {
@@ -28,7 +29,7 @@
}
@Override
- public long getUserCreationTime(UserHandleCompat user) {
- return mUserManager.getUserCreationTime(user.getUser());
+ public long getUserCreationTime(UserHandle user) {
+ return mUserManager.getUserCreationTime(user);
}
}
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVN.java b/src/com/android/launcher3/compat/UserManagerCompatVN.java
index 4edac05..50a0217 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVN.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVN.java
@@ -19,8 +19,7 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
-
-import com.android.launcher3.Utilities;
+import android.os.UserHandle;
@TargetApi(Build.VERSION_CODES.N)
public class UserManagerCompatVN extends UserManagerCompatVM {
@@ -30,13 +29,13 @@
}
@Override
- public boolean isQuietModeEnabled(UserHandleCompat user) {
- return mUserManager.isQuietModeEnabled(user.getUser());
+ public boolean isQuietModeEnabled(UserHandle user) {
+ return mUserManager.isQuietModeEnabled(user);
}
@Override
- public boolean isUserUnlocked(UserHandleCompat user) {
- return mUserManager.isUserUnlocked(user.getUser());
+ public boolean isUserUnlocked(UserHandle user) {
+ return mUserManager.isUserUnlocked(user);
}
}
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java
index 6f9f7ff..c59b3a3 100644
--- a/src/com/android/launcher3/graphics/LauncherIcons.java
+++ b/src/com/android/launcher3/graphics/LauncherIcons.java
@@ -33,11 +33,12 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
import android.os.Build;
+import android.os.Process;
+import android.os.UserHandle;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.config.FeatureFlags;
/**
@@ -105,7 +106,7 @@
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Bitmap createBadgedIconBitmap(
- Drawable icon, UserHandleCompat user, Context context) {
+ Drawable icon, UserHandle user, Context context) {
float scale = FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ?
1 : IconNormalizer.getInstance().getScale(icon, null);
Bitmap bitmap = createIconBitmap(icon, context, scale);
@@ -115,12 +116,12 @@
/**
* Badges the provided icon with the user badge if required.
*/
- public static Bitmap badgeIconForUser(Bitmap icon, UserHandleCompat user, Context context) {
+ public static Bitmap badgeIconForUser(Bitmap icon, UserHandle user, Context context) {
if (Utilities.ATLEAST_LOLLIPOP && user != null
- && !UserHandleCompat.myUserHandle().equals(user)) {
+ && !Process.myUserHandle().equals(user)) {
BitmapDrawable drawable = new FixedSizeBitmapDrawable(icon);
Drawable badged = context.getPackageManager().getUserBadgedIcon(
- drawable, user.getUser());
+ drawable, user);
if (badged instanceof BitmapDrawable) {
return ((BitmapDrawable) badged).getBitmap();
} else {
diff --git a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
index 4cbb087..a9ceb02 100644
--- a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
+++ b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.content.Intent;
+import android.os.UserHandle;
import android.util.LongSparseArray;
import android.util.Pair;
@@ -32,7 +33,6 @@
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.Provider;
@@ -141,7 +141,7 @@
* Returns true if the shortcuts already exists on the workspace. This must be called after
* the workspace has been loaded. We identify a shortcut by its intent.
*/
- protected boolean shortcutExists(BgDataModel dataModel, Intent intent, UserHandleCompat user) {
+ protected boolean shortcutExists(BgDataModel dataModel, Intent intent, UserHandle user) {
final String intentWithPkg, intentWithoutPkg;
if (intent.getComponent() != null) {
// If component is not null, an intent with null package will produce
diff --git a/src/com/android/launcher3/model/BgDataModel.java b/src/com/android/launcher3/model/BgDataModel.java
index 3d54637..05f43af 100644
--- a/src/com/android/launcher3/model/BgDataModel.java
+++ b/src/com/android/launcher3/model/BgDataModel.java
@@ -16,6 +16,7 @@
package com.android.launcher3.model;
import android.content.Context;
+import android.os.UserHandle;
import android.util.Log;
import android.util.MutableInt;
@@ -26,7 +27,6 @@
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
@@ -216,7 +216,7 @@
* Clear all the deep shortcuts for the given package, and re-add the new shortcuts.
*/
public synchronized void updateDeepShortcutMap(
- String packageName, UserHandleCompat user, List<ShortcutInfoCompat> shortcuts) {
+ String packageName, UserHandle user, List<ShortcutInfoCompat> shortcuts) {
if (packageName != null) {
Iterator<ComponentKey> keysIter = deepShortcutMap.keySet().iterator();
while (keysIter.hasNext()) {
diff --git a/src/com/android/launcher3/model/CacheDataUpdatedTask.java b/src/com/android/launcher3/model/CacheDataUpdatedTask.java
index 64771d5..9d693a4 100644
--- a/src/com/android/launcher3/model/CacheDataUpdatedTask.java
+++ b/src/com/android/launcher3/model/CacheDataUpdatedTask.java
@@ -16,6 +16,7 @@
package com.android.launcher3.model;
import android.content.ComponentName;
+import android.os.UserHandle;
import com.android.launcher3.AllAppsList;
import com.android.launcher3.AppInfo;
@@ -27,7 +28,6 @@
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import java.util.ArrayList;
import java.util.HashSet;
@@ -41,10 +41,10 @@
public static final int OP_SESSION_UPDATE = 2;
private final int mOp;
- private final UserHandleCompat mUser;
+ private final UserHandle mUser;
private final HashSet<String> mPackages;
- public CacheDataUpdatedTask(int op, UserHandleCompat user, HashSet<String> packages) {
+ public CacheDataUpdatedTask(int op, UserHandle user, HashSet<String> packages) {
mOp = op;
mUser = user;
mPackages = packages;
diff --git a/src/com/android/launcher3/model/ExtendedModelTask.java b/src/com/android/launcher3/model/ExtendedModelTask.java
index ccc6007..0541966 100644
--- a/src/com/android/launcher3/model/ExtendedModelTask.java
+++ b/src/com/android/launcher3/model/ExtendedModelTask.java
@@ -15,11 +15,12 @@
*/
package com.android.launcher3.model;
+import android.os.UserHandle;
+
+import com.android.launcher3.LauncherModel.BaseModelUpdateTask;
import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
-import com.android.launcher3.LauncherModel.BaseModelUpdateTask;
import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.MultiHashMap;
@@ -31,14 +32,14 @@
public abstract class ExtendedModelTask extends BaseModelUpdateTask {
public void bindUpdatedShortcuts(
- ArrayList<ShortcutInfo> updatedShortcuts, UserHandleCompat user) {
+ ArrayList<ShortcutInfo> updatedShortcuts, UserHandle user) {
bindUpdatedShortcuts(updatedShortcuts, new ArrayList<ShortcutInfo>(), user);
}
public void bindUpdatedShortcuts(
final ArrayList<ShortcutInfo> updatedShortcuts,
final ArrayList<ShortcutInfo> removedShortcuts,
- final UserHandleCompat user) {
+ final UserHandle user) {
if (!updatedShortcuts.isEmpty() || !removedShortcuts.isEmpty()) {
scheduleCallbackTask(new CallbackTask() {
@Override
diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java
index aae3490..bafa95b 100644
--- a/src/com/android/launcher3/model/PackageUpdatedTask.java
+++ b/src/com/android/launcher3/model/PackageUpdatedTask.java
@@ -21,6 +21,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
+import android.os.UserHandle;
import android.util.Log;
import com.android.launcher3.AllAppsList;
@@ -38,7 +39,6 @@
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherAppsCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.util.FlagOp;
@@ -70,10 +70,10 @@
public static final int OP_USER_AVAILABILITY_CHANGE = 7; // user available/unavailable
private final int mOp;
- private final UserHandleCompat mUser;
+ private final UserHandle mUser;
private final String[] mPackages;
- public PackageUpdatedTask(int op, UserHandleCompat user, String... packages) {
+ public PackageUpdatedTask(int op, UserHandle user, String... packages) {
mOp = op;
mUser = user;
mPackages = packages;
diff --git a/src/com/android/launcher3/model/SdCardAvailableReceiver.java b/src/com/android/launcher3/model/SdCardAvailableReceiver.java
index 54260c9..d710de8 100644
--- a/src/com/android/launcher3/model/SdCardAvailableReceiver.java
+++ b/src/com/android/launcher3/model/SdCardAvailableReceiver.java
@@ -20,11 +20,10 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.os.UserHandle;
-import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.compat.LauncherAppsCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.PackageManagerHelper;
@@ -43,10 +42,10 @@
private final LauncherModel mModel;
private final Context mContext;
- private final MultiHashMap<UserHandleCompat, String> mPackages;
+ private final MultiHashMap<UserHandle, String> mPackages;
public SdCardAvailableReceiver(LauncherModel model, Context context,
- MultiHashMap<UserHandleCompat, String> packages) {
+ MultiHashMap<UserHandle, String> packages) {
mModel = model;
mContext = context;
mPackages = packages;
@@ -56,8 +55,8 @@
public void onReceive(Context context, Intent intent) {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
final PackageManager manager = context.getPackageManager();
- for (Entry<UserHandleCompat, ArrayList<String>> entry : mPackages.entrySet()) {
- UserHandleCompat user = entry.getKey();
+ for (Entry<UserHandle, ArrayList<String>> entry : mPackages.entrySet()) {
+ UserHandle user = entry.getKey();
final ArrayList<String> packagesRemoved = new ArrayList<>();
final ArrayList<String> packagesUnavailable = new ArrayList<>();
diff --git a/src/com/android/launcher3/model/ShortcutsChangedTask.java b/src/com/android/launcher3/model/ShortcutsChangedTask.java
index 3314353..3750a7e 100644
--- a/src/com/android/launcher3/model/ShortcutsChangedTask.java
+++ b/src/com/android/launcher3/model/ShortcutsChangedTask.java
@@ -16,6 +16,7 @@
package com.android.launcher3.model;
import android.content.Context;
+import android.os.UserHandle;
import com.android.launcher3.AllAppsList;
import com.android.launcher3.ItemInfo;
@@ -23,7 +24,6 @@
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.util.MultiHashMap;
@@ -38,11 +38,11 @@
private final String mPackageName;
private final List<ShortcutInfoCompat> mShortcuts;
- private final UserHandleCompat mUser;
+ private final UserHandle mUser;
private final boolean mUpdateIdMap;
public ShortcutsChangedTask(String packageName, List<ShortcutInfoCompat> shortcuts,
- UserHandleCompat user, boolean updateIdMap) {
+ UserHandle user, boolean updateIdMap) {
mPackageName = packageName;
mShortcuts = shortcuts;
mUser = user;
diff --git a/src/com/android/launcher3/model/UserLockStateChangedTask.java b/src/com/android/launcher3/model/UserLockStateChangedTask.java
index a89fe0b..15496b8 100644
--- a/src/com/android/launcher3/model/UserLockStateChangedTask.java
+++ b/src/com/android/launcher3/model/UserLockStateChangedTask.java
@@ -16,6 +16,7 @@
package com.android.launcher3.model;
import android.content.Context;
+import android.os.UserHandle;
import com.android.launcher3.AllAppsList;
import com.android.launcher3.ItemInfo;
@@ -23,7 +24,6 @@
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
@@ -40,9 +40,9 @@
*/
public class UserLockStateChangedTask extends ExtendedModelTask {
- private final UserHandleCompat mUser;
+ private final UserHandle mUser;
- public UserLockStateChangedTask(UserHandleCompat user) {
+ public UserLockStateChangedTask(UserHandle user) {
mUser = user;
}
diff --git a/src/com/android/launcher3/model/WidgetItem.java b/src/com/android/launcher3/model/WidgetItem.java
index 0d7ba1e..a079301 100644
--- a/src/com/android/launcher3/model/WidgetItem.java
+++ b/src/com/android/launcher3/model/WidgetItem.java
@@ -4,13 +4,14 @@
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.os.Process;
+import android.os.UserHandle;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.ComponentKey;
import java.text.Collator;
@@ -22,7 +23,7 @@
*/
public class WidgetItem extends ComponentKey implements Comparable<WidgetItem> {
- private static UserHandleCompat sMyUserHandle;
+ private static UserHandle sMyUserHandle;
private static Collator sCollator;
public final LauncherAppWidgetProviderInfo widgetInfo;
@@ -45,7 +46,7 @@
public WidgetItem(ResolveInfo info, PackageManager pm) {
super(new ComponentName(info.activityInfo.packageName, info.activityInfo.name),
- UserHandleCompat.myUserHandle());
+ Process.myUserHandle());
label = Utilities.trim(info.loadLabel(pm));
widgetInfo = null;
activityInfo = info.activityInfo;
@@ -56,7 +57,7 @@
public int compareTo(WidgetItem another) {
if (sMyUserHandle == null) {
// Delay these object creation until required.
- sMyUserHandle = UserHandleCompat.myUserHandle();
+ sMyUserHandle = Process.myUserHandle();
sCollator = Collator.getInstance();
}
diff --git a/src/com/android/launcher3/model/WidgetsModel.java b/src/com/android/launcher3/model/WidgetsModel.java
index 5ad6f0f..59dc859 100644
--- a/src/com/android/launcher3/model/WidgetsModel.java
+++ b/src/com/android/launcher3/model/WidgetsModel.java
@@ -6,6 +6,8 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.os.Process;
+import android.os.UserHandle;
import android.util.Log;
import com.android.launcher3.AppFilter;
@@ -15,7 +17,6 @@
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.Preconditions;
@@ -99,7 +100,7 @@
mWidgetsList.clear();
InvariantDeviceProfile idp = LauncherAppState.getInstance().getInvariantDeviceProfile();
- UserHandleCompat myUser = UserHandleCompat.myUserHandle();
+ UserHandle myUser = Process.myUserHandle();
// add and update.
for (WidgetItem item: rawWidgetsShortcuts) {
diff --git a/src/com/android/launcher3/provider/ImportDataTask.java b/src/com/android/launcher3/provider/ImportDataTask.java
index 5cb34e8..9d8e62a 100644
--- a/src/com/android/launcher3/provider/ImportDataTask.java
+++ b/src/com/android/launcher3/provider/ImportDataTask.java
@@ -44,7 +44,6 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
@@ -130,7 +129,7 @@
private void importWorkspaceItems(
long firsetScreenId, LongSparseArray<Long> screenIdMap) throws Exception {
String profileId = Long.toString(UserManagerCompat.getInstance(mContext)
- .getSerialNumberForUser(UserHandleCompat.myUserHandle()));
+ .getSerialNumberForUser(Process.myUserHandle()));
boolean createEmptyRowOnFirstScreen = false;
if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
index 41f1a47..9413913 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
@@ -25,12 +25,12 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.UserHandle;
import android.util.Log;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.Utilities;
-import com.android.launcher3.compat.UserHandleCompat;
import java.util.ArrayList;
import java.util.Collections;
@@ -83,7 +83,7 @@
* because we only get "key" fields in onShortcutsChanged().
*/
public List<ShortcutInfoCompat> queryForFullDetails(String packageName,
- List<String> shortcutIds, UserHandleCompat user) {
+ List<String> shortcutIds, UserHandle user) {
return query(FLAG_GET_ALL, packageName, null, shortcutIds, user);
}
@@ -92,7 +92,7 @@
* to be displayed in the shortcuts container on long press.
*/
public List<ShortcutInfoCompat> queryForShortcutsContainer(ComponentName activity,
- List<String> ids, UserHandleCompat user) {
+ List<String> ids, UserHandle user) {
return query(ShortcutQuery.FLAG_MATCH_MANIFEST | ShortcutQuery.FLAG_MATCH_DYNAMIC,
activity.getPackageName(), activity, ids, user);
}
@@ -106,11 +106,11 @@
if (Utilities.ATLEAST_NOUGAT_MR1) {
String packageName = key.componentName.getPackageName();
String id = key.getId();
- UserHandleCompat user = key.user;
+ UserHandle user = key.user;
List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user));
pinnedIds.remove(id);
try {
- mLauncherApps.pinShortcuts(packageName, pinnedIds, user.getUser());
+ mLauncherApps.pinShortcuts(packageName, pinnedIds, user);
mWasLastCallSuccess = true;
} catch (SecurityException|IllegalStateException e) {
Log.w(TAG, "Failed to unpin shortcut", e);
@@ -128,11 +128,11 @@
if (Utilities.ATLEAST_NOUGAT_MR1) {
String packageName = key.componentName.getPackageName();
String id = key.getId();
- UserHandleCompat user = key.user;
+ UserHandle user = key.user;
List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user));
pinnedIds.add(id);
try {
- mLauncherApps.pinShortcuts(packageName, pinnedIds, user.getUser());
+ mLauncherApps.pinShortcuts(packageName, pinnedIds, user);
mWasLastCallSuccess = true;
} catch (SecurityException|IllegalStateException e) {
Log.w(TAG, "Failed to pin shortcut", e);
@@ -143,11 +143,11 @@
@TargetApi(25)
public void startShortcut(String packageName, String id, Rect sourceBounds,
- Bundle startActivityOptions, UserHandleCompat user) {
+ Bundle startActivityOptions, UserHandle user) {
if (Utilities.ATLEAST_NOUGAT_MR1) {
try {
mLauncherApps.startShortcut(packageName, id, sourceBounds,
- startActivityOptions, user.getUser());
+ startActivityOptions, user);
mWasLastCallSuccess = true;
} catch (SecurityException|IllegalStateException e) {
Log.e(TAG, "Failed to start shortcut", e);
@@ -177,12 +177,11 @@
*
* If packageName is null, returns all pinned shortcuts regardless of package.
*/
- public List<ShortcutInfoCompat> queryForPinnedShortcuts(String packageName,
- UserHandleCompat user) {
+ public List<ShortcutInfoCompat> queryForPinnedShortcuts(String packageName, UserHandle user) {
return query(ShortcutQuery.FLAG_MATCH_PINNED, packageName, null, null, user);
}
- public List<ShortcutInfoCompat> queryForAllShortcuts(UserHandleCompat user) {
+ public List<ShortcutInfoCompat> queryForAllShortcuts(UserHandle user) {
return query(FLAG_GET_ALL, null, null, null, user);
}
@@ -202,7 +201,7 @@
*/
@TargetApi(25)
private List<ShortcutInfoCompat> query(int flags, String packageName,
- ComponentName activity, List<String> shortcutIds, UserHandleCompat user) {
+ ComponentName activity, List<String> shortcutIds, UserHandle user) {
if (Utilities.ATLEAST_NOUGAT_MR1) {
ShortcutQuery q = new ShortcutQuery();
q.setQueryFlags(flags);
@@ -213,7 +212,7 @@
}
List<ShortcutInfo> shortcutInfos = null;
try {
- shortcutInfos = mLauncherApps.getShortcuts(q, user.getUser());
+ shortcutInfos = mLauncherApps.getShortcuts(q, user);
mWasLastCallSuccess = true;
} catch (SecurityException|IllegalStateException e) {
Log.e(TAG, "Failed to query for shortcuts", e);
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
index 9cbd5f8..e547f44 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
@@ -34,6 +34,7 @@
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
+import android.os.UserHandle;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -60,7 +61,6 @@
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
@@ -161,7 +161,7 @@
final Looper workerLooper = LauncherModel.getWorkerLooper();
final Handler uiHandler = new Handler(Looper.getMainLooper());
final ItemInfo originalInfo = (ItemInfo) originalIcon.getTag();
- final UserHandleCompat user = originalInfo.user;
+ final UserHandle user = originalInfo.user;
final ComponentName activity = originalInfo.getTargetComponent();
new Handler(workerLooper).postAtFrontOfQueue(new Runnable() {
@Override
diff --git a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
index a6da668..acc632c 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
@@ -22,11 +22,11 @@
import android.content.Intent;
import android.content.pm.ShortcutInfo;
import android.os.Build;
+import android.os.UserHandle;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.compat.DeferredLauncherActivityInfo;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
/**
@@ -86,8 +86,8 @@
return mShortcutInfo.getActivity();
}
- public UserHandleCompat getUserHandle() {
- return UserHandleCompat.fromUser(mShortcutInfo.getUserHandle());
+ public UserHandle getUserHandle() {
+ return mShortcutInfo.getUserHandle();
}
public boolean hasKeyFieldsOnly() {
diff --git a/src/com/android/launcher3/shortcuts/ShortcutKey.java b/src/com/android/launcher3/shortcuts/ShortcutKey.java
index a219c54..8f72666 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutKey.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutKey.java
@@ -2,9 +2,9 @@
import android.content.ComponentName;
import android.content.Intent;
+import android.os.UserHandle;
import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.ComponentKey;
/**
@@ -12,7 +12,7 @@
*/
public class ShortcutKey extends ComponentKey {
- public ShortcutKey(String packageName, UserHandleCompat user, String id) {
+ public ShortcutKey(String packageName, UserHandle user, String id) {
// Use the id as the class name.
super(new ComponentName(packageName, id), user);
}
@@ -26,7 +26,7 @@
shortcutInfo.getId());
}
- public static ShortcutKey fromIntent(Intent intent, UserHandleCompat user) {
+ public static ShortcutKey fromIntent(Intent intent, UserHandle user) {
String shortcutId = intent.getStringExtra(
ShortcutInfoCompat.EXTRA_SHORTCUT_ID);
return new ShortcutKey(intent.getPackage(), user, shortcutId);
diff --git a/src/com/android/launcher3/util/CachedPackageTracker.java b/src/com/android/launcher3/util/CachedPackageTracker.java
index 293714e..ab5f44f 100644
--- a/src/com/android/launcher3/util/CachedPackageTracker.java
+++ b/src/com/android/launcher3/util/CachedPackageTracker.java
@@ -18,12 +18,12 @@
import android.content.Context;
import android.content.SharedPreferences;
+import android.os.UserHandle;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.LauncherAppsCompat.OnAppsChangedCallbackCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import java.util.ArrayList;
@@ -55,7 +55,7 @@
* Checks the list of user apps, and generates package event accordingly.
* {@see #onLauncherAppsAdded}, {@see #onLauncherPackageRemoved}
*/
- public void processUserApps(List<LauncherActivityInfoCompat> apps, UserHandleCompat user) {
+ public void processUserApps(List<LauncherActivityInfoCompat> apps, UserHandle user) {
String prefKey = INSTALLED_PACKAGES_PREFIX + mUserManager.getSerialNumberForUser(user);
HashSet<String> oldPackageSet = new HashSet<>();
final boolean userAppsExisted = getUserApps(oldPackageSet, prefKey);
@@ -107,7 +107,7 @@
}
@Override
- public void onPackageRemoved(String packageName, UserHandleCompat user) {
+ public void onPackageRemoved(String packageName, UserHandle user) {
String prefKey = INSTALLED_PACKAGES_PREFIX + mUserManager.getSerialNumberForUser(user);
HashSet<String> packageSet = new HashSet<>();
if (getUserApps(packageSet, prefKey) && packageSet.remove(packageName)) {
@@ -118,7 +118,7 @@
}
@Override
- public void onPackageAdded(String packageName, UserHandleCompat user) {
+ public void onPackageAdded(String packageName, UserHandle user) {
String prefKey = INSTALLED_PACKAGES_PREFIX + mUserManager.getSerialNumberForUser(user);
HashSet<String> packageSet = new HashSet<>();
final boolean userAppsExisted = getUserApps(packageSet, prefKey);
@@ -138,21 +138,21 @@
}
@Override
- public void onPackageChanged(String packageName, UserHandleCompat user) { }
+ public void onPackageChanged(String packageName, UserHandle user) { }
@Override
public void onPackagesAvailable(
- String[] packageNames, UserHandleCompat user, boolean replacing) { }
+ String[] packageNames, UserHandle user, boolean replacing) { }
@Override
public void onPackagesUnavailable(
- String[] packageNames, UserHandleCompat user, boolean replacing) { }
+ String[] packageNames, UserHandle user, boolean replacing) { }
@Override
- public void onPackagesSuspended(String[] packageNames, UserHandleCompat user) { }
+ public void onPackagesSuspended(String[] packageNames, UserHandle user) { }
@Override
- public void onPackagesUnsuspended(String[] packageNames, UserHandleCompat user) { }
+ public void onPackagesUnsuspended(String[] packageNames, UserHandle user) { }
/**
* Called when new launcher apps are added.
@@ -163,12 +163,12 @@
* when Launcher was newly installed or a new user was added.
*/
protected abstract void onLauncherAppsAdded(List<LauncherActivityInstallInfo> apps,
- UserHandleCompat user, boolean userAppsExisted);
+ UserHandle user, boolean userAppsExisted);
/**
* Called when apps are removed from the system.
*/
- protected abstract void onLauncherPackageRemoved(String packageName, UserHandleCompat user);
+ protected abstract void onLauncherPackageRemoved(String packageName, UserHandle user);
public static class LauncherActivityInstallInfo
implements Comparable<LauncherActivityInstallInfo> {
diff --git a/src/com/android/launcher3/util/ComponentKey.java b/src/com/android/launcher3/util/ComponentKey.java
index 5882f21..242df2e 100644
--- a/src/com/android/launcher3/util/ComponentKey.java
+++ b/src/com/android/launcher3/util/ComponentKey.java
@@ -18,8 +18,9 @@
import android.content.ComponentName;
import android.content.Context;
+import android.os.Process;
+import android.os.UserHandle;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import java.util.Arrays;
@@ -27,11 +28,11 @@
public class ComponentKey {
public final ComponentName componentName;
- public final UserHandleCompat user;
+ public final UserHandle user;
private final int mHashCode;
- public ComponentKey(ComponentName componentName, UserHandleCompat user) {
+ public ComponentKey(ComponentName componentName, UserHandle user) {
Preconditions.assertNotNull(componentName);
Preconditions.assertNotNull(user);
this.componentName = componentName;
@@ -56,7 +57,7 @@
} else {
// No user provided, default to the current user
componentName = ComponentName.unflattenFromString(componentKeyStr);
- user = UserHandleCompat.myUserHandle();
+ user = Process.myUserHandle();
}
Preconditions.assertNotNull(componentName);
Preconditions.assertNotNull(user);
diff --git a/src/com/android/launcher3/util/ContentWriter.java b/src/com/android/launcher3/util/ContentWriter.java
index 33d979c..1c347c0 100644
--- a/src/com/android/launcher3/util/ContentWriter.java
+++ b/src/com/android/launcher3/util/ContentWriter.java
@@ -20,11 +20,11 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.os.UserHandle;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.Utilities;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
/**
@@ -36,7 +36,7 @@
private final Context mContext;
private Bitmap mIcon;
- private UserHandleCompat mUser;
+ private UserHandle mUser;
public ContentWriter(Context context) {
this(new ContentValues(), context);
@@ -72,13 +72,13 @@
return this;
}
- public ContentWriter putIcon(Bitmap value, UserHandleCompat user) {
+ public ContentWriter putIcon(Bitmap value, UserHandle user) {
mIcon = value;
mUser = user;
return this;
}
- public ContentWriter put(String key, UserHandleCompat user) {
+ public ContentWriter put(String key, UserHandle user) {
return put(key, UserManagerCompat.getInstance(mContext).getSerialNumberForUser(user));
}
diff --git a/src/com/android/launcher3/util/ItemInfoMatcher.java b/src/com/android/launcher3/util/ItemInfoMatcher.java
index 8f985c3..b6e0e6e 100644
--- a/src/com/android/launcher3/util/ItemInfoMatcher.java
+++ b/src/com/android/launcher3/util/ItemInfoMatcher.java
@@ -17,13 +17,13 @@
package com.android.launcher3.util;
import android.content.ComponentName;
+import android.os.UserHandle;
import com.android.launcher3.FolderInfo;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.ShortcutInfo;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.shortcuts.ShortcutKey;
import java.util.HashSet;
@@ -66,7 +66,7 @@
return filtered;
}
- public static ItemInfoMatcher ofUser(final UserHandleCompat user) {
+ public static ItemInfoMatcher ofUser(final UserHandle user) {
return new ItemInfoMatcher() {
@Override
public boolean matches(ItemInfo info, ComponentName cn) {
@@ -76,7 +76,7 @@
}
public static ItemInfoMatcher ofComponents(
- final HashSet<ComponentName> components, final UserHandleCompat user) {
+ final HashSet<ComponentName> components, final UserHandle user) {
return new ItemInfoMatcher() {
@Override
public boolean matches(ItemInfo info, ComponentName cn) {
@@ -86,7 +86,7 @@
}
public static ItemInfoMatcher ofPackages(
- final HashSet<String> packageNames, final UserHandleCompat user) {
+ final HashSet<String> packageNames, final UserHandle user) {
return new ItemInfoMatcher() {
@Override
public boolean matches(ItemInfo info, ComponentName cn) {
diff --git a/src/com/android/launcher3/util/ManagedProfileHeuristic.java b/src/com/android/launcher3/util/ManagedProfileHeuristic.java
index 6b4021f..2d9e368 100644
--- a/src/com/android/launcher3/util/ManagedProfileHeuristic.java
+++ b/src/com/android/launcher3/util/ManagedProfileHeuristic.java
@@ -18,6 +18,8 @@
import android.content.Context;
import android.content.SharedPreferences;
+import android.os.Process;
+import android.os.UserHandle;
import com.android.launcher3.AppInfo;
import com.android.launcher3.FolderInfo;
@@ -31,9 +33,8 @@
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
-import com.android.launcher3.shortcuts.ShortcutInfoCompat;
-import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import java.util.ArrayList;
import java.util.HashSet;
@@ -57,8 +58,8 @@
*/
private static final long AUTO_ADD_TO_FOLDER_DURATION = 8 * 60 * 60 * 1000;
- public static ManagedProfileHeuristic get(Context context, UserHandleCompat user) {
- if (Utilities.ATLEAST_LOLLIPOP && !UserHandleCompat.myUserHandle().equals(user)) {
+ public static ManagedProfileHeuristic get(Context context, UserHandle user) {
+ if (!Process.myUserHandle().equals(user)) {
return new ManagedProfileHeuristic(context, user);
}
return null;
@@ -66,10 +67,10 @@
private final Context mContext;
private final LauncherModel mModel;
- private final UserHandleCompat mUser;
+ private final UserHandle mUser;
private final IconCache mIconCache;
- private ManagedProfileHeuristic(Context context, UserHandleCompat user) {
+ private ManagedProfileHeuristic(Context context, UserHandle user) {
mContext = context;
mUser = user;
mModel = LauncherAppState.getInstance().getModel();
@@ -104,7 +105,7 @@
}
protected void onLauncherAppsAdded(
- List<LauncherActivityInstallInfo> apps, UserHandleCompat user, boolean userAppsExisted) {
+ List<LauncherActivityInstallInfo> apps, UserHandle user, boolean userAppsExisted) {
ArrayList<ShortcutInfo> workFolderApps = new ArrayList<>();
ArrayList<ShortcutInfo> homescreenApps = new ArrayList<>();
@@ -132,14 +133,14 @@
}
@Override
- protected void onLauncherPackageRemoved(String packageName, UserHandleCompat user) {
+ protected void onLauncherPackageRemoved(String packageName, UserHandle user) {
}
/**
* Adds and binds shortcuts marked to be added to the work folder.
*/
private void finalizeWorkFolder(
- UserHandleCompat user, final ArrayList<ShortcutInfo> workFolderApps,
+ UserHandle user, final ArrayList<ShortcutInfo> workFolderApps,
ArrayList<ShortcutInfo> homescreenApps) {
if (workFolderApps.isEmpty()) {
return;
@@ -190,7 +191,7 @@
@Override
public void onShortcutsChanged(String packageName, List<ShortcutInfoCompat> shortcuts,
- UserHandleCompat user) {
+ UserHandle user) {
// Do nothing
}
}
@@ -209,13 +210,13 @@
/**
* Verifies that entries corresponding to {@param users} exist and removes all invalid entries.
*/
- public static void processAllUsers(List<UserHandleCompat> users, Context context) {
+ public static void processAllUsers(List<UserHandle> users, Context context) {
if (!Utilities.ATLEAST_LOLLIPOP) {
return;
}
UserManagerCompat userManager = UserManagerCompat.getInstance(context);
HashSet<String> validKeys = new HashSet<String>();
- for (UserHandleCompat user : users) {
+ for (UserHandle user : users) {
addAllUserKeys(userManager.getSerialNumberForUser(user), validKeys);
}
@@ -242,10 +243,10 @@
*/
public static void markExistingUsersForNoFolderCreation(Context context) {
UserManagerCompat userManager = UserManagerCompat.getInstance(context);
- UserHandleCompat myUser = UserHandleCompat.myUserHandle();
+ UserHandle myUser = Process.myUserHandle();
SharedPreferences prefs = null;
- for (UserHandleCompat user : userManager.getUserProfiles()) {
+ for (UserHandle user : userManager.getUserProfiles()) {
if (myUser.equals(user)) {
continue;
}
diff --git a/src/com/android/launcher3/widget/WidgetItemComparator.java b/src/com/android/launcher3/widget/WidgetItemComparator.java
index b5aaeb9..ee23cfb 100644
--- a/src/com/android/launcher3/widget/WidgetItemComparator.java
+++ b/src/com/android/launcher3/widget/WidgetItemComparator.java
@@ -15,7 +15,9 @@
*/
package com.android.launcher3.widget;
-import com.android.launcher3.compat.UserHandleCompat;
+import android.os.Process;
+import android.os.UserHandle;
+
import com.android.launcher3.model.WidgetItem;
import java.text.Collator;
@@ -26,7 +28,7 @@
*/
public class WidgetItemComparator implements Comparator<WidgetItem> {
- private final UserHandleCompat mMyUserHandle = UserHandleCompat.myUserHandle();
+ private final UserHandle mMyUserHandle = Process.myUserHandle();
private final Collator mCollator = Collator.getInstance();
@Override