Search in sources :

Example 1 with DisplayManagerGlobal

use of android.hardware.display.DisplayManagerGlobal in project android_frameworks_base by AOSPA.

the class ResourcesManager method getAdjustedDisplay.

/**
     * Returns an adjusted {@link Display} object based on the inputs or null if display isn't
     * available.
     *
     * @param displayId display Id.
     * @param displayAdjustments display adjustments.
     */
public Display getAdjustedDisplay(final int displayId, @Nullable DisplayAdjustments displayAdjustments) {
    final DisplayAdjustments displayAdjustmentsCopy = (displayAdjustments != null) ? new DisplayAdjustments(displayAdjustments) : new DisplayAdjustments();
    final Pair<Integer, DisplayAdjustments> key = Pair.create(displayId, displayAdjustmentsCopy);
    synchronized (this) {
        WeakReference<Display> wd = mDisplays.get(key);
        if (wd != null) {
            final Display display = wd.get();
            if (display != null) {
                return display;
            }
        }
        final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
        if (dm == null) {
            // may be null early in system startup
            return null;
        }
        final Display display = dm.getCompatibleDisplay(displayId, key.second);
        if (display != null) {
            mDisplays.put(key, new WeakReference<>(display));
        }
        return display;
    }
}
Also used : DisplayManagerGlobal(android.hardware.display.DisplayManagerGlobal) DisplayAdjustments(android.view.DisplayAdjustments) Display(android.view.Display)

Example 2 with DisplayManagerGlobal

use of android.hardware.display.DisplayManagerGlobal in project android_frameworks_base by crdroidandroid.

the class ResourcesManager method getAdjustedDisplay.

/**
     * Returns an adjusted {@link Display} object based on the inputs or null if display isn't
     * available.
     *
     * @param displayId display Id.
     * @param displayAdjustments display adjustments.
     */
public Display getAdjustedDisplay(final int displayId, @Nullable DisplayAdjustments displayAdjustments) {
    final DisplayAdjustments displayAdjustmentsCopy = (displayAdjustments != null) ? new DisplayAdjustments(displayAdjustments) : new DisplayAdjustments();
    final Pair<Integer, DisplayAdjustments> key = Pair.create(displayId, displayAdjustmentsCopy);
    synchronized (this) {
        WeakReference<Display> wd = mDisplays.get(key);
        if (wd != null) {
            final Display display = wd.get();
            if (display != null) {
                return display;
            }
        }
        final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
        if (dm == null) {
            // may be null early in system startup
            return null;
        }
        final Display display = dm.getCompatibleDisplay(displayId, key.second);
        if (display != null) {
            mDisplays.put(key, new WeakReference<>(display));
        }
        return display;
    }
}
Also used : DisplayManagerGlobal(android.hardware.display.DisplayManagerGlobal) DisplayAdjustments(android.view.DisplayAdjustments) Display(android.view.Display)

Example 3 with DisplayManagerGlobal

use of android.hardware.display.DisplayManagerGlobal in project android_frameworks_base by crdroidandroid.

the class ActivityThread method createBaseContextForActivity.

