Skip to content

Commit

Permalink
Chore: migrate to new api
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr328 committed Jan 2, 2022
1 parent a224ead commit bae58f5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ subprojects {
extensions.configure<BaseExtension> {
val minSdkVersion = 29
val targetSdkVersion = 31
val buildVersionName = "v12"
val buildVersionCode = 12
val buildVersionName = "v13"
val buildVersionCode = 13

compileSdkVersion(targetSdkVersion)

Expand Down
7 changes: 2 additions & 5 deletions module/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.github.kr328.zloader.gradle.ZygoteLoader
import com.github.kr328.zloader.gradle.tasks.PackageMagiskTask
import com.github.kr328.zloader.gradle.util.toCapitalized

plugins {
Expand All @@ -23,19 +22,17 @@ zygote {
author = moduleAuthor
description = moduleDescription
entrypoint = moduleEntrypoint
archiveName = "riru-${moduleId.replace('_', '-')}-${android.defaultConfig.versionName}"
}
}

androidComponents {
onVariants {
val name = it.name
val flavorName = it.flavorName!!
val buildType = it.buildType!!

afterEvaluate {
(tasks[PackageMagiskTask.taskName(name)] as Zip).apply {
archiveBaseName.set("$flavorName-clipboard-whitelist-${android.defaultConfig.versionName}")

(tasks["packageMagisk${name.toCapitalized()}"] as Zip).apply {
val appApk = project(":app").buildDir
.resolve("outputs/apk/${buildType}/app-${buildType}.apk")

Expand Down
2 changes: 1 addition & 1 deletion module/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
-dontobfuscate

-keep class com.github.kr328.clipboard.Injector {
public static void main(java.lang.String, java.util.Properties);
public static void main(...);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@

import com.github.kr328.clipboard.shared.Constants;
import com.github.kr328.clipboard.shared.Log;
import com.github.kr328.magic.proxy.AIDLProxy.TransactProxy;
import com.github.kr328.magic.aidl.ServerProxy;
import com.github.kr328.magic.aidl.ServerProxyFactory;
import com.github.kr328.magic.aidl.TransactProxy;
import com.github.kr328.magic.util.BinderUtils;

import dev.rikka.tools.refine.Refine;

public class ClipboardProxy extends IClipboard.Stub {
public final static ServerProxyFactory<IClipboard, ClipboardProxy> FACTORY =
ServerProxy.mustCreateFactory(IClipboard.class, ClipboardProxy.class, false);

private final IClipboard original;
private final WhitelistService whitelistService = new WhitelistService();

Expand Down
17 changes: 8 additions & 9 deletions module/src/main/java/com/github/kr328/clipboard/Injector.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@
import android.os.Process;

import com.github.kr328.clipboard.shared.Log;
import com.github.kr328.magic.proxy.AIDLProxy;
import com.github.kr328.magic.proxy.ServiceManagerProxy;
import com.github.kr328.magic.services.ServiceManagerProxy;
import com.github.kr328.zloader.ZygoteLoader;

import java.util.Properties;

public class Injector {
@SuppressWarnings("unused")
public static void main(String processName, Properties properties) {
Log.i("Injected into " + processName);
public static void main() {
Log.i("Injected into " + ZygoteLoader.getPackageName());
Log.i("Uid " + Process.myUid());
Log.i("Pid " + Process.myPid());

if (!ZygoteLoader.PACKAGE_SYSTEM_SERVER.equals(processName)) {
if (!ZygoteLoader.PACKAGE_SYSTEM_SERVER.equals(ZygoteLoader.getPackageName())) {
return;
}

Expand All @@ -37,12 +34,14 @@ public static void main(String processName, Properties properties) {

private static Binder replaceService(String name, Binder service) {
if (Context.CLIPBOARD_SERVICE.equals(name)) {
Log.i("Replacing clipboard");

try {
final IClipboard original = IClipboard.Stub.asInterface(service);

return AIDLProxy.newServer(IClipboard.class, original, new ClipboardProxy(original));
return ClipboardProxy.FACTORY.create(original, new ClipboardProxy(original));
} catch (Throwable e) {
Log.e("Proxy clipboard: " + e, e);
Log.e("Replacing clipboard: " + e, e);
}
}

Expand Down
6 changes: 3 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ include(":shared", ":hideapi", ":module", ":app")
dependencyResolutionManagement {
versionCatalogs {
create("deps") {
val agp = "7.0.3"
val zloader = "1.5"
val agp = "7.0.4"
val zloader = "1.6"
val refine = "3.0.3"
val magic = "1.1"
val magic = "1.3"

alias("build-android").to("com.android.tools.build:gradle:$agp")
alias("build-zloader").to("com.github.kr328.zloader:gradle-plugin:$zloader")
Expand Down

0 comments on commit bae58f5

Please sign in to comment.