Loading core/java/android/view/SurfaceControl.java +23 −15 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ public class SurfaceControl { private static native IBinder nativeGetBuiltInDisplay(int physicalDisplayId); private static native IBinder nativeCreateDisplay(String name, boolean secure); private static native void nativeDestroyDisplay(IBinder displayToken); private static native void nativeSetDisplaySurface( IBinder displayToken, int nativeSurfaceObject); private static native void nativeSetDisplayLayerStack( Loading Loading @@ -513,6 +514,13 @@ public class SurfaceControl { return nativeCreateDisplay(name, secure); } public static void destroyDisplay(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } nativeDestroyDisplay(displayToken); } public static IBinder getBuiltInDisplay(int builtInDisplayId) { return nativeGetBuiltInDisplay(builtInDisplayId); } Loading core/jni/android_view_SurfaceControl.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -333,6 +333,12 @@ static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj, return javaObjectForIBinder(env, token); } static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; SurfaceComposerClient::destroyDisplay(token); } static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz, jobject tokenObj, jint nativeSurfaceObject) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); Loading Loading @@ -441,6 +447,8 @@ static JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeGetBuiltInDisplay }, {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;", (void*)nativeCreateDisplay }, {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V", (void*)nativeDestroyDisplay }, {"nativeSetDisplaySurface", "(Landroid/os/IBinder;I)V", (void*)nativeSetDisplaySurface }, {"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V", Loading services/java/com/android/server/display/DisplayManagerService.java +0 −12 Original line number Diff line number Diff line Loading @@ -154,9 +154,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { // List of all currently connected display devices. private final ArrayList<DisplayDevice> mDisplayDevices = new ArrayList<DisplayDevice>(); // List of all removed display devices. private final ArrayList<DisplayDevice> mRemovedDisplayDevices = new ArrayList<DisplayDevice>(); // List of all logical displays indexed by logical display id. private final SparseArray<LogicalDisplay> mLogicalDisplays = new SparseArray<LogicalDisplay>(); Loading Loading @@ -798,7 +795,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { Slog.i(TAG, "Display device removed: " + device.getDisplayDeviceInfoLocked()); mRemovedDisplayDevices.add(device); updateLogicalDisplaysLocked(); scheduleTraversalLocked(false); } Loading Loading @@ -900,14 +896,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { } private void performTraversalInTransactionLocked() { // Perform one last traversal for each removed display device. final int removedCount = mRemovedDisplayDevices.size(); for (int i = 0; i < removedCount; i++) { DisplayDevice device = mRemovedDisplayDevices.get(i); device.performTraversalInTransactionLocked(); } mRemovedDisplayDevices.clear(); // Clear all viewports before configuring displays so that we can keep // track of which ones we have configured. clearViewportsLocked(); Loading services/java/com/android/server/display/OverlayDisplayAdapter.java +7 −11 Original line number Diff line number Diff line Loading @@ -211,11 +211,13 @@ final class OverlayDisplayAdapter extends DisplayAdapter { mSurfaceTexture = surfaceTexture; } public void clearSurfaceTextureLocked() { if (mSurfaceTexture != null) { public void destroyLocked() { mSurfaceTexture = null; if (mSurface != null) { mSurface.release(); mSurface = null; } sendTraversalRequestLocked(); SurfaceControl.destroyDisplay(getDisplayTokenLocked()); } @Override Loading @@ -225,12 +227,6 @@ final class OverlayDisplayAdapter extends DisplayAdapter { mSurface = new Surface(mSurfaceTexture); } setSurfaceInTransactionLocked(mSurface); } else { setSurfaceInTransactionLocked(null); if (mSurface != null) { mSurface.destroy(); mSurface = null; } } } Loading Loading @@ -307,7 +303,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter { public void onWindowDestroyed() { synchronized (getSyncRoot()) { if (mDevice != null) { mDevice.clearSurfaceTextureLocked(); mDevice.destroyLocked(); sendDisplayDeviceEventLocked(mDevice, DISPLAY_DEVICE_EVENT_REMOVED); } } Loading services/java/com/android/server/display/VirtualDisplayAdapter.java +12 −10 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { try { appToken.linkToDeath(device, 0); } catch (RemoteException ex) { device.releaseLocked(); device.destroyLocked(); return null; } Loading @@ -72,6 +72,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { public DisplayDevice releaseVirtualDisplayLocked(IBinder appToken) { VirtualDisplayDevice device = mVirtualDisplayDevices.remove(appToken); if (device != null) { device.destroyLocked(); appToken.unlinkToDeath(device, 0); } Loading @@ -85,6 +86,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { if (device != null) { Slog.i(TAG, "Virtual display device released because application token died: " + device.mOwnerPackageName); device.destroyLocked(); sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_REMOVED); } } Loading @@ -100,7 +102,6 @@ final class VirtualDisplayAdapter extends DisplayAdapter { private final int mDensityDpi; private final int mFlags; private boolean mReleased; private Surface mSurface; private DisplayDeviceInfo mInfo; Loading @@ -122,25 +123,26 @@ final class VirtualDisplayAdapter extends DisplayAdapter { @Override public void binderDied() { synchronized (getSyncRoot()) { if (!mReleased) { if (mSurface != null) { handleBinderDiedLocked(mAppToken); } } } public void releaseLocked() { mReleased = true; sendTraversalRequestLocked(); public void destroyLocked() { if (mSurface != null) { mSurface.release(); mSurface = null; } SurfaceControl.destroyDisplay(getDisplayTokenLocked()); } @Override public void performTraversalInTransactionLocked() { if (mReleased && mSurface != null) { mSurface.destroy(); mSurface = null; } if (mSurface != null) { setSurfaceInTransactionLocked(mSurface); } } @Override public DisplayDeviceInfo getDisplayDeviceInfoLocked() { Loading Loading
core/java/android/view/SurfaceControl.java +23 −15 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ public class SurfaceControl { private static native IBinder nativeGetBuiltInDisplay(int physicalDisplayId); private static native IBinder nativeCreateDisplay(String name, boolean secure); private static native void nativeDestroyDisplay(IBinder displayToken); private static native void nativeSetDisplaySurface( IBinder displayToken, int nativeSurfaceObject); private static native void nativeSetDisplayLayerStack( Loading Loading @@ -513,6 +514,13 @@ public class SurfaceControl { return nativeCreateDisplay(name, secure); } public static void destroyDisplay(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } nativeDestroyDisplay(displayToken); } public static IBinder getBuiltInDisplay(int builtInDisplayId) { return nativeGetBuiltInDisplay(builtInDisplayId); } Loading
core/jni/android_view_SurfaceControl.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -333,6 +333,12 @@ static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj, return javaObjectForIBinder(env, token); } static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; SurfaceComposerClient::destroyDisplay(token); } static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz, jobject tokenObj, jint nativeSurfaceObject) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); Loading Loading @@ -441,6 +447,8 @@ static JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeGetBuiltInDisplay }, {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;", (void*)nativeCreateDisplay }, {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V", (void*)nativeDestroyDisplay }, {"nativeSetDisplaySurface", "(Landroid/os/IBinder;I)V", (void*)nativeSetDisplaySurface }, {"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V", Loading
services/java/com/android/server/display/DisplayManagerService.java +0 −12 Original line number Diff line number Diff line Loading @@ -154,9 +154,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { // List of all currently connected display devices. private final ArrayList<DisplayDevice> mDisplayDevices = new ArrayList<DisplayDevice>(); // List of all removed display devices. private final ArrayList<DisplayDevice> mRemovedDisplayDevices = new ArrayList<DisplayDevice>(); // List of all logical displays indexed by logical display id. private final SparseArray<LogicalDisplay> mLogicalDisplays = new SparseArray<LogicalDisplay>(); Loading Loading @@ -798,7 +795,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { Slog.i(TAG, "Display device removed: " + device.getDisplayDeviceInfoLocked()); mRemovedDisplayDevices.add(device); updateLogicalDisplaysLocked(); scheduleTraversalLocked(false); } Loading Loading @@ -900,14 +896,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { } private void performTraversalInTransactionLocked() { // Perform one last traversal for each removed display device. final int removedCount = mRemovedDisplayDevices.size(); for (int i = 0; i < removedCount; i++) { DisplayDevice device = mRemovedDisplayDevices.get(i); device.performTraversalInTransactionLocked(); } mRemovedDisplayDevices.clear(); // Clear all viewports before configuring displays so that we can keep // track of which ones we have configured. clearViewportsLocked(); Loading
services/java/com/android/server/display/OverlayDisplayAdapter.java +7 −11 Original line number Diff line number Diff line Loading @@ -211,11 +211,13 @@ final class OverlayDisplayAdapter extends DisplayAdapter { mSurfaceTexture = surfaceTexture; } public void clearSurfaceTextureLocked() { if (mSurfaceTexture != null) { public void destroyLocked() { mSurfaceTexture = null; if (mSurface != null) { mSurface.release(); mSurface = null; } sendTraversalRequestLocked(); SurfaceControl.destroyDisplay(getDisplayTokenLocked()); } @Override Loading @@ -225,12 +227,6 @@ final class OverlayDisplayAdapter extends DisplayAdapter { mSurface = new Surface(mSurfaceTexture); } setSurfaceInTransactionLocked(mSurface); } else { setSurfaceInTransactionLocked(null); if (mSurface != null) { mSurface.destroy(); mSurface = null; } } } Loading Loading @@ -307,7 +303,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter { public void onWindowDestroyed() { synchronized (getSyncRoot()) { if (mDevice != null) { mDevice.clearSurfaceTextureLocked(); mDevice.destroyLocked(); sendDisplayDeviceEventLocked(mDevice, DISPLAY_DEVICE_EVENT_REMOVED); } } Loading
services/java/com/android/server/display/VirtualDisplayAdapter.java +12 −10 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { try { appToken.linkToDeath(device, 0); } catch (RemoteException ex) { device.releaseLocked(); device.destroyLocked(); return null; } Loading @@ -72,6 +72,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { public DisplayDevice releaseVirtualDisplayLocked(IBinder appToken) { VirtualDisplayDevice device = mVirtualDisplayDevices.remove(appToken); if (device != null) { device.destroyLocked(); appToken.unlinkToDeath(device, 0); } Loading @@ -85,6 +86,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter { if (device != null) { Slog.i(TAG, "Virtual display device released because application token died: " + device.mOwnerPackageName); device.destroyLocked(); sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_REMOVED); } } Loading @@ -100,7 +102,6 @@ final class VirtualDisplayAdapter extends DisplayAdapter { private final int mDensityDpi; private final int mFlags; private boolean mReleased; private Surface mSurface; private DisplayDeviceInfo mInfo; Loading @@ -122,25 +123,26 @@ final class VirtualDisplayAdapter extends DisplayAdapter { @Override public void binderDied() { synchronized (getSyncRoot()) { if (!mReleased) { if (mSurface != null) { handleBinderDiedLocked(mAppToken); } } } public void releaseLocked() { mReleased = true; sendTraversalRequestLocked(); public void destroyLocked() { if (mSurface != null) { mSurface.release(); mSurface = null; } SurfaceControl.destroyDisplay(getDisplayTokenLocked()); } @Override public void performTraversalInTransactionLocked() { if (mReleased && mSurface != null) { mSurface.destroy(); mSurface = null; } if (mSurface != null) { setSurfaceInTransactionLocked(mSurface); } } @Override public DisplayDeviceInfo getDisplayDeviceInfoLocked() { Loading