android.content.pm.LauncherActivityInfo源码实例Demo

类android.content.pm.LauncherActivityInfo源码实例Demo

下面列出了android.content.pm.LauncherActivityInfo 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LaunchEnr   文件: LauncherAppsCompatVL.java
@Override
public ApplicationInfo getApplicationInfo(String packageName, int flags, UserHandle user) {
    final boolean isPrimaryUser = Process.myUserHandle().equals(user);
    if (!isPrimaryUser && (flags == 0)) {
        // We are looking for an installed app on a secondary profile. Prior to O, the only
        // entry point for work profiles is through the LauncherActivity.
        List<LauncherActivityInfo> activityList =
                mLauncherApps.getActivityList(packageName, user);
        return activityList.size() > 0 ? activityList.get(0).getApplicationInfo() : null;
    }
    try {
        ApplicationInfo info =
                mContext.getPackageManager().getApplicationInfo(packageName, flags);
        // There is no way to check if the app is installed for managed profile. But for
        // primary profile, we can still have this check.
        if (isPrimaryUser && ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0)
                || !info.enabled) {
            return null;
        }
        return info;
    } catch (PackageManager.NameNotFoundException e) {
        // Package not found
        return null;
    }
}
 
源代码2 项目: LaunchEnr   文件: ShortcutConfigActivityInfo.java
@Override
public boolean startConfigActivity(Activity activity, int requestCode) {
    if (getUser().equals(Process.myUserHandle())) {
        return super.startConfigActivity(activity, requestCode);
    }
    try {
        Method m = LauncherApps.class.getDeclaredMethod(
                "getShortcutConfigActivityIntent", LauncherActivityInfo.class);
        IntentSender is = (IntentSender) m.invoke(
                activity.getSystemService(LauncherApps.class), mInfo);
        activity.startIntentSenderForResult(is, requestCode, null, 0, 0, 0);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
源代码3 项目: LaunchEnr   文件: CachedPackageTracker.java
@Override
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);
    if (!packageSet.contains(packageName)) {
        List<LauncherActivityInfo> activities =
                mLauncherApps.getActivityList(packageName, user);
        if (!activities.isEmpty()) {
            LauncherActivityInfo activityInfo = activities.get(0);

            packageSet.add(packageName);
            mPrefs.edit().putStringSet(prefKey, packageSet).apply();
            onLauncherAppsAdded(Arrays.asList(
                    new LauncherActivityInstallInfo(activityInfo, System.currentTimeMillis())),
                    user, userAppsExisted);
        }
    }
}
 
源代码4 项目: LaunchEnr   文件: IconCache.java
/**
 * Updates the entries related to the given package in memory and persistent DB.
 */
public synchronized void updateIconsForPkg(String packageName, UserHandle user) {
    removeIconsForPkg(packageName, user);
    try {
        int uninstalled = android.os.Build.VERSION.SDK_INT >= 24 ? PackageManager.MATCH_UNINSTALLED_PACKAGES : PackageManager.GET_UNINSTALLED_PACKAGES;

        PackageInfo info = mPackageManager.getPackageInfo(packageName,
                uninstalled);
        long userSerial = mUserManager.getSerialNumberForUser(user);
        for (LauncherActivityInfo app : mLauncherApps.getActivityList(packageName, user)) {
            addIconToDBAndMemCache(app, info, userSerial, false /*replace existing*/);
        }
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        return;
    }
}
 
源代码5 项目: LaunchEnr   文件: IconCache.java
public void updateDbIcons(Set<String> ignorePackagesForMainUser) {
    // Remove all active icon update tasks.
    mWorkerHandler.removeCallbacksAndMessages(ICON_UPDATE_TOKEN);

    mIconProvider.updateSystemStateString();
    for (UserHandle user : mUserManager.getUserProfiles()) {
        // Query for the set of apps
        final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
        // Fail if we don't have any apps
        // TODO: Fix this. Only fail for the current user.
        if (apps == null || apps.isEmpty()) {
            return;
        }

        // Update icon cache. This happens in segments and {@link #onPackageIconsUpdated}
        // is called by the icon cache when the job is complete.
        updateDBIcons(user, apps, Process.myUserHandle().equals(user)
                ? ignorePackagesForMainUser : Collections.<String>emptySet());
    }
}
 
