Loading services/core/java/com/android/server/am/ActivityStack.java +5 −0 Original line number Diff line number Diff line Loading @@ -1414,7 +1414,12 @@ final class ActivityStack { * this function updates the rest of our state to match that fact. */ private void completeResumeLocked(ActivityRecord next) { boolean wasVisible = next.visible; next.visible = true; if (!wasVisible) { // Visibility has changed, so take a note of it so we call the TaskStackChangedListener mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true; } next.idle = false; next.results = null; next.newIntents = null; Loading services/tests/servicestests/Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ ifeq (true,$(EMMA_INSTRUMENT)) LOCAL_JACK_FLAGS := --multi-dex native endif # EMMA_INSTRUMENT_STATIC LOCAL_STATIC_JAVA_LIBRARIES += ub-uiautomator include $(BUILD_PACKAGE) ######################################################################### Loading services/tests/servicestests/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.PACKET_KEEPALIVE_OFFLOAD" /> <uses-permission android:name="android.permission.GET_INTENT_SENDER_INTENT" /> <uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" /> <application> <uses-library android:name="android.test.runner" /> Loading Loading @@ -155,6 +156,9 @@ </intent-filter> </activity-alias> <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityA" /> <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityB" /> </application> <instrumentation Loading services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java 0 → 100644 +123 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.server.am; import static android.support.test.InstrumentationRegistry.getInstrumentation; import android.app.Activity; import android.app.ActivityManagerNative; import android.app.IActivityManager; import android.app.ITaskStackListener; import android.content.Context; import android.content.Intent; import android.os.RemoteException; import android.support.test.InstrumentationRegistry; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.support.test.uiautomator.UiDevice; import com.android.internal.annotations.GuardedBy; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @MediumTest @RunWith(AndroidJUnit4.class) public class TaskStackChangedListenerTest extends ITaskStackListener.Stub { private IActivityManager mService; private static final Object sLock = new Object(); @GuardedBy("sLock") private static boolean sTaskStackChangedCalled; private static boolean sActivityBResumed; @Before public void setUp() throws Exception { mService = ActivityManagerNative.getDefault(); mService.registerTaskStackListener(this); } @Test public void testTaskStackChanged_afterFinish() throws Exception { Context ctx = InstrumentationRegistry.getContext(); ctx.startActivity(new Intent(ctx, ActivityA.class)); UiDevice.getInstance(getInstrumentation()).waitForIdle(); synchronized (sLock) { Assert.assertTrue(sTaskStackChangedCalled); } Assert.assertTrue(sActivityBResumed); } @Override public void onTaskStackChanged() throws RemoteException { synchronized (sLock) { sTaskStackChangedCalled = true; } } @Override public void onActivityPinned() throws RemoteException { } @Override public void onPinnedActivityRestartAttempt() throws RemoteException { } @Override public void onPinnedStackAnimationEnded() throws RemoteException { } @Override public void onActivityForcedResizable(String packageName, int taskId) throws RemoteException { } @Override public void onActivityDismissingDockedStack() throws RemoteException { } public static class ActivityA extends Activity { private boolean mActivityBLaunched = false; @Override protected void onPostResume() { super.onPostResume(); if (mActivityBLaunched) { return; } mActivityBLaunched = true; finish(); startActivity(new Intent(this, ActivityB.class)); } } public static class ActivityB extends Activity { @Override protected void onPostResume() { super.onPostResume(); synchronized (sLock) { sTaskStackChangedCalled = false; } sActivityBResumed = true; finish(); } } } Loading
services/core/java/com/android/server/am/ActivityStack.java +5 −0 Original line number Diff line number Diff line Loading @@ -1414,7 +1414,12 @@ final class ActivityStack { * this function updates the rest of our state to match that fact. */ private void completeResumeLocked(ActivityRecord next) { boolean wasVisible = next.visible; next.visible = true; if (!wasVisible) { // Visibility has changed, so take a note of it so we call the TaskStackChangedListener mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true; } next.idle = false; next.results = null; next.newIntents = null; Loading
services/tests/servicestests/Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ ifeq (true,$(EMMA_INSTRUMENT)) LOCAL_JACK_FLAGS := --multi-dex native endif # EMMA_INSTRUMENT_STATIC LOCAL_STATIC_JAVA_LIBRARIES += ub-uiautomator include $(BUILD_PACKAGE) ######################################################################### Loading
services/tests/servicestests/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.PACKET_KEEPALIVE_OFFLOAD" /> <uses-permission android:name="android.permission.GET_INTENT_SENDER_INTENT" /> <uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" /> <application> <uses-library android:name="android.test.runner" /> Loading Loading @@ -155,6 +156,9 @@ </intent-filter> </activity-alias> <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityA" /> <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityB" /> </application> <instrumentation Loading
services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java 0 → 100644 +123 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.server.am; import static android.support.test.InstrumentationRegistry.getInstrumentation; import android.app.Activity; import android.app.ActivityManagerNative; import android.app.IActivityManager; import android.app.ITaskStackListener; import android.content.Context; import android.content.Intent; import android.os.RemoteException; import android.support.test.InstrumentationRegistry; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.support.test.uiautomator.UiDevice; import com.android.internal.annotations.GuardedBy; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @MediumTest @RunWith(AndroidJUnit4.class) public class TaskStackChangedListenerTest extends ITaskStackListener.Stub { private IActivityManager mService; private static final Object sLock = new Object(); @GuardedBy("sLock") private static boolean sTaskStackChangedCalled; private static boolean sActivityBResumed; @Before public void setUp() throws Exception { mService = ActivityManagerNative.getDefault(); mService.registerTaskStackListener(this); } @Test public void testTaskStackChanged_afterFinish() throws Exception { Context ctx = InstrumentationRegistry.getContext(); ctx.startActivity(new Intent(ctx, ActivityA.class)); UiDevice.getInstance(getInstrumentation()).waitForIdle(); synchronized (sLock) { Assert.assertTrue(sTaskStackChangedCalled); } Assert.assertTrue(sActivityBResumed); } @Override public void onTaskStackChanged() throws RemoteException { synchronized (sLock) { sTaskStackChangedCalled = true; } } @Override public void onActivityPinned() throws RemoteException { } @Override public void onPinnedActivityRestartAttempt() throws RemoteException { } @Override public void onPinnedStackAnimationEnded() throws RemoteException { } @Override public void onActivityForcedResizable(String packageName, int taskId) throws RemoteException { } @Override public void onActivityDismissingDockedStack() throws RemoteException { } public static class ActivityA extends Activity { private boolean mActivityBLaunched = false; @Override protected void onPostResume() { super.onPostResume(); if (mActivityBLaunched) { return; } mActivityBLaunched = true; finish(); startActivity(new Intent(this, ActivityB.class)); } } public static class ActivityB extends Activity { @Override protected void onPostResume() { super.onPostResume(); synchronized (sLock) { sTaskStackChangedCalled = false; } sActivityBResumed = true; finish(); } } }