Search in sources :

Example 1 with CompatibilityInfoHolder

use of android.view.CompatibilityInfoHolder 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)

Example 2 with CompatibilityInfoHolder

use of android.view.CompatibilityInfoHolder in project android_frameworks_base by ParanoidAndroid.

the class ContextImpl method createDisplayContext.

@Override
public Context createDisplayContext(Display display) {
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }
    int displayId = display.getDisplayId();
    CompatibilityInfo ci = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
    CompatibilityInfoHolder cih = getCompatibilityInfo(displayId);
    if (cih != null) {
        ci = cih.get();
    }
    ContextImpl context = new ContextImpl();
    context.init(mPackageInfo, null, mMainThread);
    context.mDisplay = display;
    context.mResources = mMainThread.getTopLevelResources(mPackageInfo.getResDir(), displayId, null, ci);
    return context;
}
Also used : CompatibilityInfo(android.content.res.CompatibilityInfo) CompatibilityInfoHolder(android.view.CompatibilityInfoHolder)

Aggregations

CompatibilityInfoHolder (android.view.CompatibilityInfoHolder)2 CompatibilityInfo (android.content.res.CompatibilityInfo)1 DisplayManagerGlobal (android.hardware.display.DisplayManagerGlobal)1 DisplayMetrics (android.util.DisplayMetrics)1 Display (android.view.Display)1