Merge "Add versionCode"

This commit is contained in:
TreeHugger Robot
2017-01-24 20:36:38 +00:00
committed by Android (Google) Code Review
5 changed files with 42 additions and 10 deletions

View File

@@ -10194,7 +10194,8 @@ package android.content.pm {
public final class EphemeralResolveInfo implements android.os.Parcelable {
ctor public deprecated EphemeralResolveInfo(android.net.Uri, java.lang.String, java.util.List<android.content.IntentFilter>);
ctor public EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo.EphemeralDigest, java.lang.String, java.util.List<android.content.pm.EphemeralIntentFilter>);
ctor public deprecated EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo.EphemeralDigest, java.lang.String, java.util.List<android.content.pm.EphemeralIntentFilter>);
ctor public EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo.EphemeralDigest, java.lang.String, java.util.List<android.content.pm.EphemeralIntentFilter>, int);
ctor public EphemeralResolveInfo(java.lang.String, java.lang.String, java.util.List<android.content.pm.EphemeralIntentFilter>);
method public int describeContents();
method public byte[] getDigestBytes();
@@ -10202,6 +10203,7 @@ package android.content.pm {
method public deprecated java.util.List<android.content.IntentFilter> getFilters();
method public java.util.List<android.content.pm.EphemeralIntentFilter> getIntentFilters();
method public java.lang.String getPackageName();
method public int getVersionCode();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.content.pm.EphemeralResolveInfo> CREATOR;
field public static final java.lang.String SHA_ALGORITHM = "SHA-256";

View File

@@ -3965,6 +3965,12 @@ public class Intent implements Parcelable, Cloneable {
*/
public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
/**
* The version code of the app to install components from.
* @hide
*/
public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
/**
* A Bundle forming a mapping of potential target package names to different extras Bundles
* to add to the default intent extras in {@link #EXTRA_INTENT} when used with

View File

@@ -43,9 +43,11 @@ public final class EphemeralResolveInfo implements Parcelable {
private final String mPackageName;
/** The filters used to match domain */
private final List<EphemeralIntentFilter> mFilters;
/** The version code of the app that this class resolves to */
private final int mVersionCode;
/** Filters only for legacy clients */
@Deprecated
private List<IntentFilter> mLegacyFilters;
private final List<IntentFilter> mLegacyFilters;
@Deprecated
public EphemeralResolveInfo(@NonNull Uri uri, @NonNull String packageName,
@@ -59,10 +61,17 @@ public final class EphemeralResolveInfo implements Parcelable {
mFilters.add(new EphemeralIntentFilter(packageName, filters));
mLegacyFilters = new ArrayList<IntentFilter>(filters.size());
mLegacyFilters.addAll(filters);
mVersionCode = -1;
}
@Deprecated
public EphemeralResolveInfo(@NonNull EphemeralDigest digest, @Nullable String packageName,
@Nullable List<EphemeralIntentFilter> filters) {
this(digest, packageName, filters, -1 /*versionCode*/);
}
public EphemeralResolveInfo(@NonNull EphemeralDigest digest, @Nullable String packageName,
@Nullable List<EphemeralIntentFilter> filters) {
@Nullable List<EphemeralIntentFilter> filters, int versionConde) {
// validate arguments
if ((packageName == null && (filters != null && filters.size() != 0))
|| (packageName != null && (filters == null || filters.size() == 0))) {
@@ -75,7 +84,9 @@ public final class EphemeralResolveInfo implements Parcelable {
} else {
mFilters = null;
}
mLegacyFilters = null;
mPackageName = packageName;
mVersionCode = versionConde;
}
public EphemeralResolveInfo(@NonNull String hostName, @Nullable String packageName,
@@ -88,6 +99,7 @@ public final class EphemeralResolveInfo implements Parcelable {
mPackageName = in.readString();
mFilters = new ArrayList<EphemeralIntentFilter>();
in.readList(mFilters, null /*loader*/);
mVersionCode = in.readInt();
mLegacyFilters = new ArrayList<IntentFilter>();
in.readList(mLegacyFilters, null /*loader*/);
}
@@ -104,15 +116,19 @@ public final class EphemeralResolveInfo implements Parcelable {
return mPackageName;
}
public List<EphemeralIntentFilter> getIntentFilters() {
return mFilters;
}
public int getVersionCode() {
return mVersionCode;
}
@Deprecated
public List<IntentFilter> getFilters() {
return mLegacyFilters;
}
public List<EphemeralIntentFilter> getIntentFilters() {
return mFilters;
}
@Override
public int describeContents() {
return 0;
@@ -123,6 +139,7 @@ public final class EphemeralResolveInfo implements Parcelable {
out.writeParcelable(mDigest, flags);
out.writeString(mPackageName);
out.writeList(mFilters);
out.writeInt(mVersionCode);
out.writeList(mLegacyFilters);
}

View File

@@ -460,6 +460,7 @@ class ActivityStarter {
final String splitName = rInfo.ephemeralResponse.splitName;
final boolean needsPhaseTwo = rInfo.ephemeralResponse.needsPhase2;
final String token = rInfo.ephemeralResponse.token;
final int versionCode = rInfo.ephemeralResponse.resolveInfo.getVersionCode();
if (needsPhaseTwo) {
// request phase two resolution
mService.getPackageManagerInternalLocked().requestEphemeralResolutionPhaseTwo(
@@ -467,8 +468,8 @@ class ActivityStarter {
callingPackage, userId);
}
intent = EphemeralResolver.buildEphemeralInstallerIntent(intent, ephemeralIntent,
callingPackage, resolvedType, userId, packageName, splitName, token,
needsPhaseTwo);
callingPackage, resolvedType, userId, packageName, splitName, versionCode,
token, needsPhaseTwo);
resolvedType = null;
callingUid = realCallingUid;
callingPid = realCallingPid;

View File

@@ -78,6 +78,7 @@ public abstract class EphemeralResolver {
int sequence) {
final String packageName;
final String splitName;
final int versionCode;
if (ephemeralResolveInfo != null) {
final ArrayList<EphemeralResolveInfo> ephemeralResolveInfoList =
new ArrayList<EphemeralResolveInfo>(1);
@@ -91,13 +92,16 @@ public abstract class EphemeralResolver {
&& ephemeralIntentInfo.resolveInfo != null) {
packageName = ephemeralIntentInfo.resolveInfo.getPackageName();
splitName = ephemeralIntentInfo.splitName;
versionCode = ephemeralIntentInfo.resolveInfo.getVersionCode();
} else {
packageName = null;
splitName = null;
versionCode = -1;
}
} else {
packageName = null;
splitName = null;
versionCode = -1;
}
final Intent installerIntent = buildEphemeralInstallerIntent(
requestObj.launchIntent,
@@ -107,6 +111,7 @@ public abstract class EphemeralResolver {
requestObj.userId,
packageName,
splitName,
versionCode,
requestObj.responseObj.token,
false /*needsPhaseTwo*/);
installerIntent.setComponent(new ComponentName(
@@ -123,7 +128,7 @@ public abstract class EphemeralResolver {
*/
public static Intent buildEphemeralInstallerIntent(Intent launchIntent, Intent origIntent,
String callingPackage, String resolvedType, int userId, String ephemeralPackageName,
String ephemeralSplitName, String token, boolean needsPhaseTwo) {
String ephemeralSplitName, int versionCode, String token, boolean needsPhaseTwo) {
// Construct the intent that launches the ephemeral installer
int flags = launchIntent.getFlags();
final Intent intent = new Intent();
@@ -181,6 +186,7 @@ public abstract class EphemeralResolver {
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, ephemeralPackageName);
intent.putExtra(Intent.EXTRA_SPLIT_NAME, ephemeralSplitName);
intent.putExtra(Intent.EXTRA_VERSION_CODE, versionCode);
}
return intent;