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

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

Merge "DO NOT MERGE. Integrate add new screen width/height in "dp" configs." into honeycomb-mr2

parents 78b875e7 ebff8f92
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -57840,6 +57840,17 @@
 visibility="public"
>
</field>
<field name="CONFIG_SCREEN_SIZE"
 type="int"
 transient="false"
 volatile="false"
 value="1024"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CONFIG_TOUCHSCREEN"
 type="int"
 transient="false"
@@ -63902,6 +63913,28 @@
 visibility="public"
>
</field>
<field name="SCREEN_HEIGHT_DP_UNDEFINED"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SCREEN_WIDTH_DP_UNDEFINED"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="TOUCHSCREEN_FINGER"
 type="int"
 transient="false"
@@ -64145,6 +64178,16 @@
 visibility="public"
>
</field>
<field name="screenHeightDp"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="screenLayout"
 type="int"
 transient="false"
@@ -64155,6 +64198,16 @@
 visibility="public"
>
</field>
<field name="screenWidthDp"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="touchscreen"
 type="int"
 transient="false"
+37 −0
Original line number Diff line number Diff line
@@ -332,6 +332,12 @@ public class ActivityInfo extends ComponentInfo
     * {@link android.R.attr#configChanges} attribute.
     */
    public static final int CONFIG_UI_MODE = 0x0200;
    /**
     * Bit in {@link #configChanges} that indicates that the activity
     * can itself handle the screen size. Set from the
     * {@link android.R.attr#configChanges} attribute.
     */
    public static final int CONFIG_SCREEN_SIZE = 0x0400;
    /**
     * Bit in {@link #configChanges} that indicates that the activity
     * can itself handle changes to the font scaling factor.  Set from the
@@ -341,6 +347,37 @@ public class ActivityInfo extends ComponentInfo
     */
    public static final int CONFIG_FONT_SCALE = 0x40000000;
    
    /** @hide
     * Unfortunately the constants for config changes in native code are
     * different from ActivityInfo. :(  Here are the values we should use for the
     * native side given the bit we have assigned in ActivityInfo.
     */
    public static int[] CONFIG_NATIVE_BITS = new int[] {
        0x0001, // MNC
        0x0002, // MCC
        0x0004, // LOCALE
        0x0008, // TOUCH SCREEN
        0x0010, // KEYBOARD
        0x0020, // KEYBOARD HIDDEN
        0x0040, // NAVIGATION
        0x0080, // ORIENTATION
        0x0800, // SCREEN LAYOUT
        0x1000, // UI MODE
        0x0200, // SCREEN SIZE
    };
    /** @hide
     * Convert Java change bits to native.
     */
    public static int activityInfoConfigToNative(int input) {
        int output = 0;
        for (int i=0; i<CONFIG_NATIVE_BITS.length; i++) {
            if ((input&(1<<i)) != 0) {
                output |= CONFIG_NATIVE_BITS[i];
            }
        }
        return output;
    }

    /**
     * Bit mask of kinds of configuration changes that this activity
     * can handle itself (without being restarted by the system).
+6 −2
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ public class PackageParser {
            int cookie = assmgr.addAssetPath(mArchiveSourcePath);
            if (cookie != 0) {
                res = new Resources(assmgr, metrics, null);
                assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        Build.VERSION.RESOURCES_SDK_INT);
                parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
                assetError = false;
@@ -596,7 +596,7 @@ public class PackageParser {
        AssetManager assmgr = null;
        try {
            assmgr = new AssetManager();
            assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    Build.VERSION.RESOURCES_SDK_INT);
            int cookie = assmgr.addAssetPath(packageFilePath);
            parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
@@ -1931,6 +1931,10 @@ public class PackageParser {
            a.info.configChanges = sa.getInt(
                    com.android.internal.R.styleable.AndroidManifestActivity_configChanges,
                    0);
            if (owner.applicationInfo.targetSdkVersion
                        < android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
                a.info.configChanges |= ActivityInfo.CONFIG_SCREEN_SIZE;
            }
            a.info.softInputMode = sa.getInt(
                    com.android.internal.R.styleable.AndroidManifestActivity_windowSoftInputMode,
                    0);
+2 −1
Original line number Diff line number Diff line
@@ -652,7 +652,8 @@ public final class AssetManager {
    public native final void setConfiguration(int mcc, int mnc, String locale,
            int orientation, int touchscreen, int density, int keyboard,
            int keyboardHidden, int navigation, int screenWidth, int screenHeight,
            int screenLayout, int uiMode, int majorVersion);
            int screenWidthDp, int screenHeightDp, int screenLayout, int uiMode,
            int majorVersion);

    /**
     * Retrieve the resource identifier for the given resource name.
+54 −2
Original line number Diff line number Diff line
@@ -245,6 +245,20 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     */
    public int uiMode;

    public static final int SCREEN_WIDTH_DP_UNDEFINED = 0;

    /**
     * The current width of the available screen space, in dp units.
     */
    public int screenWidthDp;

    public static final int SCREEN_HEIGHT_DP_UNDEFINED = 0;

    /**
     * The current height of the available screen space, in dp units.
     */
    public int screenHeightDp;

    /**
     * @hide Internal book-keeping.
     */
@@ -282,6 +296,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        orientation = o.orientation;
        screenLayout = o.screenLayout;
        uiMode = o.uiMode;
        screenWidthDp = o.screenWidthDp;
        screenHeightDp = o.screenHeightDp;
        seq = o.seq;
    }
    
