summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-04-20 03:53:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-04-20 03:53:37 +0000
commitfb4fb03cc3aa273c763df97f99eae1ba11594997 (patch)
tree19797f683f6b32bd15d9ed539f317786075f3fcb /core/java
parent08ca0a5a9eab09686cff1ee3ba516ab9b06074a3 (diff)
parent345ffa5421f4158b9c30439b9f18aed7b61aaea9 (diff)
Merge "Address API council comments" into oc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ApplicationPackageManager.java27
-rw-r--r--core/java/android/content/pm/PackageManager.java63
2 files changed, 68 insertions, 22 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 2ce02df3b00d..e50c307df854 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -820,14 +820,18 @@ public class ApplicationPackageManager extends PackageManager {
}
}
- @Override
- public int getInstantAppCookieMaxSize() {
+ public int getInstantAppCookieMaxBytes() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.EPHEMERAL_COOKIE_MAX_SIZE_BYTES,
DEFAULT_EPHEMERAL_COOKIE_MAX_SIZE_BYTES);
}
@Override
+ public int getInstantAppCookieMaxSize() {
+ return getInstantAppCookieMaxBytes();
+ }
+
+ @Override
public @NonNull byte[] getInstantAppCookie() {
try {
final byte[] cookie = mPM.getInstantAppCookie(
@@ -843,6 +847,25 @@ public class ApplicationPackageManager extends PackageManager {
}
@Override
+ public void clearInstantAppCookie() {
+ updateInstantAppCookie(null);
+ }
+
+ @Override
+ public void updateInstantAppCookie(@NonNull byte[] cookie) {
+ if (cookie != null && cookie.length > getInstantAppCookieMaxBytes()) {
+ throw new IllegalArgumentException("instant cookie longer than "
+ + getInstantAppCookieMaxBytes());
+ }
+ try {
+ mPM.setInstantAppCookie(mContext.getPackageName(),
+ cookie, mContext.getUserId());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ @Override
public boolean setInstantAppCookie(@NonNull byte[] cookie) {
try {
return mPM.setInstantAppCookie(mContext.getPackageName(),
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 7cc2334f16d5..584f6d55e285 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -2824,7 +2824,7 @@ public abstract class PackageManager {
* by passing {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage}
* constructor.
*
- * @param versionedPackage The versioned packages for which to query.
+ * @param versionedPackage The versioned package for which to query.
* @param flags Additional option flags. Use any combination of
* {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS},
* {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION},
@@ -3846,9 +3846,9 @@ public abstract class PackageManager {
* @return Whether caller is an instant app.
*
* @see #isInstantApp(String)
- * @see #setInstantAppCookie(byte[])
+ * @see #updateInstantAppCookie(byte[])
* @see #getInstantAppCookie()
- * @see #getInstantAppCookieMaxSize()
+ * @see #getInstantAppCookieMaxBytes()
*/
public abstract boolean isInstantApp();
@@ -3859,9 +3859,10 @@ public abstract class PackageManager {
* @return Whether the given package is an instant app.
*
* @see #isInstantApp()
- * @see #setInstantAppCookie(byte[])
+ * @see #updateInstantAppCookie(byte[])
* @see #getInstantAppCookie()
- * @see #getInstantAppCookieMaxSize()
+ * @see #getInstantAppCookieMaxBytes()
+ * @see #clearInstantAppCookie()
*/
public abstract boolean isInstantApp(String packageName);
@@ -3873,8 +3874,15 @@ public abstract class PackageManager {
*
* @see #isInstantApp()
* @see #isInstantApp(String)
- * @see #setInstantAppCookie(byte[])
+ * @see #updateInstantAppCookie(byte[])
* @see #getInstantAppCookie()
+ * @see #clearInstantAppCookie()
+ */
+ public abstract int getInstantAppCookieMaxBytes();
+
+ /**
+ * @deprecated
+ * @hide
*/
public abstract int getInstantAppCookieMaxSize();
@@ -3882,7 +3890,7 @@ public abstract class PackageManager {
* Gets the instant application cookie for this app. Non
* instant apps and apps that were instant but were upgraded
* to normal apps can still access this API. For instant apps
- * this cooke is cached for some time after uninstall while for
+ * this cookie is cached for some time after uninstall while for
* normal apps the cookie is deleted after the app is uninstalled.
* The cookie is always present while the app is installed.
*
@@ -3890,31 +3898,49 @@ public abstract class PackageManager {
*
* @see #isInstantApp()
* @see #isInstantApp(String)
- * @see #setInstantAppCookie(byte[])
- * @see #getInstantAppCookieMaxSize()
+ * @see #updateInstantAppCookie(byte[])
+ * @see #getInstantAppCookieMaxBytes()
+ * @see #clearInstantAppCookie()
*/
public abstract @NonNull byte[] getInstantAppCookie();
/**
- * Sets the instant application cookie for the calling app. Non
+ * Clears the instant application cookie for the calling app.
+ *
+ * @see #isInstantApp()
+ * @see #isInstantApp(String)
+ * @see #getInstantAppCookieMaxBytes()
+ * @see #getInstantAppCookie()
+ * @see #clearInstantAppCookie()
+ */
+ public abstract void clearInstantAppCookie();
+
+ /**
+ * Updates the instant application cookie for the calling app. Non
* instant apps and apps that were instant but were upgraded
* to normal apps can still access this API. For instant apps
- * this cooke is cached for some time after uninstall while for
+ * this cookie is cached for some time after uninstall while for
* normal apps the cookie is deleted after the app is uninstalled.
* The cookie is always present while the app is installed. The
- * cookie size is limited by {@link #getInstantAppCookieMaxSize()}.
- * If the provided cookie size is over the limit this method
- * returns <code>false</code>. Passing <code>null</code> or an empty
- * array clears the cookie.
+ * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}.
+ * Passing <code>null</code> or an empty array clears the cookie.
* </p>
*
* @param cookie The cookie data.
- * @return Whether the cookie was set.
*
* @see #isInstantApp()
* @see #isInstantApp(String)
- * @see #getInstantAppCookieMaxSize()
+ * @see #getInstantAppCookieMaxBytes()
* @see #getInstantAppCookie()
+ * @see #clearInstantAppCookie()
+ *
+ * @throws IllegalArgumentException if the array exceeds max cookie size.
+ */
+ public abstract void updateInstantAppCookie(@Nullable byte[] cookie);
+
+ /**
+ * @removed
+ * @hide
*/
public abstract boolean setInstantAppCookie(@Nullable byte[] cookie);
@@ -3934,9 +3960,6 @@ public abstract class PackageManager {
* @param flags To filter the libraries to return.
* @return The shared library list.
*
- * @see #MATCH_FACTORY_ONLY
- * @see #MATCH_KNOWN_PACKAGES
- * @see #MATCH_ANY_USER
* @see #MATCH_UNINSTALLED_PACKAGES
*/
public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries(