Commit 03c04c21 authored by topjohnwu's avatar topjohnwu

Prevent duplicate policy of same package name

Fix #470
parent 2e091b04
...@@ -20,7 +20,8 @@ public class Policy implements Comparable<Policy>{ ...@@ -20,7 +20,8 @@ public class Policy implements Comparable<Policy>{
public Policy(int uid, PackageManager pm) throws PackageManager.NameNotFoundException { public Policy(int uid, PackageManager pm) throws PackageManager.NameNotFoundException {
String[] pkgs = pm.getPackagesForUid(uid); String[] pkgs = pm.getPackagesForUid(uid);
if (pkgs == null || pkgs.length == 0) throw new PackageManager.NameNotFoundException(); if (pkgs == null || pkgs.length == 0)
throw new PackageManager.NameNotFoundException();
this.uid = uid; this.uid = uid;
packageName = pkgs[0]; packageName = pkgs[0];
info = pm.getApplicationInfo(packageName, 0); info = pm.getApplicationInfo(packageName, 0);
...@@ -35,6 +36,8 @@ public class Policy implements Comparable<Policy>{ ...@@ -35,6 +36,8 @@ public class Policy implements Comparable<Policy>{
logging = c.getInt(c.getColumnIndex("logging")) != 0; logging = c.getInt(c.getColumnIndex("logging")) != 0;
notification = c.getInt(c.getColumnIndex("notification")) != 0; notification = c.getInt(c.getColumnIndex("notification")) != 0;
info = pm.getApplicationInfo(packageName, 0); info = pm.getApplicationInfo(packageName, 0);
if (info.uid != uid)
throw new PackageManager.NameNotFoundException();
appName = info.loadLabel(pm).toString(); appName = info.loadLabel(pm).toString();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment