use of com.morgoo.droidplugin.pm.parser.PluginPackageParser 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 com.morgoo.droidplugin.pm.parser.PluginPackageParser in project DroidPlugin by DroidPluginTeam.
the class IPluginManagerImpl method clearApplicationUserData.
@Override
public void clearApplicationUserData(String packageName, IPackageDataObserver observer) throws RemoteException {
boolean success = false;
try {
if (TextUtils.isEmpty(packageName)) {
return;
}
PluginPackageParser parser = mPluginCache.get(packageName);
if (parser == null) {
return;
}
ApplicationInfo applicationInfo = parser.getApplicationInfo(0);
Utils.deleteDir(applicationInfo.dataDir);
success = true;
} catch (Exception e) {
handleException(e);
} finally {
if (observer != null) {
observer.onRemoveCompleted(packageName, success);
}
}
}
use of com.morgoo.droidplugin.pm.parser.PluginPackageParser in project DroidPlugin by DroidPluginTeam.
the class IPluginManagerImpl method getReceiverInfo.
@Override
public ActivityInfo getReceiverInfo(ComponentName className, int flags) throws RemoteException {
waitForReadyInner();
try {
String pkg = getAndCheckCallingPkg(className.getPackageName());
if (pkg != null) {
enforcePluginFileExists();
PluginPackageParser parser = mPluginCache.get(className.getPackageName());
if (parser != null) {
return parser.getReceiverInfo(className, flags);
}
}
} catch (Exception e) {
handleException(e);
}
return null;
}
use of com.morgoo.droidplugin.pm.parser.PluginPackageParser in project DroidPlugin by DroidPluginTeam.
the class IPluginManagerImpl method getAllPermissionGroups.
@Override
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) throws RemoteException {
waitForReadyInner();
try {
enforcePluginFileExists();
List<PermissionGroupInfo> list = new ArrayList<PermissionGroupInfo>();
if (shouldNotBlockOtherInfo()) {
for (PluginPackageParser pluginPackageParser : mPluginCache.values()) {
List<PermissionGroupInfo> permissionGroupInfos = pluginPackageParser.getPermissionGroups();
for (PermissionGroupInfo permissionGroupInfo : permissionGroupInfos) {
if (!list.contains(permissionGroupInfo)) {
list.add(permissionGroupInfo);
}
}
}
} else {
List<String> pkgs = mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
for (PluginPackageParser pluginPackageParser : mPluginCache.values()) {
List<PermissionGroupInfo> permissionGroupInfos = pluginPackageParser.getPermissionGroups();
for (PermissionGroupInfo permissionGroupInfo : permissionGroupInfos) {
if (!list.contains(permissionGroupInfo) && pkgs.contains(permissionGroupInfo.packageName)) {
list.add(permissionGroupInfo);
}
}
}
}
return list;
} catch (Exception e) {
handleException(e);
}
return null;
}
use of com.morgoo.droidplugin.pm.parser.PluginPackageParser in project DroidPlugin by DroidPluginTeam.
the class IPluginManagerImpl method getActivityInfo.
@Override
public ActivityInfo getActivityInfo(ComponentName className, int flags) throws RemoteException {
waitForReadyInner();
try {
String pkg = getAndCheckCallingPkg(className.getPackageName());
if (pkg != null) {
enforcePluginFileExists();
PluginPackageParser parser = mPluginCache.get(className.getPackageName());
if (parser != null) {
return parser.getActivityInfo(className, flags);
}
}
} catch (Exception e) {
handleException(e);
}
return null;
}
Aggregations