am 6e0bd93a: am b1ff74c9: Merge "VirtualDisplay.Callbacks -> Callback" into lmp-dev
* commit '6e0bd93a2b7fc338c3ba64995cba309cd51035b6': VirtualDisplay.Callbacks -> Callback
This commit is contained in:
@@ -150,7 +150,7 @@ LOCAL_SRC_FILES += \
|
||||
core/java/android/hardware/ISerialManager.aidl \
|
||||
core/java/android/hardware/display/IDisplayManager.aidl \
|
||||
core/java/android/hardware/display/IDisplayManagerCallback.aidl \
|
||||
core/java/android/hardware/display/IVirtualDisplayCallbacks.aidl \
|
||||
core/java/android/hardware/display/IVirtualDisplayCallback.aidl \
|
||||
core/java/android/hardware/hdmi/IHdmiControlCallback.aidl \
|
||||
core/java/android/hardware/hdmi/IHdmiControlService.aidl \
|
||||
core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl \
|
||||
|
||||
@@ -13234,7 +13234,7 @@ package android.hardware.display {
|
||||
|
||||
public final class DisplayManager {
|
||||
method public android.hardware.display.VirtualDisplay createVirtualDisplay(java.lang.String, int, int, int, android.view.Surface, int);
|
||||
method public android.hardware.display.VirtualDisplay createVirtualDisplay(java.lang.String, int, int, int, android.view.Surface, int, android.hardware.display.VirtualDisplay.Callbacks, android.os.Handler);
|
||||
method public android.hardware.display.VirtualDisplay createVirtualDisplay(java.lang.String, int, int, int, android.view.Surface, int, android.hardware.display.VirtualDisplay.Callback, android.os.Handler);
|
||||
method public android.view.Display getDisplay(int);
|
||||
method public android.view.Display[] getDisplays();
|
||||
method public android.view.Display[] getDisplays(java.lang.String);
|
||||
@@ -13262,11 +13262,11 @@ package android.hardware.display {
|
||||
method public void setSurface(android.view.Surface);
|
||||
}
|
||||
|
||||
public static abstract class VirtualDisplay.Callbacks {
|
||||
ctor public VirtualDisplay.Callbacks();
|
||||
method public void onDisplayPaused();
|
||||
method public void onDisplayResumed();
|
||||
method public void onDisplayStopped();
|
||||
public static abstract class VirtualDisplay.Callback {
|
||||
ctor public VirtualDisplay.Callback();
|
||||
method public void onPaused();
|
||||
method public void onResumed();
|
||||
method public void onStopped();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16312,7 +16312,7 @@ package android.media.projection {
|
||||
|
||||
public final class MediaProjection {
|
||||
method public void addCallback(android.media.projection.MediaProjection.Callback, android.os.Handler);
|
||||
method public android.hardware.display.VirtualDisplay createVirtualDisplay(java.lang.String, int, int, int, int, android.view.Surface, android.hardware.display.VirtualDisplay.Callbacks, android.os.Handler);
|
||||
method public android.hardware.display.VirtualDisplay createVirtualDisplay(java.lang.String, int, int, int, int, android.view.Surface, android.hardware.display.VirtualDisplay.Callback, android.os.Handler);
|
||||
method public void removeCallback(android.media.projection.MediaProjection.Callback);
|
||||
method public void stop();
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ public final class DisplayManager {
|
||||
/**
|
||||
* Creates a virtual display.
|
||||
*
|
||||
* @see #createVirtualDisplay(String, int, int, int, Surface, int, VirtualDisplay.Callbacks)
|
||||
* @see #createVirtualDisplay(String, int, int, int, Surface, int, VirtualDisplay.Callback)
|
||||
*/
|
||||
public VirtualDisplay createVirtualDisplay(@NonNull String name,
|
||||
int width, int height, int densityDpi, @Nullable Surface surface, int flags) {
|
||||
@@ -513,7 +513,7 @@ public final class DisplayManager {
|
||||
* {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC}, {@link #VIRTUAL_DISPLAY_FLAG_PRESENTATION},
|
||||
* {@link #VIRTUAL_DISPLAY_FLAG_SECURE}, {@link #VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY},
|
||||
* or {@link #VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR}.
|
||||
* @param callbacks Callbacks to call when the state of the {@link VirtualDisplay} changes
|
||||
* @param callback Callback to call when the state of the {@link VirtualDisplay} changes
|
||||
* @param handler The handler on which the listener should be invoked, or null
|
||||
* if the listener should be invoked on the calling thread's looper.
|
||||
* @return The newly created virtual display, or null if the application could
|
||||
@@ -524,17 +524,17 @@ public final class DisplayManager {
|
||||
*/
|
||||
public VirtualDisplay createVirtualDisplay(@NonNull String name,
|
||||
int width, int height, int densityDpi, @Nullable Surface surface, int flags,
|
||||
@Nullable VirtualDisplay.Callbacks callbacks, @Nullable Handler handler) {
|
||||
@Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) {
|
||||
return createVirtualDisplay(null,
|
||||
name, width, height, densityDpi, surface, flags, callbacks, handler);
|
||||
name, width, height, densityDpi, surface, flags, callback, handler);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public VirtualDisplay createVirtualDisplay(@Nullable MediaProjection projection,
|
||||
@NonNull String name, int width, int height, int densityDpi, @Nullable Surface surface,
|
||||
int flags, @Nullable VirtualDisplay.Callbacks callbacks, @Nullable Handler handler) {
|
||||
int flags, @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) {
|
||||
return mGlobal.createVirtualDisplay(mContext, projection,
|
||||
name, width, height, densityDpi, surface, flags, callbacks, handler);
|
||||
name, width, height, densityDpi, surface, flags, callback, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -372,7 +372,7 @@ public final class DisplayManagerGlobal {
|
||||
|
||||
public VirtualDisplay createVirtualDisplay(Context context, MediaProjection projection,
|
||||
String name, int width, int height, int densityDpi, Surface surface, int flags,
|
||||
VirtualDisplay.Callbacks callbacks, Handler handler) {
|
||||
VirtualDisplay.Callback callback, Handler handler) {
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
throw new IllegalArgumentException("name must be non-null and non-empty");
|
||||
}
|
||||
@@ -381,7 +381,7 @@ public final class DisplayManagerGlobal {
|
||||
+ "greater than 0");
|
||||
}
|
||||
|
||||
VirtualDisplayCallbacks callbackWrapper = new VirtualDisplayCallbacks(callbacks, handler);
|
||||
VirtualDisplayCallback callbackWrapper = new VirtualDisplayCallback(callback, handler);
|
||||
IMediaProjection projectionToken = projection != null ? projection.getProjection() : null;
|
||||
int displayId;
|
||||
try {
|
||||
@@ -408,7 +408,7 @@ public final class DisplayManagerGlobal {
|
||||
return new VirtualDisplay(this, display, callbackWrapper, surface);
|
||||
}
|
||||
|
||||
public void setVirtualDisplaySurface(IVirtualDisplayCallbacks token, Surface surface) {
|
||||
public void setVirtualDisplaySurface(IVirtualDisplayCallback token, Surface surface) {
|
||||
try {
|
||||
mDm.setVirtualDisplaySurface(token, surface);
|
||||
} catch (RemoteException ex) {
|
||||
@@ -416,7 +416,7 @@ public final class DisplayManagerGlobal {
|
||||
}
|
||||
}
|
||||
|
||||
public void resizeVirtualDisplay(IVirtualDisplayCallbacks token,
|
||||
public void resizeVirtualDisplay(IVirtualDisplayCallback token,
|
||||
int width, int height, int densityDpi) {
|
||||
try {
|
||||
mDm.resizeVirtualDisplay(token, width, height, densityDpi);
|
||||
@@ -425,7 +425,7 @@ public final class DisplayManagerGlobal {
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseVirtualDisplay(IVirtualDisplayCallbacks token) {
|
||||
public void releaseVirtualDisplay(IVirtualDisplayCallback token) {
|
||||
try {
|
||||
mDm.releaseVirtualDisplay(token);
|
||||
} catch (RemoteException ex) {
|
||||
@@ -476,61 +476,61 @@ public final class DisplayManagerGlobal {
|
||||
}
|
||||
}
|
||||
|
||||
private final static class VirtualDisplayCallbacks extends IVirtualDisplayCallbacks.Stub {
|
||||
private VirtualDisplayCallbacksDelegate mDelegate;
|
||||
private final static class VirtualDisplayCallback extends IVirtualDisplayCallback.Stub {
|
||||
private VirtualDisplayCallbackDelegate mDelegate;
|
||||
|
||||
public VirtualDisplayCallbacks(VirtualDisplay.Callbacks callbacks, Handler handler) {
|
||||
if (callbacks != null) {
|
||||
mDelegate = new VirtualDisplayCallbacksDelegate(callbacks, handler);
|
||||
public VirtualDisplayCallback(VirtualDisplay.Callback callback, Handler handler) {
|
||||
if (callback != null) {
|
||||
mDelegate = new VirtualDisplayCallbackDelegate(callback, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void onDisplayPaused() {
|
||||
public void onPaused() {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.sendEmptyMessage(VirtualDisplayCallbacksDelegate.MSG_DISPLAY_PAUSED);
|
||||
mDelegate.sendEmptyMessage(VirtualDisplayCallbackDelegate.MSG_DISPLAY_PAUSED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void onDisplayResumed() {
|
||||
public void onResumed() {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.sendEmptyMessage(VirtualDisplayCallbacksDelegate.MSG_DISPLAY_RESUMED);
|
||||
mDelegate.sendEmptyMessage(VirtualDisplayCallbackDelegate.MSG_DISPLAY_RESUMED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void onDisplayStopped() {
|
||||
public void onStopped() {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.sendEmptyMessage(VirtualDisplayCallbacksDelegate.MSG_DISPLAY_STOPPED);
|
||||
mDelegate.sendEmptyMessage(VirtualDisplayCallbackDelegate.MSG_DISPLAY_STOPPED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final static class VirtualDisplayCallbacksDelegate extends Handler {
|
||||
private final static class VirtualDisplayCallbackDelegate extends Handler {
|
||||
public static final int MSG_DISPLAY_PAUSED = 0;
|
||||
public static final int MSG_DISPLAY_RESUMED = 1;
|
||||
public static final int MSG_DISPLAY_STOPPED = 2;
|
||||
|
||||
private final VirtualDisplay.Callbacks mCallbacks;
|
||||
private final VirtualDisplay.Callback mCallback;
|
||||
|
||||
public VirtualDisplayCallbacksDelegate(VirtualDisplay.Callbacks callbacks,
|
||||
public VirtualDisplayCallbackDelegate(VirtualDisplay.Callback callback,
|
||||
Handler handler) {
|
||||
super(handler != null ? handler.getLooper() : Looper.myLooper(), null, true /*async*/);
|
||||
mCallbacks = callbacks;
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_DISPLAY_PAUSED:
|
||||
mCallbacks.onDisplayPaused();
|
||||
mCallback.onPaused();
|
||||
break;
|
||||
case MSG_DISPLAY_RESUMED:
|
||||
mCallbacks.onDisplayResumed();
|
||||
mCallback.onResumed();
|
||||
break;
|
||||
case MSG_DISPLAY_STOPPED:
|
||||
mCallbacks.onDisplayStopped();
|
||||
mCallback.onStopped();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package android.hardware.display;
|
||||
|
||||
import android.hardware.display.IDisplayManagerCallback;
|
||||
import android.hardware.display.IVirtualDisplayCallbacks;
|
||||
import android.hardware.display.IVirtualDisplayCallback;
|
||||
import android.hardware.display.WifiDisplay;
|
||||
import android.hardware.display.WifiDisplayStatus;
|
||||
import android.media.projection.IMediaProjection;
|
||||
@@ -61,17 +61,17 @@ interface IDisplayManager {
|
||||
|
||||
// Requires CAPTURE_VIDEO_OUTPUT, CAPTURE_SECURE_VIDEO_OUTPUT, or an appropriate
|
||||
// MediaProjection token for certain combinations of flags.
|
||||
int createVirtualDisplay(in IVirtualDisplayCallbacks callbacks,
|
||||
int createVirtualDisplay(in IVirtualDisplayCallback callback,
|
||||
in IMediaProjection projectionToken, String packageName, String name,
|
||||
int width, int height, int densityDpi, in Surface surface, int flags);
|
||||
|
||||
// No permissions required, but must be same Uid as the creator.
|
||||
void resizeVirtualDisplay(in IVirtualDisplayCallbacks token,
|
||||
void resizeVirtualDisplay(in IVirtualDisplayCallback token,
|
||||
int width, int height, int densityDpi);
|
||||
|
||||
// No permissions required but must be same Uid as the creator.
|
||||
void setVirtualDisplaySurface(in IVirtualDisplayCallbacks token, in Surface surface);
|
||||
void setVirtualDisplaySurface(in IVirtualDisplayCallback token, in Surface surface);
|
||||
|
||||
// No permissions required but must be same Uid as the creator.
|
||||
void releaseVirtualDisplay(in IVirtualDisplayCallbacks token);
|
||||
void releaseVirtualDisplay(in IVirtualDisplayCallback token);
|
||||
}
|
||||
|
||||
@@ -16,20 +16,20 @@
|
||||
package android.hardware.display;
|
||||
|
||||
/** @hide */
|
||||
oneway interface IVirtualDisplayCallbacks {
|
||||
oneway interface IVirtualDisplayCallback {
|
||||
/**
|
||||
* Called when the virtual display video projection has been
|
||||
* paused by the system or when the surface has been detached
|
||||
* by the application by calling setSurface(null).
|
||||
* The surface will not receive any more buffers while paused.
|
||||
*/
|
||||
void onDisplayPaused();
|
||||
void onPaused();
|
||||
|
||||
/**
|
||||
* Called when the virtual display video projection has been
|
||||
* resumed after having been paused.
|
||||
*/
|
||||
void onDisplayResumed();
|
||||
void onResumed();
|
||||
|
||||
/**
|
||||
* Called when the virtual display video projection has been
|
||||
@@ -37,5 +37,5 @@ oneway interface IVirtualDisplayCallbacks {
|
||||
* and it will never be resumed. It is still the responsibility
|
||||
* of the application to release() the virtual display.
|
||||
*/
|
||||
void onDisplayStopped();
|
||||
void onStopped();
|
||||
}
|
||||
@@ -35,11 +35,11 @@ import android.view.Surface;
|
||||
public final class VirtualDisplay {
|
||||
private final DisplayManagerGlobal mGlobal;
|
||||
private final Display mDisplay;
|
||||
private IVirtualDisplayCallbacks mToken;
|
||||
private IVirtualDisplayCallback mToken;
|
||||
private Surface mSurface;
|
||||
|
||||
VirtualDisplay(DisplayManagerGlobal global, Display display,
|
||||
IVirtualDisplayCallbacks token, Surface surface) {
|
||||
IVirtualDisplayCallback token, Surface surface) {
|
||||
mGlobal = global;
|
||||
mDisplay = display;
|
||||
mToken = token;
|
||||
@@ -114,20 +114,20 @@ public final class VirtualDisplay {
|
||||
/**
|
||||
* Interface for receiving information about a {@link VirtualDisplay}'s state changes.
|
||||
*/
|
||||
public static abstract class Callbacks {
|
||||
public static abstract class Callback {
|
||||
/**
|
||||
* Called when the virtual display video projection has been
|
||||
* paused by the system or when the surface has been detached
|
||||
* by the application by calling setSurface(null).
|
||||
* The surface will not receive any more buffers while paused.
|
||||
*/
|
||||
public void onDisplayPaused() { }
|
||||
public void onPaused() { }
|
||||
|
||||
/**
|
||||
* Called when the virtual display video projection has been
|
||||
* resumed after having been paused.
|
||||
*/
|
||||
public void onDisplayResumed() { }
|
||||
public void onResumed() { }
|
||||
|
||||
/**
|
||||
* Called when the virtual display video projection has been
|
||||
@@ -135,6 +135,6 @@ public final class VirtualDisplay {
|
||||
* and it will never be resumed. It is still the responsibility
|
||||
* of the application to release() the virtual display.
|
||||
*/
|
||||
public void onDisplayStopped() { }
|
||||
public void onStopped() { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,12 +97,12 @@ public final class MediaProjection {
|
||||
*/
|
||||
public VirtualDisplay createVirtualDisplay(@NonNull String name,
|
||||
int width, int height, int dpi, boolean isSecure, @Nullable Surface surface,
|
||||
@Nullable VirtualDisplay.Callbacks callbacks, @Nullable Handler handler) {
|
||||
@Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) {
|
||||
DisplayManager dm = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
|
||||
int flags = isSecure ? DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE : 0;
|
||||
return dm.createVirtualDisplay(this, name, width, height, dpi, surface,
|
||||
flags | DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR |
|
||||
DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION, callbacks, handler);
|
||||
DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION, callback, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,21 +120,21 @@ public final class MediaProjection {
|
||||
* should be rendered, or null if there is none initially.
|
||||
* @param flags A combination of virtual display flags. See {@link DisplayManager} for the full
|
||||
* list of flags.
|
||||
* @param callbacks Callbacks to call when the virtual display's state
|
||||
* @param callback Callback to call when the virtual display's state
|
||||
* changes, or null if none.
|
||||
* @param handler The {@link android.os.Handler} on which the callback should be
|
||||
* invoked, or null if the callback should be invoked on the calling
|
||||
* thread's main {@link android.os.Looper}.
|
||||
*
|
||||
* @see android.hardware.display.DisplayManager#createVirtualDisplay(
|
||||
* String, int, int, int, int, Surface, VirtualDisplay.Callbacks, Handler)
|
||||
* String, int, int, int, int, Surface, VirtualDisplay.Callback, Handler)
|
||||
*/
|
||||
public VirtualDisplay createVirtualDisplay(@NonNull String name,
|
||||
int width, int height, int dpi, int flags, @Nullable Surface surface,
|
||||
@Nullable VirtualDisplay.Callbacks callbacks, @Nullable Handler handler) {
|
||||
@Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) {
|
||||
DisplayManager dm = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
|
||||
return dm.createVirtualDisplay(
|
||||
this, name, width, height, dpi, surface, flags, callbacks, handler);
|
||||
this, name, width, height, dpi, surface, flags, callback, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ import android.hardware.display.DisplayViewport;
|
||||
import android.hardware.display.DisplayManagerInternal.DisplayTransactionListener;
|
||||
import android.hardware.display.IDisplayManager;
|
||||
import android.hardware.display.IDisplayManagerCallback;
|
||||
import android.hardware.display.IVirtualDisplayCallbacks;
|
||||
import android.hardware.display.IVirtualDisplayCallback;
|
||||
import android.hardware.display.WifiDisplayStatus;
|
||||
import android.hardware.input.InputManagerInternal;
|
||||
import android.media.projection.IMediaProjection;
|
||||
@@ -491,7 +491,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
private int createVirtualDisplayInternal(IVirtualDisplayCallbacks callbacks,
|
||||
private int createVirtualDisplayInternal(IVirtualDisplayCallback callback,
|
||||
IMediaProjection projection, int callingUid, String packageName,
|
||||
String name, int width, int height, int densityDpi, Surface surface, int flags) {
|
||||
synchronized (mSyncRoot) {
|
||||
@@ -502,7 +502,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
|
||||
DisplayDevice device = mVirtualDisplayAdapter.createVirtualDisplayLocked(
|
||||
callbacks, projection, callingUid, packageName,
|
||||
callback, projection, callingUid, packageName,
|
||||
name, width, height, densityDpi, surface, flags);
|
||||
if (device == null) {
|
||||
return -1;
|
||||
@@ -517,7 +517,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
// Something weird happened and the logical display was not created.
|
||||
Slog.w(TAG, "Rejecting request to create virtual display "
|
||||
+ "because the logical display was not created.");
|
||||
mVirtualDisplayAdapter.releaseVirtualDisplayLocked(callbacks.asBinder());
|
||||
mVirtualDisplayAdapter.releaseVirtualDisplayLocked(callback.asBinder());
|
||||
handleDisplayDeviceRemovedLocked(device);
|
||||
}
|
||||
return -1;
|
||||
@@ -1251,14 +1251,14 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public int createVirtualDisplay(IVirtualDisplayCallbacks callbacks,
|
||||
public int createVirtualDisplay(IVirtualDisplayCallback callback,
|
||||
IMediaProjection projection, String packageName, String name,
|
||||
int width, int height, int densityDpi, Surface surface, int flags) {
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
if (!validatePackageName(callingUid, packageName)) {
|
||||
throw new SecurityException("packageName must match the calling uid");
|
||||
}
|
||||
if (callbacks == null) {
|
||||
if (callback == null) {
|
||||
throw new IllegalArgumentException("appToken must not be null");
|
||||
}
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
@@ -1306,7 +1306,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return createVirtualDisplayInternal(callbacks, projection, callingUid,
|
||||
return createVirtualDisplayInternal(callback, projection, callingUid,
|
||||
packageName, name, width, height, densityDpi, surface, flags);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
@@ -1314,31 +1314,31 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void resizeVirtualDisplay(IVirtualDisplayCallbacks callbacks,
|
||||
public void resizeVirtualDisplay(IVirtualDisplayCallback callback,
|
||||
int width, int height, int densityDpi) {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
resizeVirtualDisplayInternal(callbacks.asBinder(), width, height, densityDpi);
|
||||
resizeVirtualDisplayInternal(callback.asBinder(), width, height, densityDpi);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void setVirtualDisplaySurface(IVirtualDisplayCallbacks callbacks, Surface surface) {
|
||||
public void setVirtualDisplaySurface(IVirtualDisplayCallback callback, Surface surface) {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
setVirtualDisplaySurfaceInternal(callbacks.asBinder(), surface);
|
||||
setVirtualDisplaySurfaceInternal(callback.asBinder(), surface);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void releaseVirtualDisplay(IVirtualDisplayCallbacks callbacks) {
|
||||
public void releaseVirtualDisplay(IVirtualDisplayCallback callback) {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
releaseVirtualDisplayInternal(callbacks.asBinder());
|
||||
releaseVirtualDisplayInternal(callback.asBinder());
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.android.server.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.display.IVirtualDisplayCallbacks;
|
||||
import android.hardware.display.IVirtualDisplayCallback;
|
||||
import android.media.projection.IMediaProjection;
|
||||
import android.media.projection.IMediaProjectionCallback;
|
||||
import android.os.Handler;
|
||||
@@ -55,15 +55,15 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
||||
mHandler = handler;
|
||||
}
|
||||
|
||||
public DisplayDevice createVirtualDisplayLocked(IVirtualDisplayCallbacks callbacks,
|
||||
public DisplayDevice createVirtualDisplayLocked(IVirtualDisplayCallback callback,
|
||||
IMediaProjection projection, int ownerUid, String ownerPackageName,
|
||||
String name, int width, int height, int densityDpi, Surface surface, int flags) {
|
||||
boolean secure = (flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE) != 0;
|
||||
IBinder appToken = callbacks.asBinder();
|
||||
IBinder appToken = callback.asBinder();
|
||||
IBinder displayToken = SurfaceControl.createDisplay(name, secure);
|
||||
VirtualDisplayDevice device = new VirtualDisplayDevice(displayToken, appToken,
|
||||
ownerUid, ownerPackageName, name, width, height, densityDpi, surface, flags,
|
||||
new Callbacks(callbacks, mHandler));
|
||||
new Callback(callback, mHandler));
|
||||
|
||||
mVirtualDisplayDevices.put(appToken, device);
|
||||
|
||||
@@ -139,7 +139,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
||||
final String mOwnerPackageName;
|
||||
final String mName;
|
||||
private final int mFlags;
|
||||
private final Callbacks mCallbacks;
|
||||
private final Callback mCallback;
|
||||
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
@@ -153,7 +153,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
||||
public VirtualDisplayDevice(IBinder displayToken, IBinder appToken,
|
||||
int ownerUid, String ownerPackageName,
|
||||
String name, int width, int height, int densityDpi, Surface surface, int flags,
|
||||
Callbacks callbacks) {
|
||||
Callback callback) {
|
||||
super(VirtualDisplayAdapter.this, displayToken);
|
||||
mAppToken = appToken;
|
||||
mOwnerUid = ownerUid;
|
||||
@@ -164,7 +164,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
||||
mDensityDpi = densityDpi;
|
||||
mSurface = surface;
|
||||
mFlags = flags;
|
||||
mCallbacks = callbacks;
|
||||
mCallback = callback;
|
||||
mDisplayState = Display.STATE_UNKNOWN;
|
||||
mPendingChanges |= PENDING_SURFACE_CHANGE;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
||||
mSurface = null;
|
||||
}
|
||||
SurfaceControl.destroyDisplay(getDisplayTokenLocked());
|
||||
mCallbacks.dispatchDisplayStopped();
|
||||
mCallback.dispatchDisplayStopped();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,9 +192,9 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
||||
if (state != mDisplayState) {
|
||||
mDisplayState = state;
|
||||
if (state == Display.STATE_OFF) {
|
||||
mCallbacks.dispatchDisplayPaused();
|
||||
mCallback.dispatchDisplayPaused();
|
||||
} else {
|
||||
mCallbacks.dispatchDisplayResumed();
|
||||
mCallback.dispatchDisplayResumed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,16 +287,16 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Callbacks extends Handler {
|
||||
private static class Callback extends Handler {
|
||||
private static final int MSG_ON_DISPLAY_PAUSED = 0;
|
||||
private static final int MSG_ON_DISPLAY_RESUMED = 1;
|
||||
private static final int MSG_ON_DISPLAY_STOPPED = 2;
|
||||
|
||||
private final IVirtualDisplayCallbacks mCallbacks;
|
||||
private final IVirtualDisplayCallback mCallback;
|
||||
|
||||
public Callbacks(IVirtualDisplayCallbacks callbacks, Handler handler) {
|
||||
public Callback(IVirtualDisplayCallback callback, Handler handler) {
|
||||
super(handler.getLooper());
|
||||
mCallbacks = callbacks;
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -304,13 +304,13 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
|
||||
try {
|
||||
switch (msg.what) {
|
||||
case MSG_ON_DISPLAY_PAUSED:
|
||||
mCallbacks.onDisplayPaused();
|
||||
mCallback.onPaused();
|
||||
break;
|
||||
case MSG_ON_DISPLAY_RESUMED:
|
||||
mCallbacks.onDisplayResumed();
|
||||
mCallback.onResumed();
|
||||
break;
|
||||
case MSG_ON_DISPLAY_STOPPED:
|
||||
mCallbacks.onDisplayStopped();
|
||||
mCallback.onStopped();
|
||||
break;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
|
||||
Reference in New Issue
Block a user