Skip to content

Commit

Permalink
linkToDeath BlackShadowService
Browse files Browse the repository at this point in the history
  • Loading branch information
nnjun committed Jun 16, 2024
1 parent 37415a1 commit 9dd1b4f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import top.niunaijun.shadow.R;
import top.niunaijun.shadow.common.InstallResult;
import top.niunaijun.shadow.common.InstalledPlugin;
import top.niunaijun.shadow.common.RunningPlugin;
Expand Down Expand Up @@ -99,7 +98,7 @@ public void init(Application application) {
}

private IBSManagerService getBlackShadowService() {
if (mBSManagerService != null && mBSManagerService.asBinder().isBinderAlive()) {
if (mBSManagerService != null && mBSManagerService.asBinder().isBinderAlive() && mBSManagerService.asBinder().pingBinder()) {
return mBSManagerService;
}
Bundle call = ProviderCallCompat.callSafely(getContext().getPackageName() + ".BlackShadowContentProvider", "", null, null);
Expand All @@ -108,6 +107,12 @@ private IBSManagerService getBlackShadowService() {
}
IBinder service = call.getBinder("service");
mBSManagerService = IBSManagerService.Stub.asInterface(service);
if (mBSManagerService != null) {
try {
mBSManagerService.asBinder().linkToDeath(() -> mBSManagerService = null, 0);
} catch (RemoteException ignored) {
}
}
return getBlackShadowService();
}

Expand Down

0 comments on commit 9dd1b4f

Please sign in to comment.