use of android.content.res.CompatibilityInfo in project android_frameworks_base by ParanoidAndroid.
the class DisplayInfo method getMetricsWithSize.
private void getMetricsWithSize(DisplayMetrics outMetrics, CompatibilityInfoHolder cih, int width, int height) {
outMetrics.densityDpi = outMetrics.noncompatDensityDpi = logicalDensityDpi;
outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width;
outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height;
outMetrics.density = outMetrics.noncompatDensity = logicalDensityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE;
outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density;
outMetrics.xdpi = outMetrics.noncompatXdpi = physicalXDpi;
outMetrics.ydpi = outMetrics.noncompatYdpi = physicalYDpi;
if (outMetrics.isHooked()) {
outMetrics.paranoidHook();
}
if (cih != null) {
CompatibilityInfo ci = cih.getIfNeeded();
if (ci != null) {
ci.applyToDisplayMetrics(outMetrics);
}
}
}
use of android.content.res.CompatibilityInfo in project android_frameworks_base by ParanoidAndroid.
the class ViewRootImpl method updateConfiguration.
void updateConfiguration(Configuration config, boolean force) {
if (DEBUG_CONFIGURATION)
Log.v(TAG, "Applying new config to window " + mWindowAttributes.getTitle() + ": " + config);
CompatibilityInfo ci = mCompatibilityInfo.getIfNeeded();
if (ci != null) {
config = new Configuration(config);
ci.applyToConfiguration(mNoncompatDensity, config);
}
synchronized (sConfigCallbacks) {
for (int i = sConfigCallbacks.size() - 1; i >= 0; i--) {
sConfigCallbacks.get(i).onConfigurationChanged(config);
}
}
if (mView != null) {
// At this point the resources have been updated to
// have the most recent config, whatever that is. Use
// the one in them which may be newer.
config = mView.getResources().getConfiguration();
if (force || mLastConfiguration.diff(config) != 0) {
final int lastLayoutDirection = mLastConfiguration.getLayoutDirection();
final int currentLayoutDirection = config.getLayoutDirection();
mLastConfiguration.setTo(config);
if (lastLayoutDirection != currentLayoutDirection && mViewLayoutDirectionInitial == View.LAYOUT_DIRECTION_INHERIT) {
mView.setLayoutDirection(currentLayoutDirection);
}
mView.dispatchConfigurationChanged(config);
}
}
}
use of android.content.res.CompatibilityInfo in project platform_frameworks_base by android.
the class ActivityRecord method showStartingWindow.
void showStartingWindow(ActivityRecord prev, boolean createIfNeeded) {
final CompatibilityInfo compatInfo = service.compatibilityInfoForPackageLocked(info.applicationInfo);
final boolean shown = service.mWindowManager.setAppStartingWindow(appToken, packageName, theme, compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags, prev != null ? prev.appToken : null, createIfNeeded);
if (shown) {
mStartingWindowState = STARTING_WINDOW_SHOWN;
}
}
use of android.content.res.CompatibilityInfo in project platform_frameworks_base by android.
the class CompatModePackages method computeCompatModeLocked.
public int computeCompatModeLocked(ApplicationInfo ai) {
boolean enabled = (getPackageFlags(ai.packageName) & COMPAT_FLAG_ENABLED) != 0;
CompatibilityInfo info = new CompatibilityInfo(ai, mService.mConfiguration.screenLayout, mService.mConfiguration.smallestScreenWidthDp, enabled);
if (info.alwaysSupportsScreen()) {
return ActivityManager.COMPAT_MODE_NEVER;
}
if (info.neverSupportsScreen()) {
return ActivityManager.COMPAT_MODE_ALWAYS;
}
return enabled ? ActivityManager.COMPAT_MODE_ENABLED : ActivityManager.COMPAT_MODE_DISABLED;
}
use of android.content.res.CompatibilityInfo in project platform_frameworks_base by android.
the class CompatModePackages method setPackageScreenCompatModeLocked.
private void setPackageScreenCompatModeLocked(ApplicationInfo ai, int mode) {
final String packageName = ai.packageName;
int curFlags = getPackageFlags(packageName);
boolean enable;
switch(mode) {
case ActivityManager.COMPAT_MODE_DISABLED:
enable = false;
break;
case ActivityManager.COMPAT_MODE_ENABLED:
enable = true;
break;
case ActivityManager.COMPAT_MODE_TOGGLE:
enable = (curFlags & COMPAT_FLAG_ENABLED) == 0;
break;
default:
Slog.w(TAG, "Unknown screen compat mode req #" + mode + "; ignoring");
return;
}
int newFlags = curFlags;
if (enable) {
newFlags |= COMPAT_FLAG_ENABLED;
} else {
newFlags &= ~COMPAT_FLAG_ENABLED;
}
CompatibilityInfo ci = compatibilityInfoForPackageLocked(ai);
if (ci.alwaysSupportsScreen()) {
Slog.w(TAG, "Ignoring compat mode change of " + packageName + "; compatibility never needed");
newFlags = 0;
}
if (ci.neverSupportsScreen()) {
Slog.w(TAG, "Ignoring compat mode change of " + packageName + "; compatibility always needed");
newFlags = 0;
}
if (newFlags != curFlags) {
if (newFlags != 0) {
mPackages.put(packageName, newFlags);
} else {
mPackages.remove(packageName);
}
// Need to get compatibility info in new state.
ci = compatibilityInfoForPackageLocked(ai);
scheduleWrite();
final ActivityStack stack = mService.getFocusedStack();
ActivityRecord starting = stack.restartPackage(packageName);
// Tell all processes that loaded this package about the change.
for (int i = mService.mLruProcesses.size() - 1; i >= 0; i--) {
ProcessRecord app = mService.mLruProcesses.get(i);
if (!app.pkgList.containsKey(packageName)) {
continue;
}
try {
if (app.thread != null) {
if (DEBUG_CONFIGURATION)
Slog.v(TAG_CONFIGURATION, "Sending to proc " + app.processName + " new compat " + ci);
app.thread.updatePackageCompatibilityInfo(packageName, ci);
}
} catch (Exception e) {
}
}
if (starting != null) {
stack.ensureActivityConfigurationLocked(starting, 0, false);
// And we need to make sure at this point that all other activities
// are made visible with the correct configuration.
stack.ensureActivitiesVisibleLocked(starting, 0, !PRESERVE_WINDOWS);
}
}
}
Aggregations