Search in sources :

Example 41 with CompatibilityInfo

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);
        }
    }
}
Also used : CompatibilityInfo(android.content.res.CompatibilityInfo)

Example 42 with CompatibilityInfo

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);
        }
    }
}
Also used : Configuration(android.content.res.Configuration) CompatibilityInfo(android.content.res.CompatibilityInfo) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 43 with CompatibilityInfo

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;
    }
}
Also used : CompatibilityInfo(android.content.res.CompatibilityInfo)

Example 44 with CompatibilityInfo

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;
}
Also used : CompatibilityInfo(android.content.res.CompatibilityInfo)

Example 45 with CompatibilityInfo

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);
        }
    }
}
Also used : CompatibilityInfo(android.content.res.CompatibilityInfo) RemoteException(android.os.RemoteException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Aggregations

CompatibilityInfo (android.content.res.CompatibilityInfo)62 RemoteException (android.os.RemoteException)35 Point (android.graphics.Point)24 ApplicationInfo (android.content.pm.ApplicationInfo)17 Configuration (android.content.res.Configuration)13 Resources (android.content.res.Resources)13 RootViewSurfaceTaker (com.android.internal.view.RootViewSurfaceTaker)13 Paint (android.graphics.Paint)9 Rect (android.graphics.Rect)8 Region (android.graphics.Region)8 AndroidRuntimeException (android.util.AndroidRuntimeException)8 IAccessibilityInteractionConnectionCallback (android.view.accessibility.IAccessibilityInteractionConnectionCallback)8 InputMethodManager (android.view.inputmethod.InputMethodManager)8 BaseSurfaceHolder (com.android.internal.view.BaseSurfaceHolder)8 IPackageManager (android.content.pm.IPackageManager)6 FastXmlSerializer (com.android.internal.util.FastXmlSerializer)6 FileOutputStream (java.io.FileOutputStream)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)6