Loading src/com/android/settings/applications/AppStateLocaleBridge.java +62 −9 Original line number Diff line number Diff line Loading @@ -18,13 +18,19 @@ package com.android.settings.applications; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.UserHandle; import android.os.UserManager; import android.util.ArrayMap; import android.util.Log; import com.android.settings.Utils; import com.android.settingslib.applications.ApplicationsState; import com.android.settingslib.applications.ApplicationsState.AppEntry; import com.android.settingslib.applications.ApplicationsState.AppFilter; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Creates a application filter to restrict UI display of applications. Loading @@ -35,20 +41,22 @@ public class AppStateLocaleBridge extends AppStateBaseBridge { private static final String TAG = AppStateLocaleBridge.class.getSimpleName(); private final Context mContext; private final List<ResolveInfo> mListInfos; private final Map<Integer, AppInfoByProfiles> mUserIdToAppInfoByProfiles = new ArrayMap<>(); public AppStateLocaleBridge(Context context, ApplicationsState appState, Callback callback) { Callback callback, UserManager userManager) { super(appState, callback); mContext = context; mListInfos = context.getPackageManager().queryIntentActivities( AppLocaleUtil.LAUNCHER_ENTRY_INTENT, PackageManager.GET_META_DATA); collectLocaleBridgeInfo(userManager); } @Override protected void updateExtraInfo(AppEntry app, String packageName, int uid) { app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(mContext, app.info.packageName, mListInfos) ? Boolean.TRUE : Boolean.FALSE; AppInfoByProfiles appInfoByProfiles = getAppInfo(UserHandle.getUserId(uid)); app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(appInfoByProfiles.mContextAsUser, app.info.packageName, appInfoByProfiles.mListInfos) ? Boolean.TRUE : Boolean.FALSE; } @Override Loading @@ -56,9 +64,11 @@ public class AppStateLocaleBridge extends AppStateBaseBridge { final List<AppEntry> allApps = mAppSession.getAllApps(); for (int i = 0; i < allApps.size(); i++) { AppEntry app = allApps.get(i); app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(mContext, app.info.packageName, mListInfos) ? Boolean.TRUE : Boolean.FALSE; AppInfoByProfiles appInfoByProfiles = getAppInfo(UserHandle.getUserId(app.info.uid)); app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(appInfoByProfiles.mContextAsUser, app.info.packageName, appInfoByProfiles.mListInfos) ? Boolean.TRUE : Boolean.FALSE; } } Loading @@ -78,4 +88,47 @@ public class AppStateLocaleBridge extends AppStateBaseBridge { return (Boolean) entry.extraInfo; } }; private void collectLocaleBridgeInfo(UserManager userManager) { List<Integer> userIds = new ArrayList<>(); userIds.add(mContext.getUserId()); int workUserId = Utils.getManagedProfileId(userManager, mContext.getUserId()); if (workUserId != UserHandle.USER_NULL) { userIds.add(workUserId); } // Separate the app information by profiles. for (int userId : userIds) { if (!mUserIdToAppInfoByProfiles.containsKey(userId)) { mUserIdToAppInfoByProfiles.put(userId, new AppInfoByProfiles(mContext, userId)); } } } private AppInfoByProfiles getAppInfo(int userId) { AppInfoByProfiles info; if (mUserIdToAppInfoByProfiles.containsKey(userId)) { info = mUserIdToAppInfoByProfiles.get(userId); } else { info = new AppInfoByProfiles(mContext, userId); mUserIdToAppInfoByProfiles.put(userId, info); } return info; } /** * The app information by profiles. */ private static class AppInfoByProfiles { public final Context mContextAsUser; public final List<ResolveInfo> mListInfos; private AppInfoByProfiles(Context context, int userId) { mContextAsUser = context.createContextAsUser(UserHandle.of(userId), 0); mListInfos = mContextAsUser.getPackageManager().queryIntentActivities( AppLocaleUtil.LAUNCHER_ENTRY_INTENT, PackageManager.GET_META_DATA); } } } src/com/android/settings/applications/manageapplications/ManageApplications.java +2 −1 Original line number Diff line number Diff line Loading @@ -1148,7 +1148,8 @@ public class ManageApplications extends InstrumentedFragment } else if (mManageApplications.mListType == LIST_TYPE_MEDIA_MANAGEMENT_APPS) { mExtraInfoBridge = new AppStateMediaManagementAppsBridge(mContext, mState, this); } else if (mManageApplications.mListType == LIST_TYPE_APPS_LOCALE) { mExtraInfoBridge = new AppStateLocaleBridge(mContext, mState, this); mExtraInfoBridge = new AppStateLocaleBridge(mContext, mState, this, mManageApplications.mUserManager); } else if (mManageApplications.mListType == LIST_TYPE_BATTERY_OPTIMIZATION) { mExtraInfoBridge = new AppStateAppBatteryUsageBridge(mContext, mState, this); } else { Loading Loading
src/com/android/settings/applications/AppStateLocaleBridge.java +62 −9 Original line number Diff line number Diff line Loading @@ -18,13 +18,19 @@ package com.android.settings.applications; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.UserHandle; import android.os.UserManager; import android.util.ArrayMap; import android.util.Log; import com.android.settings.Utils; import com.android.settingslib.applications.ApplicationsState; import com.android.settingslib.applications.ApplicationsState.AppEntry; import com.android.settingslib.applications.ApplicationsState.AppFilter; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Creates a application filter to restrict UI display of applications. Loading @@ -35,20 +41,22 @@ public class AppStateLocaleBridge extends AppStateBaseBridge { private static final String TAG = AppStateLocaleBridge.class.getSimpleName(); private final Context mContext; private final List<ResolveInfo> mListInfos; private final Map<Integer, AppInfoByProfiles> mUserIdToAppInfoByProfiles = new ArrayMap<>(); public AppStateLocaleBridge(Context context, ApplicationsState appState, Callback callback) { Callback callback, UserManager userManager) { super(appState, callback); mContext = context; mListInfos = context.getPackageManager().queryIntentActivities( AppLocaleUtil.LAUNCHER_ENTRY_INTENT, PackageManager.GET_META_DATA); collectLocaleBridgeInfo(userManager); } @Override protected void updateExtraInfo(AppEntry app, String packageName, int uid) { app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(mContext, app.info.packageName, mListInfos) ? Boolean.TRUE : Boolean.FALSE; AppInfoByProfiles appInfoByProfiles = getAppInfo(UserHandle.getUserId(uid)); app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(appInfoByProfiles.mContextAsUser, app.info.packageName, appInfoByProfiles.mListInfos) ? Boolean.TRUE : Boolean.FALSE; } @Override Loading @@ -56,9 +64,11 @@ public class AppStateLocaleBridge extends AppStateBaseBridge { final List<AppEntry> allApps = mAppSession.getAllApps(); for (int i = 0; i < allApps.size(); i++) { AppEntry app = allApps.get(i); app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(mContext, app.info.packageName, mListInfos) ? Boolean.TRUE : Boolean.FALSE; AppInfoByProfiles appInfoByProfiles = getAppInfo(UserHandle.getUserId(app.info.uid)); app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(appInfoByProfiles.mContextAsUser, app.info.packageName, appInfoByProfiles.mListInfos) ? Boolean.TRUE : Boolean.FALSE; } } Loading @@ -78,4 +88,47 @@ public class AppStateLocaleBridge extends AppStateBaseBridge { return (Boolean) entry.extraInfo; } }; private void collectLocaleBridgeInfo(UserManager userManager) { List<Integer> userIds = new ArrayList<>(); userIds.add(mContext.getUserId()); int workUserId = Utils.getManagedProfileId(userManager, mContext.getUserId()); if (workUserId != UserHandle.USER_NULL) { userIds.add(workUserId); } // Separate the app information by profiles. for (int userId : userIds) { if (!mUserIdToAppInfoByProfiles.containsKey(userId)) { mUserIdToAppInfoByProfiles.put(userId, new AppInfoByProfiles(mContext, userId)); } } } private AppInfoByProfiles getAppInfo(int userId) { AppInfoByProfiles info; if (mUserIdToAppInfoByProfiles.containsKey(userId)) { info = mUserIdToAppInfoByProfiles.get(userId); } else { info = new AppInfoByProfiles(mContext, userId); mUserIdToAppInfoByProfiles.put(userId, info); } return info; } /** * The app information by profiles. */ private static class AppInfoByProfiles { public final Context mContextAsUser; public final List<ResolveInfo> mListInfos; private AppInfoByProfiles(Context context, int userId) { mContextAsUser = context.createContextAsUser(UserHandle.of(userId), 0); mListInfos = mContextAsUser.getPackageManager().queryIntentActivities( AppLocaleUtil.LAUNCHER_ENTRY_INTENT, PackageManager.GET_META_DATA); } } }
src/com/android/settings/applications/manageapplications/ManageApplications.java +2 −1 Original line number Diff line number Diff line Loading @@ -1148,7 +1148,8 @@ public class ManageApplications extends InstrumentedFragment } else if (mManageApplications.mListType == LIST_TYPE_MEDIA_MANAGEMENT_APPS) { mExtraInfoBridge = new AppStateMediaManagementAppsBridge(mContext, mState, this); } else if (mManageApplications.mListType == LIST_TYPE_APPS_LOCALE) { mExtraInfoBridge = new AppStateLocaleBridge(mContext, mState, this); mExtraInfoBridge = new AppStateLocaleBridge(mContext, mState, this, mManageApplications.mUserManager); } else if (mManageApplications.mListType == LIST_TYPE_BATTERY_OPTIMIZATION) { mExtraInfoBridge = new AppStateAppBatteryUsageBridge(mContext, mState, this); } else { Loading