AppDiff.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:mobile-store 作者:
private void init() {
    String pkgName = pkgInfo.packageName;
    // Check if there is already a package on the device with this name
    // but it has been renamed to something else.
    final String[] oldName = pm.canonicalToCurrentPackageNames(new String[]{pkgName});
    if (oldName != null && oldName.length > 0 && oldName[0] != null) {
        pkgName = oldName[0];
        pkgInfo.packageName = pkgName;
        pkgInfo.applicationInfo.packageName = pkgName;
    }
    // Check if package is already installed
    try {
        // This is a little convoluted because we want to get all uninstalled
        // apps, but this may include apps with just data, and if it is just
        // data we still want to count it as "installed".
        //noinspection WrongConstant (lint is actually wrong here!)
        installedAppInfo = pm.getApplicationInfo(pkgName,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        if ((installedAppInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
            installedAppInfo = null;
        }
    } catch (PackageManager.NameNotFoundException e) {
        installedAppInfo = null;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号