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

Commit 3b81bc18 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add manifest API to request a large heap.

You can now do android:largeHeap="true" on an application.

Doesn't yet do anything, waiting for Dalvik API.

Also tweak package parsing so that the SDK API level is set in the
configuration, allowing manifest resource value selection based on
that.

Change-Id: I6e035f9702a97b055416743b88f83a22ba4a9584
parent a032c901
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -5823,6 +5823,17 @@
 visibility="public"
>
</field>
<field name="largeHeap"
 type="int"
 transient="false"
 volatile="false"
 value="16843612"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="largeScreens"
 type="int"
 transient="false"
@@ -58290,6 +58301,17 @@
 visibility="public"
>
</field>
<field name="FLAG_LARGE_HEAP"
 type="int"
 transient="false"
 volatile="false"
 value="1048576"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="FLAG_PERSISTENT"
 type="int"
 transient="false"
+3 −0
Original line number Diff line number Diff line
@@ -77,6 +77,9 @@ public class ActivityManager {
     * This may be the same size as {@link #getMemoryClass()} on memory
     * constrained devices, or it may be significantly larger on devices with
     * a large amount of available RAM.
     *
     * <p>The is the size of the application's Dalvik heap if it has
     * specified <code>android:largeHeap="true"</code> in its manifest.
     */
    public int getLargeMemoryClass() {
        return staticGetLargeMemoryClass();
+5 −2
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.graphics.Canvas;
import android.net.IConnectivityManager;
import android.net.Proxy;
import android.net.ProxyProperties;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
@@ -3463,6 +3462,10 @@ public final class ActivityThread {
            mInstrumentation = new Instrumentation();
        }

        if ((data.appInfo.flags&ApplicationInfo.FLAG_LARGE_HEAP) != 0) {
            // XXX bump up Dalvik's heap.
        }

        // If the app is being launched for full backup or restore, bring it up in
        // a restricted environment with the base application class.
        Application app = data.info.makeApplication(data.restrictedBackupMode, null);
@@ -3471,7 +3474,7 @@ public final class ActivityThread {
        List<ProviderInfo> providers = data.providers;
        if (providers != null) {
            installContentProviders(app, providers);
            // For process that contain content providers, we want to
            // For process that contains content providers, we want to
            // ensure that the JIT is enabled "at some point".
            mH.sendEmptyMessageDelayed(H.ENABLE_JIT, 10*1000);
        }
+7 −9
Original line number Diff line number Diff line
@@ -270,14 +270,12 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
    
    /**
     * Value for {@link #flags}: this is true if the application has set
     * its android:neverEncrypt to true, false otherwise. It is used to specify
     * that this package specifically "opts-out" of a secured file system solution,
     * and will always store its data in-the-clear.
     *
     * {@hide}
     * Value for {@link #flags}: true when the application has requested a
     * large heap for its processes.  Corresponds to
     * {@link android.R.styleable#AndroidManifestApplication_largeHeap
     * android:largeHeap}.
     */
    public static final int FLAG_NEVER_ENCRYPT = 1<<30;
    public static final int FLAG_LARGE_HEAP = 1<<20;

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

    /**
     * Value for {@link #flags}: set to <code>true</code> if the application
@@ -298,7 +296,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     *
     * {@hide}
     */
    public static final int FLAG_CANT_SAVE_STATE = 1<<27;
    public static final int FLAG_CANT_SAVE_STATE = 1<<29;

    /**
     * Flags associated with the application.  Any combination of
+10 −5
Original line number Diff line number Diff line
@@ -389,11 +389,15 @@ public class PackageParser {

        XmlResourceParser parser = null;
        AssetManager assmgr = null;
        Resources res = null;
        boolean assetError = true;
        try {
            assmgr = new AssetManager();
            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,
                        Build.VERSION.RESOURCES_SDK_INT);
                parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
                assetError = false;
            } else {
@@ -413,7 +417,6 @@ public class PackageParser {
        Exception errorException = null;
        try {
            // XXXX todo: need to figure out correct configuration.
            Resources res = new Resources(assmgr, metrics, null);
            pkg = parsePackage(res, parser, flags, errorText);
        } catch (Exception e) {
            errorException = e;
@@ -593,6 +596,8 @@ 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,
                    Build.VERSION.RESOURCES_SDK_INT);
            int cookie = assmgr.addAssetPath(packageFilePath);
            parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
        } catch (Exception e) {
@@ -1574,9 +1579,9 @@ public class PackageParser {
        }

        if (sa.getBoolean(
                com.android.internal.R.styleable.AndroidManifestApplication_neverEncrypt,
                com.android.internal.R.styleable.AndroidManifestApplication_largeHeap,
                false)) {
            ai.flags |= ApplicationInfo.FLAG_NEVER_ENCRYPT;
            ai.flags |= ApplicationInfo.FLAG_LARGE_HEAP;
        }

        String str;
Loading