FileDocCategorySizeDatePackage
DisplayDevice.javaAPI DocAndroid 5.1 API8032Thu Mar 12 22:22:42 GMT 2015com.android.server.display

DisplayDevice

public abstract class DisplayDevice extends Object
Represents a physical display device such as the built-in display an external monitor, or a WiFi display.

Display devices are guarded by the {@link DisplayManagerService.SyncRoot} lock.

Fields Summary
private final DisplayAdapter
mDisplayAdapter
private final android.os.IBinder
mDisplayToken
private final String
mUniqueId
private int
mCurrentLayerStack
private int
mCurrentOrientation
private android.graphics.Rect
mCurrentLayerStackRect
private android.graphics.Rect
mCurrentDisplayRect
private android.view.Surface
mCurrentSurface
Constructors Summary
public DisplayDevice(DisplayAdapter displayAdapter, android.os.IBinder displayToken, String uniqueId)


           
        mDisplayAdapter = displayAdapter;
        mDisplayToken = displayToken;
        mUniqueId = uniqueId;
    
Methods Summary
public voidapplyPendingDisplayDeviceInfoChangesLocked()
Applies any pending changes to the observable state of the display device if the display adapter sent a {@link DisplayAdapter#DISPLAY_DEVICE_EVENT_CHANGED} event.

    
public voiddumpLocked(java.io.PrintWriter pw)
Dumps the local state of the display device. Does not need to dump the display device info because that is already dumped elsewhere.

        pw.println("mAdapter=" + mDisplayAdapter.getName());
        pw.println("mUniqueId=" + mUniqueId);
        pw.println("mDisplayToken=" + mDisplayToken);
        pw.println("mCurrentLayerStack=" + mCurrentLayerStack);
        pw.println("mCurrentOrientation=" + mCurrentOrientation);
        pw.println("mCurrentLayerStackRect=" + mCurrentLayerStackRect);
        pw.println("mCurrentDisplayRect=" + mCurrentDisplayRect);
        pw.println("mCurrentSurface=" + mCurrentSurface);
    
public final DisplayAdaptergetAdapterLocked()
Gets the display adapter that owns the display device.

return
The display adapter.

        return mDisplayAdapter;
    
public abstract DisplayDeviceInfogetDisplayDeviceInfoLocked()
Gets information about the display device. The information returned should not change between calls unless the display adapter sent a {@link DisplayAdapter#DISPLAY_DEVICE_EVENT_CHANGED} event and {@link #applyPendingDisplayDeviceInfoChangesLocked()} has been called to apply the pending changes.

return
The display device info, which should be treated as immutable by the caller. The display device should allocate a new display device info object whenever the data changes.

public final android.os.IBindergetDisplayTokenLocked()
Gets the Surface Flinger display token for this display.

return
The display token, or null if the display is not being managed by Surface Flinger.

        return mDisplayToken;
    
public final java.lang.StringgetNameLocked()
Gets the name of the display device.

return
The display device name.

        return getDisplayDeviceInfoLocked().name;
    
public final java.lang.StringgetUniqueId()
Returns the unique id of the display device.

        return mUniqueId;
    
public voidperformTraversalInTransactionLocked()
Gives the display device a chance to update its properties while in a transaction.

    
public final voidpopulateViewportLocked(android.hardware.display.DisplayViewport viewport)
Populates the specified viewport object with orientation, physical and logical rects based on the display's current projection.

        viewport.orientation = mCurrentOrientation;

        if (mCurrentLayerStackRect != null) {
            viewport.logicalFrame.set(mCurrentLayerStackRect);
        } else {
            viewport.logicalFrame.setEmpty();
        }

        if (mCurrentDisplayRect != null) {
            viewport.physicalFrame.set(mCurrentDisplayRect);
        } else {
            viewport.physicalFrame.setEmpty();
        }

        boolean isRotated = (mCurrentOrientation == Surface.ROTATION_90
                || mCurrentOrientation == Surface.ROTATION_270);
        DisplayDeviceInfo info = getDisplayDeviceInfoLocked();
        viewport.deviceWidth = isRotated ? info.height : info.width;
        viewport.deviceHeight = isRotated ? info.width : info.height;
    
public java.lang.RunnablerequestDisplayStateLocked(int state)
Sets the display state, if supported.

return
A runnable containing work to be deferred until after we have exited the critical section, or null if none.

        return null;
    
public voidrequestRefreshRateLocked(float refreshRate)
Sets the refresh rate, if supported.

    
public final voidsetLayerStackInTransactionLocked(int layerStack)
Sets the display layer stack while in a transaction.

        if (mCurrentLayerStack != layerStack) {
            mCurrentLayerStack = layerStack;
            SurfaceControl.setDisplayLayerStack(mDisplayToken, layerStack);
        }
    
public final voidsetProjectionInTransactionLocked(int orientation, android.graphics.Rect layerStackRect, android.graphics.Rect displayRect)
Sets the display projection while in a transaction.

param
orientation defines the display's orientation
param
layerStackRect defines which area of the window manager coordinate space will be used
param
displayRect defines where on the display will layerStackRect be mapped to. displayRect is specified post-orientation, that is it uses the orientation seen by the end-user

        if (mCurrentOrientation != orientation
                || mCurrentLayerStackRect == null
                || !mCurrentLayerStackRect.equals(layerStackRect)
                || mCurrentDisplayRect == null
                || !mCurrentDisplayRect.equals(displayRect)) {
            mCurrentOrientation = orientation;

            if (mCurrentLayerStackRect == null) {
                mCurrentLayerStackRect = new Rect();
            }
            mCurrentLayerStackRect.set(layerStackRect);

            if (mCurrentDisplayRect == null) {
                mCurrentDisplayRect = new Rect();
            }
            mCurrentDisplayRect.set(displayRect);

            SurfaceControl.setDisplayProjection(mDisplayToken,
                    orientation, layerStackRect, displayRect);
        }
    
public final voidsetSurfaceInTransactionLocked(android.view.Surface surface)
Sets the display surface while in a transaction.

        if (mCurrentSurface != surface) {
            mCurrentSurface = surface;
            SurfaceControl.setDisplaySurface(mDisplayToken, surface);
        }