android.content.pm.LauncherActivityInfo Java Examples

The following examples show how to use android.content.pm.LauncherActivityInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LauncherAppsCompatVL.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
@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;
    }
}
 
Example #2
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #3
Source File: InstallShortcutReceiver.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source File: ShortcutConfigActivityInfo.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
@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;
    }
}
 
Example #5
Source File: IconCache.java    From Taskbar with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: CachedPackageTracker.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
@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);
        }
    }
}
 
Example #7
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
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());
    }
}
 
Example #8
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source File: IconCache.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
private Drawable getIcon(PackageManager pm, LauncherActivityInfo appInfo) {
    try {
        return appInfo.getBadgedIcon(0);
    } catch (NullPointerException e) {
        return pm.getDefaultActivityIcon();
    }
}
 
Example #10
Source File: TaskbarControllerTest.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
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))
            );
}
 
Example #11
Source File: TaskbarControllerTest.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #12
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
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()));
    }
}
 
Example #13
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #14
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #15
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #16
Source File: TaskbarShadowLauncherApps.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #17
Source File: IconCache.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Thunk SerializedIconUpdateTask(long userSerial, HashMap<String, PackageInfo> pkgInfoMap,
        Stack<LauncherActivityInfo> appsToAdd,
        Stack<LauncherActivityInfo> appsToUpdate) {
    mUserSerial = userSerial;
    mPkgInfoMap = pkgInfoMap;
    mAppsToAdd = appsToAdd;
    mAppsToUpdate = appsToUpdate;
}
 
Example #18
Source File: InstallShortcutReceiver.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #19
Source File: AppInfo.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #20
Source File: TaskbarController.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example #21
Source File: FavoriteAppTileService.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #22
Source File: TaskbarShadowLauncherApps.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #23
Source File: IconThemer.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
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));
}
 
Example #24
Source File: App.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
public App(PackageManager pm, LauncherActivityInfo info) {
    _icon = info.getIcon(0);
    _label = info.getLabel().toString();
    _packageName = info.getComponentName().getPackageName();
    _className = info.getName();
}
 
Example #25
Source File: IslandManager.java    From island with Apache License 2.0 5 votes vote down vote up
@OwnerUser public static boolean launchApp(final Context context, final String pkg, final UserHandle profile) {
	final LauncherApps launcher_apps = Objects.requireNonNull((LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE));
	final List<LauncherActivityInfo> activities = launcher_apps.getActivityList(pkg, profile);
	if (activities == null || activities.isEmpty()) return false;
	launcher_apps.startMainActivity(activities.get(0).getComponentName(), profile, null, null);
	return true;
}
 
Example #26
Source File: CachedPackageTracker.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
            }
        }
    }
}
 
Example #27
Source File: MainActivity.java    From island with Apache License 2.0 5 votes vote down vote up
@Override protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	if (Users.isProfile()) {	// Should generally not run in profile, unless the managed profile provision is interrupted or manually provision is not complete.
		onCreateInProfile();
		finish();
		return;
	}
	if (mIsDeviceOwner = new DevicePolicies(this).isActiveDeviceOwner()) {
		startMainUi(savedInstanceState);	// As device owner, always show main UI.
		return;
	}
	final UserHandle profile = Users.profile;
	if (profile == null) {					// Nothing setup yet
		startSetupWizard();
		return;
	}

	final Optional<Boolean> is_profile_owner = DevicePolicies.isProfileOwner(this, profile);
	if (is_profile_owner == null) { 	// Profile owner cannot be detected, the best bet is to continue to the main UI.
		startMainUi(savedInstanceState);
	} else if (! is_profile_owner.isPresent()) {	// Profile without owner, probably caused by provisioning interrupted before device-admin is activated.
		if (IslandManager.launchApp(this, getPackageName(), profile)) finish();	// Try starting Island in profile to finish the provisioning.
		else startSetupWizard();		// Cannot resume the provisioning, probably this profile is not created by us, go ahead with normal setup.
	} else if (! is_profile_owner.get()) {			// Profile is not owned by us, show setup wizard.
		startSetupWizard();
	} else {
		final LauncherApps launcher_apps = (LauncherApps) getSystemService(Context.LAUNCHER_APPS_SERVICE);
		final List<LauncherActivityInfo> our_activities_in_launcher;
		if (launcher_apps != null && ! (our_activities_in_launcher = launcher_apps.getActivityList(getPackageName(), profile)).isEmpty()) {
			// Main activity is left enabled, probably due to pending post-provisioning in manual setup. Some domestic ROMs may block implicit broadcast, causing ACTION_USER_INITIALIZE being dropped.
			Analytics.$().event("profile_provision_leftover").send();
			Log.w(TAG, "Setup in Island is not complete, continue it now.");
			launcher_apps.startMainActivity(our_activities_in_launcher.get(0).getComponentName(), profile, null, null);
			finish();
			return;
		}
		startMainUi(savedInstanceState);
	}
}
 
Example #28
Source File: LauncherAppsCompatVL.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public List<LauncherActivityInfoCompat> getActivityList(String packageName,
        UserHandleCompat user) {
    List<LauncherActivityInfo> list = mLauncherApps.getActivityList(packageName,
            user.getUser());
    if (list.size() == 0) {
        return Collections.emptyList();
    }
    ArrayList<LauncherActivityInfoCompat> compatList =
            new ArrayList<LauncherActivityInfoCompat>(list.size());
    for (LauncherActivityInfo info : list) {
        compatList.add(new LauncherActivityInfoCompatVL(info));
    }
    return compatList;
}
 
Example #29
Source File: LauncherModel.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
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);
                }
            }
        });
    }
}
 
Example #30
Source File: AllAppsList.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}