Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions aidl/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
plugins {
id('com.android.library')
id("com.android.library")
}

android {
namespace 'rikka.shizuku.aidl'
namespace = "rikka.shizuku.aidl"
buildFeatures {
buildConfig false
aidl true
buildConfig = false
aidl = true
}
buildTypes {
release {
minifyEnabled false
minifyEnabled = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}

Expand Down
18 changes: 9 additions & 9 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
plugins {
id('com.android.library')
id("com.android.library")
}

android {
namespace 'rikka.shizuku.api'
namespace = "rikka.shizuku.api"
buildFeatures {
buildConfig false
buildConfig = false
}
buildTypes {
release {
minifyEnabled false
minifyEnabled = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}

dependencies {
api project(':aidl')
api project(':shared')
api project(":aidl")
api project(":shared")

implementation 'androidx.annotation:annotation:1.3.0'
implementation "androidx.annotation:annotation:1.3.0"
}

ext {
Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/rikka/shizuku/Shizuku.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ public static IBinder getBinder() {
* @see #addBinderDeadListener(OnBinderDeadListener)
*/
public static boolean pingBinder() {
IBinder b = binder;
return binder != null && binder.pingBinder();
}

Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
apply from: 'manifest.gradle'
apply from: "manifest.gradle"

allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption("Xdoclint:none", "-quiet")
}
}

subprojects {
afterEvaluate { project ->
if (!(it.findProperty('publishLibrary') ?: false)) {
if (!(it.findProperty("publishLibrary") ?: false)) {
return
}

plugins.apply('maven-publish')
plugins.apply('signing')
plugins.apply("maven-publish")
plugins.apply("signing")

if (project.parent == rootProject) {
group = "${groupIdBase}"
Expand Down Expand Up @@ -57,8 +57,8 @@ subprojects {
}
repositories {
maven {
name 'ossrh'
url 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
name "ossrh"
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials(PasswordCredentials)
}
}
Expand Down
12 changes: 9 additions & 3 deletions demo-hidden-api-stub/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
apply plugin: 'java-library'
plugins {
id("com.android.library")
}

sourceCompatibility = "11"
targetCompatibility = "11"
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
44 changes: 22 additions & 22 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
plugins {
id('com.android.application')
id('dev.rikka.tools.refine')
id("com.android.application")
id("dev.rikka.tools.refine")
}

android {
namespace 'rikka.shizuku.demo'
namespace = "rikka.shizuku.demo"
defaultConfig {
applicationId "rikka.shizuku.demo"
versionCode 1
versionName api_version_name
applicationId = "rikka.shizuku.demo"
versionCode = 1
versionName = api_version_name
externalNativeBuild {
cmake {
abiFilters "armeabi-v7a", 'arm64-v8a', 'x86', 'x86_64'
cppFlags "-std=c++17"
arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static'
abiFilters = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
cppFlags = ["-std=c++17"]
arguments = ["-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_static"]
}
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
path file("src/main/cpp/CMakeLists.txt")
}
}
buildFeatures {
buildConfig = true
viewBinding = true
aidl true
aidl = true
}
signingConfigs {
sign
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
minifyEnabled = true
shrinkResources = true
proguardFiles [getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
packaging {
jniLibs {
useLegacyPackaging true
useLegacyPackaging = true
}
}
}

dependencies {
implementation 'androidx.annotation:annotation:1.3.0'
implementation "androidx.annotation:annotation:1.3.0"

implementation project(':api') // required by Shizuku and Sui
implementation project(':provider') // required by Shizuku only
implementation project(":api") // required by Shizuku and Sui
implementation project(":provider") // required by Shizuku only

compileOnly project(':demo-hidden-api-stub')
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:6.1' // bypass hidden api restriction, https://github.com/LSPosed/AndroidHiddenApiBypass
compileOnly project(":demo-hidden-api-stub")
implementation "org.lsposed.hiddenapibypass:hiddenapibypass:6.1" // bypass hidden api restriction, https://github.com/LSPosed/AndroidHiddenApiBypass
}
18 changes: 9 additions & 9 deletions provider/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
plugins {
id('com.android.library')
id("com.android.library")
}

android {
namespace 'rikka.shizuku.provider'
namespace = "rikka.shizuku.provider"
defaultConfig {
consumerProguardFiles "consumer-rules.pro"
consumerProguardFiles = ["consumer-rules.pro"]
}
buildFeatures {
buildConfig false
buildConfig = false
}
buildTypes {
release {
minifyEnabled false
minifyEnabled = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}

dependencies {
implementation project(':api')
implementation 'androidx.annotation:annotation:1.3.0'
implementation project(":api")
implementation "androidx.annotation:annotation:1.3.0"
}

ext {
Expand Down
24 changes: 12 additions & 12 deletions rish/build.gradle
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
plugins {
id('com.android.library')
id("com.android.library")
}

android {
namespace 'rikka.rish'
namespace = "rikka.rish"
defaultConfig {
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=none'
arguments = ["-DANDROID_STL=none"]
}
}
}
buildFeatures {
prefab true
prefab = true
}
buildTypes {
release {
minifyEnabled false
minifyEnabled = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
externalNativeBuild {
cmake {
path 'src/main/cpp/CMakeLists.txt'
version "3.31.0+"
path = file("src/main/cpp/CMakeLists.txt")
version = "3.31.0+"
}
}
}

dependencies {
implementation project(':api')
implementation project(":api")

implementation 'androidx.annotation:annotation:1.3.0'
implementation 'org.lsposed.libcxx:libcxx:27.0.12077973'
implementation "androidx.annotation:annotation:1.3.0"
implementation "org.lsposed.libcxx:libcxx:27.0.12077973"
}

ext {
Expand Down
24 changes: 12 additions & 12 deletions server-shared/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
plugins {
id('com.android.library')
id('dev.rikka.tools.refine')
id("com.android.library")
id("dev.rikka.tools.refine")
}

android {
namespace 'rikka.shizuku.server'
namespace = "rikka.shizuku.server"
buildTypes {
release {
minifyEnabled false
minifyEnabled = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}

dependencies {
implementation 'androidx.annotation:annotation:1.3.0'
implementation 'androidx.core:core:1.16.0'
implementation 'dev.rikka.rikkax.parcelablelist:parcelablelist:2.0.1'
implementation "androidx.annotation:annotation:1.3.0"
implementation "androidx.core:core:1.16.0"
implementation "dev.rikka.rikkax.parcelablelist:parcelablelist:2.0.1"

api project(':aidl')
api project(':shared')
api project(':rish')
api project(":aidl")
api project(":shared")
api project(":rish")

implementation libs.refine.runtime
implementation libs.hidden.compat
Expand Down
31 changes: 20 additions & 11 deletions server-shared/src/main/java/rikka/shizuku/server/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,33 @@ public static Pair<IBinder, String> create(String[] args) {
? UserHandleHidden.of(userId)
: new UserHandleHidden(userId));
Context context = Refine.<ContextHidden>unsafeCast(systemContext).createPackageContextAsUser(pkg, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY, userHandle);
Field mPackageInfo = context.getClass().getDeclaredField("mPackageInfo");
mPackageInfo.setAccessible(true);
Object loadedApk = mPackageInfo.get(context);
Method makeApplication = loadedApk.getClass().getDeclaredMethod("makeApplication", boolean.class, Instrumentation.class);
Application application = (Application) makeApplication.invoke(loadedApk, true, null);
Field mInitialApplication = activityThread.getClass().getDeclaredField("mInitialApplication");
mInitialApplication.setAccessible(true);
mInitialApplication.set(activityThread, application);

ClassLoader classLoader = application.getClassLoader();

Application application = null;
try {
Field mPackageInfo = context.getClass().getDeclaredField("mPackageInfo");
mPackageInfo.setAccessible(true);
Object loadedApk = mPackageInfo.get(context);
Method makeApplication = loadedApk.getClass().getDeclaredMethod("makeApplication", boolean.class, Instrumentation.class);
application = (Application) makeApplication.invoke(loadedApk, true, null);
Field mInitialApplication = activityThread.getClass().getDeclaredField("mInitialApplication");
mInitialApplication.setAccessible(true);
mInitialApplication.set(activityThread, application);
} catch (Throwable e) {
// Catch any errors initializing the application, and use the old Context method as a fallback instead
// Especially relevant for MediaTek devices, see GitHub issue 1171
Log.w(TAG, "Failed to initialize Application, using Context as fallback", e);
application = null;
}

ClassLoader classLoader = (application != null ? application.getClassLoader() : context.getClassLoader());
Class<?> serviceClass = classLoader.loadClass(cls);
Constructor<?> constructorWithContext = null;
try {
constructorWithContext = serviceClass.getConstructor(Context.class);
} catch (NoSuchMethodException | SecurityException ignored) {
}
if (constructorWithContext != null) {
service = (IBinder) constructorWithContext.newInstance(application);
service = (IBinder) constructorWithContext.newInstance(application != null ? application : context);
} else {
service = (IBinder) serviceClass.newInstance();
}
Expand Down
Loading