@@ -320,6 +336,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        sb.append(java.lang.Integer.toHexString(screenLayout));
        sb.append(" uiMode=0x");
        sb.append(java.lang.Integer.toHexString(uiMode));
        sb.append(" wdp=");
        sb.append(screenWidthDp);
        sb.append(" hdp=");
        sb.append(screenHeightDp);
        if (seq != 0) {
            sb.append(" seq=");
            sb.append(seq);
@@ -345,6 +365,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        orientation = ORIENTATION_UNDEFINED;
        screenLayout = SCREENLAYOUT_SIZE_UNDEFINED;
        uiMode = UI_MODE_TYPE_UNDEFINED;
        screenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
        screenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
        seq = 0;
    }

@@ -438,6 +460,16 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                        | (delta.uiMode&UI_MODE_NIGHT_MASK);
            }
        }
        if (delta.screenWidthDp != SCREEN_WIDTH_DP_UNDEFINED
                && screenWidthDp != delta.screenWidthDp) {
            changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
            screenWidthDp = delta.screenWidthDp;
        }
        if (delta.screenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED
                && screenHeightDp != delta.screenHeightDp) {
            changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
            screenHeightDp = delta.screenHeightDp;
        }
        
        if (delta.seq != 0) {
            seq = delta.seq;
@@ -467,9 +499,11 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     * {@link android.content.pm.ActivityInfo#CONFIG_NAVIGATION
     * PackageManager.ActivityInfo.CONFIG_NAVIGATION},
     * {@link android.content.pm.ActivityInfo#CONFIG_ORIENTATION
     * PackageManager.ActivityInfo.CONFIG_ORIENTATION}, or
     * PackageManager.ActivityInfo.CONFIG_ORIENTATION},
     * {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_LAYOUT
     * PackageManager.ActivityInfo.CONFIG_SCREEN_LAYOUT}.
     * PackageManager.ActivityInfo.CONFIG_SCREEN_LAYOUT}, or
     * {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE
     * PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE}.
     */
    public int diff(Configuration delta) {
        int changed = 0;
@@ -522,6 +556,14 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                && uiMode != delta.uiMode) {
            changed |= ActivityInfo.CONFIG_UI_MODE;
        }
        if (delta.screenWidthDp != SCREEN_WIDTH_DP_UNDEFINED
                && screenWidthDp != delta.screenWidthDp) {
            changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
        }
        if (delta.screenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED
                && screenHeightDp != delta.screenHeightDp) {
            changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
        }
        
        return changed;
    }
@@ -603,6 +645,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        dest.writeInt(orientation);
        dest.writeInt(screenLayout);
        dest.writeInt(uiMode);
        dest.writeInt(screenWidthDp);
        dest.writeInt(screenHeightDp);
        dest.writeInt(seq);
    }

@@ -624,6 +668,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        orientation = source.readInt();
        screenLayout = source.readInt();
        uiMode = source.readInt();
        screenWidthDp = source.readInt();
        screenHeightDp = source.readInt();
        seq = source.readInt();
    }
    
@@ -684,6 +730,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        n = this.screenLayout - that.screenLayout;
        if (n != 0) return n;
        n = this.uiMode - that.uiMode;
        if (n != 0) return n;
        n = this.screenWidthDp - that.screenWidthDp;
        if (n != 0) return n;
        n = this.screenHeightDp - that.screenHeightDp;
        //if (n != 0) return n;
        return n;
    }
@@ -717,6 +767,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        result = 31 * result + orientation;
        result = 31 * result + screenLayout;
        result = 31 * result + uiMode;
        result = 31 * result + screenWidthDp;
        result = 31 * result + screenHeightDp;
        return result;
    }
}
Loading