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;
}
use of android.view.DisplayAdjustments in project android_frameworks_base by ResurrectionRemix.
the class ResourcesManager method applyConfigurationToResourcesLocked.
public final boolean applyConfigurationToResourcesLocked(@NonNull Configuration config, @Nullable CompatibilityInfo compat) {
try {
Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "ResourcesManager#applyConfigurationToResourcesLocked");
if (!mResConfiguration.isOtherSeqNewer(config) && compat == null) {
if (DEBUG || DEBUG_CONFIGURATION)
Slog.v(TAG, "Skipping new config: curSeq=" + mResConfiguration.seq + ", newSeq=" + config.seq);
return false;
}
int changes = mResConfiguration.updateFrom(config);
// Things might have changed in display manager, so clear the cached displays.
mDisplays.clear();
DisplayMetrics defaultDisplayMetrics = getDisplayMetrics();
if (compat != null && (mResCompatibilityInfo == null || !mResCompatibilityInfo.equals(compat))) {
mResCompatibilityInfo = compat;
changes |= ActivityInfo.CONFIG_SCREEN_LAYOUT | ActivityInfo.CONFIG_SCREEN_SIZE | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
}
Resources.updateSystemConfiguration(config, defaultDisplayMetrics, compat);
ApplicationPackageManager.configurationChanged();
//Slog.i(TAG, "Configuration changed in " + currentPackageName());
Configuration tmpConfig = null;
for (int i = mResourceImpls.size() - 1; i >= 0; i--) {
ResourcesKey key = mResourceImpls.keyAt(i);
WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
ResourcesImpl r = weakImplRef != null ? weakImplRef.get() : null;
if (r != null) {
if (DEBUG || DEBUG_CONFIGURATION)
Slog.v(TAG, "Changing resources " + r + " config to: " + config);
int displayId = key.mDisplayId;
boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
DisplayMetrics dm = defaultDisplayMetrics;
final boolean hasOverrideConfiguration = key.hasOverrideConfiguration();
if (!isDefaultDisplay || hasOverrideConfiguration) {
if (tmpConfig == null) {
tmpConfig = new Configuration();
}
tmpConfig.setTo(config);
// Get new DisplayMetrics based on the DisplayAdjustments given
// to the ResourcesImpl. Update a copy if the CompatibilityInfo
// changed, because the ResourcesImpl object will handle the
// update internally.
DisplayAdjustments daj = r.getDisplayAdjustments();
if (compat != null) {
daj = new DisplayAdjustments(daj);
daj.setCompatibilityInfo(compat);
}
dm = getDisplayMetrics(displayId, daj);
if (!isDefaultDisplay) {
applyNonDefaultDisplayMetricsToConfiguration(dm, tmpConfig);
}
if (hasOverrideConfiguration) {
tmpConfig.updateFrom(key.mOverrideConfiguration);
}
r.updateConfiguration(tmpConfig, dm, compat);
} else {
r.updateConfiguration(config, dm, compat);
}
//Slog.i(TAG, "Updated app resources " + v.getKey()
// + " " + r + ": " + r.getConfiguration());
} else {
//Slog.i(TAG, "Removing old resources " + v.getKey());
mResourceImpls.removeAt(i);
}
}
return changes != 0;
} finally {
Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
}
}
use of android.view.DisplayAdjustments in project android_frameworks_base by DirtyUnicorns.
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 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;
}
Aggregations