/system/app/LALA にある APK から Service をロードしようとしています。問題は、APP AndroidManifest でサービスにandroid:exported = false
. ロードする方法はありますか?
コード
String packagePath = "other.app.package";
String apkName = null;
try {
apkName = getPackageManager().getApplicationInfo(packagePath, 0).sourceDir;
} catch (Exception e) {
e.printStackTrace();
}
PathClassLoader cLoader = new PathClassLoader(apkName, ClassLoader.getSystemClassLoader());
Context otherAppContext = createPackageContext(appPackage, CONTEXT_IGNORE_SECURITY | CONTEXT_INCLUDE_CODE);
String servicePath = packagePath + ".path.to.Service";
Class<?> Service = null;
try {
Service = Class.forName(servicePath, true, cLoader);
} catch (Exception e) {
e.printStackTrace();
}
otherAppContext.startService(new Intent(otherAppContext, Service));
エラー
原因: java.lang.SecurityException: Not allowed to start service Intent { cmp=other.app.package/.path.to.Service } without permission not export from uid X
[]の