am 4b81e89d: am 2fd3cb95: Merge "Fix ActivityContainer callback parcelling." into klp-modular-dev
* commit '4b81e89d9b7a2cf3ed5aacd9c647aed47f4c4675':
Fix ActivityContainer callback parcelling.
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 9f1b56e..44c74d8 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -2029,7 +2029,7 @@
data.enforceInterface(IActivityManager.descriptor);
IBinder parentActivityToken = data.readStrongBinder();
IActivityContainerCallback callback =
- (IActivityContainerCallback) data.readStrongBinder();
+ IActivityContainerCallback.Stub.asInterface(data.readStrongBinder());
IActivityContainer activityContainer =
createActivityContainer(parentActivityToken, callback);
reply.writeNoException();
@@ -4744,7 +4744,7 @@
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(parentActivityToken);
- data.writeStrongBinder((IBinder)callback);
+ data.writeStrongBinder(callback == null ? null : callback.asBinder());
mRemote.transact(CREATE_ACTIVITY_CONTAINER_TRANSACTION, data, reply, 0);
reply.readException();
final int result = reply.readInt();
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java
index 113f123..51cb12a 100644
--- a/core/java/android/app/ActivityView.java
+++ b/core/java/android/app/ActivityView.java
@@ -92,8 +92,8 @@
super.onAttachedToWindow();
try {
final IBinder token = mActivity.getActivityToken();
- mActivityContainer =
- ActivityManagerNative.getDefault().createActivityContainer(token, null);
+ mActivityContainer = ActivityManagerNative.getDefault().createActivityContainer(token,
+ new ActivityContainerCallback());
} catch (RemoteException e) {
throw new IllegalStateException("ActivityView: Unable to create ActivityContainer. "
+ e);
@@ -282,4 +282,14 @@
}
}
+
+ private class ActivityContainerCallback extends IActivityContainerCallback.Stub {
+ @Override
+ public void setVisible(IBinder container, boolean visible) {
+ if (DEBUG) Log.v(TAG, "setVisible(): container=" + container + " visible=" + visible);
+ if (visible) {
+ } else {
+ }
+ }
+ }
}
diff --git a/core/java/android/app/IActivityContainerCallback.aidl b/core/java/android/app/IActivityContainerCallback.aidl
index 55c2001..7f6d2c3 100644
--- a/core/java/android/app/IActivityContainerCallback.aidl
+++ b/core/java/android/app/IActivityContainerCallback.aidl
@@ -20,5 +20,5 @@
/** @hide */
interface IActivityContainerCallback {
- oneway void onLastActivityRemoved(IBinder container);
+ oneway void setVisible(IBinder container, boolean visible);
}
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index b894724..8dd4317 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1063,6 +1063,16 @@
return mStackSupervisor.isFrontStack(this);
}
+ private void setVisibile(ActivityRecord r, boolean visible) {
+ r.visible = visible;
+ mWindowManager.setAppVisibility(r.appToken, visible);
+ final ArrayList<ActivityStack> containers = r.mChildContainers;
+ for (int containerNdx = containers.size() - 1; containerNdx >= 0; --containerNdx) {
+ ActivityContainer container = containers.get(containerNdx).mActivityContainer;
+ container.setVisible(visible);
+ }
+ }
+
/**
* Version of ensureActivitiesVisible that can easily be called anywhere.
*/
@@ -1141,8 +1151,7 @@
if (!r.visible) {
if (DEBUG_VISBILITY) Slog.v(
TAG, "Starting and making visible: " + r);
- r.visible = true;
- mWindowManager.setAppVisibility(r.appToken, true);
+ setVisibile(r, true);
}
if (r != starting) {
mStackSupervisor.startSpecificActivityLocked(r, false, false);
@@ -1168,7 +1177,7 @@
if (mTranslucentActivityWaiting != null) {
mUndrawnActivitiesBelowTopTranslucent.add(r);
}
- mWindowManager.setAppVisibility(r.appToken, true);
+ setVisibile(r, true);
r.sleeping = false;
r.app.pendingUiClean = true;
r.app.thread.scheduleWindowVisibility(r.appToken, true);
@@ -1204,9 +1213,8 @@
// sure they no longer are keeping the screen frozen.
if (r.visible) {
if (DEBUG_VISBILITY) Slog.v(TAG, "Making invisible: " + r);
- r.visible = false;
try {
- mWindowManager.setAppVisibility(r.appToken, false);
+ setVisibile(r, false);
switch (r.state) {
case STOPPING:
case STOPPED:
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 47b4d0a..63f9d09 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -127,6 +127,7 @@
static final int HANDLE_DISPLAY_ADDED = FIRST_SUPERVISOR_STACK_MSG + 5;
static final int HANDLE_DISPLAY_CHANGED = FIRST_SUPERVISOR_STACK_MSG + 6;
static final int HANDLE_DISPLAY_REMOVED = FIRST_SUPERVISOR_STACK_MSG + 7;
+ static final int CONTAINER_CALLBACK_VISIBILITY = FIRST_SUPERVISOR_STACK_MSG + 8;
private final static String VIRTUAL_DISPLAY_BASE_NAME = "ActivityViewVirtualDisplay";
@@ -3015,6 +3016,14 @@
case HANDLE_DISPLAY_REMOVED: {
handleDisplayRemovedLocked(msg.arg1);
} break;
+ case CONTAINER_CALLBACK_VISIBILITY: {
+ final ActivityContainer container = (ActivityContainer) msg.obj;
+ try {
+ // We only send this message if mCallback is non-null.
+ container.mCallback.setVisible(container.asBinder(), msg.arg1 == 1);
+ } catch (RemoteException e) {
+ }
+ }
}
}
}
@@ -3026,6 +3035,8 @@
final ActivityRecord mParentActivity;
final String mIdString;
+ boolean mVisible = true;
+
/** Display this ActivityStack is currently on. Null if not attached to a Display. */
ActivityDisplay mActivityDisplay;
@@ -3173,6 +3184,16 @@
}
}
+ void setVisible(boolean visible) {
+ if (mVisible != visible) {
+ mVisible = visible;
+ if (mCallback != null) {
+ mHandler.obtainMessage(CONTAINER_CALLBACK_VISIBILITY, visible ? 1 : 0,
+ 0 /* unused */, this).sendToTarget();
+ }
+ }
+ }
+
@Override
public String toString() {
return mIdString + (mActivityDisplay == null ? "N" : "A");