summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapi/current.txt9
-rw-r--r--core/java/android/os/Build.java62
2 files changed, 71 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index c132efb31ce4..7d6c9397e940 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -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;
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 6bd2e76cdf35..8681893702b4 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -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");