use of android.view.DisplayAdjustments in project android_frameworks_base by AOSPA.
the class ResourcesManager method createResourcesImpl.
@Nullable
private ResourcesImpl createResourcesImpl(@NonNull ResourcesKey key) {
final DisplayAdjustments daj = new DisplayAdjustments(key.mOverrideConfiguration);
daj.setCompatibilityInfo(key.mCompatInfo);
final AssetManager assets = createAssetManager(key);
if (assets == null) {
return null;
}
final DisplayMetrics dm = getDisplayMetrics(key.mDisplayId, daj);
final Configuration config = generateConfig(key, dm);
final ResourcesImpl impl = new ResourcesImpl(assets, dm, config, daj);
if (DEBUG) {
Slog.d(TAG, "- creating impl=" + impl + " with key: " + key);
}
return impl;
}
use of android.view.DisplayAdjustments 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;
}
}
use of android.view.DisplayAdjustments in project android_frameworks_base by AOSPA.
the class ResourcesManagerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mDisplayMetrics = new DisplayMetrics();
mDisplayMetrics.setToDefaults();
// Override defaults (which take device specific properties).
mDisplayMetrics.density = 1.0f;
mDisplayMetrics.densityDpi = DisplayMetrics.DENSITY_DEFAULT;
mDisplayMetrics.xdpi = DisplayMetrics.DENSITY_DEFAULT;
mDisplayMetrics.ydpi = DisplayMetrics.DENSITY_DEFAULT;
mDisplayMetrics.noncompatDensity = mDisplayMetrics.density;
mDisplayMetrics.noncompatDensityDpi = mDisplayMetrics.densityDpi;
mDisplayMetrics.noncompatXdpi = DisplayMetrics.DENSITY_DEFAULT;
mDisplayMetrics.noncompatYdpi = DisplayMetrics.DENSITY_DEFAULT;
mResourcesManager = new ResourcesManager() {
@Override
protected AssetManager createAssetManager(@NonNull ResourcesKey key) {
return new AssetManager();
}
@Override
protected DisplayMetrics getDisplayMetrics(int displayId, DisplayAdjustments daj) {
return mDisplayMetrics;
}
};
}
use of android.view.DisplayAdjustments in project android_frameworks_base by ResurrectionRemix.
the class ResourcesManagerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mDisplayMetrics = new DisplayMetrics();
mDisplayMetrics.setToDefaults();
// Override defaults (which take device specific properties).
mDisplayMetrics.density = 1.0f;
mDisplayMetrics.densityDpi = DisplayMetrics.DENSITY_DEFAULT;
mDisplayMetrics.xdpi = DisplayMetrics.DENSITY_DEFAULT;
mDisplayMetrics.ydpi = DisplayMetrics.DENSITY_DEFAULT;
mDisplayMetrics.noncompatDensity = mDisplayMetrics.density;
mDisplayMetrics.noncompatDensityDpi = mDisplayMetrics.densityDpi;
mDisplayMetrics.noncompatXdpi = DisplayMetrics.DENSITY_DEFAULT;
mDisplayMetrics.noncompatYdpi = DisplayMetrics.DENSITY_DEFAULT;
mResourcesManager = new ResourcesManager() {
@Override
protected AssetManager createAssetManager(@NonNull ResourcesKey key) {
return new AssetManager();
}
@Override
protected DisplayMetrics getDisplayMetrics(int displayId, DisplayAdjustments daj) {
return mDisplayMetrics;
}
};
}
use of android.view.DisplayAdjustments in project android_frameworks_base by ResurrectionRemix.
the class ResourcesManager method createResourcesImpl.
@Nullable
private ResourcesImpl createResourcesImpl(@NonNull ResourcesKey key) {
final DisplayAdjustments daj = new DisplayAdjustments(key.mOverrideConfiguration);
daj.setCompatibilityInfo(key.mCompatInfo);
final AssetManager assets = createAssetManager(key);
if (assets == null) {
return null;
}
final DisplayMetrics dm = getDisplayMetrics(key.mDisplayId, daj);
final Configuration config = generateConfig(key, dm);
final ResourcesImpl impl = new ResourcesImpl(assets, dm, config, daj);
if (DEBUG) {
Slog.d(TAG, "- creating impl=" + impl + " with key: " + key);
}
return impl;
}
Aggregations