Loading core/java/android/view/SurfaceControl.java +3 −2 Original line number Diff line number Diff line Loading @@ -2830,7 +2830,7 @@ public final class SurfaceControl implements Parcelable { * * @hide */ public static SurfaceControl mirrorSurface(SurfaceControl mirrorOf) { public static SurfaceControl mirrorSurface(@NonNull SurfaceControl mirrorOf) { return mirrorSurface(mirrorOf, null); } Loading Loading @@ -2861,7 +2861,8 @@ public final class SurfaceControl implements Parcelable { * * @hide */ public static SurfaceControl mirrorSurface(SurfaceControl mirrorOf, SurfaceControl stopAt) { public static SurfaceControl mirrorSurface(@NonNull SurfaceControl mirrorOf, SurfaceControl stopAt) { long stopAtObj = stopAt != null ? stopAt.mNativeObject : 0; long nativeObj = nativeMirrorSurface(mirrorOf.mNativeObject, stopAtObj); SurfaceControl sc = new SurfaceControl(); Loading core/jni/android_view_SurfaceControl.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -2182,7 +2182,9 @@ static jlong nativeMirrorSurface(JNIEnv* env, jclass clazz, jlong mirrorOfObj, j SurfaceControl *mirrorOf = reinterpret_cast<SurfaceControl*>(mirrorOfObj); SurfaceControl* stopAt = reinterpret_cast<SurfaceControl*>(stopAtObj); sp<SurfaceControl> surface = client->mirrorSurface(mirrorOf, stopAt); if (surface == nullptr) { return 0; } surface->incStrong((void *)nativeCreate); return reinterpret_cast<jlong>(surface.get()); } Loading core/tests/coretests/src/android/view/OWNERS +2 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ per-file *View* = file:/services/core/java/com/android/server/wm/OWNERS per-file *Visibility* = file:/services/core/java/com/android/server/wm/OWNERS per-file *Window* = file:/services/core/java/com/android/server/wm/OWNERS per-file *ContentRecord* = file:/services/core/java/com/android/server/wm/OWNERS per-file SurfaceControlTest.java = file:/services/core/java/com/android/server/wm/OWNERS # Scroll Capture per-file *ScrollCapture*.java = file:/packages/SystemUI/src/com/android/systemui/screenshot/OWNERS Loading core/tests/coretests/src/android/view/SurfaceControlTest.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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 android.view; import static org.junit.Assert.assertFalse; import android.platform.test.annotations.Presubmit; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @Presubmit @RunWith(AndroidJUnit4.class) public class SurfaceControlTest { @Test public void testMirrorSurface_invalidMirrorRoot() { SurfaceControl invalidSurfaceControl = new SurfaceControl(); SurfaceControl mirror = SurfaceControl.mirrorSurface(invalidSurfaceControl); assertFalse(mirror.isValid()); } } Loading
core/java/android/view/SurfaceControl.java +3 −2 Original line number Diff line number Diff line Loading @@ -2830,7 +2830,7 @@ public final class SurfaceControl implements Parcelable { * * @hide */ public static SurfaceControl mirrorSurface(SurfaceControl mirrorOf) { public static SurfaceControl mirrorSurface(@NonNull SurfaceControl mirrorOf) { return mirrorSurface(mirrorOf, null); } Loading Loading @@ -2861,7 +2861,8 @@ public final class SurfaceControl implements Parcelable { * * @hide */ public static SurfaceControl mirrorSurface(SurfaceControl mirrorOf, SurfaceControl stopAt) { public static SurfaceControl mirrorSurface(@NonNull SurfaceControl mirrorOf, SurfaceControl stopAt) { long stopAtObj = stopAt != null ? stopAt.mNativeObject : 0; long nativeObj = nativeMirrorSurface(mirrorOf.mNativeObject, stopAtObj); SurfaceControl sc = new SurfaceControl(); Loading
core/jni/android_view_SurfaceControl.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -2182,7 +2182,9 @@ static jlong nativeMirrorSurface(JNIEnv* env, jclass clazz, jlong mirrorOfObj, j SurfaceControl *mirrorOf = reinterpret_cast<SurfaceControl*>(mirrorOfObj); SurfaceControl* stopAt = reinterpret_cast<SurfaceControl*>(stopAtObj); sp<SurfaceControl> surface = client->mirrorSurface(mirrorOf, stopAt); if (surface == nullptr) { return 0; } surface->incStrong((void *)nativeCreate); return reinterpret_cast<jlong>(surface.get()); } Loading
core/tests/coretests/src/android/view/OWNERS +2 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ per-file *View* = file:/services/core/java/com/android/server/wm/OWNERS per-file *Visibility* = file:/services/core/java/com/android/server/wm/OWNERS per-file *Window* = file:/services/core/java/com/android/server/wm/OWNERS per-file *ContentRecord* = file:/services/core/java/com/android/server/wm/OWNERS per-file SurfaceControlTest.java = file:/services/core/java/com/android/server/wm/OWNERS # Scroll Capture per-file *ScrollCapture*.java = file:/packages/SystemUI/src/com/android/systemui/screenshot/OWNERS Loading
core/tests/coretests/src/android/view/SurfaceControlTest.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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 android.view; import static org.junit.Assert.assertFalse; import android.platform.test.annotations.Presubmit; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @Presubmit @RunWith(AndroidJUnit4.class) public class SurfaceControlTest { @Test public void testMirrorSurface_invalidMirrorRoot() { SurfaceControl invalidSurfaceControl = new SurfaceControl(); SurfaceControl mirror = SurfaceControl.mirrorSurface(invalidSurfaceControl); assertFalse(mirror.isValid()); } }