From a59ac9cd645d25f03e4e488100bd99f92e83a3a7 Mon Sep 17 00:00:00 2001 From: Filip Gruszczynski Date: Thu, 10 Sep 2015 18:28:48 -0700 Subject: Preserve window during resize triggered relaunches. This changes application code behavior when the activity relaunches due to configuration change. It only applies to scenarios, where the configuration change was triggered by a user generated resize of an activity (i.e. user drags a corner of an activity and thus changes its size). Preserving a window means that we will keep the decor view and non client decor view around, but remove all children views when the activity gets destroyed. When the activity gets created again, it will attach its new content to the preserved view hierarchy. Mind, we actually recreate application side Window object, since some of its features might changed, but we retain its elevation (to not trigger relayout with new layout params). Preserving the window also means that we don't call the window manager service to remove and later add the window. Instead, we continue using a single window state throughout the resize operation. Change-Id: Ie3d2878ed09c99ff343044bfe7a29a0ba07a265e --- core/java/android/app/ApplicationThreadNative.java | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'core/java/android/app/ApplicationThreadNative.java') diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index f164a0a76d8f..bead625a0bc1 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -63,14 +63,14 @@ public abstract class ApplicationThreadNative extends Binder if (in != null) { return in; } - + return new ApplicationThreadProxy(obj); } - + public ApplicationThreadNative() { attachInterface(this, descriptor); } - + @Override public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { @@ -96,7 +96,7 @@ public abstract class ApplicationThreadNative extends Binder scheduleStopActivity(b, show, configChanges); return true; } - + case SCHEDULE_WINDOW_VISIBILITY_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); @@ -125,7 +125,7 @@ public abstract class ApplicationThreadNative extends Binder scheduleResumeActivity(b, procState, isForward, resumeArgs); return true; } - + case SCHEDULE_SEND_RESULT_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); @@ -179,7 +179,9 @@ public abstract class ApplicationThreadNative extends Binder if (data.readInt() != 0) { overrideConfig = Configuration.CREATOR.createFromParcel(data); } - scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config, overrideConfig); + boolean preserveWindows = data.readInt() == 1; + scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config, overrideConfig, + preserveWindows); return true; } @@ -201,7 +203,7 @@ public abstract class ApplicationThreadNative extends Binder scheduleDestroyActivity(b, finishing, configChanges); return true; } - + case SCHEDULE_RECEIVER_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); @@ -371,7 +373,7 @@ public abstract class ApplicationThreadNative extends Binder } return true; } - + case DUMP_PROVIDER_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); ParcelFileDescriptor fd = data.readFileDescriptor(); @@ -731,15 +733,15 @@ public abstract class ApplicationThreadNative extends Binder class ApplicationThreadProxy implements IApplicationThread { private final IBinder mRemote; - + public ApplicationThreadProxy(IBinder remote) { mRemote = remote; } - + public final IBinder asBinder() { return mRemote; } - + public final void schedulePauseActivity(IBinder token, boolean finished, boolean userLeaving, int configChanges, boolean dontReport) throws RemoteException { Parcel data = Parcel.obtain(); @@ -856,7 +858,7 @@ class ApplicationThreadProxy implements IApplicationThread { public final void scheduleRelaunchActivity(IBinder token, List pendingResults, List pendingNewIntents, int configChanges, boolean notResumed, Configuration config, - Configuration overrideConfig) throws RemoteException { + Configuration overrideConfig, boolean preserveWindow) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeStrongBinder(token); @@ -871,6 +873,7 @@ class ApplicationThreadProxy implements IApplicationThread { } else { data.writeInt(0); } + data.writeInt(preserveWindow ? 1 : 0); mRemote.transact(SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); data.recycle(); @@ -898,7 +901,7 @@ class ApplicationThreadProxy implements IApplicationThread { IBinder.FLAG_ONEWAY); data.recycle(); } - + public final void scheduleReceiver(Intent intent, ActivityInfo info, CompatibilityInfo compatInfo, int resultCode, String resultData, Bundle map, boolean sync, int sendingUser, int processState) throws RemoteException { @@ -940,7 +943,7 @@ class ApplicationThreadProxy implements IApplicationThread { IBinder.FLAG_ONEWAY); data.recycle(); } - + public final void scheduleCreateService(IBinder token, ServiceInfo info, CompatibilityInfo compatInfo, int processState) throws RemoteException { Parcel data = Parcel.obtain(); @@ -1055,7 +1058,7 @@ class ApplicationThreadProxy implements IApplicationThread { IBinder.FLAG_ONEWAY); data.recycle(); } - + public final void scheduleExit() throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); @@ -1128,7 +1131,7 @@ class ApplicationThreadProxy implements IApplicationThread { mRemote.transact(DUMP_SERVICE_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); data.recycle(); } - + public void dumpProvider(FileDescriptor fd, IBinder token, String[] args) throws RemoteException { Parcel data = Parcel.obtain(); -- cgit v1.2.3