Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Fix am lock check
Browse files Browse the repository at this point in the history
Refs #1757
  • Loading branch information
M66B committed Feb 15, 2015
1 parent 01a7e4f commit b805a72
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/biz/bokhorst/xprivacy/PrivacyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

public class PrivacyService extends IPrivacyService.Stub {
private static int mXUid = -1;
private static Object mAm;
private static Context mContext;
private static String mSecret = null;
private static Thread mWorker = null;
Expand Down Expand Up @@ -129,6 +130,7 @@ private PrivacyService() {

public static void register(List<String> listError, ClassLoader classLoader, String secret, Object am) {
// Store secret and errors
mAm = am;
mSecret = secret;
mListError.addAll(listError);

Expand Down Expand Up @@ -2264,8 +2266,13 @@ private void enforcePermission(int uid) {

private boolean isAMLocked(int uid) {
try {
Class<?> cam = Class.forName("com.android.server.am.ActivityManagerService");
Object am = cam.getMethod("self").invoke(null);
Object am;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
am = mAm;
else {
Class<?> cam = Class.forName("com.android.server.am.ActivityManagerService");
am = cam.getMethod("self").invoke(null);
}
boolean locked = Thread.holdsLock(am);
if (locked) {
boolean freeze = getSettingBool(uid, PrivacyManager.cSettingFreeze, false);
Expand Down

0 comments on commit b805a72

Please sign in to comment.