Loading services/core/java/com/android/server/wm/TaskSnapshotController.java +2 −1 Original line number Diff line number Diff line Loading @@ -369,7 +369,8 @@ class TaskSnapshotController { SurfaceControl[] excludeLayers; final WindowState imeWindow = task.getDisplayContent().mInputMethodWindow; // Exclude IME window snapshot when IME isn't proper to attach to app. if (imeWindow != null && !task.getDisplayContent().isImeAttachedToApp()) { if (imeWindow != null && imeWindow.getSurfaceControl() != null && !task.getDisplayContent().isImeAttachedToApp()) { excludeLayers = new SurfaceControl[1]; excludeLayers[0] = imeWindow.getSurfaceControl(); } else { Loading services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.app.WindowConfiguration; Loading Loading @@ -183,6 +185,24 @@ public class TaskSnapshotControllerTest extends WindowTestsBase { } } @UseTestDisplay(addWindows = {W_ACTIVITY, W_INPUT_METHOD}) @Test public void testCreateTaskSnapshotWithExcludingIme() { Task task = mAppWindow.mActivityRecord.getTask(); spyOn(task); spyOn(mDisplayContent); when(task.getDisplayContent().isImeAttachedToApp()).thenReturn(false); // Intentionally set the SurfaceControl of input method window as null. mDisplayContent.mInputMethodWindow.setSurfaceControl(null); // Verify no NPE happens when calling createTaskSnapshot. try { mWm.mTaskSnapshotController.createTaskSnapshot(mAppWindow.mActivityRecord.getTask(), 1f /* scaleFraction */, PixelFormat.UNKNOWN, null /* outTaskSize */); } catch (NullPointerException e) { fail("There should be no exception when calling createTaskSnapshot"); } } @UseTestDisplay(addWindows = W_ACTIVITY) @Test public void testPrepareTaskSnapshot() { Loading Loading
services/core/java/com/android/server/wm/TaskSnapshotController.java +2 −1 Original line number Diff line number Diff line Loading @@ -369,7 +369,8 @@ class TaskSnapshotController { SurfaceControl[] excludeLayers; final WindowState imeWindow = task.getDisplayContent().mInputMethodWindow; // Exclude IME window snapshot when IME isn't proper to attach to app. if (imeWindow != null && !task.getDisplayContent().isImeAttachedToApp()) { if (imeWindow != null && imeWindow.getSurfaceControl() != null && !task.getDisplayContent().isImeAttachedToApp()) { excludeLayers = new SurfaceControl[1]; excludeLayers[0] = imeWindow.getSurfaceControl(); } else { Loading
services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.app.WindowConfiguration; Loading Loading @@ -183,6 +185,24 @@ public class TaskSnapshotControllerTest extends WindowTestsBase { } } @UseTestDisplay(addWindows = {W_ACTIVITY, W_INPUT_METHOD}) @Test public void testCreateTaskSnapshotWithExcludingIme() { Task task = mAppWindow.mActivityRecord.getTask(); spyOn(task); spyOn(mDisplayContent); when(task.getDisplayContent().isImeAttachedToApp()).thenReturn(false); // Intentionally set the SurfaceControl of input method window as null. mDisplayContent.mInputMethodWindow.setSurfaceControl(null); // Verify no NPE happens when calling createTaskSnapshot. try { mWm.mTaskSnapshotController.createTaskSnapshot(mAppWindow.mActivityRecord.getTask(), 1f /* scaleFraction */, PixelFormat.UNKNOWN, null /* outTaskSize */); } catch (NullPointerException e) { fail("There should be no exception when calling createTaskSnapshot"); } } @UseTestDisplay(addWindows = W_ACTIVITY) @Test public void testPrepareTaskSnapshot() { Loading