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

Commit 75d6b3c2 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #4502672: Wrong xml resources used for homescreen widgets." into honeycomb-mr2

parents d40a5d5c 2f0b1757
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -172,6 +172,11 @@ public final class ActivityThread {
    // These can be accessed by multiple threads; mPackages is the lock.
    // XXX For now we keep around information about all packages we have
    // seen, not removing entries from this map.
    // NOTE: The activity manager in its process needs to call in to
    // ActivityThread to do things like update resource configurations,
    // which means this lock gets held while the activity manager holds its
    // own lock.  Thus you MUST NEVER call back into the activity manager
    // or anything that depends on it while holding this lock.
    final HashMap<String, WeakReference<LoadedApk>> mPackages
            = new HashMap<String, WeakReference<LoadedApk>>();
    final HashMap<String, WeakReference<LoadedApk>> mResourcePackages
@@ -1480,7 +1485,7 @@ public final class ActivityThread {
    }

    public Configuration getConfiguration() {
        return mConfiguration;
        return mResConfiguration;
    }

    public boolean isProfiling() {
@@ -1525,7 +1530,7 @@ public final class ActivityThread {
        synchronized (this) {
            ContextImpl context = getSystemContext();
            context.init(new LoadedApk(this, "android", context, info,
                    new CompatibilityInfo(info, 0, 0, false)), null, this);
                    CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO), null, this);
        }
    }

@@ -3274,6 +3279,12 @@ public final class ActivityThread {
        }
    }

    public final void applyConfigurationToResources(Configuration config) {
        synchronized (mPackages) {
            applyConfigurationToResourcesLocked(config, null);
        }
    }

    final boolean applyConfigurationToResourcesLocked(Configuration config,
            CompatibilityInfo compat) {
        if (mResConfiguration == null) {
@@ -3492,8 +3503,7 @@ public final class ActivityThread {
         * reflect configuration changes. The configuration object passed
         * in AppBindData can be safely assumed to be up to date
         */
        Resources.getSystem().updateConfiguration(mConfiguration,
                Resources.getSystem().getDisplayMetrics(), data.compatInfo);
        applyConfigurationToResourcesLocked(data.config, data.compatInfo);

        data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo);

+6 −0
Original line number Diff line number Diff line
@@ -98,6 +98,12 @@ final class LoadedApk {
        return mApplication;
    }

    /**
     * Create information about a new .apk
     *
     * NOTE: This constructor is called with ActivityThread's lock held,
     * so MUST NOT call back out to the activity manager.
     */
    public LoadedApk(ActivityThread activityThread, ApplicationInfo aInfo,
            CompatibilityInfo compatInfo,
            ActivityThread mainThread, ClassLoader baseLoader,
+4 −11
Original line number Diff line number Diff line
@@ -243,11 +243,11 @@ public class CompatibilityInfo implements Parcelable {
    }
    
    public boolean neverSupportsScreen() {
        return (mCompatibilityFlags&NEVER_NEEDS_COMPAT) != 0;
        return (mCompatibilityFlags&ALWAYS_NEEDS_COMPAT) != 0;
    }

    public boolean alwaysSupportsScreen() {
        return (mCompatibilityFlags&ALWAYS_NEEDS_COMPAT) != 0;
        return (mCompatibilityFlags&NEVER_NEEDS_COMPAT) != 0;
    }

    /**
@@ -406,7 +406,7 @@ public class CompatibilityInfo implements Parcelable {
        if (!supportsScreen()) {
            // This is a larger screen device and the app is not
            // compatible with large screens, so diddle it.
            CompatibilityInfo.updateCompatibleScreenFrame(inoutDm, null, inoutDm);
            CompatibilityInfo.computeCompatibleScaling(inoutDm, inoutDm);
        } else {
            inoutDm.widthPixels = inoutDm.unscaledWidthPixels;
            inoutDm.heightPixels = inoutDm.unscaledHeightPixels;
@@ -443,8 +443,7 @@ public class CompatibilityInfo implements Parcelable {
     * @param outRect the output parameter which will contain the result.
     * @return Returns the scaling factor for the window.
     */
    public static float updateCompatibleScreenFrame(DisplayMetrics dm,
            Rect outRect, DisplayMetrics outDm) {
    public static float computeCompatibleScaling(DisplayMetrics dm, DisplayMetrics outDm) {
        final int width = dm.unscaledWidthPixels;
        final int height = dm.unscaledHeightPixels;
        int shortSize, longSize;
@@ -477,12 +476,6 @@ public class CompatibilityInfo implements Parcelable {
            scale = 1;
        }

        if (outRect != null) {
            final int left = (int)((width-(newWidth*scale))/2);
            final int top = (int)((height-(newHeight*scale))/2);
            outRect.set(left, top, left+newWidth, top+newHeight);
        }

        if (outDm != null) {
            outDm.widthPixels = newWidth;
            outDm.heightPixels = newHeight;
+12 −2
Original line number Diff line number Diff line
@@ -28,14 +28,13 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable.ConstantState;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.util.TypedValue;
import android.util.LongSparseArray;
import android.view.Display;

import java.io.IOException;
import java.io.InputStream;
@@ -1406,6 +1405,12 @@ public class Resources {
    public void updateConfiguration(Configuration config,
            DisplayMetrics metrics, CompatibilityInfo compat) {
        synchronized (mTmpValue) {
            if (false) {
                Slog.i(TAG, "**** Updating config of " + this + ": old config is "
                        + mConfiguration + " old compat is " + mCompatibilityInfo);
                Slog.i(TAG, "**** Updating config of " + this + ": new config is "
                        + config + " new compat is " + compat);
            }
            if (compat != null) {
                mCompatibilityInfo = compat;
            }
@@ -1471,6 +1476,11 @@ public class Resources {
                    mConfiguration.screenLayout, mConfiguration.uiMode,
                    Build.VERSION.RESOURCES_SDK_INT);

            if (false) {
                Slog.i(TAG, "**** Updating config of " + this + ": final config is " + mConfiguration
                        + " final compat is " + mCompatibilityInfo);
            }

            clearDrawableCache(mDrawableCache, configChanges);
            clearDrawableCache(mColorDrawableCache, configChanges);

+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view;
import com.android.internal.view.IInputContext;
import com.android.internal.view.IInputMethodClient;

import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Point;
@@ -88,7 +89,7 @@ interface IWindowManager
    void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim);
    void executeAppTransition();
    void setAppStartingWindow(IBinder token, String pkg, int theme,
            CharSequence nonLocalizedLabel, int labelRes,
            in CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes,
            int icon, int windowFlags, IBinder transferFrom, boolean createIfNeeded);
    void setAppWillBeHidden(IBinder token);
    void setAppVisibility(IBinder token, boolean visible);
Loading