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

LocalDisplayAdapter

public final class LocalDisplayAdapter extends DisplayAdapter
A display adapter for the local displays managed by Surface Flinger.

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

Fields Summary
private static final String
TAG
private static final String
UNIQUE_ID_PREFIX
private static final int[]
BUILT_IN_DISPLAY_IDS_TO_SCAN
private final android.util.SparseArray
mDevices
private HotplugDisplayEventReceiver
mHotplugReceiver
Constructors Summary
public LocalDisplayAdapter(DisplayManagerService.SyncRoot syncRoot, android.content.Context context, android.os.Handler handler, Listener listener)


    // Called with SyncRoot lock held.
      
                  
        super(syncRoot, context, handler, listener, TAG);
    
Methods Summary
static intgetPowerModeForState(int state)

        switch (state) {
            case Display.STATE_OFF:
                return SurfaceControl.POWER_MODE_OFF;
            case Display.STATE_DOZE:
                return SurfaceControl.POWER_MODE_DOZE;
            case Display.STATE_DOZE_SUSPEND:
                return SurfaceControl.POWER_MODE_DOZE_SUSPEND;
            default:
                return SurfaceControl.POWER_MODE_NORMAL;
        }
    
public voidregisterLocked()

        super.registerLocked();

        mHotplugReceiver = new HotplugDisplayEventReceiver(getHandler().getLooper());

        for (int builtInDisplayId : BUILT_IN_DISPLAY_IDS_TO_SCAN) {
            tryConnectDisplayLocked(builtInDisplayId);
        }
    
private voidtryConnectDisplayLocked(int builtInDisplayId)

        IBinder displayToken = SurfaceControl.getBuiltInDisplay(builtInDisplayId);
        if (displayToken != null) {
            SurfaceControl.PhysicalDisplayInfo[] configs =
                    SurfaceControl.getDisplayConfigs(displayToken);
            if (configs == null) {
                // There are no valid configs for this device, so we can't use it
                Slog.w(TAG, "No valid configs found for display device " +
                        builtInDisplayId);
                return;
            }
            int activeConfig = SurfaceControl.getActiveConfig(displayToken);
            if (activeConfig < 0) {
                // There is no active config, and for now we don't have the
                // policy to set one.
                Slog.w(TAG, "No active config found for display device " +
                        builtInDisplayId);
                return;
            }
            LocalDisplayDevice device = mDevices.get(builtInDisplayId);
            if (device == null) {
                // Display was added.
                device = new LocalDisplayDevice(displayToken, builtInDisplayId,
                        configs, activeConfig);
                mDevices.put(builtInDisplayId, device);
                sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED);
            } else if (device.updatePhysicalDisplayInfoLocked(configs, activeConfig)) {
                // Display properties changed.
                sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED);
            }
        } else {
            // The display is no longer available. Ignore the attempt to add it.
            // If it was connected but has already been disconnected, we'll get a
            // disconnect event that will remove it from mDevices.
        }
    
private voidtryDisconnectDisplayLocked(int builtInDisplayId)

        LocalDisplayDevice device = mDevices.get(builtInDisplayId);
        if (device != null) {
            // Display was removed.
            mDevices.remove(builtInDisplayId);
            sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_REMOVED);
        }