use of android.content.pm.PackageInfo in project DroidPlugin by DroidPluginTeam.
the class IPluginManagerImpl method loadAllPlugin.
private void loadAllPlugin(Context context) {
long b = System.currentTimeMillis();
ArrayList<File> apkfiles = null;
try {
apkfiles = new ArrayList<File>();
File baseDir = new File(PluginDirHelper.getBaseDir(context));
File[] dirs = baseDir.listFiles();
for (File dir : dirs) {
if (dir.isDirectory()) {
File file = new File(dir, "apk/base-1.apk");
if (file.exists()) {
apkfiles.add(file);
}
}
}
} catch (Exception e) {
Log.e(TAG, "scan a apk file error", e);
}
Log.i(TAG, "Search apk cost %s ms", (System.currentTimeMillis() - b));
b = System.currentTimeMillis();
if (apkfiles != null && apkfiles.size() > 0) {
for (File pluginFile : apkfiles) {
long b1 = System.currentTimeMillis();
try {
PluginPackageParser pluginPackageParser = new PluginPackageParser(mContext, pluginFile);
Signature[] signatures = readSignatures(pluginPackageParser.getPackageName());
if (signatures == null || signatures.length <= 0) {
pluginPackageParser.collectCertificates(0);
PackageInfo info = pluginPackageParser.getPackageInfo(PackageManager.GET_SIGNATURES);
saveSignatures(info);
} else {
mSignatureCache.put(pluginPackageParser.getPackageName(), signatures);
pluginPackageParser.writeSignature(signatures);
}
if (!mPluginCache.containsKey(pluginPackageParser.getPackageName())) {
mPluginCache.put(pluginPackageParser.getPackageName(), pluginPackageParser);
}
} catch (Throwable e) {
Log.e(TAG, "parse a apk file error %s", e, pluginFile.getPath());
} finally {
Log.i(TAG, "Parse %s apk cost %s ms", pluginFile.getPath(), (System.currentTimeMillis() - b1));
}
}
}
Log.i(TAG, "Parse all apk cost %s ms", (System.currentTimeMillis() - b));
b = System.currentTimeMillis();
try {
mActivityManagerService.onCreate(IPluginManagerImpl.this);
} catch (Throwable e) {
Log.e(TAG, "mActivityManagerService.onCreate", e);
}
Log.i(TAG, "ActivityManagerService.onCreate %s ms", (System.currentTimeMillis() - b));
}
use of android.content.pm.PackageInfo in project DroidPlugin by DroidPluginTeam.
the class IPluginManagerImpl method getInstalledPackages.
@Override
public List<PackageInfo> getInstalledPackages(int flags) throws RemoteException {
waitForReadyInner();
try {
enforcePluginFileExists();
List<PackageInfo> infos = new ArrayList<PackageInfo>(mPluginCache.size());
if (shouldNotBlockOtherInfo()) {
for (PluginPackageParser pluginPackageParser : mPluginCache.values()) {
infos.add(pluginPackageParser.getPackageInfo(flags));
}
} else {
List<String> pkgs = mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
for (PluginPackageParser pluginPackageParser : mPluginCache.values()) {
if (pkgs.contains(pluginPackageParser.getPackageName())) {
infos.add(pluginPackageParser.getPackageInfo(flags));
}
}
}
return infos;
} catch (Exception e) {
handleException(e);
}
return null;
}
use of android.content.pm.PackageInfo in project DroidPlugin by DroidPluginTeam.
the class IPluginManagerImpl method loadHostRequestedPermission.
private void loadHostRequestedPermission() {
try {
mHostRequestedPermission.clear();
PackageManager pm = mContext.getPackageManager();
PackageInfo pms = pm.getPackageInfo(mContext.getPackageName(), PackageManager.GET_PERMISSIONS);
if (pms != null && pms.requestedPermissions != null && pms.requestedPermissions.length > 0) {
for (String requestedPermission : pms.requestedPermissions) {
mHostRequestedPermission.add(requestedPermission);
}
}
} catch (Exception e) {
}
}
use of android.content.pm.PackageInfo in project AndroidChromium by JackyAndroid.
the class WebApkUpdateManager method updateIfNeeded.
/**
* Checks whether the WebAPK's Web Manifest has changed. Requests an updated WebAPK if the
* Web Manifest has changed. Skips the check if the check was done recently.
* @param tab The tab of the WebAPK.
* @param info The WebappInfo of the WebAPK.
*/
public void updateIfNeeded(Tab tab, WebappInfo info) {
PackageInfo packageInfo = readPackageInfoFromAndroidManifest(info.webApkPackageName());
if (packageInfo == null) {
return;
}
mVersionCode = packageInfo.versionCode;
final Bundle metadata = packageInfo.applicationInfo.metaData;
mShellApkVersion = IntentUtils.safeGetInt(metadata, WebApkMetaDataKeys.SHELL_APK_VERSION, 0);
mUpgradeDetector = new ManifestUpgradeDetector(tab, info, metadata, this);
WebappRegistry.FetchWebappDataStorageCallback callback = new WebappRegistry.FetchWebappDataStorageCallback() {
@Override
public void onWebappDataStorageRetrieved(WebappDataStorage storage) {
if (forceUpgrade(storage)) {
mForceUpgrade = true;
}
// TODO(pkotwicz|hanxi): Request upgrade if ShellAPK version changes if
// ManifestUpgradeDetector cannot fetch the Web Manifest. For instance, the
// web developer may have removed the Web Manifest from their site.
// (http://crbug.com/639536)
long sinceLastCheckDuration = System.currentTimeMillis() - storage.getLastCheckForWebManifestUpdateTime();
if (sinceLastCheckDuration > FULL_CHECK_UPDATE_INTERVAL || mForceUpgrade) {
if (mUpgradeDetector.start()) {
// crbug.com/636525. The timestamp of the last check for updated
// Web Manifest should be updated after the detector finds the
// Web Manifest, not when the detector is started.
storage.updateTimeOfLastCheckForUpdatedWebManifest();
}
}
}
};
WebappRegistry.getWebappDataStorage(info.id(), callback);
}
use of android.content.pm.PackageInfo in project AndroidDevelop by 7449.
the class RootUtils method isApk.
/**
* hide之后的app是false
*/
static boolean isApk(String packageName) {
final PackageManager packageManager = App.getApp().getPackageManager();
List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
if (pinfo != null) {
for (PackageInfo packageInfo : pinfo) {
if (packageInfo.packageName.equals(packageName)) {
return true;
}
}
}
return false;
}
Aggregations