From c38de4118a2ff81625c206ce94e95777304aba7c Mon Sep 17 00:00:00 2001 From: Tornaco Date: Thu, 9 Nov 2023 20:50:39 +0800 Subject: [PATCH] [service] change service publish solution --- .../github/tornaco/android/thanos/core/T.kt | 8 ------- .../thanos/core/app/ThanosManagerNative.java | 23 +++++++++++++++---- android/app/build.gradle.kts | 2 ++ .../tornaco/android/thanos/ThanosApp.kt | 6 +++++ .../project/android/thanox/Dependencies.kt | 1 + android/internal/Thanox-Internal | 2 +- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/T.kt b/android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/T.kt index fe8f85aee..6351e6bbf 100644 --- a/android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/T.kt +++ b/android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/T.kt @@ -1,14 +1,6 @@ package github.tornaco.android.thanos.core -import android.content.Context - object T { - - @JvmStatic - fun serviceInstallName(): String { - return Context.TV_INPUT_SERVICE - } - @JvmStatic fun serviceContextName(): String { return "thanos" diff --git a/android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/app/ThanosManagerNative.java b/android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/app/ThanosManagerNative.java index 4f8452b74..4875d5cc2 100644 --- a/android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/app/ThanosManagerNative.java +++ b/android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/app/ThanosManagerNative.java @@ -2,15 +2,18 @@ import static github.tornaco.android.thanos.core.app.ThanosManager.PROXIED_ANDROID_SERVICE_NAME; +import android.content.Context; +import android.content.pm.ParceledListSlice; +import android.os.Bundle; import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; import android.os.ServiceManager; +import com.android.internal.appwidget.IAppWidgetService; import com.elvishew.xlog.XLog; import github.tornaco.android.thanos.core.IThanos; -import github.tornaco.android.thanos.core.T; import util.Singleton; public class ThanosManagerNative { @@ -27,10 +30,20 @@ protected IThanos create() { if (localService != null) { return localService; } - IThanos thanos = IThanos.Stub.asInterface( - ServiceManager.getService(T.serviceInstallName())); - if (thanos != null) { - return thanos; + + 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); + Bundle bundle = (Bundle) list.getList().get(0); + IBinder thanox = bundle.getBinder("thanox-binder"); + XLog.d("IAppWidgetService thanox binder: " + thanox); + IThanos thanos = IThanos.Stub.asInterface(thanox); + if (thanos != null) { + return thanos; + } + } catch (Throwable e) { + XLog.e(e, "call IAppWidgetService"); } Parcel data = Parcel.obtain(); diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 264994180..65428eb61 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -180,6 +180,8 @@ dependencies { compileOnly(Libs.Others.xposedApi) + implementation(Libs.Others.hiddenApiByPass) + implementation(Libs.Others.retrofit) implementation(Libs.Others.retrofitConverterGson) implementation(Libs.Others.retrofitAdapterRxJava2) diff --git a/android/app/src/main/java/github/tornaco/android/thanos/ThanosApp.kt b/android/app/src/main/java/github/tornaco/android/thanos/ThanosApp.kt index 1c8370ca6..2f43051f5 100644 --- a/android/app/src/main/java/github/tornaco/android/thanos/ThanosApp.kt +++ b/android/app/src/main/java/github/tornaco/android/thanos/ThanosApp.kt @@ -18,6 +18,7 @@ package github.tornaco.android.thanos import android.content.Context +import android.os.Build import com.elvishew.xlog.XLog import dagger.hilt.android.HiltAndroidApp import dev.enro.annotations.NavigationComponent @@ -33,6 +34,7 @@ import github.tornaco.android.thanos.core.app.AppGlobals import github.tornaco.thanos.android.noroot.NoRootSupport import github.tornaco.thanos.module.component.manager.initRules import io.reactivex.plugins.RxJavaPlugins +import org.lsposed.hiddenapibypass.HiddenApiBypass @HiltAndroidApp @NavigationComponent @@ -63,6 +65,10 @@ class ThanosApp : MultipleModulesApp(), NavigationApplication { DeveloperDiag.diag(this) } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + HiddenApiBypass.addHiddenApiExemptions("") + } + Init.init(this) FeatureAccessStats.init(this) initRules(this.applicationContext) diff --git a/android/buildSrc/src/main/kotlin/tornaco/project/android/thanox/Dependencies.kt b/android/buildSrc/src/main/kotlin/tornaco/project/android/thanox/Dependencies.kt index ebe726f7b..e9f2d089c 100644 --- a/android/buildSrc/src/main/kotlin/tornaco/project/android/thanox/Dependencies.kt +++ b/android/buildSrc/src/main/kotlin/tornaco/project/android/thanox/Dependencies.kt @@ -138,6 +138,7 @@ object Libs { const val glideCompiler = "com.github.bumptech.glide:compiler:4.13.0" const val xposedApi = "de.robv.android.xposed:api:82" + const val hiddenApiByPass = "org.lsposed.hiddenapibypass:hiddenapibypass:4.3" const val lombok = "org.projectlombok:lombok:1.18.20" diff --git a/android/internal/Thanox-Internal b/android/internal/Thanox-Internal index f1997fcef..99f33ffd8 160000 --- a/android/internal/Thanox-Internal +++ b/android/internal/Thanox-Internal @@ -1 +1 @@ -Subproject commit f1997fcef50cc730c3c28ab10b29a3cef5536392 +Subproject commit 99f33ffd87e1d3f393720763e5e220ee913d2aa5