Skip to content

Commit

Permalink
Add a new solution to get thanox binder
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Jan 3, 2025
1 parent 654b20f commit a446218
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import static github.tornaco.android.thanos.core.app.ThanosManager.PROXIED_ANDROID_SERVICE_NAME;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ParceledListSlice;
import android.os.Bundle;
import android.os.IBinder;
Expand Down Expand Up @@ -32,42 +35,66 @@ protected IThanos create() {
return localService;
}

// Solution 1
IThanos thanos = IThanos.Stub.asInterface(
ServiceManager.getService(T.serviceInstallName()));
if (thanos != null) {
XLog.w("ThanosManagerNative serviceInstallName Use it.");
return thanos;
}

// Solution 2
try {
IAppWidgetService appWidgetService = IAppWidgetService.Stub.asInterface(ServiceManager.getService(Context.APPWIDGET_SERVICE));
ParceledListSlice list = appWidgetService.startListening(null, "thanox", 6, new int[]{2, 0, 2, 3});
XLog.d("IAppWidgetService thanox list: " + list);
XLog.d("ThanosManagerNative IAppWidgetService thanox list: " + list);
Bundle bundle = (Bundle) list.getList().get(0);
IBinder thanox = bundle.getBinder("thanox-binder");
XLog.d("IAppWidgetService thanox binder: " + thanox);
XLog.d("ThanosManagerNative IAppWidgetService thanox binder: " + thanox);
thanos = IThanos.Stub.asInterface(thanox);
if (thanos != null) {
XLog.w("ThanosManagerNative IAppWidgetService Use it.");
return thanos;
}
} catch (Throwable e) {
XLog.e(e, "call IAppWidgetService");
XLog.e(e, "ThanosManagerNativecall IAppWidgetService");
}

// Solution 3
try {
ClipboardManager clipboardManager = (ClipboardManager) AppGlobals.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clipData = clipboardManager.getPrimaryClip();
int clipCount = clipData.getItemCount();
ClipData.Item lastItem = clipData.getItemAt(clipCount - 1);
Intent intent = lastItem.getIntent();
Bundle bundle = intent.getBundleExtra("thanox-bundle");
IBinder thanox = bundle.getBinder("thanox-binder");
XLog.d("ThanosManagerNative ClipboardService thanox binder: " + thanox);
thanos = IThanos.Stub.asInterface(thanox);
if (thanos != null) {
XLog.w("ThanosManagerNative ClipboardService Use it.");
return thanos;
}
} catch (Throwable e) {
XLog.e(e, "ThanosManagerNative call ClipboardService");
}

// Solution 4
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
try {
IBinder backup = ServiceManager.getService(PROXIED_ANDROID_SERVICE_NAME);
if (backup == null) {
XLog.w("Get Thanos from IPC_TRANS_CODE_THANOS_SERVER, service is null.");
XLog.w("ThanosManagerNative Get Thanos from IPC_TRANS_CODE_THANOS_SERVER, service is null.");
return null;
}
data.writeInterfaceToken(IThanos.class.getName());
backup.transact(ThanosManager.IPC_TRANS_CODE_THANOS_SERVER, data, reply, 0);
IBinder binder = reply.readStrongBinder();
XLog.d("Get Thanos from IPC_TRANS_CODE_THANOS_SERVER: %s", binder);
XLog.w("ThanosManagerNative Get Thanos from IPC_TRANS_CODE_THANOS_SERVER: %s", binder);
return IThanos.Stub.asInterface(binder);
} catch (RemoteException e) {
XLog.e("Get Thanos from IPC_TRANS_CODE_THANOS_SERVER err", e);
XLog.e("ThanosManagerNative Get Thanos from IPC_TRANS_CODE_THANOS_SERVER err", e);
} finally {
data.recycle();
reply.recycle();
Expand Down
2 changes: 1 addition & 1 deletion android/internal/Thanox-Internal

0 comments on commit a446218

Please sign in to comment.