From 04cc191c3cb79fd8875d813dcd25b6f797eb34cc Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Fri, 3 Mar 2017 13:05:12 -0800 Subject: [PATCH] expose isSealed() from the installer session Change-Id: I5232a012fbee8931b0e3f584d6bb2e273a789dee Fixes: 35948628 Test: Manual --- api/current.txt | 3 ++- api/system-current.txt | 4 +++- api/test-current.txt | 3 ++- .../android/content/pm/PackageInstaller.java | 17 ++++++++++++++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/api/current.txt b/api/current.txt index 0872b2d7d7072..4ab4afa8f72fb 100644 --- a/api/current.txt +++ b/api/current.txt @@ -10221,6 +10221,7 @@ package android.content.pm { method public float getProgress(); method public int getSessionId(); method public boolean isActive(); + method public boolean isSealed(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } @@ -30125,12 +30126,12 @@ package android.os { field public static final int BATTERY_PLUGGED_AC = 1; // 0x1 field public static final int BATTERY_PLUGGED_USB = 2; // 0x2 field public static final int BATTERY_PLUGGED_WIRELESS = 4; // 0x4 - field public static final int BATTERY_PROPERTY_STATUS = 6; // 0x6 field public static final int BATTERY_PROPERTY_CAPACITY = 4; // 0x4 field public static final int BATTERY_PROPERTY_CHARGE_COUNTER = 1; // 0x1 field public static final int BATTERY_PROPERTY_CURRENT_AVERAGE = 3; // 0x3 field public static final int BATTERY_PROPERTY_CURRENT_NOW = 2; // 0x2 field public static final int BATTERY_PROPERTY_ENERGY_COUNTER = 5; // 0x5 + field public static final int BATTERY_PROPERTY_STATUS = 6; // 0x6 field public static final int BATTERY_STATUS_CHARGING = 2; // 0x2 field public static final int BATTERY_STATUS_DISCHARGING = 3; // 0x3 field public static final int BATTERY_STATUS_FULL = 5; // 0x5 diff --git a/api/system-current.txt b/api/system-current.txt index c321e08619c80..c4829fb4a0e30 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -10700,6 +10700,7 @@ package android.content.pm { method public android.content.pm.PackageInstaller.Session openSession(int) throws java.io.IOException; method public void registerSessionCallback(android.content.pm.PackageInstaller.SessionCallback); method public void registerSessionCallback(android.content.pm.PackageInstaller.SessionCallback, android.os.Handler); + method public void setPermissionsResult(int, boolean); method public void uninstall(java.lang.String, android.content.IntentSender); method public void uninstall(android.content.pm.VersionedPackage, android.content.IntentSender); method public void unregisterSessionCallback(android.content.pm.PackageInstaller.SessionCallback); @@ -10757,6 +10758,7 @@ package android.content.pm { method public float getProgress(); method public int getSessionId(); method public boolean isActive(); + method public boolean isSealed(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } @@ -32726,12 +32728,12 @@ package android.os { field public static final int BATTERY_PLUGGED_AC = 1; // 0x1 field public static final int BATTERY_PLUGGED_USB = 2; // 0x2 field public static final int BATTERY_PLUGGED_WIRELESS = 4; // 0x4 - field public static final int BATTERY_PROPERTY_STATUS = 6; // 0x6 field public static final int BATTERY_PROPERTY_CAPACITY = 4; // 0x4 field public static final int BATTERY_PROPERTY_CHARGE_COUNTER = 1; // 0x1 field public static final int BATTERY_PROPERTY_CURRENT_AVERAGE = 3; // 0x3 field public static final int BATTERY_PROPERTY_CURRENT_NOW = 2; // 0x2 field public static final int BATTERY_PROPERTY_ENERGY_COUNTER = 5; // 0x5 + field public static final int BATTERY_PROPERTY_STATUS = 6; // 0x6 field public static final int BATTERY_STATUS_CHARGING = 2; // 0x2 field public static final int BATTERY_STATUS_DISCHARGING = 3; // 0x3 field public static final int BATTERY_STATUS_FULL = 5; // 0x5 diff --git a/api/test-current.txt b/api/test-current.txt index 584903293669f..f324bfb434ef9 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -10253,6 +10253,7 @@ package android.content.pm { method public float getProgress(); method public int getSessionId(); method public boolean isActive(); + method public boolean isSealed(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } @@ -30221,12 +30222,12 @@ package android.os { field public static final int BATTERY_PLUGGED_AC = 1; // 0x1 field public static final int BATTERY_PLUGGED_USB = 2; // 0x2 field public static final int BATTERY_PLUGGED_WIRELESS = 4; // 0x4 - field public static final int BATTERY_PROPERTY_STATUS = 6; // 0x6 field public static final int BATTERY_PROPERTY_CAPACITY = 4; // 0x4 field public static final int BATTERY_PROPERTY_CHARGE_COUNTER = 1; // 0x1 field public static final int BATTERY_PROPERTY_CURRENT_AVERAGE = 3; // 0x3 field public static final int BATTERY_PROPERTY_CURRENT_NOW = 2; // 0x2 field public static final int BATTERY_PROPERTY_ENERGY_COUNTER = 5; // 0x5 + field public static final int BATTERY_PROPERTY_STATUS = 6; // 0x6 field public static final int BATTERY_STATUS_CHARGING = 2; // 0x2 field public static final int BATTERY_STATUS_DISCHARGING = 3; // 0x3 field public static final int BATTERY_STATUS_FULL = 5; // 0x5 diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 9d04cc9bff5e7..76c29bcd5ae61 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -465,6 +465,7 @@ public class PackageInstaller { } /** {@hide} */ + @SystemApi public void setPermissionsResult(int sessionId, boolean accepted) { try { mInstaller.setPermissionsResult(sessionId, accepted); @@ -845,9 +846,9 @@ public class PackageInstaller { * user intervention, and so it may not happen immediately. The final * result of the commit will be reported through the given callback. *

- * Once this method is called, no additional mutations may be performed - * on the session. If the device reboots before the session has been - * finalized, you may commit the session again. + * Once this method is called, the session is sealed and no additional + * mutations may be performed on the session. If the device reboots + * before the session has been finalized, you may commit the session again. * * @throws SecurityException if streams opened through * {@link #openWrite(String, long, long)} are still open. @@ -1278,6 +1279,16 @@ public class PackageInstaller { return active; } + /** + * Return if this session is sealed. + *

+ * Once sealed, no further changes may be made to the session. A session + * is sealed the moment {@link Session#commit(IntentSender)} is called. + */ + public boolean isSealed() { + return sealed; + } + /** * Return the reason for installing this package. *