Search in sources :

Example 6 with PackageInstallerCompat

use of com.android.launcher3.compat.PackageInstallerCompat in project Neo-Launcher by NeoApplications.

the class ItemClickHandler method startMarketIntentForPackage.

private static void startMarketIntentForPackage(View v, Launcher launcher, String packageName) {
    ItemInfo item = (ItemInfo) v.getTag();
    if (Utilities.ATLEAST_Q) {
        PackageInstallerCompat pkgInstaller = PackageInstallerCompat.getInstance(launcher);
        SessionInfo sessionInfo = pkgInstaller.getActiveSessionInfo(item.user, packageName);
        if (sessionInfo != null) {
            LauncherApps launcherApps = launcher.getSystemService(LauncherApps.class);
            try {
                launcherApps.startPackageInstallerSessionDetailsActivity(sessionInfo, null, launcher.getActivityLaunchOptionsAsBundle(v));
                return;
            } catch (Exception e) {
                Log.e(TAG, "Unable to launch market intent for package=" + packageName, e);
            }
        }
    }
    // Fallback to using custom market intent.
    Intent intent = new PackageManagerHelper(launcher).getMarketIntent(packageName);
    launcher.startActivitySafely(v, intent, item, null);
}
Also used : WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ItemInfo(com.android.launcher3.ItemInfo) PackageInstallerCompat(com.android.launcher3.compat.PackageInstallerCompat) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) LauncherApps(android.content.pm.LauncherApps) Intent(android.content.Intent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper)

Example 7 with PackageInstallerCompat

use of com.android.launcher3.compat.PackageInstallerCompat in project android_packages_apps_Trebuchet by LineageOS.

the class SessionCommitReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    if (!isEnabled(context) || !Utilities.ATLEAST_OREO) {
        // User has decided to not add icons on homescreen.
        return;
    }
    SessionInfo info = intent.getParcelableExtra(PackageInstaller.EXTRA_SESSION);
    UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER);
    if (!PackageInstaller.ACTION_SESSION_COMMITTED.equals(intent.getAction()) || info == null || user == null) {
        // Invalid intent.
        return;
    }
    InstallSessionHelper packageInstallerCompat = InstallSessionHelper.INSTANCE.get(context);
    packageInstallerCompat.restoreDbIfApplicable(info);
    if (TextUtils.isEmpty(info.getAppPackageName()) || info.getInstallReason() != PackageManager.INSTALL_REASON_USER || packageInstallerCompat.promiseIconAddedForId(info.getSessionId())) {
        packageInstallerCompat.removePromiseIconId(info.getSessionId());
        return;
    }
    queueAppIconAddition(context, info.getAppPackageName(), user);
}
Also used : InstallSessionHelper.getUserHandle(com.android.launcher3.pm.InstallSessionHelper.getUserHandle) UserHandle(android.os.UserHandle) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) InstallSessionHelper(com.android.launcher3.pm.InstallSessionHelper)

Example 8 with PackageInstallerCompat

use of com.android.launcher3.compat.PackageInstallerCompat in project android_packages_apps_Launcher3 by ArrowOS.

the class SessionCommitReceiver method processIntent.

@WorkerThread
private static void processIntent(Context context, Intent intent) {
    if (!isEnabled(context)) {
        // User has decided to not add icons on homescreen.
        return;
    }
    SessionInfo info = intent.getParcelableExtra(PackageInstaller.EXTRA_SESSION);
    UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER);
    if (!PackageInstaller.ACTION_SESSION_COMMITTED.equals(intent.getAction()) || info == null || user == null) {
        // Invalid intent.
        return;
    }
    InstallSessionHelper packageInstallerCompat = InstallSessionHelper.INSTANCE.get(context);
    packageInstallerCompat.restoreDbIfApplicable(info);
    if (TextUtils.isEmpty(info.getAppPackageName()) || info.getInstallReason() != PackageManager.INSTALL_REASON_USER || packageInstallerCompat.promiseIconAddedForId(info.getSessionId())) {
        packageInstallerCompat.removePromiseIconId(info.getSessionId());
        return;
    }
    FileLog.d(LOG, "Adding package name to install queue. Package name: " + info.getAppPackageName() + ", has app icon: " + (info.getAppIcon() != null) + ", has app label: " + !TextUtils.isEmpty(info.getAppLabel()));
    ItemInstallQueue.INSTANCE.get(context).queueItem(info.getAppPackageName(), user);
}
Also used : UserHandle(android.os.UserHandle) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) InstallSessionHelper(com.android.launcher3.pm.InstallSessionHelper) WorkerThread(androidx.annotation.WorkerThread)

Example 9 with PackageInstallerCompat

use of com.android.launcher3.compat.PackageInstallerCompat in project android_packages_apps_Launcher3 by ProtonAOSP.

the class SessionCommitReceiver method processIntent.

@WorkerThread
private static void processIntent(Context context, Intent intent) {
    if (!isEnabled(context)) {
        // User has decided to not add icons on homescreen.
        return;
    }
    SessionInfo info = intent.getParcelableExtra(PackageInstaller.EXTRA_SESSION);
    UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER);
    if (!PackageInstaller.ACTION_SESSION_COMMITTED.equals(intent.getAction()) || info == null || user == null) {
        // Invalid intent.
        return;
    }
    InstallSessionHelper packageInstallerCompat = InstallSessionHelper.INSTANCE.get(context);
    packageInstallerCompat.restoreDbIfApplicable(info);
    if (TextUtils.isEmpty(info.getAppPackageName()) || info.getInstallReason() != PackageManager.INSTALL_REASON_USER || packageInstallerCompat.promiseIconAddedForId(info.getSessionId())) {
        packageInstallerCompat.removePromiseIconId(info.getSessionId());
        return;
    }
    FileLog.d(LOG, "Adding package name to install queue. Package name: " + info.getAppPackageName() + ", has app icon: " + (info.getAppIcon() != null) + ", has app label: " + !TextUtils.isEmpty(info.getAppLabel()));
    ItemInstallQueue.INSTANCE.get(context).queueItem(info.getAppPackageName(), user);
}
Also used : UserHandle(android.os.UserHandle) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) InstallSessionHelper(com.android.launcher3.pm.InstallSessionHelper) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

SessionInfo (android.content.pm.PackageInstaller.SessionInfo)9 UserHandle (android.os.UserHandle)7 InstallSessionHelper (com.android.launcher3.pm.InstallSessionHelper)6 WorkerThread (androidx.annotation.WorkerThread)5 PackageInstallerCompat (com.android.launcher3.compat.PackageInstallerCompat)3 ItemInfo (com.android.launcher3.ItemInfo)2 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)2 Intent (android.content.Intent)1 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)1 LauncherApps (android.content.pm.LauncherApps)1 AppInfo (com.android.launcher3.AppInfo)1 FolderInfo (com.android.launcher3.FolderInfo)1 LauncherAppWidgetInfo (com.android.launcher3.LauncherAppWidgetInfo)1 CallbackTask (com.android.launcher3.LauncherModel.CallbackTask)1 LauncherAppsCompat (com.android.launcher3.compat.LauncherAppsCompat)1 PackageInstallerCompat.getUserHandle (com.android.launcher3.compat.PackageInstallerCompat.getUserHandle)1 Callbacks (com.android.launcher3.model.BgDataModel.Callbacks)1 InstallSessionHelper.getUserHandle (com.android.launcher3.pm.InstallSessionHelper.getUserHandle)1 IntArray (com.android.launcher3.util.IntArray)1 PackageManagerHelper (com.android.launcher3.util.PackageManagerHelper)1