Methods Summary |
---|
public void | connectWifiDisplay(java.lang.String deviceAddress)
if (deviceAddress == null) {
throw new IllegalArgumentException("deviceAddress must not be null");
}
try {
mDm.connectWifiDisplay(deviceAddress);
} catch (RemoteException ex) {
Log.e(TAG, "Failed to connect to Wifi display " + deviceAddress + ".", ex);
}
|
public VirtualDisplay | createVirtualDisplay(android.content.Context context, android.media.projection.MediaProjection projection, java.lang.String name, int width, int height, int densityDpi, android.view.Surface surface, int flags, VirtualDisplay.Callback callback, android.os.Handler handler)
if (TextUtils.isEmpty(name)) {
throw new IllegalArgumentException("name must be non-null and non-empty");
}
if (width <= 0 || height <= 0 || densityDpi <= 0) {
throw new IllegalArgumentException("width, height, and densityDpi must be "
+ "greater than 0");
}
VirtualDisplayCallback callbackWrapper = new VirtualDisplayCallback(callback, handler);
IMediaProjection projectionToken = projection != null ? projection.getProjection() : null;
int displayId;
try {
displayId = mDm.createVirtualDisplay(callbackWrapper, projectionToken,
context.getPackageName(), name, width, height, densityDpi, surface, flags);
} catch (RemoteException ex) {
Log.e(TAG, "Could not create virtual display: " + name, ex);
return null;
}
if (displayId < 0) {
Log.e(TAG, "Could not create virtual display: " + name);
return null;
}
Display display = getRealDisplay(displayId);
if (display == null) {
Log.wtf(TAG, "Could not obtain display info for newly created "
+ "virtual display: " + name);
try {
mDm.releaseVirtualDisplay(callbackWrapper);
} catch (RemoteException ex) {
}
return null;
}
return new VirtualDisplay(this, display, callbackWrapper, surface);
|
public void | disconnectWifiDisplay()
try {
mDm.disconnectWifiDisplay();
} catch (RemoteException ex) {
Log.e(TAG, "Failed to disconnect from Wifi display.", ex);
}
|
private int | findDisplayListenerLocked(android.hardware.display.DisplayManager.DisplayListener listener)
final int numListeners = mDisplayListeners.size();
for (int i = 0; i < numListeners; i++) {
if (mDisplayListeners.get(i).mListener == listener) {
return i;
}
}
return -1;
|
public void | forgetWifiDisplay(java.lang.String deviceAddress)
if (deviceAddress == null) {
throw new IllegalArgumentException("deviceAddress must not be null");
}
try {
mDm.forgetWifiDisplay(deviceAddress);
} catch (RemoteException ex) {
Log.e(TAG, "Failed to forget Wifi display.", ex);
}
|
public android.view.Display | getCompatibleDisplay(int displayId, android.view.DisplayAdjustments daj)Gets information about a logical display.
The display metrics may be adjusted to provide compatibility
for legacy applications or limited screen areas.
DisplayInfo displayInfo = getDisplayInfo(displayId);
if (displayInfo == null) {
return null;
}
return new Display(this, displayId, displayInfo, daj);
|
public int[] | getDisplayIds()Gets all currently valid logical display ids.
try {
synchronized (mLock) {
if (USE_CACHE) {
if (mDisplayIdCache != null) {
return mDisplayIdCache;
}
}
int[] displayIds = mDm.getDisplayIds();
if (USE_CACHE) {
mDisplayIdCache = displayIds;
}
registerCallbackIfNeededLocked();
return displayIds;
}
} catch (RemoteException ex) {
Log.e(TAG, "Could not get display ids from display manager.", ex);
return new int[] { Display.DEFAULT_DISPLAY };
}
|
public android.view.DisplayInfo | getDisplayInfo(int displayId)Get information about a particular logical display.
try {
synchronized (mLock) {
DisplayInfo info;
if (USE_CACHE) {
info = mDisplayInfoCache.get(displayId);
if (info != null) {
return info;
}
}
info = mDm.getDisplayInfo(displayId);
if (info == null) {
return null;
}
if (USE_CACHE) {
mDisplayInfoCache.put(displayId, info);
}
registerCallbackIfNeededLocked();
if (DEBUG) {
Log.d(TAG, "getDisplayInfo: displayId=" + displayId + ", info=" + info);
}
return info;
}
} catch (RemoteException ex) {
Log.e(TAG, "Could not get display information from display manager.", ex);
return null;
}
|
public static android.hardware.display.DisplayManagerGlobal | getInstance()Gets an instance of the display manager global singleton.
synchronized (DisplayManagerGlobal.class) {
if (sInstance == null) {
IBinder b = ServiceManager.getService(Context.DISPLAY_SERVICE);
if (b != null) {
sInstance = new DisplayManagerGlobal(IDisplayManager.Stub.asInterface(b));
}
}
return sInstance;
}
|
public android.view.Display | getRealDisplay(int displayId)Gets information about a logical display without applying any compatibility metrics.
return getCompatibleDisplay(displayId, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
|
public android.view.Display | getRealDisplay(int displayId, android.os.IBinder token)Gets information about a logical display without applying any compatibility metrics.
return getCompatibleDisplay(displayId, new DisplayAdjustments(token));
|
public WifiDisplayStatus | getWifiDisplayStatus()
try {
return mDm.getWifiDisplayStatus();
} catch (RemoteException ex) {
Log.e(TAG, "Failed to get Wifi display status.", ex);
return new WifiDisplayStatus();
}
|
private void | handleDisplayEvent(int displayId, int event)
synchronized (mLock) {
if (USE_CACHE) {
mDisplayInfoCache.remove(displayId);
if (event == EVENT_DISPLAY_ADDED || event == EVENT_DISPLAY_REMOVED) {
mDisplayIdCache = null;
}
}
final int numListeners = mDisplayListeners.size();
for (int i = 0; i < numListeners; i++) {
mDisplayListeners.get(i).sendDisplayEvent(displayId, event);
}
}
|
public void | pauseWifiDisplay()
try {
mDm.pauseWifiDisplay();
} catch (RemoteException ex) {
Log.e(TAG, "Failed to pause Wifi display.", ex);
}
|
private void | registerCallbackIfNeededLocked()
if (mCallback == null) {
mCallback = new DisplayManagerCallback();
try {
mDm.registerCallback(mCallback);
} catch (RemoteException ex) {
Log.e(TAG, "Failed to register callback with display manager service.", ex);
mCallback = null;
}
}
|
public void | registerDisplayListener(android.hardware.display.DisplayManager.DisplayListener listener, android.os.Handler handler)
if (listener == null) {
throw new IllegalArgumentException("listener must not be null");
}
synchronized (mLock) {
int index = findDisplayListenerLocked(listener);
if (index < 0) {
mDisplayListeners.add(new DisplayListenerDelegate(listener, handler));
registerCallbackIfNeededLocked();
}
}
|
public void | releaseVirtualDisplay(IVirtualDisplayCallback token)
try {
mDm.releaseVirtualDisplay(token);
} catch (RemoteException ex) {
Log.w(TAG, "Failed to release virtual display.", ex);
}
|
public void | renameWifiDisplay(java.lang.String deviceAddress, java.lang.String alias)
if (deviceAddress == null) {
throw new IllegalArgumentException("deviceAddress must not be null");
}
try {
mDm.renameWifiDisplay(deviceAddress, alias);
} catch (RemoteException ex) {
Log.e(TAG, "Failed to rename Wifi display " + deviceAddress
+ " with alias " + alias + ".", ex);
}
|
public void | resizeVirtualDisplay(IVirtualDisplayCallback token, int width, int height, int densityDpi)
try {
mDm.resizeVirtualDisplay(token, width, height, densityDpi);
} catch (RemoteException ex) {
Log.w(TAG, "Failed to resize virtual display.", ex);
}
|
public void | resumeWifiDisplay()
try {
mDm.resumeWifiDisplay();
} catch (RemoteException ex) {
Log.e(TAG, "Failed to resume Wifi display.", ex);
}
|
public void | setVirtualDisplaySurface(IVirtualDisplayCallback token, android.view.Surface surface)
try {
mDm.setVirtualDisplaySurface(token, surface);
} catch (RemoteException ex) {
Log.w(TAG, "Failed to set virtual display surface.", ex);
}
|
public void | startWifiDisplayScan()
synchronized (mLock) {
if (mWifiDisplayScanNestCount++ == 0) {
registerCallbackIfNeededLocked();
try {
mDm.startWifiDisplayScan();
} catch (RemoteException ex) {
Log.e(TAG, "Failed to scan for Wifi displays.", ex);
}
}
}
|
public void | stopWifiDisplayScan()
synchronized (mLock) {
if (--mWifiDisplayScanNestCount == 0) {
try {
mDm.stopWifiDisplayScan();
} catch (RemoteException ex) {
Log.e(TAG, "Failed to scan for Wifi displays.", ex);
}
} else if (mWifiDisplayScanNestCount < 0) {
Log.wtf(TAG, "Wifi display scan nest count became negative: "
+ mWifiDisplayScanNestCount);
mWifiDisplayScanNestCount = 0;
}
}
|
public void | unregisterDisplayListener(android.hardware.display.DisplayManager.DisplayListener listener)
if (listener == null) {
throw new IllegalArgumentException("listener must not be null");
}
synchronized (mLock) {
int index = findDisplayListenerLocked(listener);
if (index >= 0) {
DisplayListenerDelegate d = mDisplayListeners.get(index);
d.clearEvents();
mDisplayListeners.remove(index);
}
}
|