diff --git a/build.gradle b/build.gradle index 1f8e146bf8..fbd279bcd6 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5' + classpath 'dev.rikka.tools.refine:gradle-plugin:3.1.1' } } @@ -90,6 +91,7 @@ apply plugin: 'com.google.android.gms.oss-licenses-plugin' apply plugin: 'kotlin-parcelize' apply plugin: 'kotlin-kapt' apply plugin: 'org.jetbrains.kotlin.plugin.serialization' +apply plugin: 'dev.rikka.tools.refine' final def commitHash = { -> final def stdout = new ByteArrayOutputStream() @@ -333,6 +335,7 @@ dependencies { // Recents lib dependency withQuickstepImplementation project(':SystemUIShared') + withQuickstepCompileOnly project(':hidden-api') implementation fileTree(dir: "${FRAMEWORK_PREBUILTS_DIR}/libs", include: 'WindowManager-Shell.jar') // Required for AOSP to compile. This is already included in the sysui_shared.jar @@ -349,6 +352,7 @@ dependencies { androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3' androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}" implementation 'com.github.ChickenHook:RestrictionBypass:2.2' + implementation 'dev.rikka.tools.refine:runtime:3.1.1' implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.ui:ui-tooling:$compose_version" diff --git a/hidden-api/.gitignore b/hidden-api/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/hidden-api/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/hidden-api/build.gradle b/hidden-api/build.gradle new file mode 100644 index 0000000000..0ad6eee351 --- /dev/null +++ b/hidden-api/build.gradle @@ -0,0 +1,36 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'app.lawnchair.hidden_api' + compileSdk 32 + + defaultConfig { + minSdk 26 + targetSdk 32 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + annotationProcessor 'dev.rikka.tools.refine:annotation-processor:3.1.1' + compileOnly 'dev.rikka.tools.refine:annotation:3.1.1' +} diff --git a/hidden-api/consumer-rules.pro b/hidden-api/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/hidden-api/proguard-rules.pro b/hidden-api/proguard-rules.pro new file mode 100644 index 0000000000..481bb43481 --- /dev/null +++ b/hidden-api/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/hidden-api/src/main/AndroidManifest.xml b/hidden-api/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..a5918e68ab --- /dev/null +++ b/hidden-api/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/hidden-api/src/main/java/android/app/IActivityTaskManager.java b/hidden-api/src/main/java/android/app/IActivityTaskManager.java new file mode 100644 index 0000000000..020a2509b4 --- /dev/null +++ b/hidden-api/src/main/java/android/app/IActivityTaskManager.java @@ -0,0 +1,4 @@ +package android.app; + +public interface IActivityTaskManager { +} diff --git a/hidden-api/src/main/java/android/app/IActivityTaskManagerHidden.java b/hidden-api/src/main/java/android/app/IActivityTaskManagerHidden.java new file mode 100644 index 0000000000..959f66b552 --- /dev/null +++ b/hidden-api/src/main/java/android/app/IActivityTaskManagerHidden.java @@ -0,0 +1,17 @@ +package android.app; + +import android.os.IBinder; +import android.os.RemoteException; +import android.view.RemoteAnimationAdapter; + +import dev.rikka.tools.refine.RefineAs; + +@RefineAs(IActivityTaskManager.class) +public interface IActivityTaskManagerHidden { + + void registerRemoteAnimationForNextActivityStart( + String packageName, RemoteAnimationAdapter adapter, IBinder launchCookie) throws RemoteException; + + void registerRemoteAnimationForNextActivityStart( + String packageName, RemoteAnimationAdapter adapter) throws RemoteException; +} diff --git a/hidden-api/src/main/java/android/view/RemoteAnimationAdapter.java b/hidden-api/src/main/java/android/view/RemoteAnimationAdapter.java new file mode 100644 index 0000000000..b01c02f91a --- /dev/null +++ b/hidden-api/src/main/java/android/view/RemoteAnimationAdapter.java @@ -0,0 +1,4 @@ +package android.view; + +public class RemoteAnimationAdapter { +} diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java index ed71562643..757bb9c9d9 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java @@ -19,6 +19,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH import android.app.ActivityOptions; import android.app.ActivityTaskManager; +import android.app.IActivityTaskManagerHidden; import android.app.PendingIntent; import android.content.Intent; import android.os.IBinder; @@ -35,6 +36,8 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.util.ActivityOptionsWrapper; import com.android.launcher3.widget.LauncherAppWidgetHostView; +import dev.rikka.tools.refine.Refine; + /** Provides a Quickstep specific animation when launching an activity from an app widget. */ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { @@ -69,11 +72,17 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { // In the event this pending intent eventually launches an activity, i.e. a trampoline, // use the Quickstep transition animation. try { - ActivityTaskManager.getService() - .registerRemoteAnimationForNextActivityStart( - pendingIntent.getCreatorPackage(), - activityOptions.options.getRemoteAnimationAdapter(), - launchCookie); + IActivityTaskManagerHidden atm = Refine.unsafeCast(ActivityTaskManager.getService()); + try { + atm.registerRemoteAnimationForNextActivityStart( + pendingIntent.getCreatorPackage(), + activityOptions.options.getRemoteAnimationAdapter(), + launchCookie); + } catch (NoSuchMethodError e) { + atm.registerRemoteAnimationForNextActivityStart( + pendingIntent.getCreatorPackage(), + activityOptions.options.getRemoteAnimationAdapter()); + } } catch (RemoteException e) { // Do nothing. } diff --git a/settings.gradle b/settings.gradle index ddf70238da..e1f79417cf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,3 +8,4 @@ include ':SystemUIShared' include ':CompatLib' include ':CompatLibVR' include ':CompatLibVS' +include ':hidden-api'