當前位置: 首頁>>代碼示例>>Java>>正文


Java PackageInstallerCompat類代碼示例

本文整理匯總了Java中com.android.launcher3.compat.PackageInstallerCompat的典型用法代碼示例。如果您正苦於以下問題:Java PackageInstallerCompat類的具體用法?Java PackageInstallerCompat怎麽用?Java PackageInstallerCompat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PackageInstallerCompat類屬於com.android.launcher3.compat包,在下文中一共展示了PackageInstallerCompat類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTerminate

import com.android.launcher3.compat.PackageInstallerCompat; //導入依賴的package包/類
/**
 * Call from Application.onTerminate(), which is not guaranteed to ever be called.
 */
public void onTerminate() {
    sContext.unregisterReceiver(mModel);
    final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(sContext);
    launcherApps.removeOnAppsChangedCallback(mModel);
    PackageInstallerCompat.getInstance(sContext).onStop();
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:10,代碼來源:LauncherAppState.java

示例2: getValidPackages

import com.android.launcher3.compat.PackageInstallerCompat; //導入依賴的package包/類
protected static HashSet<String> getValidPackages(Context context) {
    // Initialize list of valid packages. This contain all the packages which are already on
    // the device and packages which are being installed. Any item which doesn't belong to
    // this set is removed.
    // Since the loader removes such items anyway, removing these items here doesn't cause
    // any extra data loss and gives us more free space on the grid for better migration.
    HashSet validPackages = new HashSet<>();
    for (PackageInfo info : context.getPackageManager()
            .getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES)) {
        validPackages.add(info.packageName);
    }
    validPackages.addAll(PackageInstallerCompat.getInstance(context)
            .updateAndGetActiveSessionCache().keySet());
    return validPackages;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:16,代碼來源:GridSizeMigrationTask.java

示例3: getInvalidWidgetInfo

import com.android.launcher3.compat.PackageInstallerCompat; //導入依賴的package包/類
/**
 * Returns a LauncherAppWidgetInfo with package name which is not present on the device
 */
private LauncherAppWidgetInfo getInvalidWidgetInfo() {
    String invalidPackage = "com.invalidpackage";
    int count = 0;
    String pkg = invalidPackage;

    Set<String> activePackage = getOnUiThread(new Callable<Set<String>>() {
        @Override
        public Set<String> call() throws Exception {
            return PackageInstallerCompat.getInstance(mTargetContext)
                    .updateAndGetActiveSessionCache().keySet();
        }
    });
    while(true) {
        try {
            mTargetContext.getPackageManager().getPackageInfo(
                    pkg, PackageManager.GET_UNINSTALLED_PACKAGES);
        } catch (Exception e) {
            if (!activePackage.contains(pkg)) {
                break;
            }
        }
        pkg = invalidPackage + count;
        count ++;
    }
    LauncherAppWidgetInfo item = new LauncherAppWidgetInfo(10,
            new ComponentName(pkg, "com.test.widgetprovider"));
    item.spanX = 2;
    item.spanY = 2;
    item.minSpanX = 2;
    item.minSpanY = 2;
    item.cellX = 0;
    item.cellY = 1;
    item.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
    return item;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:39,代碼來源:BindWidgetTest.java

示例4: setPackageState

import com.android.launcher3.compat.PackageInstallerCompat; //導入依賴的package包/類
public void setPackageState(final PackageInstallInfo installInfo) {
    Runnable updateRunnable = new Runnable() {

        @Override
        public void run() {
            synchronized (sBgLock) {
                final HashSet<ItemInfo> updates = new HashSet<>();

                if (installInfo.state == PackageInstallerCompat.STATUS_INSTALLED) {
                    // Ignore install success events as they are handled by Package add events.
                    return;
                }

                for (ItemInfo info : sBgItemsIdMap) {
                    if (info instanceof ShortcutInfo) {
                        ShortcutInfo si = (ShortcutInfo) info;
                        ComponentName cn = si.getTargetComponent();
                        if (si.isPromise() && (cn != null)
                                && installInfo.packageName.equals(cn.getPackageName())) {
                            si.setInstallProgress(installInfo.progress);

                            if (installInfo.state == PackageInstallerCompat.STATUS_FAILED) {
                                // Mark this info as broken.
                                si.status &= ~ShortcutInfo.FLAG_INSTALL_SESSION_ACTIVE;
                            }
                            updates.add(si);
                        }
                    }
                }

                for (LauncherAppWidgetInfo widget : sBgAppWidgets) {
                    if (widget.providerName.getPackageName().equals(installInfo.packageName)) {
                        widget.installProgress = installInfo.progress;
                        updates.add(widget);
                    }
                }

                if (!updates.isEmpty()) {
                    // Push changes to the callback.
                    Runnable r = new Runnable() {
                        public void run() {
                            Callbacks callbacks = getCallback();
                            if (callbacks != null) {
                                callbacks.bindRestoreItemsChange(updates);
                            }
                        }
                    };
                    mHandler.post(r);
                }
            }
        }
    };
    runOnWorkerThread(updateRunnable);
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:55,代碼來源:LauncherModel.java


注:本文中的com.android.launcher3.compat.PackageInstallerCompat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。