源代码6 项目: LaunchEnr   文件: IconCache.java
/**
 * Adds an entry into the DB and the in-memory cache.
 * @param replaceExisting if true, it will recreate the bitmap even if it already exists in
 *                        the memory. This is useful then the previous bitmap was created using
 *                        old data.
 */
@Thunk private synchronized void addIconToDBAndMemCache(LauncherActivityInfo app,
        PackageInfo info, long userSerial, boolean replaceExisting) {
    final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
    CacheEntry entry = null;
    if (!replaceExisting) {
        entry = mCache.get(key);
        // We can't reuse the entry if the high-res icon is not present.
        if (entry == null || entry.isLowResIcon || entry.icon == null) {
            entry = null;
        }
    }
    if (entry == null) {
        entry = new CacheEntry();
        entry.icon = LauncherIcons.createBadgedIconBitmap(getFullResIcon(app), app.getUser(),
                mContext,  app.getApplicationInfo().targetSdkVersion);
    }
    entry.title = app.getLabel();
    entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
    mCache.put(key, entry);

    Bitmap lowResIcon = generateLowResIcon(entry.icon, mActivityBgColor);
    ContentValues values = newContentValues(entry.icon, lowResIcon, entry.title.toString(),
            app.getApplicationInfo().packageName);
    addIconToDB(values, app.getComponentName(), info, userSerial);
}
 
源代码7 项目: LaunchEnr   文件: InstallShortcutReceiver.java
/**
 * Tries to create a new PendingInstallShortcutInfo which represents the same target,
 * but is an app target and not a shortcut.
 * @return the newly created info or the original one.
 */
private static PendingInstallShortcutInfo convertToLauncherActivityIfPossible(
        PendingInstallShortcutInfo original) {
    if (original.isLauncherActivity()) {
        // Already an activity target
        return original;
    }
    if (!Utilities.isLauncherAppTarget(original.launchIntent)) {
        return original;
    }

    LauncherActivityInfo info = LauncherAppsCompat.getInstance(original.mContext)
            .resolveActivity(original.launchIntent, original.user);
    if (info == null) {
        return original;
    }
    // Ignore any conflicts in the label name, as that can change based on locale.
    return new PendingInstallShortcutInfo(info, original.mContext);
}
 
源代码8 项目: Taskbar   文件: IconCache.java
public BitmapDrawable getIcon(Context context, PackageManager pm, LauncherActivityInfo appInfo) {
    UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    String name = appInfo.getComponentName().flattenToString() + ":" + userManager.getSerialNumberForUser(appInfo.getUser());

    BitmapDrawable drawable;

    synchronized (drawables) {
        drawable = drawables.get(name);
        if(drawable == null) {
            Drawable loadedIcon = loadIcon(context, pm, appInfo);
            drawable = U.convertToBitmapDrawable(context, loadedIcon);

            drawables.put(name, drawable);
        }
    }

    return drawable;
}
 
