当前位置: 首页>>代码示例>>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;未经允许,请勿转载。