Skip to content

Commit c38de41

Browse files
committed
[service] change service publish solution
1 parent 0cdc808 commit c38de41

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/T.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
package github.tornaco.android.thanos.core
22

3-
import android.content.Context
4-
53
object T {
6-
7-
@JvmStatic
8-
fun serviceInstallName(): String {
9-
return Context.TV_INPUT_SERVICE
10-
}
11-
124
@JvmStatic
135
fun serviceContextName(): String {
146
return "thanos"

android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/app/ThanosManagerNative.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

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

5+
import android.content.Context;
6+
import android.content.pm.ParceledListSlice;
7+
import android.os.Bundle;
58
import android.os.IBinder;
69
import android.os.Parcel;
710
import android.os.RemoteException;
811
import android.os.ServiceManager;
912

13+
import com.android.internal.appwidget.IAppWidgetService;
1014
import com.elvishew.xlog.XLog;
1115

1216
import github.tornaco.android.thanos.core.IThanos;
13-
import github.tornaco.android.thanos.core.T;
1417
import util.Singleton;
1518

1619
public class ThanosManagerNative {
@@ -27,10 +30,20 @@ protected IThanos create() {
2730
if (localService != null) {
2831
return localService;
2932
}
30-
IThanos thanos = IThanos.Stub.asInterface(
31-
ServiceManager.getService(T.serviceInstallName()));
32-
if (thanos != null) {
33-
return thanos;
33+
34+
try {
35+
IAppWidgetService appWidgetService = IAppWidgetService.Stub.asInterface(ServiceManager.getService(Context.APPWIDGET_SERVICE));
36+
ParceledListSlice list = appWidgetService.startListening(null, "thanox", 6, new int[]{2, 0, 2, 3});
37+
XLog.d("IAppWidgetService thanox list: " + list);
38+
Bundle bundle = (Bundle) list.getList().get(0);
39+
IBinder thanox = bundle.getBinder("thanox-binder");
40+
XLog.d("IAppWidgetService thanox binder: " + thanox);
41+
IThanos thanos = IThanos.Stub.asInterface(thanox);
42+
if (thanos != null) {
43+
return thanos;
44+
}
45+
} catch (Throwable e) {
46+
XLog.e(e, "call IAppWidgetService");
3447
}
3548

3649
Parcel data = Parcel.obtain();

android/app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ dependencies {
180180

181181
compileOnly(Libs.Others.xposedApi)
182182

183+
implementation(Libs.Others.hiddenApiByPass)
184+
183185
implementation(Libs.Others.retrofit)
184186
implementation(Libs.Others.retrofitConverterGson)
185187
implementation(Libs.Others.retrofitAdapterRxJava2)

android/app/src/main/java/github/tornaco/android/thanos/ThanosApp.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package github.tornaco.android.thanos
1919

2020
import android.content.Context
21+
import android.os.Build
2122
import com.elvishew.xlog.XLog
2223
import dagger.hilt.android.HiltAndroidApp
2324
import dev.enro.annotations.NavigationComponent
@@ -33,6 +34,7 @@ import github.tornaco.android.thanos.core.app.AppGlobals
3334
import github.tornaco.thanos.android.noroot.NoRootSupport
3435
import github.tornaco.thanos.module.component.manager.initRules
3536
import io.reactivex.plugins.RxJavaPlugins
37+
import org.lsposed.hiddenapibypass.HiddenApiBypass
3638

3739
@HiltAndroidApp
3840
@NavigationComponent
@@ -63,6 +65,10 @@ class ThanosApp : MultipleModulesApp(), NavigationApplication {
6365
DeveloperDiag.diag(this)
6466
}
6567

68+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
69+
HiddenApiBypass.addHiddenApiExemptions("")
70+
}
71+
6672
Init.init(this)
6773
FeatureAccessStats.init(this)
6874
initRules(this.applicationContext)

android/buildSrc/src/main/kotlin/tornaco/project/android/thanox/Dependencies.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ object Libs {
138138
const val glideCompiler = "com.github.bumptech.glide:compiler:4.13.0"
139139

140140
const val xposedApi = "de.robv.android.xposed:api:82"
141+
const val hiddenApiByPass = "org.lsposed.hiddenapibypass:hiddenapibypass:4.3"
141142

142143
const val lombok = "org.projectlombok:lombok:1.18.20"
143144

0 commit comments

Comments
 (0)