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

Commit 23085b78 authored by Ben Cheng's avatar Ben Cheng
Browse files

Support per-application switch to execute the VM in safe mode.

The new attribute can be set by adding android:safeMode="true"
in AndroidManifest.xml with the SDK.

Tested with pairing locally compiled SDK with Eclipse and verified that the JIT
(the only component currently included in the safe mode) is indeed disabled
with the new attribute.

Bug: 2267583
parent 60586f2e
Loading
Loading
Loading
Loading
+35 −2
Original line number Diff line number Diff line
@@ -6829,6 +6829,17 @@
 visibility="public"
>
</field>
<field name="safeMode"
 type="int"
 transient="false"
 volatile="false"
 value="16843449"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="saveEnabled"
 type="int"
 transient="false"
@@ -41876,6 +41887,17 @@
 visibility="public"
>
</field>
<field name="FLAG_VM_SAFE_MODE"
 type="int"
 transient="false"
 volatile="false"
 value="16384"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="className"
 type="java.lang.String"
 transient="false"
@@ -72605,7 +72627,7 @@
 type="float"
 transient="false"
 volatile="false"
 value="0.001f"
 value="0.0010f"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -210370,7 +210392,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
@@ -214130,6 +214152,17 @@
 visibility="public"
>
</field>
<field name="DEBUG_ENABLE_SAFEMODE"
 type="int"
 transient="false"
 volatile="false"
 value="8"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
</package>
<package name="java.awt.font"
+16 −8
Original line number Diff line number Diff line
@@ -177,13 +177,21 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
    
    /**
     * Value for {@link #flags}: set to true if this application would like to
     * request the VM to operate under the safe mode. Comes from
     * {@link android.R.styleable#AndroidManifestApplication_safeMode
     * android:safeMode} of the &lt;application&gt; tag.
     */
    public static final int FLAG_VM_SAFE_MODE = 1<<14;

    /**
     * Value for {@link #flags}: this is false if the application has set
     * its android:allowBackup to false, true otherwise.
     * 
     * {@hide}
     */
    public static final int FLAG_ALLOW_BACKUP = 1<<14;
    public static final int FLAG_ALLOW_BACKUP = 1<<15;

    /**
     * Value for {@link #flags}: this is false if the application has set
@@ -194,7 +202,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     * {@hide}
     */
    public static final int FLAG_KILL_AFTER_RESTORE = 1<<15;
    public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;

    /**
     * Value for {@link #flags}: this is true if the application has set
@@ -205,7 +213,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     * {@hide}
     */
    public static final int FLAG_RESTORE_NEEDS_APPLICATION = 1<<16;
    public static final int FLAG_RESTORE_NEEDS_APPLICATION = 1<<17;

    /**
     * Value for {@link #flags}: this is true if the application has set
@@ -215,7 +223,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     * {@hide}
     */
    public static final int FLAG_NEVER_ENCRYPT = 1<<17;
    public static final int FLAG_NEVER_ENCRYPT = 1<<18;

    /**
     * Value for {@link #flags}: Set to true if the application has been
@@ -223,7 +231,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     * {@hide}
     */
    public static final int FLAG_FORWARD_LOCK = 1<<18;
    public static final int FLAG_FORWARD_LOCK = 1<<19;

    /**
     * Value for {@link #flags}: Set to true if the application is
@@ -231,7 +239,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     * {@hide}
     */
    public static final int FLAG_ON_SDCARD = 1<<19;
    public static final int FLAG_ON_SDCARD = 1<<20;

    /**
     * Value for {@link #flags}: Set to true if the application is
@@ -239,7 +247,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     * {@hide}
     */
    public static final int FLAG_NATIVE_DEBUGGABLE = 1<<20;
    public static final int FLAG_NATIVE_DEBUGGABLE = 1<<21;

    /**
     * Flags associated with the application.  Any combination of
@@ -250,7 +258,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
     * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
     * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_RESIZEABLE_FOR_SCREENS},
     * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}
     * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE}
     */
    public int flags = 0;
    
+6 −0
Original line number Diff line number Diff line
@@ -1428,6 +1428,12 @@ public class PackageParser {
            ai.flags |= ApplicationInfo.FLAG_DEBUGGABLE;
        }

        if (sa.getBoolean(
                com.android.internal.R.styleable.AndroidManifestApplication_safeMode,
                false)) {
            ai.flags |= ApplicationInfo.FLAG_VM_SAFE_MODE;
        }

        if (sa.getBoolean(
                com.android.internal.R.styleable.AndroidManifestApplication_hasCode,
                true)) {
+3 −0
Original line number Diff line number Diff line
@@ -504,6 +504,9 @@ public class Process {
            argsForZygote.add("--runtime-init");
            argsForZygote.add("--setuid=" + uid);
            argsForZygote.add("--setgid=" + gid);
            if ((debugFlags & Zygote.DEBUG_ENABLE_SAFEMODE) != 0) {
                argsForZygote.add("--enable-safemode");
            }
            if ((debugFlags & Zygote.DEBUG_ENABLE_DEBUGGER) != 0) {
                argsForZygote.add("--enable-debugger");
            }
+6 −1
Original line number Diff line number Diff line
@@ -295,7 +295,10 @@ class ZygoteConnection {
        /** from --peer-wait */
        boolean peerWait;

        /** from --enable-debugger, --enable-checkjni, --enable-assert */
        /**
         * From --enable-debugger, --enable-checkjni, --enable-assert, and
         * --enable-safemode
         */
        int debugFlags;

        /** from --classpath */
@@ -363,6 +366,8 @@ class ZygoteConnection {
                            arg.substring(arg.indexOf('=') + 1));
                } else if (arg.equals("--enable-debugger")) {
                    debugFlags |= Zygote.DEBUG_ENABLE_DEBUGGER;
                } else if (arg.equals("--enable-safemode")) {
                    debugFlags |= Zygote.DEBUG_ENABLE_SAFEMODE;
                } else if (arg.equals("--enable-checkjni")) {
                    debugFlags |= Zygote.DEBUG_ENABLE_CHECKJNI;
                } else if (arg.equals("--enable-assert")) {
Loading