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

Commit 1cd0782d authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge changes from topic "nov13" into main

* changes:
  PersistableBundle for Ravenwood, with CTS.
  More android.os work for Ravenwood, with CTS.
parents 951fd41d 4ee8a655
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -832,10 +832,16 @@ public class Process {
    /**
     * Returns true if the current process is a 64-bit runtime.
     */
    @android.ravenwood.annotation.RavenwoodReplace
    public static final boolean is64Bit() {
        return VMRuntime.getRuntime().is64Bit();
    }

    /** @hide */
    public static final boolean is64Bit$ravenwood() {
        return "amd64".equals(System.getProperty("os.arch"));
    }

    private static SomeArgs sIdentity$ravenwood;

    /** @hide */
@@ -906,6 +912,7 @@ public class Process {
     * {@link #myUid()} in that a particular user will have multiple
     * distinct apps running under it each with their own uid.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static UserHandle myUserHandle() {
        return UserHandle.of(UserHandle.getUserId(myUid()));
    }
@@ -914,6 +921,7 @@ public class Process {
     * Returns whether the given uid belongs to a system core component or not.
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isCoreUid(int uid) {
        return UserHandle.isCore(uid);
    }
@@ -924,6 +932,7 @@ public class Process {
     * @return Whether the uid corresponds to an application sandbox running in
     *     a specific user.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isApplicationUid(int uid) {
        return UserHandle.isApp(uid);
    }
@@ -931,6 +940,7 @@ public class Process {
    /**
     * Returns whether the current process is in an isolated sandbox.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isIsolated() {
        return isIsolated(myUid());
    }
@@ -942,6 +952,7 @@ public class Process {
    @Deprecated
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
            publicAlternatives = "Use {@link #isIsolatedUid(int)} instead.")
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isIsolated(int uid) {
        return isIsolatedUid(uid);
    }
@@ -949,6 +960,7 @@ public class Process {
    /**
     * Returns whether the process with the given {@code uid} is an isolated sandbox.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isIsolatedUid(int uid) {
        uid = UserHandle.getAppId(uid);
        return (uid >= FIRST_ISOLATED_UID && uid <= LAST_ISOLATED_UID)
@@ -962,6 +974,7 @@ public class Process {
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isSdkSandboxUid(int uid) {
        uid = UserHandle.getAppId(uid);
        return (uid >= FIRST_SDK_SANDBOX_UID && uid <= LAST_SDK_SANDBOX_UID);
@@ -975,6 +988,7 @@ public class Process {
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    @android.ravenwood.annotation.RavenwoodKeep
    public static final int getAppUidForSdkSandboxUid(int uid) {
        return uid - (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
    }
@@ -987,6 +1001,7 @@ public class Process {
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    @android.ravenwood.annotation.RavenwoodKeep
    public static final int toSdkSandboxUid(int uid) {
        return uid + (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
    }
@@ -994,6 +1009,7 @@ public class Process {
    /**
     * Returns whether the current process is a sdk sandbox process.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isSdkSandbox() {
        return isSdkSandboxUid(myUid());
    }
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import java.util.Random;
/**
 * Representation of a user on the device.
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class UserHandle implements Parcelable {
    // NOTE: keep logic in sync with system/core/libcutils/multiuser.c

+68 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.internal.util.ArtBinaryXmlPullParser;
import com.android.internal.util.ArtBinaryXmlSerializer;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.XmlUtils;
import com.android.modules.utils.BinaryXmlPullParser;
import com.android.modules.utils.BinaryXmlSerializer;
import com.android.modules.utils.TypedXmlPullParser;
import com.android.modules.utils.TypedXmlSerializer;
@@ -38,6 +39,7 @@ import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlSerializer;

import java.io.BufferedInputStream;
@@ -115,6 +117,7 @@ public class Xml {
    /**
     * Returns a new pull parser with namespace support.
     */
    @android.ravenwood.annotation.RavenwoodReplace
    public static XmlPullParser newPullParser() {
        try {
            XmlPullParser parser = XmlObjectFactory.newXmlPullParser();
@@ -126,6 +129,12 @@ public class Xml {
        }
    }

    /** @hide */
    public static XmlPullParser newPullParser$ravenwood() {
        // TODO: remove once we're linking against libcore
        return new BinaryXmlPullParser();
    }

    /**
     * Creates a new {@link TypedXmlPullParser} which is optimized for use
     * inside the system, typically by supporting only a basic set of features.
@@ -136,10 +145,17 @@ public class Xml {
     * @hide
     */
    @SuppressWarnings("AndroidFrameworkEfficientXml")
    @android.ravenwood.annotation.RavenwoodReplace
    public static @NonNull TypedXmlPullParser newFastPullParser() {
        return XmlUtils.makeTyped(newPullParser());
    }

    /** @hide */
    public static TypedXmlPullParser newFastPullParser$ravenwood() {
        // TODO: remove once we're linking against libcore
        return new BinaryXmlPullParser();
    }

    /**
     * Creates a new {@link XmlPullParser} that reads XML documents using a
     * custom binary wire protocol which benchmarking has shown to be 8.5x
@@ -148,10 +164,17 @@ public class Xml {
     *
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodReplace
    public static @NonNull TypedXmlPullParser newBinaryPullParser() {
        return new ArtBinaryXmlPullParser();
    }

    /** @hide */
    public static TypedXmlPullParser newBinaryPullParser$ravenwood() {
        // TODO: remove once we're linking against libcore
        return new BinaryXmlPullParser();
    }

    /**
     * Creates a new {@link XmlPullParser} which is optimized for use inside the
     * system, typically by supporting only a basic set of features.
@@ -166,6 +189,7 @@ public class Xml {
     *
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodReplace
    public static @NonNull TypedXmlPullParser resolvePullParser(@NonNull InputStream in)
            throws IOException {
        final byte[] magic = new byte[4];
@@ -198,13 +222,33 @@ public class Xml {
        return xml;
    }

    /** @hide */
    public static @NonNull TypedXmlPullParser resolvePullParser$ravenwood(@NonNull InputStream in)
            throws IOException {
        // TODO: remove once we're linking against libcore
        final TypedXmlPullParser xml = new BinaryXmlPullParser();
        try {
            xml.setInput(in, StandardCharsets.UTF_8.name());
        } catch (XmlPullParserException e) {
            throw new IOException(e);
        }
        return xml;
    }

    /**
     * Creates a new xml serializer.
     */
    @android.ravenwood.annotation.RavenwoodReplace
    public static XmlSerializer newSerializer() {
        return XmlObjectFactory.newXmlSerializer();
    }

    /** @hide */
    public static XmlSerializer newSerializer$ravenwood() {
        // TODO: remove once we're linking against libcore
        return new BinaryXmlSerializer();
    }

    /**
     * Creates a new {@link XmlSerializer} which is optimized for use inside the
     * system, typically by supporting only a basic set of features.
@@ -215,10 +259,17 @@ public class Xml {
     * @hide
     */
    @SuppressWarnings("AndroidFrameworkEfficientXml")
    @android.ravenwood.annotation.RavenwoodReplace
    public static @NonNull TypedXmlSerializer newFastSerializer() {
        return XmlUtils.makeTyped(new FastXmlSerializer());
    }

    /** @hide */
    public static @NonNull TypedXmlSerializer newFastSerializer$ravenwood() {
        // TODO: remove once we're linking against libcore
        return new BinaryXmlSerializer();
    }

    /**
     * Creates a new {@link XmlSerializer} that writes XML documents using a
     * custom binary wire protocol which benchmarking has shown to be 4.4x
@@ -227,10 +278,17 @@ public class Xml {
     *
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodReplace
    public static @NonNull TypedXmlSerializer newBinarySerializer() {
        return new ArtBinaryXmlSerializer();
    }

    /** @hide */
    public static @NonNull TypedXmlSerializer newBinarySerializer$ravenwood() {
        // TODO: remove once we're linking against libcore
        return new BinaryXmlSerializer();
    }

    /**
     * Creates a new {@link XmlSerializer} which is optimized for use inside the
     * system, typically by supporting only a basic set of features.
@@ -245,6 +303,7 @@ public class Xml {
     *
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodReplace
    public static @NonNull TypedXmlSerializer resolveSerializer(@NonNull OutputStream out)
            throws IOException {
        final TypedXmlSerializer xml;
@@ -257,6 +316,15 @@ public class Xml {
        return xml;
    }

    /** @hide */
    public static @NonNull TypedXmlSerializer resolveSerializer$ravenwood(@NonNull OutputStream out)
            throws IOException {
        // TODO: remove once we're linking against libcore
        final TypedXmlSerializer xml = new BinaryXmlSerializer();
        xml.setOutput(out, StandardCharsets.UTF_8.name());
        return xml;
    }

    /**
     * Copy the first XML document into the second document.
     * <p>
+12 −3
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.util.CharsetUtils;

import com.android.modules.utils.FastDataInput;

import dalvik.system.VMRuntime;

import java.io.DataInput;
import java.io.IOException;
import java.io.InputStream;
@@ -35,13 +37,14 @@ import java.util.concurrent.atomic.AtomicReference;
 */
public class ArtFastDataInput extends FastDataInput {
    private static AtomicReference<ArtFastDataInput> sInCache = new AtomicReference<>();
    private static VMRuntime sRuntime = VMRuntime.getRuntime();

    private final long mBufferPtr;

    public ArtFastDataInput(@NonNull InputStream in, int bufferSize) {
        super(in, bufferSize);

        mBufferPtr = mRuntime.addressOf(mBuffer);
        mBufferPtr = sRuntime.addressOf(mBuffer);
    }

    /**
@@ -66,6 +69,7 @@ public class ArtFastDataInput extends FastDataInput {
     * Release a {@link ArtFastDataInput} to potentially be recycled. You must not
     * interact with the object after releasing it.
     */
    @Override
    public void release() {
        super.release();

@@ -75,6 +79,11 @@ public class ArtFastDataInput extends FastDataInput {
        }
    }

    @Override
    public byte[] newByteArray(int bufferSize) {
        return (byte[]) sRuntime.newNonMovableArray(byte.class, bufferSize);
    }

    @Override
    public String readUTF() throws IOException {
        // Attempt to read directly from buffer space if there's enough room,
@@ -86,9 +95,9 @@ public class ArtFastDataInput extends FastDataInput {
            mBufferPos += len;
            return res;
        } else {
            final byte[] tmp = (byte[]) mRuntime.newNonMovableArray(byte.class, len + 1);
            final byte[] tmp = (byte[]) sRuntime.newNonMovableArray(byte.class, len + 1);
            readFully(tmp, 0, len);
            return CharsetUtils.fromModifiedUtf8Bytes(mRuntime.addressOf(tmp), 0, len);
            return CharsetUtils.fromModifiedUtf8Bytes(sRuntime.addressOf(tmp), 0, len);
        }
    }
}
+11 −3
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.util.CharsetUtils;

import com.android.modules.utils.FastDataOutput;

import dalvik.system.VMRuntime;

import java.io.DataOutput;
import java.io.IOException;
import java.io.OutputStream;
@@ -35,13 +37,14 @@ import java.util.concurrent.atomic.AtomicReference;
 */
public class ArtFastDataOutput extends FastDataOutput {
    private static AtomicReference<ArtFastDataOutput> sOutCache = new AtomicReference<>();
    private static VMRuntime sRuntime = VMRuntime.getRuntime();

    private final long mBufferPtr;

    public ArtFastDataOutput(@NonNull OutputStream out, int bufferSize) {
        super(out, bufferSize);

        mBufferPtr = mRuntime.addressOf(mBuffer);
        mBufferPtr = sRuntime.addressOf(mBuffer);
    }

    /**
@@ -72,6 +75,11 @@ public class ArtFastDataOutput extends FastDataOutput {
        }
    }

    @Override
    public byte[] newByteArray(int bufferSize) {
        return (byte[]) sRuntime.newNonMovableArray(byte.class, bufferSize);
    }

    @Override
    public void writeUTF(String s) throws IOException {
        // Attempt to write directly to buffer space if there's enough room,
@@ -94,8 +102,8 @@ public class ArtFastDataOutput extends FastDataOutput {
            // Negative value indicates buffer was too small and we need to
            // allocate a temporary buffer for encoding
            len = -len;
            final byte[] tmp = (byte[]) mRuntime.newNonMovableArray(byte.class, len + 1);
            CharsetUtils.toModifiedUtf8Bytes(s, mRuntime.addressOf(tmp), 0, tmp.length);
            final byte[] tmp = (byte[]) sRuntime.newNonMovableArray(byte.class, len + 1);
            CharsetUtils.toModifiedUtf8Bytes(s, sRuntime.addressOf(tmp), 0, tmp.length);
            writeShort(len);
            write(tmp, 0, len);
        }
Loading