use of android.content.pm.LauncherActivityInfo in project lnch by italankin.
the class LauncherActivityInfoUtils method groupByPackage.
static Map<String, List<LauncherActivityInfo>> groupByPackage(List<LauncherActivityInfo> infoList) {
Map<String, List<LauncherActivityInfo>> infosByPackageName = new LinkedHashMap<>(infoList.size());
for (LauncherActivityInfo info : infoList) {
String packageName = info.getApplicationInfo().packageName;
List<LauncherActivityInfo> list = infosByPackageName.get(packageName);
if (list == null) {
list = new ArrayList<>(1);
infosByPackageName.put(packageName, list);
}
list.add(info);
}
return infosByPackageName;
}
use of android.content.pm.LauncherActivityInfo in project lnch by italankin.
the class PackagesMap method poll.
/**
* Get matching {@link LauncherActivityInfo} for a given {@link AppDescriptor}.
* If {@code null} is returned, the app probably got deleted.
*/
LauncherActivityInfo poll(AppDescriptor item) {
List<LauncherActivityInfo> infos = packages.get(item.packageName);
if (infos == null || infos.isEmpty()) {
return null;
}
if (infos.size() == 1) {
LauncherActivityInfo result = infos.remove(0);
packages.remove(item.packageName);
return result;
} else if (item.componentName != null) {
Iterator<LauncherActivityInfo> iter = infos.iterator();
while (iter.hasNext()) {
LauncherActivityInfo info = iter.next();
String componentName = getComponentName(info);
if (componentName.equals(item.componentName)) {
iter.remove();
return info;
}
}
}
return null;
}
use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class ShortcutConfigActivityInfo method queryList.
public static List<ShortcutConfigActivityInfo> queryList(Context context, @Nullable PackageUserKey packageUser) {
List<ShortcutConfigActivityInfo> result = new ArrayList<>();
UserHandle myUser = Process.myUserHandle();
final List<UserHandle> users;
final String packageName;
if (packageUser == null) {
users = UserCache.INSTANCE.get(context).getUserProfiles();
packageName = null;
} else {
users = Collections.singletonList(packageUser.mUser);
packageName = packageUser.mPackageName;
}
LauncherApps launcherApps = context.getSystemService(LauncherApps.class);
for (UserHandle user : users) {
boolean ignoreTargetSdk = myUser.equals(user);
for (LauncherActivityInfo activityInfo : launcherApps.getShortcutConfigActivityList(packageName, user)) {
if (ignoreTargetSdk || activityInfo.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O) {
result.add(new ShortcutConfigActivityInfoVO(activityInfo));
}
}
}
return result;
}
use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class SecondaryDropTarget method getUninstallTarget.
/**
* @return the component name that should be uninstalled or null.
*/
private ComponentName getUninstallTarget(ItemInfo item) {
Intent intent = null;
UserHandle user = null;
if (item != null && item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
intent = item.getIntent();
user = item.user;
}
if (intent != null) {
LauncherActivityInfo info = mLauncher.getSystemService(LauncherApps.class).resolveActivity(intent, user);
if (info != null && (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
return info.getComponentName();
}
}
return null;
}
use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class LoaderTask method loadAllApps.
private List<LauncherActivityInfo> loadAllApps() {
final List<UserHandle> profiles = mUserCache.getUserProfiles();
List<LauncherActivityInfo> allActivityList = new ArrayList<>();
// Clear the list of apps
mBgAllAppsList.clear();
List<IconRequestInfo<AppInfo>> iconRequestInfos = new ArrayList<>();
for (UserHandle user : profiles) {
// Query for the set of apps
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
// TODO: Fix this. Only fail for the current user.
if (apps == null || apps.isEmpty()) {
return allActivityList;
}
boolean quietMode = mUserManagerState.isUserQuiet(user);
// Create the ApplicationInfos
for (int i = 0; i < apps.size(); i++) {
LauncherActivityInfo app = apps.get(i);
AppInfo appInfo = new AppInfo(app, user, quietMode);
iconRequestInfos.add(new IconRequestInfo<>(appInfo, app, /* useLowResIcon= */
false));
mBgAllAppsList.add(appInfo, app, !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
}
allActivityList.addAll(apps);
}
if (FeatureFlags.PROMISE_APPS_IN_ALL_APPS.get()) {
// get all active sessions and add them to the all apps list
for (PackageInstaller.SessionInfo info : mSessionHelper.getAllVerifiedSessions()) {
AppInfo promiseAppInfo = mBgAllAppsList.addPromiseApp(mApp.getContext(), PackageInstallInfo.fromInstallingState(info), !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
if (promiseAppInfo != null) {
iconRequestInfos.add(new IconRequestInfo<>(promiseAppInfo, /* launcherActivityInfo= */
null, promiseAppInfo.usingLowResIcon()));
}
}
}
if (FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get()) {
Trace.beginSection("LoadAllAppsIconsInBulk");
try {
mIconCache.getTitlesAndIconsInBulk(iconRequestInfos);
iconRequestInfos.forEach(iconRequestInfo -> mBgAllAppsList.updateSectionName(iconRequestInfo.itemInfo));
} finally {
Trace.endSection();
}
}
mBgAllAppsList.setFlags(FLAG_QUIET_MODE_ENABLED, mUserManagerState.isAnyProfileQuietModeEnabled());
mBgAllAppsList.setFlags(FLAG_HAS_SHORTCUT_PERMISSION, hasShortcutsPermission(mApp.getContext()));
mBgAllAppsList.setFlags(FLAG_QUIET_MODE_CHANGE_PERMISSION, mApp.getContext().checkSelfPermission("android.permission.MODIFY_QUIET_MODE") == PackageManager.PERMISSION_GRANTED);
mBgAllAppsList.getAndResetChangeFlag();
return allActivityList;
}
Aggregations