Merge "Address API council comments" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-04-20 03:53:33 +00:00
committed by Android (Google) Code Review
11 changed files with 140 additions and 42 deletions

View File

@@ -10571,6 +10571,7 @@ package android.content.pm {
method public abstract int checkPermission(java.lang.String, java.lang.String);
method public abstract int checkSignatures(java.lang.String, java.lang.String);
method public abstract int checkSignatures(int, int);
method public abstract void clearInstantAppCookie();
method public abstract void clearPackagePreferredActivities(java.lang.String);
method public abstract java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
method public abstract void extendVerificationTimeout(int, int, long);
@@ -10599,7 +10600,7 @@ package android.content.pm {
method public abstract java.util.List<android.content.pm.PackageInfo> getInstalledPackages(int);
method public abstract java.lang.String getInstallerPackageName(java.lang.String);
method public abstract byte[] getInstantAppCookie();
method public abstract int getInstantAppCookieMaxSize();
method public abstract int getInstantAppCookieMaxBytes();
method public abstract android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.Intent getLaunchIntentForPackage(java.lang.String);
method public abstract android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
@@ -10654,7 +10655,7 @@ package android.content.pm {
method public abstract void setApplicationEnabledSetting(java.lang.String, int, int);
method public abstract void setComponentEnabledSetting(android.content.ComponentName, int, int);
method public abstract void setInstallerPackageName(java.lang.String, java.lang.String);
method public abstract boolean setInstantAppCookie(byte[]);
method public abstract void updateInstantAppCookie(byte[]);
method public abstract void verifyPendingInstall(int, int);
field public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; // 0x0
field public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; // 0x2
@@ -40979,6 +40980,7 @@ package android.test.mock {
method public int checkPermission(java.lang.String, java.lang.String);
method public int checkSignatures(java.lang.String, java.lang.String);
method public int checkSignatures(int, int);
method public void clearInstantAppCookie();
method public void clearPackagePreferredActivities(java.lang.String);
method public java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
method public void extendVerificationTimeout(int, int, long);
@@ -41008,7 +41010,7 @@ package android.test.mock {
method public java.util.List<android.content.pm.PackageInfo> getInstalledPackages(int);
method public java.lang.String getInstallerPackageName(java.lang.String);
method public byte[] getInstantAppCookie();
method public int getInstantAppCookieMaxSize();
method public int getInstantAppCookieMaxBytes();
method public android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.Intent getLaunchIntentForPackage(java.lang.String);
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
@@ -41062,7 +41064,7 @@ package android.test.mock {
method public void setApplicationEnabledSetting(java.lang.String, int, int);
method public void setComponentEnabledSetting(android.content.ComponentName, int, int);
method public void setInstallerPackageName(java.lang.String, java.lang.String);
method public boolean setInstantAppCookie(byte[]);
method public void updateInstantAppCookie(byte[]);
method public void verifyPendingInstall(int, int);
}

View File

@@ -63,6 +63,10 @@ package android.content.pm {
field public static final int REQUESTED_PERMISSION_REQUIRED = 1; // 0x1
}
public abstract class PackageManager {
method public abstract boolean setInstantAppCookie(byte[]);
}
public final class SharedLibraryInfo implements android.os.Parcelable {
method public boolean isBuiltin();
method public boolean isDynamic();

View File

@@ -11244,6 +11244,7 @@ package android.content.pm {
method public abstract int checkPermission(java.lang.String, java.lang.String);
method public abstract int checkSignatures(java.lang.String, java.lang.String);
method public abstract int checkSignatures(int, int);
method public abstract void clearInstantAppCookie();
method public abstract void clearPackagePreferredActivities(java.lang.String);
method public abstract java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
method public abstract void extendVerificationTimeout(int, int, long);
@@ -11275,7 +11276,7 @@ package android.content.pm {
method public abstract java.util.List<android.content.pm.PackageInfo> getInstalledPackagesAsUser(int, int);
method public abstract java.lang.String getInstallerPackageName(java.lang.String);
method public abstract byte[] getInstantAppCookie();
method public abstract int getInstantAppCookieMaxSize();
method public abstract int getInstantAppCookieMaxBytes();
method public abstract android.graphics.drawable.Drawable getInstantAppIcon(java.lang.String);
method public abstract android.content.ComponentName getInstantAppInstallerComponent();
method public abstract android.content.ComponentName getInstantAppResolverSettingsComponent();
@@ -11342,8 +11343,8 @@ package android.content.pm {
method public abstract void setComponentEnabledSetting(android.content.ComponentName, int, int);
method public abstract boolean setDefaultBrowserPackageNameAsUser(java.lang.String, int);
method public abstract void setInstallerPackageName(java.lang.String, java.lang.String);
method public abstract boolean setInstantAppCookie(byte[]);
method public abstract void setUpdateAvailable(java.lang.String, boolean);
method public abstract void updateInstantAppCookie(byte[]);
method public abstract boolean updateIntentVerificationStatusAsUser(java.lang.String, int, int);
method public abstract void updatePermissionFlags(java.lang.String, java.lang.String, int, int, android.os.UserHandle);
method public abstract void verifyIntentFilter(int, int, java.util.List<java.lang.String>);
@@ -44537,6 +44538,7 @@ package android.test.mock {
method public int checkPermission(java.lang.String, java.lang.String);
method public int checkSignatures(java.lang.String, java.lang.String);
method public int checkSignatures(int, int);
method public void clearInstantAppCookie();
method public void clearPackagePreferredActivities(java.lang.String);
method public java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
method public void extendVerificationTimeout(int, int, long);
@@ -44568,7 +44570,7 @@ package android.test.mock {
method public java.util.List<android.content.pm.PackageInfo> getInstalledPackagesAsUser(int, int);
method public java.lang.String getInstallerPackageName(java.lang.String);
method public byte[] getInstantAppCookie();
method public int getInstantAppCookieMaxSize();
method public int getInstantAppCookieMaxBytes();
method public android.graphics.drawable.Drawable getInstantAppIcon(java.lang.String);
method public android.content.ComponentName getInstantAppInstallerComponent();
method public android.content.ComponentName getInstantAppResolverSettingsComponent();
@@ -44633,8 +44635,8 @@ package android.test.mock {
method public void setComponentEnabledSetting(android.content.ComponentName, int, int);
method public boolean setDefaultBrowserPackageNameAsUser(java.lang.String, int);
method public void setInstallerPackageName(java.lang.String, java.lang.String);
method public boolean setInstantAppCookie(byte[]);
method public void setUpdateAvailable(java.lang.String, boolean);
method public void updateInstantAppCookie(byte[]);
method public boolean updateIntentVerificationStatusAsUser(java.lang.String, int, int);
method public void updatePermissionFlags(java.lang.String, java.lang.String, int, int, android.os.UserHandle);
method public void verifyIntentFilter(int, int, java.util.List<java.lang.String>);

View File

@@ -61,6 +61,10 @@ package android.content.pm {
field public static final int REQUESTED_PERMISSION_REQUIRED = 1; // 0x1
}
public abstract class PackageManager {
method public abstract boolean setInstantAppCookie(byte[]);
}
public final class SharedLibraryInfo implements android.os.Parcelable {
method public boolean isBuiltin();
method public boolean isDynamic();

View File

@@ -10608,6 +10608,7 @@ package android.content.pm {
method public abstract int checkPermission(java.lang.String, java.lang.String);
method public abstract int checkSignatures(java.lang.String, java.lang.String);
method public abstract int checkSignatures(int, int);
method public abstract void clearInstantAppCookie();
method public abstract void clearPackagePreferredActivities(java.lang.String);
method public abstract java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
method public abstract void extendVerificationTimeout(int, int, long);
@@ -10638,7 +10639,7 @@ package android.content.pm {
method public abstract java.util.List<android.content.pm.PackageInfo> getInstalledPackages(int);
method public abstract java.lang.String getInstallerPackageName(java.lang.String);
method public abstract byte[] getInstantAppCookie();
method public abstract int getInstantAppCookieMaxSize();
method public abstract int getInstantAppCookieMaxBytes();
method public abstract android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.Intent getLaunchIntentForPackage(java.lang.String);
method public abstract android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
@@ -10694,7 +10695,7 @@ package android.content.pm {
method public abstract void setApplicationEnabledSetting(java.lang.String, int, int);
method public abstract void setComponentEnabledSetting(android.content.ComponentName, int, int);
method public abstract void setInstallerPackageName(java.lang.String, java.lang.String);
method public abstract boolean setInstantAppCookie(byte[]);
method public abstract void updateInstantAppCookie(byte[]);
method public abstract void verifyPendingInstall(int, int);
field public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; // 0x0
field public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; // 0x2
@@ -41174,6 +41175,7 @@ package android.test.mock {
method public int checkPermission(java.lang.String, java.lang.String);
method public int checkSignatures(java.lang.String, java.lang.String);
method public int checkSignatures(int, int);
method public void clearInstantAppCookie();
method public void clearPackagePreferredActivities(java.lang.String);
method public java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
method public void extendVerificationTimeout(int, int, long);
@@ -41205,7 +41207,7 @@ package android.test.mock {
method public java.util.List<android.content.pm.PackageInfo> getInstalledPackages(int);
method public java.lang.String getInstallerPackageName(java.lang.String);
method public byte[] getInstantAppCookie();
method public int getInstantAppCookieMaxSize();
method public int getInstantAppCookieMaxBytes();
method public android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.Intent getLaunchIntentForPackage(java.lang.String);
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
@@ -41260,7 +41262,7 @@ package android.test.mock {
method public void setApplicationEnabledSetting(java.lang.String, int, int);
method public void setComponentEnabledSetting(android.content.ComponentName, int, int);
method public void setInstallerPackageName(java.lang.String, java.lang.String);
method public boolean setInstantAppCookie(byte[]);
method public void updateInstantAppCookie(byte[]);
method public void verifyPendingInstall(int, int);
}

View File

@@ -63,6 +63,10 @@ package android.content.pm {
field public static final int REQUESTED_PERMISSION_REQUIRED = 1; // 0x1
}
public abstract class PackageManager {
method public abstract boolean setInstantAppCookie(byte[]);
}
public final class SharedLibraryInfo implements android.os.Parcelable {
method public boolean isBuiltin();
method public boolean isDynamic();

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(

View File

@@ -146,7 +146,7 @@ class InstantAppRegistry {
@Nullable byte[] cookie, @UserIdInt int userId) {
if (cookie != null && cookie.length > 0) {
final int maxCookieSize = mService.mContext.getPackageManager()
.getInstantAppCookieMaxSize();
.getInstantAppCookieMaxBytes();
if (cookie.length > maxCookieSize) {
Slog.e(LOG_TAG, "Instant app cookie for package " + packageName + " size "
+ cookie.length + " bytes while max size is " + maxCookieSize);

View File

@@ -369,12 +369,30 @@ public class MockPackageManager extends PackageManager {
throw new UnsupportedOperationException();
}
/** @hide */
@Override
public int getInstantAppCookieMaxBytes() {
throw new UnsupportedOperationException();
}
/** @hide */
@Override
public int getInstantAppCookieMaxSize() {
throw new UnsupportedOperationException();
}
/** @hide */
@Override
public void clearInstantAppCookie() {
throw new UnsupportedOperationException();
}
/** @hide */
@Override
public void updateInstantAppCookie(@NonNull byte[] cookie) {
throw new UnsupportedOperationException();
}
/** @hide */
@Override
public boolean setInstantAppCookie(@NonNull byte[] cookie) {

View File

@@ -17,6 +17,7 @@
package com.android.layoutlib.bridge.android;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.PackageInstallObserver;
import android.content.ComponentName;
import android.content.Intent;
@@ -327,11 +328,26 @@ public class BridgePackageManager extends PackageManager {
return false;
}
@Override
public int getInstantAppCookieMaxBytes() {
return 0;
}
@Override
public int getInstantAppCookieMaxSize() {
return 0;
}
@Override
public void clearInstantAppCookie() {;
}
@Override
public void updateInstantAppCookie(@Nullable byte[] cookie) {
}
@Override
public boolean setInstantAppCookie(@NonNull byte[] cookie) {
return false;