Java Code Examples for android.content.pm.PackageManager.GET_META_DATA

The following are Jave code examples for showing how to use GET_META_DATA of the android.content.pm.PackageManager class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: VirtualHook   File: PackageParserEx.java   View Source Code Vote up 6 votes
public static ProviderInfo generateProviderInfo(VPackage.ProviderComponent p, int flags,
                                                PackageUserState state, int userId) {
    if (p == null) return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    // Make shallow copies so we can store the metadata safely
    ProviderInfo pi = new ProviderInfo(p.info);
    if ((flags & PackageManager.GET_META_DATA) != 0
            && (p.metaData != null)) {
        pi.metaData = p.metaData;
    }

    if ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) == 0) {
        pi.uriPermissionPatterns = null;
    }
    pi.applicationInfo = generateApplicationInfo(p.owner, flags, state, userId);
    return pi;
}
 
Example 2
Project: TPlayer   File: PackageParserEx.java   View Source Code Vote up 6 votes
public static ProviderInfo generateProviderInfo(VPackage.ProviderComponent p, int flags,
                                                PackageUserState state, int userId) {
    if (p == null) return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    // Make shallow copies so we can store the metadata safely
    ProviderInfo pi = new ProviderInfo(p.info);
    if ((flags & PackageManager.GET_META_DATA) != 0
            && (p.metaData != null)) {
        pi.metaData = p.metaData;
    }

    if ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) == 0) {
        pi.uriPermissionPatterns = null;
    }
    pi.applicationInfo = generateApplicationInfo(p.owner, flags, state, userId);
    return pi;
}
 
Example 3
Project: VirtualHook   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static ApplicationInfo generateApplicationInfo(VPackage p, int flags,
                                                      PackageUserState state, int userId) {
    if (p == null) return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }

    // Make shallow copy so we can store the metadata/libraries safely
    ApplicationInfo ai = new ApplicationInfo(p.applicationInfo);
    if ((flags & PackageManager.GET_META_DATA) != 0) {
        ai.metaData = p.mAppMetaData;
    }
    initApplicationAsUser(ai, userId);
    return ai;
}
 
Example 4
Project: VirtualHook   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static ActivityInfo generateActivityInfo(VPackage.ActivityComponent a, int flags,
                                                PackageUserState state, int userId) {
    if (a == null) return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    // Make shallow copies so we can store the metadata safely
    ActivityInfo ai = new ActivityInfo(a.info);
    if ((flags & PackageManager.GET_META_DATA) != 0
            && (a.metaData != null)) {
        ai.metaData = a.metaData;
    }
    ai.applicationInfo = generateApplicationInfo(a.owner, flags, state, userId);
    return ai;
}
 
Example 5
Project: VirtualHook   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static ServiceInfo generateServiceInfo(VPackage.ServiceComponent s, int flags,
                                              PackageUserState state, int userId) {
    if (s == null) return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    ServiceInfo si = new ServiceInfo(s.info);
    // Make shallow copies so we can store the metadata safely
    if ((flags & PackageManager.GET_META_DATA) != 0 && s.metaData != null) {
        si.metaData = s.metaData;
    }
    si.applicationInfo = generateApplicationInfo(s.owner, flags, state, userId);
    return si;
}
 
Example 6
Project: VirtualHook   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static InstrumentationInfo generateInstrumentationInfo(
        VPackage.InstrumentationComponent i, int flags) {
    if (i == null) return null;
    if ((flags & PackageManager.GET_META_DATA) == 0) {
        return i.info;
    }
    InstrumentationInfo ii = new InstrumentationInfo(i.info);
    ii.metaData = i.metaData;
    return ii;
}
 
Example 7
Project: VirtualHook   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static PermissionInfo generatePermissionInfo(
        VPackage.PermissionComponent p, int flags) {
    if (p == null) return null;
    if ((flags & PackageManager.GET_META_DATA) == 0) {
        return p.info;
    }
    PermissionInfo pi = new PermissionInfo(p.info);
    pi.metaData = p.metaData;
    return pi;
}
 
Example 8
Project: VirtualHook   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static PermissionGroupInfo generatePermissionGroupInfo(
        VPackage.PermissionGroupComponent pg, int flags) {
    if (pg == null) return null;
    if ((flags & PackageManager.GET_META_DATA) == 0) {
        return pg.info;
    }
    PermissionGroupInfo pgi = new PermissionGroupInfo(pg.info);
    pgi.metaData = pg.metaData;
    return pgi;
}
 
Example 9
Project: TPlayer   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static ApplicationInfo generateApplicationInfo(VPackage p, int flags,
                                                      PackageUserState state, int userId) {
    if (p == null) return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }

    // Make shallow copy so we can store the metadata/libraries safely
    ApplicationInfo ai = new ApplicationInfo(p.applicationInfo);
    if ((flags & PackageManager.GET_META_DATA) != 0) {
        ai.metaData = p.mAppMetaData;
    }
    initApplicationAsUser(ai, userId);
    return ai;
}
 
Example 10
Project: TPlayer   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static ActivityInfo generateActivityInfo(VPackage.ActivityComponent a, int flags,
                                                PackageUserState state, int userId) {
    if (a == null) return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    // Make shallow copies so we can store the metadata safely
    ActivityInfo ai = new ActivityInfo(a.info);
    if ((flags & PackageManager.GET_META_DATA) != 0
            && (a.metaData != null)) {
        ai.metaData = a.metaData;
    }
    ai.applicationInfo = generateApplicationInfo(a.owner, flags, state, userId);
    return ai;
}
 
