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

Commit

Permalink
Fixed pre Lollipop service name
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Apr 17, 2015
1 parent c16c9b2 commit 8b68f33
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/biz/bokhorst/xprivacy/PrivacyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ private PrivacyService() {

private static PrivacyService mPrivacyService = null;

private static String getServiceName() {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? "user." : "") + cServiceName;
}

public static void register(List<String> listError, ClassLoader classLoader, String secret, Object am) {
// Store secret and errors
mAm = am;
Expand All @@ -150,14 +154,14 @@ public static void register(List<String> listError, ClassLoader classLoader, Str
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Method mAddService = cServiceManager.getDeclaredMethod("addService", String.class, IBinder.class,
boolean.class);
mAddService.invoke(null, "user." + cServiceName, mPrivacyService, true);
mAddService.invoke(null, getServiceName(), mPrivacyService, true);
} else {
Method mAddService = cServiceManager.getDeclaredMethod("addService", String.class, IBinder.class);
mAddService.invoke(null, cServiceName, mPrivacyService);
mAddService.invoke(null, getServiceName(), mPrivacyService);
}

// This will and should open the database
Util.log(null, Log.WARN, "Service registered name=" + cServiceName + " version=" + cCurrentVersion);
Util.log(null, Log.WARN, "Service registered name=" + getServiceName() + " version=" + cCurrentVersion);

// Publish semaphore to activity manager service
XActivityManagerService.setSemaphore(mOndemandSemaphore);
Expand Down Expand Up @@ -213,11 +217,7 @@ public static IPrivacyService getClient() {
// public static IBinder getService(String name)
Class<?> cServiceManager = Class.forName("android.os.ServiceManager");
Method mGetService = cServiceManager.getDeclaredMethod("getService", String.class);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
mClient = IPrivacyService.Stub.asInterface((IBinder) mGetService.invoke(null, cServiceName));
else
mClient = IPrivacyService.Stub.asInterface((IBinder) mGetService.invoke(null, "user."
+ cServiceName));
mClient = IPrivacyService.Stub.asInterface((IBinder) mGetService.invoke(null, getServiceName()));
} catch (Throwable ex) {
Util.bug(null, ex);
}
Expand Down

0 comments on commit 8b68f33

Please sign in to comment.