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

Commit acdc1133 authored by Anton Hansson's avatar Anton Hansson Committed by Android (Google) Code Review
Browse files

Merge "Add per-partition build constants to Build class."

parents 5d61fb37 91b54f17
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -32522,6 +32522,7 @@ package android.os {
  public class Build {
    ctor public Build();
    method public static java.util.List<android.os.Build.Partition> getPartitions();
    method public static java.lang.String getRadioVersion();
    method public static java.lang.String getSerial();
    field public static final java.lang.String BOARD;
@@ -32550,6 +32551,14 @@ package android.os {
    field public static final java.lang.String USER;
  }
  public static class Build.Partition {
    ctor public Build.Partition();
    method public java.lang.String getFingerprint();
    method public java.lang.String getName();
    method public long getTimeMillis();
    field public static final java.lang.String PARTITION_NAME_SYSTEM = "system";
  }
  public static class Build.VERSION {
    ctor public Build.VERSION();
    field public static final java.lang.String BASE_OS;
+62 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import com.android.internal.telephony.TelephonyProperties;

import dalvik.system.VMRuntime;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
@@ -1083,7 +1085,67 @@ public class Build {
        return true;
    }

    /** Build information for a particular device partition. */
    public static class Partition {
        /** The name identifying the system partition. */
        public static final String PARTITION_NAME_SYSTEM = "system";

        private String mName;
        private String mFingerprint;
        private long mTimeMs;

        public Partition() {}

        private Partition(String name, String fingerprint, long timeMs) {
            mName = name;
            mFingerprint = fingerprint;
            mTimeMs = timeMs;
        }

        /** The name of this partition, e.g. "system", or "vendor" */
        public String getName() {
            return mName;
        }

        /** The build fingerprint of this partition, see {@link Build#FINGERPRINT}. */
        public String getFingerprint() {
            return mFingerprint;
        }

        /** The time (ms since epoch), at which this partition was built, see {@link Build#TIME}. */
        public long getTimeMillis() {
            return mTimeMs;
        }
    }

    /**
     * Get build information about partitions that have a separate fingerprint defined.
     *
     * The list includes partitions that are suitable candidates for over-the-air updates. This is
     * not an exhaustive list of partitions on the device.
     */
    public static List<Partition> getPartitions() {
        ArrayList<Partition> partitions = new ArrayList();

        String[] names = new String[] {
            "bootimage", "odm", "product", "product_services", Partition.PARTITION_NAME_SYSTEM,
            "vendor"
        };
        for (String name : names) {
            String fingerprint = SystemProperties.get("ro." + name + ".build.fingerprint");
            if (TextUtils.isEmpty(fingerprint)) {
                continue;
            }
            long time = getLong("ro." + name + ".build.date.utc") * 1000;
            partitions.add(new Partition(name, fingerprint, time));
        }

        return partitions;
    }

    // The following properties only make sense for internal engineering builds.

    /** The time at which the build was produced, given in milliseconds since the UNIX epoch. */
    public static final long TIME = getLong("ro.build.date.utc") * 1000;
    public static final String USER = getString("ro.build.user");
    public static final String HOST = getString("ro.build.host");