【发布时间】:2013-06-13 19:15:22
【问题描述】:
我想从位于 /system/app/LALA 的 APK 加载服务。问题是,我收到以下错误,因为在 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 } 未经许可未从uid X导出 p>
[]的
【问题讨论】:
标签: android security reflection apk