diff options
author | Justin Klaassen <justinklaassen@google.com> | 2017-11-30 18:18:21 -0500 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2017-11-30 18:18:21 -0500 |
commit | 4217cf85c20565a3446a662a7f07f26137b26b7f (patch) | |
tree | a0417b47a8cc802f6642f369fd2371165bec7b5c /android/content | |
parent | 6a65f2da209bff03cb0eb6da309710ac6ee5026d (diff) | |
download | android-28-4217cf85c20565a3446a662a7f07f26137b26b7f.tar.gz |
Import Android SDK Platform P [4477446]
/google/data/ro/projects/android/fetch_artifact \
--bid 4477446 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4477446.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: If0559643d7c328e36aafca98f0c114641d33642c
Diffstat (limited to 'android/content')
-rw-r--r-- | android/content/CursorLoader.java | 2 | ||||
-rw-r--r-- | android/content/pm/ActivityInfo.java | 2 | ||||
-rw-r--r-- | android/content/pm/ApplicationInfo.java | 28 | ||||
-rw-r--r-- | android/content/pm/InstantAppInfo.java | 2 | ||||
-rw-r--r-- | android/content/pm/PackageInfo.java | 28 | ||||
-rw-r--r-- | android/content/pm/PackageInstaller.java | 3 | ||||
-rw-r--r-- | android/content/pm/PackageManager.java | 278 | ||||
-rw-r--r-- | android/content/pm/PackageManagerInternal.java | 8 | ||||
-rw-r--r-- | android/content/pm/PackageParser.java | 123 | ||||
-rw-r--r-- | android/content/pm/PermissionInfo.java | 18 |
10 files changed, 271 insertions, 221 deletions
diff --git a/android/content/CursorLoader.java b/android/content/CursorLoader.java index 33386e5c..7f24c51d 100644 --- a/android/content/CursorLoader.java +++ b/android/content/CursorLoader.java @@ -145,7 +145,7 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> { } /** - * Starts an asynchronous load of the contacts list data. When the result is ready the callbacks + * Starts an asynchronous load of the data. When the result is ready the callbacks * will be called on the UI thread. If a previous load has been completed and is still valid * the result may be passed to the callbacks immediately. * diff --git a/android/content/pm/ActivityInfo.java b/android/content/pm/ActivityInfo.java index 837c00a7..f8cdce64 100644 --- a/android/content/pm/ActivityInfo.java +++ b/android/content/pm/ActivityInfo.java @@ -1156,6 +1156,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { dest.writeString(permission); dest.writeString(taskAffinity); dest.writeString(targetActivity); + dest.writeString(launchToken); dest.writeInt(flags); dest.writeInt(screenOrientation); dest.writeInt(configChanges); @@ -1282,6 +1283,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { permission = source.readString(); taskAffinity = source.readString(); targetActivity = source.readString(); + launchToken = source.readString(); flags = source.readInt(); screenOrientation = source.readInt(); configChanges = source.readInt(); diff --git a/android/content/pm/ApplicationInfo.java b/android/content/pm/ApplicationInfo.java index 20342807..edb27cd4 100644 --- a/android/content/pm/ApplicationInfo.java +++ b/android/content/pm/ApplicationInfo.java @@ -19,6 +19,7 @@ package android.content.pm; import static android.os.Build.VERSION_CODES.DONUT; import android.annotation.IntDef; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; import android.content.Context; @@ -890,6 +891,29 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { public int versionCode; /** + * The user-visible SDK version (ex. 26) of the framework against which the application claims + * to have been compiled, or {@code 0} if not specified. + * <p> + * This property is the compile-time equivalent of + * {@link android.os.Build.VERSION#CODENAME Build.VERSION.SDK_INT}. + * + * @hide For platform use only; we don't expect developers to need to read this value. + */ + public int compileSdkVersion; + + /** + * The development codename (ex. "O", "REL") of the framework against which the application + * claims to have been compiled, or {@code null} if not specified. + * <p> + * This property is the compile-time equivalent of + * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}. + * + * @hide For platform use only; we don't expect developers to need to read this value. + */ + @Nullable + public String compileSdkVersionCodename; + + /** * When false, indicates that all components within this application are * considered disabled, regardless of their individually set enabled status. */ @@ -1305,6 +1329,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { dest.writeInt(targetSandboxVersion); dest.writeString(classLoaderName); dest.writeStringArray(splitClassLoaderNames); + dest.writeInt(compileSdkVersion); + dest.writeString(compileSdkVersionCodename); } public static final Parcelable.Creator<ApplicationInfo> CREATOR @@ -1372,6 +1398,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { targetSandboxVersion = source.readInt(); classLoaderName = source.readString(); splitClassLoaderNames = source.readStringArray(); + compileSdkVersion = source.readInt(); + compileSdkVersionCodename = source.readString(); } /** diff --git a/android/content/pm/InstantAppInfo.java b/android/content/pm/InstantAppInfo.java index 67afc928..cb04fc3c 100644 --- a/android/content/pm/InstantAppInfo.java +++ b/android/content/pm/InstantAppInfo.java @@ -18,6 +18,7 @@ package android.content.pm; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemApi; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; @@ -31,6 +32,7 @@ import android.os.Parcelable; * * @hide */ +@SystemApi public final class InstantAppInfo implements Parcelable { private final ApplicationInfo mApplicationInfo; diff --git a/android/content/pm/PackageInfo.java b/android/content/pm/PackageInfo.java index ba488f6a..f8889b68 100644 --- a/android/content/pm/PackageInfo.java +++ b/android/content/pm/PackageInfo.java @@ -16,6 +16,7 @@ package android.content.pm; +import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; @@ -289,6 +290,29 @@ public class PackageInfo implements Parcelable { /** @hide */ public boolean isStaticOverlay; + /** + * The user-visible SDK version (ex. 26) of the framework against which the application claims + * to have been compiled, or {@code 0} if not specified. + * <p> + * This property is the compile-time equivalent of + * {@link android.os.Build.VERSION#SDK_INT Build.VERSION.SDK_INT}. + * + * @hide For platform use only; we don't expect developers to need to read this value. + */ + public int compileSdkVersion; + + /** + * The development codename (ex. "O", "REL") of the framework against which the application + * claims to have been compiled, or {@code null} if not specified. + * <p> + * This property is the compile-time equivalent of + * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}. + * + * @hide For platform use only; we don't expect developers to need to read this value. + */ + @Nullable + public String compileSdkVersionCodename; + public PackageInfo() { } @@ -344,6 +368,8 @@ public class PackageInfo implements Parcelable { dest.writeString(overlayTarget); dest.writeInt(isStaticOverlay ? 1 : 0); dest.writeInt(overlayPriority); + dest.writeInt(compileSdkVersion); + dest.writeString(compileSdkVersionCodename); } public static final Parcelable.Creator<PackageInfo> CREATOR @@ -396,6 +422,8 @@ public class PackageInfo implements Parcelable { overlayTarget = source.readString(); isStaticOverlay = source.readInt() != 0; overlayPriority = source.readInt(); + compileSdkVersion = source.readInt(); + compileSdkVersionCodename = source.readString(); // The component lists were flattened with the redundant ApplicationInfo // instances omitted. Distribute the canonical one here as appropriate. diff --git a/android/content/pm/PackageInstaller.java b/android/content/pm/PackageInstaller.java index 86288396..77c5743f 100644 --- a/android/content/pm/PackageInstaller.java +++ b/android/content/pm/PackageInstaller.java @@ -81,6 +81,9 @@ import java.util.List; * <li>All APKs must have unique split names. * <li>All installations must contain a single base APK. * </ul> + * <p> + * The ApiDemos project contains examples of using this API: + * <code>ApiDemos/src/com/example/android/apis/content/InstallApk*.java</code>. */ public class PackageInstaller { private static final String TAG = "PackageInstaller"; diff --git a/android/content/pm/PackageManager.java b/android/content/pm/PackageManager.java index 31ca1985..f796aabe 100644 --- a/android/content/pm/PackageManager.java +++ b/android/content/pm/PackageManager.java @@ -871,8 +871,8 @@ public abstract class PackageManager { public static final int INSTALL_REASON_USER = 4; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} on success. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * on success. * * @hide */ @@ -880,8 +880,8 @@ public abstract class PackageManager { public static final int INSTALL_SUCCEEDED = 1; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the package is already installed. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the package is already installed. * * @hide */ @@ -889,8 +889,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the package archive file is invalid. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the package archive file is invalid. * * @hide */ @@ -898,8 +898,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_INVALID_APK = -2; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the URI passed in is invalid. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the URI passed in is invalid. * * @hide */ @@ -907,9 +907,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_INVALID_URI = -3; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the package manager service found that - * the device didn't have enough storage space to install the app. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the package manager service found that the device didn't have enough storage space to + * install the app. * * @hide */ @@ -917,9 +917,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if a package is already installed with - * the same name. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if a package is already installed with the same name. * * @hide */ @@ -927,9 +926,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the requested shared user does not - * exist. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the requested shared user does not exist. * * @hide */ @@ -937,10 +935,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_NO_SHARED_USER = -6; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if a previously installed package of the - * same name has a different signature than the new package (and the old - * package's data was not removed). + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if a previously installed package of the same name has a different signature than the new + * package (and the old package's data was not removed). * * @hide */ @@ -948,10 +945,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package is requested a shared - * user which is already installed on the device and does not have matching - * signature. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package is requested a shared user which is already installed on the device and + * does not have matching signature. * * @hide */ @@ -959,9 +955,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package uses a shared library - * that is not available. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package uses a shared library that is not available. * * @hide */ @@ -969,9 +964,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package uses a shared library - * that is not available. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package uses a shared library that is not available. * * @hide */ @@ -979,10 +973,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package failed while - * optimizing and validating its dex files, either because there was not - * enough storage or the validation failed. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package failed while optimizing and validating its dex files, either because there + * was not enough storage or the validation failed. * * @hide */ @@ -990,9 +983,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_DEXOPT = -11; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package failed because the - * current SDK version is older than that required by the package. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package failed because the current SDK version is older than that required by the + * package. * * @hide */ @@ -1000,10 +993,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_OLDER_SDK = -12; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package failed because it - * contains a content provider with the same authority as a provider already - * installed in the system. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package failed because it contains a content provider with the same authority as a + * provider already installed in the system. * * @hide */ @@ -1011,9 +1003,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package failed because the - * current SDK version is newer than that required by the package. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package failed because the current SDK version is newer than that required by the + * package. * * @hide */ @@ -1021,10 +1013,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_NEWER_SDK = -14; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package failed because it has - * specified that it is a test-only package and the caller has not supplied - * the {@link #INSTALL_ALLOW_TEST} flag. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package failed because it has specified that it is a test-only package and the + * caller has not supplied the {@link #INSTALL_ALLOW_TEST} flag. * * @hide */ @@ -1032,9 +1023,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_TEST_ONLY = -15; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the package being installed contains - * native code, but none that is compatible with the device's CPU_ABI. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the package being installed contains native code, but none that is compatible with the + * device's CPU_ABI. * * @hide */ @@ -1042,9 +1033,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package uses a feature that is - * not available. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package uses a feature that is not available. * * @hide */ @@ -1053,9 +1043,9 @@ public abstract class PackageManager { // ------ Errors related to sdcard /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if a secure container mount point - * couldn't be accessed on external media. + * Installation return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if a secure container mount point couldn't be + * accessed on external media. * * @hide */ @@ -1063,9 +1053,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package couldn't be installed - * in the specified install location. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package couldn't be installed in the specified install location. * * @hide */ @@ -1073,9 +1062,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package couldn't be installed - * in the specified install location because the media is not available. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package couldn't be installed in the specified install location because the media + * is not available. * * @hide */ @@ -1083,9 +1072,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package couldn't be installed - * because the verification timed out. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package couldn't be installed because the verification timed out. * * @hide */ @@ -1093,9 +1081,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package couldn't be installed - * because the verification did not succeed. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package couldn't be installed because the verification did not succeed. * * @hide */ @@ -1103,9 +1090,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the package changed from what the - * calling program expected. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the package changed from what the calling program expected. * * @hide */ @@ -1113,28 +1099,25 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package is assigned a - * different UID than it previously held. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package is assigned a different UID than it previously held. * * @hide */ public static final int INSTALL_FAILED_UID_CHANGED = -24; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package has an older version - * code than the currently installed package. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package has an older version code than the currently installed package. * * @hide */ public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the old package has target SDK high - * enough to support runtime permission and the new package has target SDK - * low enough to not support runtime permissions. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the old package has target SDK high enough to support runtime permission and the new + * package has target SDK low enough to not support runtime permissions. * * @hide */ @@ -1142,9 +1125,8 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26; /** - * Installation return code: this is passed to the - * {@link IPackageInstallObserver} if the new package attempts to downgrade the - * target sandbox version of the app. + * Installation return code: this is passed in the {@link PackageInstaller#EXTRA_LEGACY_STATUS} + * if the new package attempts to downgrade the target sandbox version of the app. * * @hide */ @@ -1152,9 +1134,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser was given a path that is - * not a file, or does not end with the expected '.apk' extension. + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was given a path that is not a + * file, or does not end with the expected '.apk' extension. * * @hide */ @@ -1162,8 +1144,8 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser was unable to retrieve the + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser was unable to retrieve the * AndroidManifest.xml file. * * @hide @@ -1172,8 +1154,8 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser encountered an unexpected + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered an unexpected * exception. * * @hide @@ -1182,9 +1164,9 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser did not find any - * certificates in the .apk. + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any certificates in + * the .apk. * * @hide */ @@ -1192,9 +1174,9 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser found inconsistent - * certificates on the files in the .apk. + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser found inconsistent certificates on + * the files in the .apk. * * @hide */ @@ -1202,8 +1184,8 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser encountered a + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a * CertificateEncodingException in one of the files in the .apk. * * @hide @@ -1212,9 +1194,9 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser encountered a bad or - * missing package name in the manifest. + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad or missing + * package name in the manifest. * * @hide */ @@ -1222,9 +1204,9 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser encountered a bad shared - * user id name in the manifest. + * Installation parse return code: tthis is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered a bad shared user id + * name in the manifest. * * @hide */ @@ -1232,8 +1214,8 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser encountered some structural + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser encountered some structural * problem in the manifest. * * @hide @@ -1242,9 +1224,9 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; /** - * Installation parse return code: this is passed to the - * {@link IPackageInstallObserver} if the parser did not find any actionable - * tags (instrumentation or application) in the manifest. + * Installation parse return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the parser did not find any actionable tags + * (instrumentation or application) in the manifest. * * @hide */ @@ -1252,9 +1234,9 @@ public abstract class PackageManager { public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; /** - * Installation failed return code: this is passed to the - * {@link IPackageInstallObserver} if the system failed to install the - * package because of system issues. + * Installation failed return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package + * because of system issues. * * @hide */ @@ -1262,24 +1244,23 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; /** - * Installation failed return code: this is passed to the - * {@link IPackageInstallObserver} if the system failed to install the - * package because the user is restricted from installing apps. + * Installation failed return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package + * because the user is restricted from installing apps. * * @hide */ public static final int INSTALL_FAILED_USER_RESTRICTED = -111; /** - * Installation failed return code: this is passed to the - * {@link IPackageInstallObserver} if the system failed to install the - * package because it is attempting to define a permission that is already - * defined by some existing package. + * Installation failed return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package + * because it is attempting to define a permission that is already defined by some existing + * package. * <p> - * The package name of the app which has already defined the permission is - * passed to a {@link PackageInstallObserver}, if any, as the - * {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string extra; and the name of the - * permission being redefined is passed in the + * The package name of the app which has already defined the permission is passed to a + * {@link PackageInstallObserver}, if any, as the {@link #EXTRA_FAILURE_EXISTING_PACKAGE} string + * extra; and the name of the permission being redefined is passed in the * {@link #EXTRA_FAILURE_EXISTING_PERMISSION} string extra. * * @hide @@ -1287,10 +1268,9 @@ public abstract class PackageManager { public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; /** - * Installation failed return code: this is passed to the - * {@link IPackageInstallObserver} if the system failed to install the - * package because its packaged native code did not match any of the ABIs - * supported by the system. + * Installation failed return code: this is passed in the + * {@link PackageInstaller#EXTRA_LEGACY_STATUS} if the system failed to install the package + * because its packaged native code did not match any of the ABIs supported by the system. * * @hide */ @@ -1322,6 +1302,7 @@ public abstract class PackageManager { DELETE_ALL_USERS, DELETE_SYSTEM_APP, DELETE_DONT_KILL_APP, + DELETE_CHATTY, }) @Retention(RetentionPolicy.SOURCE) public @interface DeleteFlags {} @@ -1363,6 +1344,14 @@ public abstract class PackageManager { public static final int DELETE_DONT_KILL_APP = 0x00000008; /** + * Flag parameter for {@link #deletePackage} to indicate that package deletion + * should be chatty. + * + * @hide + */ + public static final int DELETE_CHATTY = 0x80000000; + + /** * Return code for when package deletion succeeds. This is passed to the * {@link IPackageDeleteObserver} if the system succeeded in deleting the * package. @@ -4718,16 +4707,6 @@ public abstract class PackageManager { @Deprecated public abstract void installPackage( Uri packageURI, - IPackageInstallObserver observer, - @InstallFlags int flags, - String installerPackageName); - /** - * @deprecated replaced by {@link PackageInstaller} - * @hide - */ - @Deprecated - public abstract void installPackage( - Uri packageURI, PackageInstallObserver observer, @InstallFlags int flags, String installerPackageName); @@ -5743,25 +5722,6 @@ public abstract class PackageManager { } /** {@hide} */ - public static class LegacyPackageInstallObserver extends PackageInstallObserver { - private final IPackageInstallObserver mLegacy; - - public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { - mLegacy = legacy; - } - - @Override - public void onPackageInstalled(String basePackageName, int returnCode, String msg, - Bundle extras) { - if (mLegacy == null) return; - try { - mLegacy.packageInstalled(basePackageName, returnCode); - } catch (RemoteException ignored) { - } - } - } - - /** {@hide} */ public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { private final IPackageDeleteObserver mLegacy; diff --git a/android/content/pm/PackageManagerInternal.java b/android/content/pm/PackageManagerInternal.java index 14cf8557..713cd109 100644 --- a/android/content/pm/PackageManagerInternal.java +++ b/android/content/pm/PackageManagerInternal.java @@ -164,6 +164,14 @@ public abstract class PackageManagerInternal { @PackageInfoFlags int flags, int filterCallingUid, int userId); /** + * Do a straight uid lookup for the given package/application in the given user. + * @see PackageManager#getPackageUidAsUser(String, int, int) + * @return The app's uid, or < 0 if the package was not found in that user + */ + public abstract int getPackageUid(String packageName, + @PackageInfoFlags int flags, int userId); + + /** * Retrieve all of the information we know about a particular package/application. * @param filterCallingUid The results will be filtered in the context of this UID instead * of the calling UID. diff --git a/android/content/pm/PackageParser.java b/android/content/pm/PackageParser.java index 1c5cf15d..ebeaad78 100644 --- a/android/content/pm/PackageParser.java +++ b/android/content/pm/PackageParser.java @@ -42,6 +42,7 @@ import static android.os.Build.VERSION_CODES.O; import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER; import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED; +import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; @@ -107,6 +108,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Constructor; import java.security.GeneralSecurityException; import java.security.KeyFactory; @@ -678,6 +681,8 @@ public class PackageParser { pi.overlayTarget = p.mOverlayTarget; pi.overlayPriority = p.mOverlayPriority; pi.isStaticOverlay = p.mIsStaticOverlay; + pi.compileSdkVersion = p.mCompileSdkVersion; + pi.compileSdkVersionCodename = p.mCompileSdkVersionCodename; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; if ((flags&PackageManager.GET_GIDS) != 0) { @@ -816,22 +821,33 @@ public class PackageParser { } } - public static final int PARSE_IS_SYSTEM = 1 << 0; - public static final int PARSE_CHATTY = 1 << 1; - public static final int PARSE_MUST_BE_APK = 1 << 2; - public static final int PARSE_IGNORE_PROCESSES = 1 << 3; - public static final int PARSE_FORWARD_LOCK = 1 << 4; - public static final int PARSE_EXTERNAL_STORAGE = 1 << 5; - public static final int PARSE_IS_SYSTEM_DIR = 1 << 6; - public static final int PARSE_IS_PRIVILEGED = 1 << 7; - public static final int PARSE_COLLECT_CERTIFICATES = 1 << 8; - public static final int PARSE_TRUSTED_OVERLAY = 1 << 9; - public static final int PARSE_ENFORCE_CODE = 1 << 10; - /** @deprecated remove when fixing b/34761192 */ + public static final int PARSE_MUST_BE_APK = 1 << 0; + public static final int PARSE_IGNORE_PROCESSES = 1 << 1; + public static final int PARSE_FORWARD_LOCK = 1 << 2; + public static final int PARSE_EXTERNAL_STORAGE = 1 << 3; + public static final int PARSE_IS_SYSTEM_DIR = 1 << 4; + public static final int PARSE_COLLECT_CERTIFICATES = 1 << 5; + public static final int PARSE_ENFORCE_CODE = 1 << 6; + public static final int PARSE_FORCE_SDK = 1 << 7; + /** @deprecated remove when fixing b/68860689 */ @Deprecated - public static final int PARSE_IS_EPHEMERAL = 1 << 11; - public static final int PARSE_FORCE_SDK = 1 << 12; - public static final int PARSE_IS_OEM = 1 << 13; + public static final int PARSE_IS_EPHEMERAL = 1 << 8; + public static final int PARSE_CHATTY = 1 << 31; + + @IntDef(flag = true, prefix = { "PARSE_" }, value = { + PARSE_CHATTY, + PARSE_COLLECT_CERTIFICATES, + PARSE_ENFORCE_CODE, + PARSE_EXTERNAL_STORAGE, + PARSE_FORCE_SDK, + PARSE_FORWARD_LOCK, + PARSE_IGNORE_PROCESSES, + PARSE_IS_EPHEMERAL, + PARSE_IS_SYSTEM_DIR, + PARSE_MUST_BE_APK, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface ParseFlags {} private static final Comparator<String> sSplitNameComparator = new SplitNameComparator(); @@ -1242,9 +1258,12 @@ public class PackageParser { } } - pkg.setCodePath(packageDir.getAbsolutePath()); + pkg.setCodePath(packageDir.getCanonicalPath()); pkg.setUse32bitAbi(lite.use32bitAbi); return pkg; + } catch (IOException e) { + throw new PackageParserException(INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION, + "Failed to get path: " + lite.baseCodePath, e); } finally { IoUtils.closeQuietly(assetLoader); } @@ -1273,9 +1292,12 @@ public class PackageParser { try { final Package pkg = parseBaseApk(apkFile, assets, flags); - pkg.setCodePath(apkFile.getAbsolutePath()); + pkg.setCodePath(apkFile.getCanonicalPath()); pkg.setUse32bitAbi(lite.use32bitAbi); return pkg; + } catch (IOException e) { + throw new PackageParserException(INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION, + "Failed to get path: " + apkFile, e); } finally { IoUtils.closeQuietly(assets); } @@ -1505,7 +1527,7 @@ public class PackageParser { * populating {@link Package#mSignatures}. Also asserts that all APK * contents are signed correctly and consistently. */ - public static void collectCertificates(Package pkg, int parseFlags) + public static void collectCertificates(Package pkg, @ParseFlags int parseFlags) throws PackageParserException { collectCertificatesInternal(pkg, parseFlags); final int childCount = (pkg.childPackages != null) ? pkg.childPackages.size() : 0; @@ -1517,7 +1539,7 @@ public class PackageParser { } } - private static void collectCertificatesInternal(Package pkg, int parseFlags) + private static void collectCertificatesInternal(Package pkg, @ParseFlags int parseFlags) throws PackageParserException { pkg.mCertificates = null; pkg.mSignatures = null; @@ -1537,7 +1559,7 @@ public class PackageParser { } } - private static void collectCertificates(Package pkg, File apkFile, int parseFlags) + private static void collectCertificates(Package pkg, File apkFile, @ParseFlags int parseFlags) throws PackageParserException { final String apkPath = apkFile.getAbsolutePath(); @@ -2076,6 +2098,16 @@ public class PackageParser { pkg.coreApp = parser.getAttributeBooleanValue(null, "coreApp", false); + pkg.mCompileSdkVersion = sa.getInteger( + com.android.internal.R.styleable.AndroidManifest_compileSdkVersion, 0); + pkg.applicationInfo.compileSdkVersion = pkg.mCompileSdkVersion; + pkg.mCompileSdkVersionCodename = sa.getNonConfigurationString( + com.android.internal.R.styleable.AndroidManifest_compileSdkVersionCodename, 0); + if (pkg.mCompileSdkVersionCodename != null) { + pkg.mCompileSdkVersionCodename = pkg.mCompileSdkVersionCodename.intern(); + } + pkg.applicationInfo.compileSdkVersionCodename = pkg.mCompileSdkVersionCodename; + sa.recycle(); return parseBaseApkCommon(pkg, null, res, parser, flags, outError); @@ -2442,7 +2474,7 @@ public class PackageParser { sa.recycle(); - if (name != null && (flags&PARSE_IS_SYSTEM) != 0) { + if (name != null) { if (pkg.protectedBroadcasts == null) { pkg.protectedBroadcasts = new ArrayList<String>(); } @@ -3243,9 +3275,6 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0); perm.info.priority = sa.getInt( com.android.internal.R.styleable.AndroidManifestPermissionGroup_priority, 0); - if (perm.info.priority > 0 && (flags&PARSE_IS_SYSTEM) == 0) { - perm.info.priority = 0; - } sa.recycle(); @@ -3551,17 +3580,14 @@ public class PackageParser { ai.descriptionRes = sa.getResourceId( com.android.internal.R.styleable.AndroidManifestApplication_description, 0); - if ((flags&PARSE_IS_SYSTEM) != 0) { - if (sa.getBoolean( - com.android.internal.R.styleable.AndroidManifestApplication_persistent, - false)) { - // Check if persistence is based on a feature being present - final String requiredFeature = sa.getNonResourceString( - com.android.internal.R.styleable. - AndroidManifestApplication_persistentWhenFeatureAvailable); - if (requiredFeature == null || mCallback.hasFeature(requiredFeature)) { - ai.flags |= ApplicationInfo.FLAG_PERSISTENT; - } + if (sa.getBoolean( + com.android.internal.R.styleable.AndroidManifestApplication_persistent, + false)) { + // Check if persistence is based on a feature being present + final String requiredFeature = sa.getNonResourceString(com.android.internal.R.styleable + .AndroidManifestApplication_persistentWhenFeatureAvailable); + if (requiredFeature == null || mCallback.hasFeature(requiredFeature)) { + ai.flags |= ApplicationInfo.FLAG_PERSISTENT; } } @@ -4431,13 +4457,6 @@ public class PackageParser { if (sa.getBoolean(R.styleable.AndroidManifestActivity_singleUser, false)) { a.info.flags |= ActivityInfo.FLAG_SINGLE_USER; - if (a.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) { - Slog.w(TAG, "Activity exported request ignored due to singleUser: " - + a.className + " at " + mArchiveSourcePath + " " - + parser.getPositionDescription()); - a.info.exported = false; - setExported = true; - } } a.info.encryptionAware = a.info.directBootAware = sa.getBoolean( @@ -5026,12 +5045,6 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifestProvider_singleUser, false)) { p.info.flags |= ProviderInfo.FLAG_SINGLE_USER; - if (p.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) { - Slog.w(TAG, "Provider exported request ignored due to singleUser: " - + p.className + " at " + mArchiveSourcePath + " " - + parser.getPositionDescription()); - p.info.exported = false; - } } p.info.encryptionAware = p.info.directBootAware = sa.getBoolean( @@ -5353,13 +5366,6 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifestService_singleUser, false)) { s.info.flags |= ServiceInfo.FLAG_SINGLE_USER; - if (s.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) { - Slog.w(TAG, "Service exported request ignored due to singleUser: " - + s.className + " at " + mArchiveSourcePath + " " - + parser.getPositionDescription()); - s.info.exported = false; - setExported = true; - } } s.info.encryptionAware = s.info.directBootAware = sa.getBoolean( @@ -5967,6 +5973,9 @@ public class PackageParser { public boolean mIsStaticOverlay; public boolean mTrustedOverlay; + public int mCompileSdkVersion; + public String mCompileSdkVersionCodename; + /** * Data used to feed the KeySetManagerService */ @@ -6458,6 +6467,8 @@ public class PackageParser { mOverlayPriority = dest.readInt(); mIsStaticOverlay = (dest.readInt() == 1); mTrustedOverlay = (dest.readInt() == 1); + mCompileSdkVersion = dest.readInt(); + mCompileSdkVersionCodename = dest.readString(); mSigningKeys = (ArraySet<PublicKey>) dest.readArraySet(boot); mUpgradeKeySets = (ArraySet<String>) dest.readArraySet(boot); @@ -6581,6 +6592,8 @@ public class PackageParser { dest.writeInt(mOverlayPriority); dest.writeInt(mIsStaticOverlay ? 1 : 0); dest.writeInt(mTrustedOverlay ? 1 : 0); + dest.writeInt(mCompileSdkVersion); + dest.writeString(mCompileSdkVersionCodename); dest.writeArraySet(mSigningKeys); dest.writeArraySet(mUpgradeKeySets); writeKeySetMapping(dest, mKeySetMapping); diff --git a/android/content/pm/PermissionInfo.java b/android/content/pm/PermissionInfo.java index 5dd7aeda..75887624 100644 --- a/android/content/pm/PermissionInfo.java +++ b/android/content/pm/PermissionInfo.java @@ -155,12 +155,18 @@ public class PermissionInfo extends PackageItemInfo implements Parcelable { /** * The level of access this permission is protecting, as per - * {@link android.R.attr#protectionLevel}. Values may be - * {@link #PROTECTION_NORMAL}, {@link #PROTECTION_DANGEROUS}, or - * {@link #PROTECTION_SIGNATURE}. May also include the additional - * flags {@link #PROTECTION_FLAG_SYSTEM} or {@link #PROTECTION_FLAG_DEVELOPMENT} - * (which only make sense in combination with the base - * {@link #PROTECTION_SIGNATURE}. + * {@link android.R.attr#protectionLevel}. Consists of + * a base permission type and zero or more flags: + * + * <pre> + * int basePermissionType = protectionLevel & {@link #PROTECTION_MASK_BASE}; + * int permissionFlags = protectionLevel & {@link #PROTECTION_MASK_FLAGS}; + * </pre> + * + * <p></p>Base permission types are {@link #PROTECTION_NORMAL}, + * {@link #PROTECTION_DANGEROUS}, {@link #PROTECTION_SIGNATURE} + * and the deprecated {@link #PROTECTION_SIGNATURE_OR_SYSTEM}. + * Flags are listed under {@link android.R.attr#protectionLevel}. */ public int protectionLevel; |