Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +3 −3 Original line number Diff line number Diff line Loading @@ -84,7 +84,6 @@ import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.PRE import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.SCREEN_COMPAT_PACKAGES; import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.ScreenCompatPackage.MODE; import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.ScreenCompatPackage.PACKAGE; import static com.android.server.wm.ActivityRecord.FINISH_RESULT_CANCELLED; import static com.android.server.wm.ActivityStack.REMOVE_TASK_MODE_DESTROYING; import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME; import static com.android.server.wm.ActivityStackSupervisor.ON_TOP; Loading Loading @@ -1618,8 +1617,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // Explicitly dismissing the activity so reset its relaunch flag. r.mRelaunchReason = RELAUNCH_REASON_NONE; } else { res = r.finishActivityLocked(resultCode, resultData, "app-request", true /* oomAdj */) != FINISH_RESULT_CANCELLED; r.finishActivityLocked(resultCode, resultData, "app-request", true /* oomAdj */); res = r.finishing; if (!res) { Slog.i(TAG, "Failed to finish by app-request"); } Loading services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.wm; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static org.junit.Assert.assertTrue; import android.app.Activity; import androidx.test.filters.MediumTest; import org.junit.Before; import org.junit.Test; /** * Tests for the {@link ActivityTaskManagerService} class. * * Build/Install/Run: * atest WmTests:ActivityTaskManagerServiceTests */ @MediumTest public class ActivityTaskManagerServiceTests extends ActivityTestsBase { @Before public void setUp() throws Exception { doReturn(false).when(mService).isBooting(); doReturn(true).when(mService).isBooted(); } /** Verify that activity is finished correctly upon request. */ @Test public void testActivityFinish() { final TestActivityStack stack = (TestActivityStack) new StackBuilder(mRootActivityContainer).build(); final ActivityRecord activity = stack.getChildAt(0).getTopActivity(); assertTrue("Activity must be finished", mService.finishActivity(activity.appToken, 0 /* resultCode */, null /* resultData */, Activity.DONT_FINISH_TASK_WITH_ACTIVITY)); assertTrue(activity.finishing); assertTrue("Duplicate activity finish request must also return 'true'", mService.finishActivity(activity.appToken, 0 /* resultCode */, null /* resultData */, Activity.DONT_FINISH_TASK_WITH_ACTIVITY)); } } Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +3 −3 Original line number Diff line number Diff line Loading @@ -84,7 +84,6 @@ import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.PRE import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.SCREEN_COMPAT_PACKAGES; import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.ScreenCompatPackage.MODE; import static com.android.server.am.ActivityManagerServiceDumpProcessesProto.ScreenCompatPackage.PACKAGE; import static com.android.server.wm.ActivityRecord.FINISH_RESULT_CANCELLED; import static com.android.server.wm.ActivityStack.REMOVE_TASK_MODE_DESTROYING; import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME; import static com.android.server.wm.ActivityStackSupervisor.ON_TOP; Loading Loading @@ -1618,8 +1617,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // Explicitly dismissing the activity so reset its relaunch flag. r.mRelaunchReason = RELAUNCH_REASON_NONE; } else { res = r.finishActivityLocked(resultCode, resultData, "app-request", true /* oomAdj */) != FINISH_RESULT_CANCELLED; r.finishActivityLocked(resultCode, resultData, "app-request", true /* oomAdj */); res = r.finishing; if (!res) { Slog.i(TAG, "Failed to finish by app-request"); } Loading
services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.wm; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static org.junit.Assert.assertTrue; import android.app.Activity; import androidx.test.filters.MediumTest; import org.junit.Before; import org.junit.Test; /** * Tests for the {@link ActivityTaskManagerService} class. * * Build/Install/Run: * atest WmTests:ActivityTaskManagerServiceTests */ @MediumTest public class ActivityTaskManagerServiceTests extends ActivityTestsBase { @Before public void setUp() throws Exception { doReturn(false).when(mService).isBooting(); doReturn(true).when(mService).isBooted(); } /** Verify that activity is finished correctly upon request. */ @Test public void testActivityFinish() { final TestActivityStack stack = (TestActivityStack) new StackBuilder(mRootActivityContainer).build(); final ActivityRecord activity = stack.getChildAt(0).getTopActivity(); assertTrue("Activity must be finished", mService.finishActivity(activity.appToken, 0 /* resultCode */, null /* resultData */, Activity.DONT_FINISH_TASK_WITH_ACTIVITY)); assertTrue(activity.finishing); assertTrue("Duplicate activity finish request must also return 'true'", mService.finishActivity(activity.appToken, 0 /* resultCode */, null /* resultData */, Activity.DONT_FINISH_TASK_WITH_ACTIVITY)); } }