private Context createBaseContextForActivity(ActivityClientRecord r, final Activity activity) {
    int displayId = Display.DEFAULT_DISPLAY;
    try {
        displayId = ActivityManagerNative.getDefault().getActivityDisplayId(r.token);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
    ContextImpl appContext = ContextImpl.createActivityContext(this, r.packageInfo, r.token, displayId, r.overrideConfig);
    appContext.setOuterContext(activity);
    Context baseContext = appContext;
    final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
    // For debugging purposes, if the activity's package name contains the value of
    // the "debug.use-second-display" system property as a substring, then show
    // its content on a secondary display if there is one.
    String pkgName = SystemProperties.get("debug.second-display.pkg");
    if (pkgName != null && !pkgName.isEmpty() && r.packageInfo.mPackageName.contains(pkgName)) {
        for (int id : dm.getDisplayIds()) {
            if (id != Display.DEFAULT_DISPLAY) {
                Display display = dm.getCompatibleDisplay(id, appContext.getDisplayAdjustments(id));
                baseContext = appContext.createDisplayContext(display);
                break;
            }
        }
    }
    return baseContext;
}
Also used : Context(android.content.Context) DisplayManagerGlobal(android.hardware.display.DisplayManagerGlobal) RemoteException(android.os.RemoteException) Display(android.view.Display)

Example 4 with DisplayManagerGlobal

use of android.hardware.display.DisplayManagerGlobal in project platform_frameworks_base by android.

the class ActivityThread method createBaseContextForActivity.

private Context createBaseContextForActivity(ActivityClientRecord r, final Activity activity) {
    int displayId = Display.DEFAULT_DISPLAY;
    try {
        displayId = ActivityManagerNative.getDefault().getActivityDisplayId(r.token);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
    ContextImpl appContext = ContextImpl.createActivityContext(this, r.packageInfo, r.token, displayId, r.overrideConfig);
    appContext.setOuterContext(activity);
    Context baseContext = appContext;
    final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
    // For debugging purposes, if the activity's package name contains the value of
    // the "debug.use-second-display" system property as a substring, then show
    // its content on a secondary display if there is one.
    String pkgName = SystemProperties.get("debug.second-display.pkg");
    if (pkgName != null && !pkgName.isEmpty() && r.packageInfo.mPackageName.contains(pkgName)) {
        for (int id : dm.getDisplayIds()) {
            if (id != Display.DEFAULT_DISPLAY) {
                Display display = dm.getCompatibleDisplay(id, appContext.getDisplayAdjustments(id));
                baseContext = appContext.createDisplayContext(display);
                break;
            }
        }
    }
    return baseContext;
}
Also used : Context(android.content.Context) DisplayManagerGlobal(android.hardware.display.DisplayManagerGlobal) RemoteException(android.os.RemoteException) Display(android.view.Display)

Example 5 with DisplayManagerGlobal

use of android.hardware.display.DisplayManagerGlobal in project android_frameworks_base by ParanoidAndroid.

the class ActivityThread method getDisplayMetricsLocked.

DisplayMetrics getDisplayMetricsLocked(int displayId, CompatibilityInfo ci) {
    boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
    DisplayMetrics dm = isDefaultDisplay ? mDefaultDisplayMetrics.get(ci) : null;
    if (dm != null) {
        return dm;
    }
    dm = new DisplayMetrics();
    DisplayManagerGlobal displayManager = DisplayManagerGlobal.getInstance();
    if (displayManager == null) {
        // may be null early in system startup
        dm.setToDefaults();
        return dm;
    }
    if (isDefaultDisplay) {
        mDefaultDisplayMetrics.put(ci, dm);
    }
    CompatibilityInfoHolder cih = new CompatibilityInfoHolder();
    cih.set(ci);
    Display d = displayManager.getCompatibleDisplay(displayId, cih);
    if (d != null) {
        d.getMetrics(dm);
    } else {
        // Display no longer exists
        // FIXME: This would not be a problem if we kept the Display object around
        // instead of using the raw display id everywhere.  The Display object caches
        // its information even after the display has been removed.
        dm.setToDefaults();
    }
    //        + " xdpi=" + metrics.xdpi + " ydpi=" + metrics.ydpi);
    return dm;
}
Also used : DisplayManagerGlobal(android.hardware.display.DisplayManagerGlobal) CompatibilityInfoHolder(android.view.CompatibilityInfoHolder) DisplayMetrics(android.util.DisplayMetrics) Display(android.view.Display)

Aggregations

DisplayManagerGlobal (android.hardware.display.DisplayManagerGlobal)13 Display (android.view.Display)12 Context (android.content.Context)6 RemoteException (android.os.RemoteException)5 DisplayAdjustments (android.view.DisplayAdjustments)5 IDisplayManager (android.hardware.display.IDisplayManager)1 DisplayMetrics (android.util.DisplayMetrics)1 CompatibilityInfoHolder (android.view.CompatibilityInfoHolder)1 Implementation (org.robolectric.annotation.Implementation)1