Example 11
Project: TPlayer   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static ServiceInfo generateServiceInfo(VPackage.ServiceComponent s, int flags,
                                              PackageUserState state, int userId) {
    if (s == null) return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    ServiceInfo si = new ServiceInfo(s.info);
    // Make shallow copies so we can store the metadata safely
    if ((flags & PackageManager.GET_META_DATA) != 0 && s.metaData != null) {
        si.metaData = s.metaData;
    }
    si.applicationInfo = generateApplicationInfo(s.owner, flags, state, userId);
    return si;
}
 
Example 12
Project: TPlayer   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static InstrumentationInfo generateInstrumentationInfo(
        VPackage.InstrumentationComponent i, int flags) {
    if (i == null) return null;
    if ((flags & PackageManager.GET_META_DATA) == 0) {
        return i.info;
    }
    InstrumentationInfo ii = new InstrumentationInfo(i.info);
    ii.metaData = i.metaData;
    return ii;
}
 
Example 13
Project: TPlayer   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static PermissionInfo generatePermissionInfo(
        VPackage.PermissionComponent p, int flags) {
    if (p == null) return null;
    if ((flags & PackageManager.GET_META_DATA) == 0) {
        return p.info;
    }
    PermissionInfo pi = new PermissionInfo(p.info);
    pi.metaData = p.metaData;
    return pi;
}
 
Example 14
Project: TPlayer   File: PackageParserEx.java   View Source Code Vote up 5 votes
public static PermissionGroupInfo generatePermissionGroupInfo(
        VPackage.PermissionGroupComponent pg, int flags) {
    if (pg == null) return null;
    if ((flags & PackageManager.GET_META_DATA) == 0) {
        return pg.info;
    }
    PermissionGroupInfo pgi = new PermissionGroupInfo(pg.info);
    pgi.metaData = pg.metaData;
    return pgi;
}
 
Example 15
Project: springreplugin   File: PluginManagerServer.java   View Source Code Vote up 4 votes
private PluginInfo installLocked(String path) {
    final boolean verifySignEnable = RePlugin.getConfig().getVerifySign();
    final int flags = verifySignEnable ? PackageManager.GET_META_DATA | PackageManager.GET_SIGNATURES : PackageManager.GET_META_DATA;

    // 1. 读取APK内容
    PackageInfo pi = mContext.getPackageManager().getPackageArchiveInfo(path, flags);
    if (pi == null) {
        if (LogDebug.LOG) {
            LogDebug.e(TAG, "installLocked: Not a valid apk. path=" + path);
        }

        RePlugin.getConfig().getEventCallbacks().onInstallPluginFailed(path, RePluginEventCallbacks.InstallResult.READ_PKG_INFO_FAIL);
        return null;
    }

    // 2. 校验插件签名
    if (verifySignEnable) {
        if (!verifySignature(pi, path)) {
            return null;
        }
    }

    // 3. 解析出名字和三元组
    PluginInfo instPli = PluginInfo.parseFromPackageInfo(pi, path);
    if (LogDebug.LOG) {
        LogDebug.i(TAG, "installLocked: Info=" + instPli);
    }
    instPli.setType(PluginInfo.TYPE_NOT_INSTALL);

    // 若要安装的插件版本小于或等于当前版本,则安装失败
    // NOTE 绝大多数情况下,应该在调用RePlugin.install方法前,根据云端回传的信息来判断,以防止下载旧插件,浪费流量
    // NOTE 这里仅做双保险,或通过特殊渠道安装时会有用

    // 注意:这里必须用“非Clone过的”PluginInfo,因为要修改里面的内容
    PluginInfo curPli = RePluginOS.getPlugin(instPli.getName(), false);
    if (curPli != null) {
        if (LogDebug.LOG) {
            LogDebug.i(TAG, "installLocked: Has installed plugin. current=" + curPli);
        }

        // 版本较老?直接返回
        final int checkResult = checkVersion(instPli, curPli);
        if (checkResult < 0) {
            RePlugin.getConfig().getEventCallbacks().onInstallPluginFailed(path, RePluginEventCallbacks.InstallResult.VERIFY_VER_FAIL);
            return null;
        } else if (checkResult == 0){
            instPli.setIsPendingCover(true);
        }
    }

    // 4. 将合法的APK改名后,移动(或复制,见RePluginConfig.isMoveFileWhenInstalling)到新位置
    // 注意:不能和p-n的最终释放位置相同,因为管理方式不一样
    if (!copyOrMoveApk(path, instPli)) {
        RePlugin.getConfig().getEventCallbacks().onInstallPluginFailed(path, RePluginEventCallbacks.InstallResult.COPY_APK_FAIL);
        return null;
    }

    // 5. 从插件中释放 So 文件
    PluginNativeLibsHelper.install(instPli.getPath(), instPli.getNativeLibsDir());

    // 6. 若已经安装旧版本插件,则尝试更新插件信息,否则直接加入到列表中
    if (curPli != null) {
        updateOrLater(curPli, instPli);
    } else {
        mList.add(instPli);
    }

    // 7. 保存插件信息到文件中,下次可直接使用
    mList.save(mContext);

    return instPli;
}