Skip to content

Commit 056dc68

Browse files
committed
Android 12: Fix ClientTransactionHandler
Signed-off-by: tiann <[email protected]>
1 parent 6bb556d commit 056dc68

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

VirtualApp/lib/src/main/java/android/app/ClientTransactionHandler.java

+29
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import java.util.List;
3131
import java.util.Map;
3232

33+
import mirror.com.android.internal.content.ReferrerIntent;
34+
3335
/**
3436
* Defines operations that a {@link ClientTransaction} or its items
3537
* can perform on client.
@@ -69,6 +71,15 @@ public abstract void handleDestroyActivity(IBinder token, boolean finishing, int
6971
/** Pause the activity. */
7072
public abstract void handlePauseActivity(IBinder token, boolean finished, boolean userLeaving,
7173
int configChanges, PendingTransactionActions pendingActions, String reason);
74+
75+
// Android 12
76+
/** Destroy the activity. */
77+
public abstract void handleDestroyActivity(ActivityThread.ActivityClientRecord r, boolean finishing,
78+
int configChanges, boolean getNonConfigInstance, String reason);
79+
80+
/** Pause the activity. */
81+
public abstract void handlePauseActivity(ActivityThread.ActivityClientRecord r, boolean finished, boolean userLeaving,
82+
int configChanges, PendingTransactionActions pendingActions, String reason);
7283
/**
7384
* Resume the activity.
7485
* @param token Target activity token.
@@ -102,27 +113,45 @@ public abstract void handleStopActivity(IBinder token, boolean show, int configC
102113
public abstract void handleStopActivity(IBinder token, int configChanges,
103114
PendingTransactionActions pendingActions, boolean finalStateRequest, String reason);
104115

116+
// Android 12
117+
public abstract void handleStopActivity(ActivityThread.ActivityClientRecord r, int configChanges,
118+
PendingTransactionActions pendingActions, boolean finalStateRequest, String reason);
119+
105120
/** Report that activity was stopped to server. */
106121
public abstract void reportStop(PendingTransactionActions pendingActions);
107122
/** Restart the activity after it was stopped. */
108123
public abstract void performRestartActivity(IBinder token, boolean start);
124+
/** Restart the activity after it was stopped. */
125+
public abstract void performRestartActivity(ActivityThread.ActivityClientRecord r, boolean start);
126+
109127
/** Deliver activity (override) configuration change. */
110128
public abstract void handleActivityConfigurationChanged(IBinder activityToken,
111129
Configuration overrideConfig, int displayId);
130+
public abstract void handleActivityConfigurationChanged(ActivityThread.ActivityClientRecord r,
131+
Configuration overrideConfig, int displayId);
132+
112133
/** Deliver result from another activity. */
113134
public abstract void handleSendResult(IBinder token, List results, String reason);
135+
136+
/** Deliver result from another activity. */
137+
public abstract void handleSendResult(
138+
ActivityThread.ActivityClientRecord r, List results, String reason);
139+
114140
/** Deliver multi-window mode change notification. */
115141
public abstract void handleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode,
116142
Configuration overrideConfig);
117143
/** Deliver new intent. */
118144
public abstract void handleNewIntent(IBinder token, List intents,
119145
boolean andPause);
146+
public abstract void handleNewIntent(
147+
ActivityThread.ActivityClientRecord r, List<ReferrerIntent> intents);
120148
/** Deliver picture-in-picture mode change notification. */
121149
public abstract void handlePictureInPictureModeChanged(IBinder token, boolean isInPipMode,
122150
Configuration overrideConfig);
123151

124152
// Android 11
125153
public abstract void handlePictureInPictureRequested(IBinder token);
154+
public abstract void handlePictureInPictureRequested(ActivityThread.ActivityClientRecord r);
126155

