Fix widgets interaction before June patch

This commit is contained in:
Suphon Thanakornpakapong
2022-06-22 17:49:14 +07:00
parent 45f73a9c7b
commit c471e08b94
11 changed files with 106 additions and 5 deletions

View File

@@ -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"

1
hidden-api/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

36
hidden-api/build.gradle Normal file
View File

@@ -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'
}

View File

21
hidden-api/proguard-rules.pro vendored Normal file
View File

@@ -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

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@@ -0,0 +1,4 @@
package android.app;
public interface IActivityTaskManager {
}

View File

@@ -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;
}

View File

@@ -0,0 +1,4 @@
package android.view;
public class RemoteAnimationAdapter {
}

View File

@@ -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.
}

View File

@@ -8,3 +8,4 @@ include ':SystemUIShared'
include ':CompatLib'
include ':CompatLibVR'
include ':CompatLibVS'
include ':hidden-api'