源代码9 项目: LaunchEnr   文件: LauncherAppsCompatVO.java
@Override
public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList(
        @Nullable PackageUserKey packageUser) {
    List<ShortcutConfigActivityInfo> result = new ArrayList<>();
    UserHandle myUser = Process.myUserHandle();

    try {
        Method m = LauncherApps.class.getDeclaredMethod("getShortcutConfigActivityList",
                String.class, UserHandle.class);
        final List<UserHandle> users;
        final String packageName;
        if (packageUser == null) {
            users = UserManagerCompat.getInstance(mContext).getUserProfiles();
            packageName = null;
        } else {
            users = new ArrayList<>(1);
            users.add(packageUser.mUser);
            packageName = packageUser.mPackageName;
        }
        for (UserHandle user : users) {
            boolean ignoreTargetSdk = myUser.equals(user);
            List<LauncherActivityInfo> activities =
                    (List<LauncherActivityInfo>) m.invoke(mLauncherApps, packageName, user);
            for (LauncherActivityInfo activityInfo : activities) {
                if (ignoreTargetSdk || activityInfo.getApplicationInfo().targetSdkVersion >=
                        Build.VERSION_CODES.O) {
                    result.add(new ShortcutConfigActivityInfoVO(activityInfo));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return result;
}
 
源代码10 项目: LaunchEnr   文件: AllAppsList.java
/**
 * Add the supplied ApplicationInfo objects to the list, and enqueue it into the
 * list to broadcast when notify() is called.
 *
 * If the app is already in the list, doesn't add it.
 */
public void add(AppInfo info, LauncherActivityInfo activityInfo) {
    if (!mAppFilter.shouldShowApp(info.componentName.getPackageName(), mContext)) {
        return;
    }
    if (findActivity(data, info.componentName, info.user)) {
        return;
    }
    mIconCache.getTitleAndIcon(info, activityInfo, true /* useLowResIcon */);

    data.add(info);
    added.add(info);
}
 
源代码11 项目: LaunchEnr   文件: AllAppsList.java
/**
 * Add the icons for the supplied apk called packageName.
 */
public void addPackage(Context context, String packageName, UserHandle user) {
    final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
    final List<LauncherActivityInfo> matches = launcherApps.getActivityList(packageName,
            user);

    for (LauncherActivityInfo info : matches) {
        add(new AppInfo(context, info, user), info);
    }
}
 
源代码12 项目: LaunchEnr   文件: AllAppsList.java
/**
 * Returns whether <em>apps</em> contains <em>component</em>.
 */
private static boolean findActivity(List<LauncherActivityInfo> apps,
        ComponentName component) {
    for (LauncherActivityInfo info : apps) {
        if (info.getComponentName().equals(component)) {
            return true;
        }
    }
    return false;
}
 
源代码13 项目: LaunchEnr   文件: LauncherModel.java
private void scheduleManagedHeuristicRunnable(final ManagedProfileHeuristic heuristic,
        final UserHandle user, final List<LauncherActivityInfo> apps) {
    if (heuristic != null) {
        // Assume the app lists now is updated.
        mIsManagedHeuristicAppsUpdated = false;
        final Runnable managedHeuristicRunnable = new Runnable() {
            @Override
            public void run() {
                if (mIsManagedHeuristicAppsUpdated) {
                    // If app list is updated, we need to reschedule it otherwise old app
                    // list will override everything in processUserApps().
                    sWorker.post(new Runnable() {
                        public void run() {
                            final List<LauncherActivityInfo> updatedApps =
                                    mLauncherApps.getActivityList(null, user);
                            scheduleManagedHeuristicRunnable(heuristic, user,
                                    updatedApps);
                        }
                    });
                } else {
                    heuristic.processUserApps(apps);
                }
            }
        };
        runOnMainThread(new Runnable() {
            @Override
            public void run() {
                // Check isLoadingWorkspace on the UI thread, as it is updated on the UI
                // thread.
                if (mIsLoadingAndBindingWorkspace) {
                    synchronized (mBindCompleteRunnables) {
                        mBindCompleteRunnables.add(managedHeuristicRunnable);
                    }
                } else {
                    runOnWorkerThread(managedHeuristicRunnable);
                }
            }
        });
    }
}
 
源代码14 项目: LaunchEnr   文件: CachedPackageTracker.java
/**
 * Checks the list of user apps, and generates package event accordingly.
 * {@see #onLauncherAppsAdded}, {@see #onLauncherPackageRemoved}
 */
void processUserApps(List<LauncherActivityInfo> apps, UserHandle user) {
    String prefKey = INSTALLED_PACKAGES_PREFIX + mUserManager.getSerialNumberForUser(user);
    HashSet<String> oldPackageSet = new HashSet<>();
    final boolean userAppsExisted = getUserApps(oldPackageSet, prefKey);

    HashSet<String> packagesRemoved = new HashSet<>(oldPackageSet);
    HashSet<String> newPackageSet = new HashSet<>();
    ArrayList<LauncherActivityInstallInfo> packagesAdded = new ArrayList<>();

    for (LauncherActivityInfo info : apps) {
        String packageName = info.getComponentName().getPackageName();
        newPackageSet.add(packageName);
        packagesRemoved.remove(packageName);

        if (!oldPackageSet.contains(packageName)) {
            oldPackageSet.add(packageName);
            packagesAdded.add(new LauncherActivityInstallInfo(
                    info, info.getFirstInstallTime()));
        }
    }

    if (!packagesAdded.isEmpty() || !packagesRemoved.isEmpty()) {
        mPrefs.edit().putStringSet(prefKey, newPackageSet).apply();

        if (!packagesAdded.isEmpty()) {
            Collections.sort(packagesAdded);
            onLauncherAppsAdded(packagesAdded, user, userAppsExisted);
        }

        if (!packagesRemoved.isEmpty()) {
            for (String pkg : packagesRemoved) {
                onLauncherPackageRemoved(pkg, user);
            }
        }
    }
}
 
源代码15 项目: LaunchEnr   文件: IconThemer.java
private Drawable getIconFromHandler(LauncherActivityInfo info) {
    Bitmap bm = mIconsManager.getDrawableIconForPackage(info.getComponentName());
    if (bm == null) {
        return null;
    }
    return new BitmapDrawable(mContext.getResources(), LauncherIcons.createIconBitmap(bm, mContext));
}
 
源代码16 项目: LaunchEnr   文件: IconCache.java
public void addCustomInfoToDataBase(Drawable icon, ItemInfo info, CharSequence title) {
    LauncherActivityInfo app = mLauncherApps.resolveActivity(info.getIntent(), info.user);
    final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
    CacheEntry entry = mCache.get(key);
    PackageInfo packageInfo = null;
    try {
        packageInfo = mPackageManager.getPackageInfo(
                app.getComponentName().getPackageName(), 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    // We can't reuse the entry if the high-res icon is not present.
    if (entry == null || entry.isLowResIcon || entry.icon == null) {
        entry = new CacheEntry();
    }
    entry.icon = LauncherIcons.createIconBitmap(icon, mContext);

    entry.title = title != null ? title : app.getLabel();

    entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
    mCache.put(key, entry);

    Bitmap lowResIcon = generateLowResIcon(entry.icon, mActivityBgColor);
    ContentValues values = newContentValues(entry.icon, lowResIcon, entry.title.toString(),
            app.getApplicationInfo().packageName);
    if (packageInfo != null) {
        addIconToDB(values, app.getComponentName(), packageInfo,
                mUserManager.getSerialNumberForUser(app.getUser()));
    }
}
 
源代码17 项目: LaunchEnr   文件: IconCache.java
/**
 * Updates {@param application} only if a valid entry is found.
 */
public synchronized void updateTitleAndIcon(AppInfo application) {
    CacheEntry entry = cacheLocked(application.componentName,
            Provider.<LauncherActivityInfo>of(null),
            application.user, false, application.usingLowResIcon);
    if (entry.icon != null && !isDefaultIcon(entry.icon, application.user)) {
        applyCacheEntry(entry, application);
    }
}
 
源代码18 项目: LaunchEnr   文件: IconCache.java
/**
 * Fill in {@param info} with the icon and label for {@param activityInfo}
 */
public synchronized void getTitleAndIcon(ItemInfoWithIcon info,
        LauncherActivityInfo activityInfo, boolean useLowResIcon) {

    // If we already have activity info, no need to use package icon
    getTitleAndIcon(info, Provider.of(activityInfo), false, useLowResIcon);
}
 
源代码19 项目: LaunchEnr   文件: IconCache.java
/**
 * Fill in {@param shortcutInfo} with the icon and label for {@param info}
 */
private synchronized void getTitleAndIcon(
        @NonNull ItemInfoWithIcon infoInOut,
        @NonNull Provider<LauncherActivityInfo> activityInfoProvider,
        boolean usePkgIcon, boolean useLowResIcon) {
    CacheEntry entry = cacheLocked(infoInOut.getTargetComponent(), activityInfoProvider,
            infoInOut.user, usePkgIcon, useLowResIcon);
    applyCacheEntry(entry, infoInOut);
}
 
源代码20 项目: LaunchEnr   文件: IconCache.java
@Thunk SerializedIconUpdateTask(long userSerial, HashMap<String, PackageInfo> pkgInfoMap,
        Stack<LauncherActivityInfo> appsToAdd,
        Stack<LauncherActivityInfo> appsToUpdate) {
    mUserSerial = userSerial;
    mPkgInfoMap = pkgInfoMap;
    mAppsToAdd = appsToAdd;
    mAppsToUpdate = appsToUpdate;
}
 
源代码21 项目: LaunchEnr   文件: InstallShortcutReceiver.java
/**
 * Initializes a PendingInstallShortcutInfo to represent a launcher target.
 */
PendingInstallShortcutInfo(LauncherActivityInfo info, Context context) {
    activityInfo = info;
    shortcutInfo = null;
    providerInfo = null;

    data = null;
    user = info.getUser();
    mContext = context;

    launchIntent = AppInfo.makeLaunchIntent(info);
    label = info.getLabel().toString();
}
 
源代码22 项目: LaunchEnr   文件: AppInfo.java
public AppInfo(LauncherActivityInfo info, UserHandle user, boolean quietModeEnabled) {
    this.componentName = info.getComponentName();
    this.container = ItemInfo.NO_ID;
    this.user = user;
    if (PackageManagerHelper.isAppSuspended(info.getApplicationInfo())) {
        isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
    }
    if (quietModeEnabled) {
        isDisabled |= ShortcutInfo.FLAG_DISABLED_QUIET_USER;
    }

    intent = makeLaunchIntent(info);
}
 
源代码23 项目: Taskbar   文件: FavoriteAppTileService.java
private void updateState() {
    Tile tile = getQsTile();
    if(tile == null) return;

    SharedPreferences pref = U.getSharedPreferences(this);
    if(pref.getBoolean(prefix + "added", false)) {
        tile.setState(Tile.STATE_ACTIVE);
        tile.setLabel(pref.getString(prefix + "label", getString(R.string.tb_new_shortcut)));

        String componentName = pref.getString(prefix + "component_name", null);
        float threshold = pref.getFloat(prefix + "icon_threshold", -1);

        if(componentName != null && threshold >= 0) {
            UserManager userManager = (UserManager) getSystemService(USER_SERVICE);
            LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE);
            long userId = pref.getLong(prefix + "user_id", userManager.getSerialNumberForUser(Process.myUserHandle()));

            Intent intent = new Intent();
            intent.setComponent(ComponentName.unflattenFromString(componentName));
            LauncherActivityInfo info = launcherApps.resolveActivity(intent, userManager.getUserForSerialNumber(userId));

            IconCache cache = IconCache.getInstance(this);
            BitmapDrawable icon = U.convertToMonochrome(this, cache.getIcon(this, info), threshold);

            tile.setIcon(Icon.createWithBitmap(icon.getBitmap()));
        } else
            tile.setIcon(Icon.createWithResource(this, R.drawable.tb_favorite_app_tile));
    } else {
        tile.setState(Tile.STATE_INACTIVE);
        tile.setLabel(getString(R.string.tb_new_shortcut));
        tile.setIcon(Icon.createWithResource(this, R.drawable.tb_favorite_app_tile));
    }

    tile.updateTile();
}
 
源代码24 项目: Taskbar   文件: TaskbarController.java
@VisibleForTesting
void populateAppEntries(Context context,
                        PackageManager pm,
                        List<AppEntry> entries,
                        List<LauncherActivityInfo> launcherAppCache) {
    UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);

    int launcherAppCachePos = -1;
    for(int i = 0; i < entries.size(); i++) {
        if(entries.get(i).getComponentName() == null) {
            launcherAppCachePos++;
            LauncherActivityInfo appInfo = launcherAppCache.get(launcherAppCachePos);
            String packageName = entries.get(i).getPackageName();
            long lastTimeUsed = entries.get(i).getLastTimeUsed();

            entries.remove(i);

            AppEntry newEntry = new AppEntry(
                    packageName,
                    appInfo.getComponentName().flattenToString(),
                    appInfo.getLabel().toString(),
                    IconCache.getInstance(context).getIcon(context, pm, appInfo),
                    false);

            newEntry.setUserId(userManager.getSerialNumberForUser(appInfo.getUser()));
            newEntry.setLastTimeUsed(lastTimeUsed);
            entries.add(i, newEntry);
        }
    }
}
 
源代码25 项目: Taskbar   文件: IconCache.java
private Drawable getIcon(PackageManager pm, LauncherActivityInfo appInfo) {
    try {
        return appInfo.getBadgedIcon(0);
    } catch (NullPointerException e) {
        return pm.getDefaultActivityIcon();
    }
}
 
源代码26 项目: Taskbar   文件: TaskbarControllerTest.java
@Test
public void testPopulateAppEntries() {
    List<AppEntry> entries = new ArrayList<>();
    PackageManager pm = context.getPackageManager();
    List<LauncherActivityInfo> launcherAppCache = new ArrayList<>();

    uiController.populateAppEntries(context, pm, entries, launcherAppCache);
    assertEquals(0, entries.size());

    AppEntry appEntry = generateTestAppEntry(1);
    entries.add(appEntry);
    uiController.populateAppEntries(context, pm, entries, launcherAppCache);
    assertEquals(1, entries.size());
    assertSame(appEntry, entries.get(0));

    AppEntry firstEntry = appEntry;
    appEntry = new AppEntry(ENTRY_TEST_PACKAGE, null, null, null, false);
    appEntry.setLastTimeUsed(System.currentTimeMillis());
    entries.add(appEntry);
    ActivityInfo info = new ActivityInfo();
    info.packageName = appEntry.getPackageName();
    info.name = ENTRY_TEST_NAME;
    info.nonLocalizedLabel = ENTRY_TEST_LABEL;
    LauncherActivityInfo launcherActivityInfo =
            generateTestLauncherActivityInfo(context, info, DEFAULT_TEST_USER_ID);
    launcherAppCache.add(launcherActivityInfo);
    uiController.populateAppEntries(context, pm, entries, launcherAppCache);
    assertEquals(2, entries.size());
    assertSame(firstEntry, entries.get(0));
    AppEntry populatedEntry = entries.get(1);
    assertEquals(info.packageName, populatedEntry.getPackageName());
    assertEquals(
            launcherActivityInfo.getComponentName().flattenToString(),
            populatedEntry.getComponentName()
    );
    assertEquals(info.nonLocalizedLabel.toString(), populatedEntry.getLabel());
    assertEquals(DEFAULT_TEST_USER_ID, populatedEntry.getUserId(context));
    assertEquals(appEntry.getLastTimeUsed(), populatedEntry.getLastTimeUsed());
}
 
源代码27 项目: Taskbar   文件: TaskbarControllerTest.java
private LauncherActivityInfo generateTestLauncherActivityInfo(Context context,
                                                              ActivityInfo activityInfo,
                                                              int userHandleId) {
    return
            ReflectionHelpers.callConstructor(
                    LauncherActivityInfo.class,
                    from(Context.class, context),
                    from(ActivityInfo.class, activityInfo),
                    from(UserHandle.class, UserHandle.getUserHandleForUid(userHandleId))
            );
}
 
源代码28 项目: Taskbar   文件: TaskbarShadowLauncherApps.java
/**
 * Add an {@link LauncherActivityInfo} to be got by {@link #getActivityList(String, UserHandle)}.
 *
 * @param userHandle   the user handle to be added.
 * @param activityInfo the {@link LauncherActivityInfo} to be added.
 */
public void addActivity(UserHandle userHandle, LauncherActivityInfo activityInfo) {
    List<LauncherActivityInfo> activityInfoList = activityList.get(userHandle);
    if (activityInfoList == null) {
        activityInfoList = new ArrayList<>();
    }
    activityInfoList.remove(activityInfo);
    activityInfoList.add(activityInfo);
    activityList.put(userHandle, activityInfoList);
}
 
源代码29 项目: Taskbar   文件: TaskbarShadowLauncherApps.java
@Implementation
public List<LauncherActivityInfo> getActivityList(String packageName, UserHandle user) {
    List<LauncherActivityInfo> activityInfoList = activityList.get(user);
    if (activityInfoList == null || packageName == null) {
        return Collections.emptyList();
    }
    final Predicate<LauncherActivityInfo> predicatePackage =
            info ->
                    info.getComponentName() != null
                            && packageName.equals(info.getComponentName().getPackageName());
    return activityInfoList.stream().filter(predicatePackage).collect(Collectors.toList());
}
 
源代码30 项目: openlauncher   文件: App.java
@SuppressLint("NewApi")
public App(PackageManager pm, LauncherActivityInfo info) {
    _icon = info.getIcon(0);
    _label = info.getLabel().toString();
    _packageName = info.getComponentName().getPackageName();
    _className = info.getName();
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类所在包
 同包方法