Loading core/java/android/app/ActivityView.java +29 −6 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.view.WindowManager; public class ActivityView extends ViewGroup { private final String TAG = "ActivityView"; private final boolean DEBUG = false; private final TextureView mTextureView; private IActivityContainer mActivityContainer; Loading Loading @@ -76,6 +77,7 @@ public class ActivityView extends ViewGroup { mTextureView = new TextureView(context); mTextureView.setSurfaceTextureListener(new ActivityViewSurfaceTextureListener()); addView(mTextureView); if (DEBUG) Log.v(TAG, "ctor()"); } @Override Loading @@ -85,6 +87,8 @@ public class ActivityView extends ViewGroup { @Override protected void onAttachedToWindow() { if (DEBUG) Log.v(TAG, "onAttachedToWindow()"); super.onAttachedToWindow(); try { final IBinder token = mActivity.getActivityToken(); mActivityContainer = Loading @@ -99,6 +103,8 @@ public class ActivityView extends ViewGroup { @Override protected void onDetachedFromWindow() { if (DEBUG) Log.v(TAG, "onDetachedFromWindow(): mActivityContainer=" + mActivityContainer); super.onDetachedFromWindow(); if (mActivityContainer != null) { detach(); mActivityContainer = null; Loading @@ -107,11 +113,17 @@ public class ActivityView extends ViewGroup { @Override protected void onWindowVisibilityChanged(int visibility) { if (DEBUG) Log.v(TAG, "onWindowVisibilityChanged(): visibility=" + visibility); super.onWindowVisibilityChanged(visibility); if (visibility == View.VISIBLE) { switch (visibility) { case View.VISIBLE: attachToSurfaceWhenReady(); } else { break; case View.INVISIBLE: break; case View.GONE: detach(); break; } } Loading Loading @@ -143,6 +155,8 @@ public class ActivityView extends ViewGroup { } public void startActivity(Intent intent) { if (DEBUG) Log.v(TAG, "startActivity(): intent=" + intent + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); if (mSurface != null) { try { mActivityContainer.startActivity(intent); Loading @@ -165,6 +179,8 @@ public class ActivityView extends ViewGroup { } public void startActivity(IntentSender intentSender) { if (DEBUG) Log.v(TAG, "startActivityIntentSender(): intentSender=" + intentSender + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); final IIntentSender iIntentSender = intentSender.getTarget(); if (mSurface != null) { startActivityIntentSender(iIntentSender); Loading @@ -175,6 +191,8 @@ public class ActivityView extends ViewGroup { } public void startActivity(PendingIntent pendingIntent) { if (DEBUG) Log.v(TAG, "startActivityPendingIntent(): PendingIntent=" + pendingIntent + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); final IIntentSender iIntentSender = pendingIntent.getTarget(); if (mSurface != null) { startActivityIntentSender(iIntentSender); Loading Loading @@ -205,6 +223,8 @@ public class ActivityView extends ViewGroup { "ActivityView: Unable to create ActivityContainer. " + e); } if (DEBUG) Log.v(TAG, "attachToSurfaceWhenReady: " + (mQueuedIntent != null || mQueuedPendingIntent != null ? "" : "no") + " queued intent"); if (mQueuedIntent != null) { startActivity(mQueuedIntent); mQueuedIntent = null; Loading @@ -215,6 +235,7 @@ public class ActivityView extends ViewGroup { } private void detach() { if (DEBUG) Log.d(TAG, "detach: attached=" + isAttachedToDisplay()); if (mSurface != null) { try { mActivityContainer.detachFromDisplay(); Loading @@ -229,6 +250,8 @@ public class ActivityView extends ViewGroup { @Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { if (DEBUG) Log.d(TAG, "onSurfaceTextureAvailable: width=" + width + " height=" + height); mWidth = width; mHeight = height; if (mActivityContainer != null) { Loading @@ -239,12 +262,12 @@ public class ActivityView extends ViewGroup { @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) { Log.d(TAG, "onSurfaceTextureSizeChanged: w=" + width + " h=" + height); if (DEBUG) Log.d(TAG, "onSurfaceTextureSizeChanged: w=" + width + " h=" + height); } @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { Log.d(TAG, "onSurfaceTextureDestroyed"); if (DEBUG) Log.d(TAG, "onSurfaceTextureDestroyed"); detach(); return true; } Loading services/core/java/com/android/server/am/ActivityStackSupervisor.java +18 −7 Original line number Diff line number Diff line Loading @@ -1375,8 +1375,15 @@ public final class ActivityStackSupervisor implements DisplayListener { void setFocusedStack(ActivityRecord r) { if (r != null) { final boolean isHomeActivity = !r.isApplicationActivity() || (r.task != null && !r.task.isApplicationTask()); final TaskRecord task = r.task; boolean isHomeActivity = !r.isApplicationActivity(); if (!isHomeActivity && task != null) { isHomeActivity = !task.isApplicationTask(); } if (!isHomeActivity && task != null) { final ActivityRecord parent = task.stack.mActivityContainer.mParentActivity; isHomeActivity = parent != null && parent.isHomeActivity(); } moveHomeStack(isHomeActivity); } } Loading Loading @@ -2058,17 +2065,21 @@ public final class ActivityStackSupervisor implements DisplayListener { if (targetStack == null) { targetStack = getFocusedStack(); } // Do targetStack first. boolean result = false; if (isFrontStack(targetStack)) { result = targetStack.resumeTopActivityLocked(target, targetOptions); } for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) { final ArrayList<ActivityStack> stacks = mActivityDisplays.valueAt(displayNdx).mStacks; for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) { final ActivityStack stack = stacks.get(stackNdx); if (isFrontStack(stack)) { if (stack == targetStack) { result = stack.resumeTopActivityLocked(target, targetOptions); } else { stack.resumeTopActivityLocked(null); // Already started above. continue; } if (isFrontStack(stack)) { stack.resumeTopActivityLocked(null); } } } Loading Loading
core/java/android/app/ActivityView.java +29 −6 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.view.WindowManager; public class ActivityView extends ViewGroup { private final String TAG = "ActivityView"; private final boolean DEBUG = false; private final TextureView mTextureView; private IActivityContainer mActivityContainer; Loading Loading @@ -76,6 +77,7 @@ public class ActivityView extends ViewGroup { mTextureView = new TextureView(context); mTextureView.setSurfaceTextureListener(new ActivityViewSurfaceTextureListener()); addView(mTextureView); if (DEBUG) Log.v(TAG, "ctor()"); } @Override Loading @@ -85,6 +87,8 @@ public class ActivityView extends ViewGroup { @Override protected void onAttachedToWindow() { if (DEBUG) Log.v(TAG, "onAttachedToWindow()"); super.onAttachedToWindow(); try { final IBinder token = mActivity.getActivityToken(); mActivityContainer = Loading @@ -99,6 +103,8 @@ public class ActivityView extends ViewGroup { @Override protected void onDetachedFromWindow() { if (DEBUG) Log.v(TAG, "onDetachedFromWindow(): mActivityContainer=" + mActivityContainer); super.onDetachedFromWindow(); if (mActivityContainer != null) { detach(); mActivityContainer = null; Loading @@ -107,11 +113,17 @@ public class ActivityView extends ViewGroup { @Override protected void onWindowVisibilityChanged(int visibility) { if (DEBUG) Log.v(TAG, "onWindowVisibilityChanged(): visibility=" + visibility); super.onWindowVisibilityChanged(visibility); if (visibility == View.VISIBLE) { switch (visibility) { case View.VISIBLE: attachToSurfaceWhenReady(); } else { break; case View.INVISIBLE: break; case View.GONE: detach(); break; } } Loading Loading @@ -143,6 +155,8 @@ public class ActivityView extends ViewGroup { } public void startActivity(Intent intent) { if (DEBUG) Log.v(TAG, "startActivity(): intent=" + intent + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); if (mSurface != null) { try { mActivityContainer.startActivity(intent); Loading @@ -165,6 +179,8 @@ public class ActivityView extends ViewGroup { } public void startActivity(IntentSender intentSender) { if (DEBUG) Log.v(TAG, "startActivityIntentSender(): intentSender=" + intentSender + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); final IIntentSender iIntentSender = intentSender.getTarget(); if (mSurface != null) { startActivityIntentSender(iIntentSender); Loading @@ -175,6 +191,8 @@ public class ActivityView extends ViewGroup { } public void startActivity(PendingIntent pendingIntent) { if (DEBUG) Log.v(TAG, "startActivityPendingIntent(): PendingIntent=" + pendingIntent + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); final IIntentSender iIntentSender = pendingIntent.getTarget(); if (mSurface != null) { startActivityIntentSender(iIntentSender); Loading Loading @@ -205,6 +223,8 @@ public class ActivityView extends ViewGroup { "ActivityView: Unable to create ActivityContainer. " + e); } if (DEBUG) Log.v(TAG, "attachToSurfaceWhenReady: " + (mQueuedIntent != null || mQueuedPendingIntent != null ? "" : "no") + " queued intent"); if (mQueuedIntent != null) { startActivity(mQueuedIntent); mQueuedIntent = null; Loading @@ -215,6 +235,7 @@ public class ActivityView extends ViewGroup { } private void detach() { if (DEBUG) Log.d(TAG, "detach: attached=" + isAttachedToDisplay()); if (mSurface != null) { try { mActivityContainer.detachFromDisplay(); Loading @@ -229,6 +250,8 @@ public class ActivityView extends ViewGroup { @Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { if (DEBUG) Log.d(TAG, "onSurfaceTextureAvailable: width=" + width + " height=" + height); mWidth = width; mHeight = height; if (mActivityContainer != null) { Loading @@ -239,12 +262,12 @@ public class ActivityView extends ViewGroup { @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) { Log.d(TAG, "onSurfaceTextureSizeChanged: w=" + width + " h=" + height); if (DEBUG) Log.d(TAG, "onSurfaceTextureSizeChanged: w=" + width + " h=" + height); } @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { Log.d(TAG, "onSurfaceTextureDestroyed"); if (DEBUG) Log.d(TAG, "onSurfaceTextureDestroyed"); detach(); return true; } Loading
services/core/java/com/android/server/am/ActivityStackSupervisor.java +18 −7 Original line number Diff line number Diff line Loading @@ -1375,8 +1375,15 @@ public final class ActivityStackSupervisor implements DisplayListener { void setFocusedStack(ActivityRecord r) { if (r != null) { final boolean isHomeActivity = !r.isApplicationActivity() || (r.task != null && !r.task.isApplicationTask()); final TaskRecord task = r.task; boolean isHomeActivity = !r.isApplicationActivity(); if (!isHomeActivity && task != null) { isHomeActivity = !task.isApplicationTask(); } if (!isHomeActivity && task != null) { final ActivityRecord parent = task.stack.mActivityContainer.mParentActivity; isHomeActivity = parent != null && parent.isHomeActivity(); } moveHomeStack(isHomeActivity); } } Loading Loading @@ -2058,17 +2065,21 @@ public final class ActivityStackSupervisor implements DisplayListener { if (targetStack == null) { targetStack = getFocusedStack(); } // Do targetStack first. boolean result = false; if (isFrontStack(targetStack)) { result = targetStack.resumeTopActivityLocked(target, targetOptions); } for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) { final ArrayList<ActivityStack> stacks = mActivityDisplays.valueAt(displayNdx).mStacks; for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) { final ActivityStack stack = stacks.get(stackNdx); if (isFrontStack(stack)) { if (stack == targetStack) { result = stack.resumeTopActivityLocked(target, targetOptions); } else { stack.resumeTopActivityLocked(null); // Already started above. continue; } if (isFrontStack(stack)) { stack.resumeTopActivityLocked(null); } } } Loading