Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ddde4706 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix undefined fontScale issue in Configuration"

parents 886bb815 bad43fca
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -679,7 +679,7 @@ public class ResourcesManager {
                if (overrideConfig != null) {
                    activityResources.overrideConfig.setTo(overrideConfig);
                } else {
                    activityResources.overrideConfig.setToDefaults();
                    activityResources.overrideConfig.unset();
                }

                if (DEBUG) {
+24 −3
Original line number Diff line number Diff line
@@ -725,11 +725,23 @@ public final class Configuration implements Parcelable, Comparable<Configuration
    public static final int NATIVE_CONFIG_LAYOUTDIR = 0x4000;

    /**
     * Construct an invalid Configuration.  You must call {@link #setToDefaults}
     * for this object to be valid.  {@more}
     * <p>Construct an invalid Configuration. This state is only suitable for constructing a
     * Configuration delta that will be applied to some valid Configuration object. In order to
     * create a valid standalone Configuration, you must call {@link #setToDefaults}. </p>
     *
     * <p>Example:</p>
     * <pre class="prettyprint">
     *     Configuration validConfig = new Configuration();
     *     validConfig.setToDefaults();
     *
     *     Configuration deltaOnlyConfig = new Configuration();
     *     deltaOnlyConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
     *
     *     validConfig.updateFrom(deltaOnlyConfig);
     * </pre>
     */
    public Configuration() {
        setToDefaults();
        unset();
    }

    /**
@@ -939,6 +951,15 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        seq = 0;
    }

    /**
     * Set this object to completely undefined.
     * @hide
     */
    public void unset() {
        setToDefaults();
        fontScale = 0;
    }

    /** {@hide} */
    @Deprecated public void makeDefault() {
        setToDefaults();
+5 −1
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ public class ResourcesImpl {
        mAssets = assets;
        mMetrics.setToDefaults();
        mDisplayAdjustments = displayAdjustments;
        mConfiguration.setToDefaults();
        updateConfiguration(config, metrics, displayAdjustments.getCompatibilityInfo());
        mAssets.ensureStringBlocks();
    }
@@ -383,7 +384,10 @@ public class ResourcesImpl {
                    mMetrics.density =
                            mConfiguration.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE;
                }
                mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;

                // Protect against an unset fontScale.
                mMetrics.scaledDensity = mMetrics.density *
                        (mConfiguration.fontScale != 0 ? mConfiguration.fontScale : 1.0f);

                final int width, height;
                if (mMetrics.widthPixels >= mMetrics.heightPixels) {
+2 −9
Original line number Diff line number Diff line
@@ -447,17 +447,10 @@ final class ActivityRecord {
            return;
        }
        try {
            // Make sure fontScale is always equal to global. For fullscreen apps, config is
            // the shared EMPTY config, which has default fontScale of 1.0. We don't want it
            // to be applied as an override config.
            Configuration overrideConfig = new Configuration(config);
            overrideConfig.fontScale = service.mConfiguration.fontScale;

            if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + this + " " +
                    "reportToActivity=" + reportToActivity + " and config: " + overrideConfig);
                    "reportToActivity=" + reportToActivity + " and config: " + config);

            app.thread.scheduleActivityConfigurationChanged(
                    appToken, overrideConfig, reportToActivity);
            app.thread.scheduleActivityConfigurationChanged(appToken, config, reportToActivity);
        } catch (RemoteException e) {
            // If process died, whatever.
        }
+0 −8
Original line number Diff line number Diff line
@@ -1537,11 +1537,6 @@ final class TaskRecord {
                ? Configuration.ORIENTATION_PORTRAIT
                : Configuration.ORIENTATION_LANDSCAPE;

        // Always set fontScale to be euqal to global. Can't set to 0, as that makes the override
        // config not equal to EMPTY. Also can't set to 1, as Configuration.updateFrom will use
        // the override scale as long as it's non-zero, and we'll always use 1.
        config.fontScale = serviceConfig.fontScale;

        // For calculating screen layout, we need to use the non-decor inset screen area for the
        // calculation for compatibility reasons, i.e. screen area without system bars that could
        // never go away in Honeycomb.
@@ -1603,9 +1598,6 @@ final class TaskRecord {
        newScreenLayout = (newScreenLayout & ~SCREENLAYOUT_SIZE_MASK)
                | (overrideScreenLayout & SCREENLAYOUT_SIZE_MASK);
        mOverrideConfig.screenLayout = newScreenLayout;
        // we never override the fontScale, however we need to copy over the global value
        // so that the default 1.0 doesn't get applied as an override.
        mOverrideConfig.fontScale = globalConfig.fontScale;
    }

    static Rect validateBounds(Rect bounds) {
Loading