summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/pm/PackagePartitions.java64
-rwxr-xr-xcore/java/android/os/Build.java20
2 files changed, 74 insertions, 10 deletions
diff --git a/core/java/android/content/pm/PackagePartitions.java b/core/java/android/content/pm/PackagePartitions.java
index d1577684aac6..ff80e614be58 100644
--- a/core/java/android/content/pm/PackagePartitions.java
+++ b/core/java/android/content/pm/PackagePartitions.java
@@ -19,8 +19,11 @@ package android.content.pm;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.os.Build;
+import android.os.Build.Partition;
import android.os.Environment;
import android.os.FileUtils;
+import android.os.SystemProperties;
import com.android.internal.annotations.VisibleForTesting;
@@ -64,20 +67,34 @@ public class PackagePartitions {
*/
private static final ArrayList<SystemPartition> SYSTEM_PARTITIONS =
new ArrayList<>(Arrays.asList(
- new SystemPartition(Environment.getRootDirectory(), PARTITION_SYSTEM,
+ new SystemPartition(Environment.getRootDirectory(),
+ PARTITION_SYSTEM, Partition.PARTITION_NAME_SYSTEM,
true /* containsPrivApp */, false /* containsOverlay */),
- new SystemPartition(Environment.getVendorDirectory(), PARTITION_VENDOR,
+ new SystemPartition(Environment.getVendorDirectory(),
+ PARTITION_VENDOR, Partition.PARTITION_NAME_VENDOR,
true /* containsPrivApp */, true /* containsOverlay */),
- new SystemPartition(Environment.getOdmDirectory(), PARTITION_ODM,
+ new SystemPartition(Environment.getOdmDirectory(),
+ PARTITION_ODM, Partition.PARTITION_NAME_ODM,
true /* containsPrivApp */, true /* containsOverlay */),
- new SystemPartition(Environment.getOemDirectory(), PARTITION_OEM,
+ new SystemPartition(Environment.getOemDirectory(),
+ PARTITION_OEM, Partition.PARTITION_NAME_OEM,
false /* containsPrivApp */, true /* containsOverlay */),
- new SystemPartition(Environment.getProductDirectory(), PARTITION_PRODUCT,
+ new SystemPartition(Environment.getProductDirectory(),
+ PARTITION_PRODUCT, Partition.PARTITION_NAME_PRODUCT,
true /* containsPrivApp */, true /* containsOverlay */),
- new SystemPartition(Environment.getSystemExtDirectory(), PARTITION_SYSTEM_EXT,
+ new SystemPartition(Environment.getSystemExtDirectory(),
+ PARTITION_SYSTEM_EXT, Partition.PARTITION_NAME_SYSTEM_EXT,
true /* containsPrivApp */, true /* containsOverlay */)));
/**
+ * A string to represent the fingerprint of this build and all package partitions. Using it to
+ * determine whether the system update has occurred. Different from {@link Build#FINGERPRINT},
+ * this string is digested from the fingerprints of the build and all package partitions to
+ * help detect the partition update.
+ */
+ public static final String FINGERPRINT = getFingerprint();
+
+ /**
* Returns a list in which the elements are products of the specified function applied to the
* list of {@link #SYSTEM_PARTITIONS} in increasing specificity order.
*/
@@ -101,6 +118,23 @@ public class PackagePartitions {
}
}
+ /**
+ * Returns a fingerprint string for this build and all package partitions. The string is
+ * digested from the fingerprints of the build and all package partitions.
+ *
+ * @return A string to represent the fingerprint of this build and all package partitions.
+ */
+ @NonNull
+ private static String getFingerprint() {
+ final String[] digestProperties = new String[SYSTEM_PARTITIONS.size() + 1];
+ for (int i = 0; i < SYSTEM_PARTITIONS.size(); i++) {
+ final String partitionName = SYSTEM_PARTITIONS.get(i).getName();
+ digestProperties[i] = "ro." + partitionName + ".build.fingerprint";
+ }
+ digestProperties[SYSTEM_PARTITIONS.size()] = "ro.build.fingerprint"; // build fingerprint
+ return SystemProperties.digestOf(digestProperties);
+ }
+
/** Represents a partition that contains application packages. */
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
public static class SystemPartition {
@@ -108,6 +142,9 @@ public class PackagePartitions {
public final int type;
@NonNull
+ private final String mName;
+
+ @NonNull
private final DeferredCanonicalFile mFolder;
@Nullable
@@ -122,9 +159,10 @@ public class PackagePartitions {
@NonNull
private final File mNonConicalFolder;
- private SystemPartition(@NonNull File folder, @PartitionType int type,
+ private SystemPartition(@NonNull File folder, @PartitionType int type, String name,
boolean containsPrivApp, boolean containsOverlay) {
this.type = type;
+ this.mName = name;
this.mFolder = new DeferredCanonicalFile(folder);
this.mAppFolder = new DeferredCanonicalFile(folder, "app");
this.mPrivAppFolder = containsPrivApp ? new DeferredCanonicalFile(folder, "priv-app")
@@ -136,6 +174,7 @@ public class PackagePartitions {
public SystemPartition(@NonNull SystemPartition original) {
this.type = original.type;
+ this.mName = original.mName;
this.mFolder = new DeferredCanonicalFile(original.mFolder.getFile());
this.mAppFolder = original.mAppFolder;
this.mPrivAppFolder = original.mPrivAppFolder;
@@ -148,10 +187,19 @@ public class PackagePartitions {
* different root folder.
*/
public SystemPartition(@NonNull File rootFolder, @NonNull SystemPartition partition) {
- this(rootFolder, partition.type, partition.mPrivAppFolder != null,
+ this(rootFolder, partition.type, partition.mName, partition.mPrivAppFolder != null,
partition.mOverlayFolder != null);
}
+ /**
+ * Returns the name identifying the partition.
+ * @see Partition
+ */
+ @NonNull
+ public String getName() {
+ return mName;
+ }
+
/** Returns the canonical folder of the partition. */
@NonNull
public File getFolder() {
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 743468a6dd08..35b9ccc83e0b 100755
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -1294,6 +1294,18 @@ public class Build {
public static class Partition {
/** The name identifying the system partition. */
public static final String PARTITION_NAME_SYSTEM = "system";
+ /** @hide */
+ public static final String PARTITION_NAME_BOOTIMAGE = "bootimage";
+ /** @hide */
+ public static final String PARTITION_NAME_ODM = "odm";
+ /** @hide */
+ public static final String PARTITION_NAME_OEM = "oem";
+ /** @hide */
+ public static final String PARTITION_NAME_PRODUCT = "product";
+ /** @hide */
+ public static final String PARTITION_NAME_SYSTEM_EXT = "system_ext";
+ /** @hide */
+ public static final String PARTITION_NAME_VENDOR = "vendor";
private final String mName;
private final String mFingerprint;
@@ -1350,8 +1362,12 @@ public class Build {
ArrayList<Partition> partitions = new ArrayList();
String[] names = new String[] {
- "bootimage", "odm", "product", "system_ext", Partition.PARTITION_NAME_SYSTEM,
- "vendor"
+ Partition.PARTITION_NAME_BOOTIMAGE,
+ Partition.PARTITION_NAME_ODM,
+ Partition.PARTITION_NAME_PRODUCT,
+ Partition.PARTITION_NAME_SYSTEM_EXT,
+ Partition.PARTITION_NAME_SYSTEM,
+ Partition.PARTITION_NAME_VENDOR
};
for (String name : names) {
String fingerprint = SystemProperties.get("ro." + name + ".build.fingerprint");