Skip to content

Commit

Permalink
catch exceptions from registerProcessObserver and registerUidObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Mar 27, 2019
1 parent 11156c6 commit 366f305
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ task clean(type: Delete) {

def gitCommitId = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def gitCommitCount = Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())
def baseVersionName = '3.2.0'
def baseVersionName = '3.2.1'

ext {
androidXLibraryVersion = '1.0.0'
Expand Down
20 changes: 14 additions & 6 deletions server/src/main/java/moe/shizuku/server/BinderSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,24 @@ private static void onActive(int uid, int pid) throws RemoteException {
}
}

public static void register(ShizukuService shizukuService) throws RemoteException {
public static void register(ShizukuService shizukuService) {
sShizukuService = shizukuService;

Api.registerProcessObserver(new ProcessObserver());
try {
Api.registerProcessObserver(new ProcessObserver());
} catch (Throwable tr) {
LOGGER.e(tr, "registerProcessObserver");
}

if (Build.VERSION.SDK_INT >= 26) {
Api.registerUidObserver(new UidObserver(),
ActivityManager.UID_OBSERVER_ACTIVE,
ActivityManager.PROCESS_STATE_UNKNOWN,
null);
try {
Api.registerUidObserver(new UidObserver(),
ActivityManager.UID_OBSERVER_ACTIVE,
ActivityManager.PROCESS_STATE_UNKNOWN,
null);
} catch (Throwable tr) {
LOGGER.e(tr, "registerUidObserver");
}
}
}
}
6 changes: 1 addition & 5 deletions server/src/main/java/moe/shizuku/server/ShizukuService.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ public class ShizukuService extends IShizukuService.Stub {
mToken = token.toString();
}

try {
BinderSender.register(this);
} catch (RemoteException e) {
LOGGER.e(e, "registerProcessObserver");
}
BinderSender.register(this);
}

static Map<Integer, String> getPidToken() {
Expand Down

0 comments on commit 366f305

Please sign in to comment.