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

Commit

Permalink
Prevent referencing the database multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Feb 9, 2014
1 parent ebfc22e commit 857a707
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/biz/bokhorst/xprivacy/PrivacyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

public class PrivacyService {
private static int mXUid = -1;
private static boolean mRegistered = false;
private static boolean mUseCache = false;
private static String mSecret = null;
private static Thread mWorker = null;
Expand Down Expand Up @@ -154,6 +155,8 @@ public void run() {
Util.log(null, Log.WARN, "Invoking " + mAddService);
mAddService.invoke(null, cServiceName, mPrivacyService);
}

mRegistered = true;
Util.log(null, Log.WARN, "Service registered name=" + cServiceName);
} catch (Throwable ex) {
Util.bug(null, ex);
Expand Down Expand Up @@ -206,9 +209,12 @@ public static void reportErrorInternal(String message) {
}
}

public static boolean getSettingBool(int uid, String name, boolean defaultValue) throws RemoteException {
String value = mPrivacyService.getSetting(new PSetting(uid, name, Boolean.toString(defaultValue))).value;
return Boolean.parseBoolean(value);
public static boolean isLoggingEnabled() throws RemoteException {
if (mRegistered)
return Boolean.parseBoolean(mPrivacyService.getSetting(new PSetting(0, PrivacyManager.cSettingLog, Boolean
.toString(false))).value);
else
return PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false, true);
}

private static final IPrivacyService.Stub mPrivacyService = new IPrivacyService.Stub() {
Expand Down
5 changes: 1 addition & 4 deletions src/biz/bokhorst/xprivacy/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ public static void log(XHook hook, int priority, String msg) {
if (!mLogDetermined && uid > 0) {
mLogDetermined = true;
try {
if (uid == Process.SYSTEM_UID)
mLog = PrivacyService.getSettingBool(0, PrivacyManager.cSettingLog, false);
else
mLog = PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false, true);
mLog = PrivacyService.isLoggingEnabled();
} catch (Throwable ignored) {
mLog = false;
}
Expand Down

0 comments on commit 857a707

Please sign in to comment.