Skip to content

Commit

Permalink
added hidden-api-stub module (copied from Shizuku-API demo-hidden-api…
Browse files Browse the repository at this point in the history
…-stub)
  • Loading branch information
BLuFeNiX committed Mar 18, 2023
1 parent 264e885 commit fb198ee
Show file tree
Hide file tree
Showing 27 changed files with 484 additions and 1 deletion.
1 change: 1 addition & 0 deletions smtshell/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions smtshell/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ android {
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.appcompat:appcompat:1.6.1'
compileOnly project(':hidden-api-stub')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
Expand Down
1 change: 1 addition & 0 deletions smtshell/hidden-api-stub/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
4 changes: 4 additions & 0 deletions smtshell/hidden-api-stub/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apply plugin: 'java-library'

sourceCompatibility = "1.7"
targetCompatibility = "1.7"
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* 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 android.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.SOURCE;

/**
* Denotes that a parameter, field or method return value can never be null.
* <p>
* This is a marker annotation and it has no specific attributes.
*
* @paramDoc This value must never be {@code null}.
* @returnDoc This value will never be {@code null}.
* @hide
*/
@Retention(SOURCE)
@Target({METHOD, PARAMETER, FIELD})
public @interface NonNull {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* 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 android.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.SOURCE;

/**
* Denotes that a parameter, field or method return value can be null.
* <p>
* When decorating a method call parameter, this denotes that the parameter can
* legitimately be null and the method will gracefully deal with it. Typically
* used on optional parameters.
* <p>
* When decorating a method, this denotes the method might legitimately return
* null.
* <p>
* This is a marker annotation and it has no specific attributes.
*
* @paramDoc This value may be {@code null}.
* @returnDoc This value may be {@code null}.
*/
@Retention(SOURCE)
@Target({METHOD, PARAMETER, FIELD})
public @interface Nullable {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package android.content;

import android.os.Binder;
import android.os.Bundle;

public interface IIntentReceiver {

void performReceive(Intent intent, int resultCode, String data, Bundle extras,
boolean ordered, boolean sticky, int sendingUser)
throws android.os.RemoteException;

abstract class Stub extends Binder implements IIntentReceiver {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package android.content;

import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IInterface;

import androidx.annotation.RequiresApi;

public interface IIntentSender extends IInterface {

int send(int code, Intent intent, String resolvedType,
IIntentReceiver finishedReceiver, String requiredPermission, Bundle options);

@RequiresApi(26)
void send(int code, Intent intent, String resolvedType, IBinder whitelistToken,
IIntentReceiver finishedReceiver, String requiredPermission, Bundle options);

abstract class Stub extends Binder implements IIntentSender {

public Stub() {
throw new UnsupportedOperationException();
}

@Override
public android.os.IBinder asBinder() {
throw new UnsupportedOperationException();
}

public static IIntentSender asInterface(IBinder binder) {
throw new UnsupportedOperationException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package android.content;

public class Intent {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package android.content;

public class IntentSender {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package android.content.pm;

import java.util.List;

abstract class BaseParceledListSlice<T> {

public List<T> getList() {
throw new RuntimeException("STUB");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package android.content.pm;

import android.os.Binder;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;

public interface IPackageInstaller extends IInterface {

void abandonSession(int sessionId)
throws RemoteException;

IPackageInstallerSession openSession(int sessionId)
throws RemoteException;

ParceledListSlice<PackageInstaller.SessionInfo> getMySessions(String installerPackageName, int userId)
throws RemoteException;

abstract class Stub extends Binder implements IPackageInstaller {

public static IPackageInstaller asInterface(IBinder binder) {
throw new UnsupportedOperationException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package android.content.pm;

import android.os.Binder;
import android.os.IBinder;
import android.os.IInterface;

public interface IPackageInstallerSession extends IInterface {

abstract class Stub extends Binder implements IPackageInstallerSession {

public static IPackageInstallerSession asInterface(IBinder binder) {
throw new UnsupportedOperationException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package android.content.pm;

import android.os.Binder;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;

import androidx.annotation.RequiresApi;

public interface IPackageManager extends IInterface {

IPackageInstaller getPackageInstaller()
throws RemoteException;

abstract class Stub extends Binder implements IPackageManager {

public static IPackageManager asInterface(IBinder obj) {
throw new UnsupportedOperationException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package android.content.pm;

public class PackageInstaller {

public static class SessionParams {

}

public static class SessionInfo {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package android.content.pm;

public class ParceledListSlice<T> extends BaseParceledListSlice<T> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package android.content.pm;

public class UserInfo {

public int id;
}
58 changes: 58 additions & 0 deletions smtshell/hidden-api-stub/src/main/java/android/os/Binder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package android.os;

import android.annotation.NonNull;
import android.annotation.Nullable;

import java.io.FileDescriptor;

public class Binder implements IBinder {

@Override
public boolean transact(int code, @NonNull Parcel data, Parcel reply, int flags) {
throw new RuntimeException("STUB");
}

@Override
public String getInterfaceDescriptor() {
throw new RuntimeException("STUB");
}

public boolean pingBinder() {
throw new RuntimeException("STUB");
}

@Override
public boolean isBinderAlive() {
throw new RuntimeException("STUB");
}

@Override
public IInterface queryLocalInterface(@NonNull String descriptor) {
throw new RuntimeException("STUB");
}

@Override
public void dump(@NonNull FileDescriptor fd, String[] args) {
throw new RuntimeException("STUB");
}

@Override
public void dumpAsync(@NonNull FileDescriptor fd, String[] args) {
throw new RuntimeException("STUB");
}

@Override
public void linkToDeath(@NonNull DeathRecipient recipient, int flags) {
throw new RuntimeException("STUB");
}

@Override
public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags) {
throw new RuntimeException("STUB");
}

protected boolean onTransact(int code, @NonNull Parcel data, @Nullable Parcel reply,
int flags) throws RemoteException {
throw new RuntimeException("STUB");
}
}
4 changes: 4 additions & 0 deletions smtshell/hidden-api-stub/src/main/java/android/os/Bundle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package android.os;

public class Bundle {
}
33 changes: 33 additions & 0 deletions smtshell/hidden-api-stub/src/main/java/android/os/IBinder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package android.os;

import android.annotation.NonNull;
import android.annotation.Nullable;

import java.io.FileDescriptor;

public interface IBinder {

boolean transact(int code, @NonNull Parcel data, @Nullable Parcel reply, int flags);

@Nullable
String getInterfaceDescriptor();

boolean pingBinder();

boolean isBinderAlive();

@Nullable
IInterface queryLocalInterface(@NonNull String descriptor);

void dump(@NonNull FileDescriptor fd, @Nullable String[] args);

void dumpAsync(@NonNull FileDescriptor fd, @Nullable String[] args);

void linkToDeath(@NonNull DeathRecipient recipient, int flags);

boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags);

interface DeathRecipient {
void binderDied();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package android.os;

public interface IInterface {

IBinder asBinder();
}
Loading

0 comments on commit fb198ee

Please sign in to comment.