Skip to content

Commit

Permalink
[service] change service publish solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Nov 9, 2023
1 parent 0cdc808 commit c38de41
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion android/internal/Thanox-Internal

0 comments on commit c38de41

Please sign in to comment.