嗨,我在加载所有应用程序时出现应用程序崩溃,崩溃并没有出现在我身上,但是在其他一些家伙设备上,所以我要做的是我检查了所有已安装的应用程序,包括系统,它运行正常,没有问题,但是崩溃发生在“ getPackageInfo “
我的下面的代码
public ArrayList<PInfo> getInstalledApps(boolean getSysPackages) {
ArrayList<PInfo> res = new ArrayList<PInfo>();
List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
for (int i = 0; i < packs.size(); i++) {
PackageInfo p = packs.get(i);
boolean issystemapp = isSystemPackage(p);
if ((!getSysPackages) && issystemapp)
continue;
if (p.packageName.equals(getPackageName()))
continue;
PInfo newInfo = new PInfo();
newInfo.pname = p.packageName;
res.add(newInfo);
}
return res;
}
private boolean isSystemPackage(PackageInfo packageInfo) {
return ((packageInfo.applicationInfo.flags & android.content.pm.ApplicationInfo.FLAG_SYSTEM) != 0);
}
public List<AppInfo> getApplicationsInfo(Context context) {
pinfos = getInstalledApps(true); // get installed user apps (true = system as well)
List<AppInfo> apps = new ArrayList<AppInfo>();
if (pinfos == null || pinfos.size() <= 0) {
Log.v(TAG, "no apps..");
return apps;
}
for (int ii = 0; ii < pinfos.size(); ii++) {
AppInfo info = new AppInfo();
// PackageManager pm = context.getPackageManager(); (calling new pm object so transaction issue dont come so i comment it out and called seprate)
String pkg_name = pinfos.get(ii).pname; //(package name of app)
try {
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(pkg_name, PackageManager.GET_META_DATA);
PackageInfo pInfo = context.getPackageManager().getPackageInfo(pkg_name, PackageManager.GET_PERMISSIONS); // MAYBE ISSUE HERE
ActivityInfo aInfo[] = context.getPackageManager().getPackageInfo(pkg_name, PackageManager.GET_ACTIVITIES).activities; // MAYBE ISSUE HERE
String adspresent = "ads not present";
String internet_status = "Internet not check";
if (aInfo != null && aInfo.length >= 1) {
for (int i = 0; i < aInfo.length; i++) {
String activityname = aInfo[i].name;
if (activityname.equals("com.google.android.gms.ads.AdActivity")) {
adspresent = "ads present";
}
}
}
String[] requestedPermissions = pInfo.requestedPermissions;
if (requestedPermissions != null) {
List<String> stringList = new ArrayList<String>(Arrays.asList(requestedPermissions)); // string array to array list
if (stringList.contains("com.android.INTERNET")) {
internet_status = "Internet check";
}
}
info.packageName = pkg_name;
info.icon = context.getPackageManager().getApplicationIcon(ai);
info.name = context.getPackageManager().getApplicationLabel(ai).toString();
info.status = internet_status;
info.ads = adspresent;
apps.add(info);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
return apps;
}
问题似乎是由于此行
PackageInfo pInfo = context.getPackageManager().getPackageInfo(pkg_name, PackageManager.GET_PERMISSIONS); // MAYBE ISSUE HERE
ActivityInfo aInfo[] = context.getPackageManager().getPackageInfo(pkg_name, PackageManager.GET_ACTIVITIES).activities; // MAYBE ISSUE HERE
问题
08-07 06:54:34.303 E/AndroidRuntime(13823): at android.os.AsyncTask$2.call(AsyncTask.java:295)
08-07 06:54:34.303 E/AndroidRuntime(13823): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-07 06:54:34.303 E/AndroidRuntime(13823): ... 4 more
08-07 06:54:34.303 E/AndroidRuntime(13823): Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
08-07 06:54:34.303 E/AndroidRuntime(13823): at android.os.BinderProxy.transactNative(Native Method)
08-07 06:54:34.303 E/AndroidRuntime(13823): at android.os.BinderProxy.transact(Binder.java:503)
08-07 06:54:34.303 E/AndroidRuntime(13823): at android.content.pm.IPackageManager$Stub$Proxy.getPackageInfo(IPackageManager.java:2252)
08-07 06:54:34.303 E/AndroidRuntime(13823): at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:133)
08-07 06:54:34.303 E/AndroidRuntime(13823): ... 14 more
java.lang.RuntimeException: An error occurred while executing doInBackground()
08-07 06:55:24.498 E/AndroidRuntime(13878): at android.os.AsyncTask$3.done(AsyncTask.java:309)
08-07 06:55:24.498 E/AndroidRuntime(13878): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
08-07 06:55:24.498 E/AndroidRuntime(13878): at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
08-07 06:55:24.498 E/AndroidRuntime(13878): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
08-07 06:55:24.498 E/AndroidRuntime(13878): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
08-07 06:55:24.498 E/AndroidRuntime(13878): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
08-07 06:55:24.498 E/AndroidRuntime(13878): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
08-07 06:55:24.498 E/AndroidRuntime(13878): at java.lang.Thread.run(Thread.java:818)
08-07 06:55:24.498 E/AndroidRuntime(13878): Caused by: java.lang.RuntimeException: Package manager has died
08-07 06:55:24.498 E/AndroidRuntime(13878): at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:138)
08-07 06:55:24.498 E/AndroidRuntime(13878): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
08-07 06:55:24.498 E/AndroidRuntime(13878): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
08-07 06:55:24.498 E/AndroidRuntime(13878): at android.app.ApplicationPackageManager.getPackageInfo(<Xposed>)
我不知道哪里出了问题以及如何解决,如果您有任何线索,请告诉我