Merge "Address API council comments" into oc-dev

am: fb4fb03cc3

Change-Id: I32f062c901fa3b71b5782af734b93fd8ac877d1f
This commit is contained in:
Svetoslav Ganov
2017-04-20 04:02:40 +00:00
committed by android-build-merger
11 changed files with 140 additions and 42 deletions

View File

@@ -820,13 +820,17 @@ 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 {
@@ -842,6 +846,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 {

View File

@@ -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
* 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
* 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.
* </p>
*
* @param cookie The cookie data.
* @return Whether the cookie was set.
* Clears the instant application cookie for the calling app.
*
* @see #isInstantApp()
* @see #isInstantApp(String)
* @see #getInstantAppCookieMaxSize()
* @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 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 #getInstantAppCookieMaxBytes()}.
* Passing <code>null</code> or an empty array clears the cookie.
* </p>
*
* @param cookie The cookie data.
*
* @see #isInstantApp()
* @see #isInstantApp(String)
* @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(