Search in sources :

Example 11 with DisplayManagerGlobal

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

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 12 with DisplayManagerGlobal

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

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)

Aggregations

DisplayManagerGlobal (android.hardware.display.DisplayManagerGlobal)12 Display (android.view.Display)12 Context (android.content.Context)6 RemoteException (android.os.RemoteException)5 DisplayAdjustments (android.view.DisplayAdjustments)5 DisplayMetrics (android.util.DisplayMetrics)1 CompatibilityInfoHolder (android.view.CompatibilityInfoHolder)1