-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[app/services] misc for noroot support
- Loading branch information
Showing
12 changed files
with
267 additions
and
52 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...roid_framework/base/src/main/java/github/tornaco/android/thanos/core/IThanosProvider.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package github.tornaco.android.thanos.core; | ||
|
||
import github.tornaco.android.thanos.core.IThanos; | ||
|
||
|
||
import android.content.IntentFilter; | ||
|
||
interface IThanosProvider { | ||
IThanos getThanos(); | ||
} |
127 changes: 127 additions & 0 deletions
127
...roid_framework/base/src/main/java/github/tornaco/android/thanos/core/IThanosProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* This file is auto-generated. DO NOT MODIFY. | ||
*/ | ||
package github.tornaco.android.thanos.core; | ||
public interface IThanosProvider extends android.os.IInterface | ||
{ | ||
/** Default implementation for IThanosProvider. */ | ||
public static class Default implements github.tornaco.android.thanos.core.IThanosProvider | ||
{ | ||
@Override public github.tornaco.android.thanos.core.IThanos getThanos() throws android.os.RemoteException | ||
{ | ||
return null; | ||
} | ||
@Override | ||
public android.os.IBinder asBinder() { | ||
return null; | ||
} | ||
} | ||
/** Local-side IPC implementation stub class. */ | ||
public static abstract class Stub extends android.os.Binder implements github.tornaco.android.thanos.core.IThanosProvider | ||
{ | ||
private static final java.lang.String DESCRIPTOR = "github.tornaco.android.thanos.core.IThanosProvider"; | ||
/** Construct the stub at attach it to the interface. */ | ||
public Stub() | ||
{ | ||
this.attachInterface(this, DESCRIPTOR); | ||
} | ||
/** | ||
* Cast an IBinder object into an github.tornaco.android.thanos.core.IThanosProvider interface, | ||
* generating a proxy if needed. | ||
*/ | ||
public static github.tornaco.android.thanos.core.IThanosProvider asInterface(android.os.IBinder obj) | ||
{ | ||
if ((obj==null)) { | ||
return null; | ||
} | ||
android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR); | ||
if (((iin!=null)&&(iin instanceof github.tornaco.android.thanos.core.IThanosProvider))) { | ||
return ((github.tornaco.android.thanos.core.IThanosProvider)iin); | ||
} | ||
return new github.tornaco.android.thanos.core.IThanosProvider.Stub.Proxy(obj); | ||
} | ||
@Override public android.os.IBinder asBinder() | ||
{ | ||
return this; | ||
} | ||
@Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException | ||
{ | ||
java.lang.String descriptor = DESCRIPTOR; | ||
switch (code) | ||
{ | ||
case INTERFACE_TRANSACTION: | ||
{ | ||
reply.writeString(descriptor); | ||
return true; | ||
} | ||
case TRANSACTION_getThanos: | ||
{ | ||
data.enforceInterface(descriptor); | ||
github.tornaco.android.thanos.core.IThanos _result = this.getThanos(); | ||
reply.writeNoException(); | ||
reply.writeStrongBinder((((_result!=null))?(_result.asBinder()):(null))); | ||
return true; | ||
} | ||
default: | ||
{ | ||
return super.onTransact(code, data, reply, flags); | ||
} | ||
} | ||
} | ||
private static class Proxy implements github.tornaco.android.thanos.core.IThanosProvider | ||
{ | ||
private android.os.IBinder mRemote; | ||
Proxy(android.os.IBinder remote) | ||
{ | ||
mRemote = remote; | ||
} | ||
@Override public android.os.IBinder asBinder() | ||
{ | ||
return mRemote; | ||
} | ||
public java.lang.String getInterfaceDescriptor() | ||
{ | ||
return DESCRIPTOR; | ||
} | ||
@Override public github.tornaco.android.thanos.core.IThanos getThanos() throws android.os.RemoteException | ||
{ | ||
android.os.Parcel _data = android.os.Parcel.obtain(); | ||
android.os.Parcel _reply = android.os.Parcel.obtain(); | ||
github.tornaco.android.thanos.core.IThanos _result; | ||
try { | ||
_data.writeInterfaceToken(DESCRIPTOR); | ||
boolean _status = mRemote.transact(Stub.TRANSACTION_getThanos, _data, _reply, 0); | ||
if (!_status && getDefaultImpl() != null) { | ||
return getDefaultImpl().getThanos(); | ||
} | ||
_reply.readException(); | ||
_result = github.tornaco.android.thanos.core.IThanos.Stub.asInterface(_reply.readStrongBinder()); | ||
} | ||
finally { | ||
_reply.recycle(); | ||
_data.recycle(); | ||
} | ||
return _result; | ||
} | ||
public static github.tornaco.android.thanos.core.IThanosProvider sDefaultImpl; | ||
} | ||
static final int TRANSACTION_getThanos = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); | ||
public static boolean setDefaultImpl(github.tornaco.android.thanos.core.IThanosProvider impl) { | ||
// Only one user of this interface can use this function | ||
// at a time. This is a heuristic to detect if two different | ||
// users in the same process use this function. | ||
if (Stub.Proxy.sDefaultImpl != null) { | ||
throw new IllegalStateException("setDefaultImpl() called twice"); | ||
} | ||
if (impl != null) { | ||
Stub.Proxy.sDefaultImpl = impl; | ||
return true; | ||
} | ||
return false; | ||
} | ||
public static github.tornaco.android.thanos.core.IThanosProvider getDefaultImpl() { | ||
return Stub.Proxy.sDefaultImpl; | ||
} | ||
} | ||
public github.tornaco.android.thanos.core.IThanos getThanos() throws android.os.RemoteException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Thanox-Internal
updated
from 48a609 to f0d76a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...oot_support/src/main/java/github/tornaco/thanos/android/noroot/ThanosProviderService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* (C) Copyright 2022 Thanox | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package github.tornaco.thanos.android.noroot; | ||
|
||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.ContentResolver; | ||
import android.content.Context; | ||
import android.content.ContextWrapper; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
import android.os.Binder; | ||
import android.os.Handler; | ||
import android.os.Process; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.elvishew.xlog.XLog; | ||
|
||
import github.tornaco.android.thanos.core.IThanos; | ||
import github.tornaco.android.thanos.core.IThanosProvider; | ||
import github.tornaco.android.thanos.core.app.ThanosManagerNative; | ||
import github.tornaco.android.thanos.services.BootStrap; | ||
|
||
public class ThanosProviderService extends IThanosProvider.Stub { | ||
public ThanosProviderService() { | ||
} | ||
|
||
@Override | ||
public IThanos getThanos() { | ||
if (ThanosManagerNative.getLocalService() == null) { | ||
installThanosService(); | ||
} | ||
return ThanosManagerNative.getLocalService(); | ||
} | ||
|
||
private void installThanosService() { | ||
XLog.w("installThanosService: " + " --- p" + Process.myPid() + " u" + Process.myUid()); | ||
XLog.w("installThanosService, currentApplication: " + BootStrap.currentApplication()); | ||
long ident = Binder.clearCallingIdentity(); | ||
try { | ||
BootStrap.main("Shizuku", new String[0]); | ||
BootStrap.start(new ShellProcessContext(BootStrap.currentApplication())); | ||
BootStrap.ready(); | ||
} catch (Throwable e) { | ||
XLog.e("********* ThanosProviderService#installThanosService *********", e); | ||
} | ||
Binder.restoreCallingIdentity(ident); | ||
} | ||
|
||
static class ShellProcessContext extends ContextWrapper { | ||
public ShellProcessContext(Context base) { | ||
super(base); | ||
} | ||
|
||
@Override | ||
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter) { | ||
XLog.w("ShellProcessContext, drop registerReceiver call..." + receiver); | ||
return new Intent(); | ||
} | ||
|
||
@Override | ||
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter, int flags) { | ||
XLog.w("ShellProcessContext, drop registerReceiver call..." + receiver); | ||
return new Intent(); | ||
} | ||
|
||
@Override | ||
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter, @Nullable String broadcastPermission, @Nullable Handler scheduler) { | ||
XLog.w("ShellProcessContext, drop registerReceiver call..." + receiver); | ||
return new Intent(); | ||
} | ||
|
||
@Override | ||
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter, @Nullable String broadcastPermission, @Nullable Handler scheduler, int flags) { | ||
XLog.w("ShellProcessContext, drop registerReceiver call..." + receiver); | ||
return new Intent(); | ||
} | ||
|
||
@Override | ||
public ContentResolver getContentResolver() { | ||
XLog.w("ShellProcessContext, drop getContentResolver call..."); | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.