127156
/** Signal to an activity (that is currently in PiP) of PiP state changes. */
128157
public abstract void handlePictureInPictureStateChanged(ActivityThread.ActivityClientRecord r,

VirtualApp/lib/src/main/java/android/app/TransactionHandlerProxy.java

+42
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import mirror.android.app.ActivityManagerNative;
2929
import mirror.android.app.IActivityManager;
30+
import mirror.com.android.internal.content.ReferrerIntent;
3031

3132

3233
/**
@@ -73,6 +74,16 @@ public void handlePauseActivity(IBinder token, boolean finished, boolean userLea
7374
originalHandler.handlePauseActivity(token, finished, userLeaving, configChanges, pendingActions, reason);
7475
}
7576

77+
@Override
78+
public void handleDestroyActivity(ActivityClientRecord r, boolean finishing, int configChanges, boolean getNonConfigInstance, String reason) {
79+
originalHandler.handleDestroyActivity(r, finishing, configChanges, getNonConfigInstance, reason);
80+
}
81+
82+
@Override
83+
public void handlePauseActivity(ActivityClientRecord r, boolean finished, boolean userLeaving, int configChanges, PendingTransactionActions pendingActions, String reason) {
84+
originalHandler.handlePauseActivity(r, finished, userLeaving, configChanges, pendingActions, reason);
85+
}
86+
7687
@Override
7788
public void handleResumeActivity(IBinder token, boolean finalStateRequest, boolean isForward, String reason) {
7889
originalHandler.handleResumeActivity(token, finalStateRequest, isForward, reason);
@@ -93,6 +104,11 @@ public void handleStopActivity(IBinder token, int configChanges, PendingTransact
93104
originalHandler.handleStopActivity(token, configChanges, pendingActions, finalStateRequest, reason);
94105
}
95106

107+
@Override
108+
public void handleStopActivity(ActivityClientRecord r, int configChanges, PendingTransactionActions pendingActions, boolean finalStateRequest, String reason) {
109+
originalHandler.handleStopActivity(r, configChanges, pendingActions, finalStateRequest, reason);
110+
}
111+
96112
@Override
97113
public void reportStop(PendingTransactionActions pendingActions) {
98114
originalHandler.reportStop(pendingActions);
@@ -103,16 +119,31 @@ public void performRestartActivity(IBinder token, boolean start) {
103119
originalHandler.performRestartActivity(token, start);
104120
}
105121

122+
@Override
123+
public void performRestartActivity(ActivityClientRecord r, boolean start) {
124+
originalHandler.performRestartActivity(r, start);
125+
}
126+
106127
@Override
107128
public void handleActivityConfigurationChanged(IBinder activityToken, Configuration overrideConfig, int displayId) {
108129
originalHandler.handleActivityConfigurationChanged(activityToken, overrideConfig, displayId);
109130
}
110131

132+
@Override
133+
public void handleActivityConfigurationChanged(ActivityClientRecord r, Configuration overrideConfig, int displayId) {
134+
originalHandler.handleActivityConfigurationChanged(r, overrideConfig, displayId);
135+
}
136+
111137
@Override
112138
public void handleSendResult(IBinder token, List results, String reason) {
113139
originalHandler.handleSendResult(token, results, reason);
114140
}
115141

142+
@Override
143+
public void handleSendResult(ActivityClientRecord r, List results, String reason) {
144+
originalHandler.handleSendResult(r, results, reason);
145+
}
146+
116147
@Override
117148
public void handleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode, Configuration overrideConfig) {
118149
originalHandler.handleMultiWindowModeChanged(token, isInMultiWindowMode, overrideConfig);
@@ -133,6 +164,11 @@ public void handlePictureInPictureRequested(IBinder token) {
133164
originalHandler.handlePictureInPictureRequested(token);
134165
}
135166

167+
@Override
168+
public void handlePictureInPictureRequested(ActivityClientRecord r) {
169+
originalHandler.handlePictureInPictureRequested(r);
170+
}
171+
136172
@Override
137173
public void handlePictureInPictureStateChanged(ActivityClientRecord r, Parcelable pipState) {
138174
originalHandler.handlePictureInPictureStateChanged(r, pipState);
@@ -307,4 +343,10 @@ public void countLaunchingActivities(int num) {
307343
public void handleNewIntent(IBinder token, List intents) {
308344
originalHandler.handleNewIntent(token, intents);
309345
}
346+
347+
@Override
348+
public void handleNewIntent(ActivityClientRecord r, List<ReferrerIntent> intents) {
349+
originalHandler.handleNewIntent(r, intents);
350+
}
351+
310352
}

VirtualApp/lib/src/main/java/com/lody/virtual/client/VClientImpl.java

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.os.StrictMode;
2727
import android.system.ErrnoException;
2828
import android.system.Os;
29+
import android.util.Log;
2930

3031
import com.lody.virtual.client.core.CrashHandler;
3132
import com.lody.virtual.client.core.InvocationStubManager;
@@ -344,6 +345,10 @@ private void bindApplicationNoCheck(String packageName, String processName, Cond
344345
} else {
345346
VLog.w(TAG, "Xposed is disable..");
346347
}
348+
349+
ClassLoader call = LoadedApk.getClassLoader.call(data.info);
350+
Log.i("mylog", "classloader: " + call + " parent: " + call.getParent());
351+
347352
if (Build.VERSION.SDK_INT >= 30)
348353
ApplicationConfig.setDefaultInstance.call(new Object[] { null });
349354
mInitialApplication = LoadedApk.makeApplication.call(data.info, false, null);

0 commit comments

Comments
 (0)