Merge "Bind with the correct action" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e7ec7ec634
@@ -21,6 +21,7 @@ import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.InstantAppResolveInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -28,9 +29,12 @@ import android.os.IRemoteCallback;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.internal.os.SomeArgs;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -39,6 +43,9 @@ import java.util.List;
|
||||
*/
|
||||
@SystemApi
|
||||
public abstract class InstantAppResolverService extends Service {
|
||||
private static final boolean DEBUG_EPHEMERAL = Build.IS_DEBUGGABLE;
|
||||
private static final String TAG = "PackageManager";
|
||||
|
||||
/** @hide */
|
||||
public static final String EXTRA_RESOLVE_INFO = "android.app.extra.RESOLVE_INFO";
|
||||
/** @hide */
|
||||
@@ -132,11 +139,19 @@ public abstract class InstantAppResolverService extends Service {
|
||||
@Deprecated
|
||||
void _onGetInstantAppResolveInfo(int[] digestPrefix, String token,
|
||||
InstantAppResolutionCallback callback) {
|
||||
if (DEBUG_EPHEMERAL) {
|
||||
Slog.d(TAG, "Instant resolver; getInstantAppResolveInfo;"
|
||||
+ " prefix: " + Arrays.toString(digestPrefix));
|
||||
}
|
||||
onGetInstantAppResolveInfo(digestPrefix, token, callback);
|
||||
}
|
||||
@Deprecated
|
||||
void _onGetInstantAppIntentFilter(int digestPrefix[], String token, String hostName,
|
||||
InstantAppResolutionCallback callback) {
|
||||
if (DEBUG_EPHEMERAL) {
|
||||
Slog.d(TAG, "Instant resolver; getInstantAppIntentFilter;"
|
||||
+ " prefix: " + Arrays.toString(digestPrefix));
|
||||
}
|
||||
onGetInstantAppIntentFilter(digestPrefix, token, callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,10 @@ final class EphemeralResolverConnection implements DeathRecipient {
|
||||
private volatile boolean mBindRequested;
|
||||
private IInstantAppResolver mRemoteInstance;
|
||||
|
||||
public EphemeralResolverConnection(Context context, ComponentName componentName) {
|
||||
public EphemeralResolverConnection(
|
||||
Context context, ComponentName componentName, String action) {
|
||||
mContext = context;
|
||||
mIntent = new Intent(Intent.ACTION_RESOLVE_INSTANT_APP_PACKAGE).setComponent(componentName);
|
||||
mIntent = new Intent(action).setComponent(componentName);
|
||||
}
|
||||
|
||||
public final List<InstantAppResolveInfo> getInstantAppResolveInfoList(int hashPrefix[],
|
||||
|
||||
@@ -2813,15 +2813,17 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
mInstallerService = new PackageInstallerService(context, this);
|
||||
final ComponentName ephemeralResolverComponent = getEphemeralResolverLPr();
|
||||
if (ephemeralResolverComponent != null) {
|
||||
final Pair<ComponentName, String> instantAppResolverComponent =
|
||||
getInstantAppResolverLPr();
|
||||
if (instantAppResolverComponent != null) {
|
||||
if (DEBUG_EPHEMERAL) {
|
||||
Slog.d(TAG, "Set ephemeral resolver: " + ephemeralResolverComponent);
|
||||
Slog.d(TAG, "Set ephemeral resolver: " + instantAppResolverComponent);
|
||||
}
|
||||
mInstantAppResolverConnection =
|
||||
new EphemeralResolverConnection(mContext, ephemeralResolverComponent);
|
||||
mInstantAppResolverConnection = new EphemeralResolverConnection(
|
||||
mContext, instantAppResolverComponent.first,
|
||||
instantAppResolverComponent.second);
|
||||
mInstantAppResolverSettingsComponent =
|
||||
getEphemeralResolverSettingsLPr(ephemeralResolverComponent);
|
||||
getInstantAppResolverSettingsLPr(instantAppResolverComponent.first);
|
||||
} else {
|
||||
mInstantAppResolverConnection = null;
|
||||
mInstantAppResolverSettingsComponent = null;
|
||||
@@ -2868,7 +2870,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
private void updateInstantAppInstallerLocked() {
|
||||
final ComponentName oldInstantAppInstallerComponent = mInstantAppInstallerComponent;
|
||||
final ActivityInfo newInstantAppInstaller = getEphemeralInstallerLPr();
|
||||
final ActivityInfo newInstantAppInstaller = getInstantAppInstallerLPr();
|
||||
ComponentName newInstantAppInstallerComponent = newInstantAppInstaller == null
|
||||
? null : newInstantAppInstaller.getComponentName();
|
||||
|
||||
@@ -3045,7 +3047,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable ComponentName getEphemeralResolverLPr() {
|
||||
private @Nullable Pair<ComponentName, String> getInstantAppResolverLPr() {
|
||||
final String[] packageArray =
|
||||
mContext.getResources().getStringArray(R.array.config_ephemeralResolverPackage);
|
||||
if (packageArray.length == 0 && !Build.IS_DEBUGGABLE) {
|
||||
@@ -3060,7 +3062,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
MATCH_DIRECT_BOOT_AWARE
|
||||
| MATCH_DIRECT_BOOT_UNAWARE
|
||||
| (!Build.IS_DEBUGGABLE ? MATCH_SYSTEM_ONLY : 0);
|
||||
final Intent resolverIntent = new Intent(Intent.ACTION_RESOLVE_INSTANT_APP_PACKAGE);
|
||||
String actionName = Intent.ACTION_RESOLVE_INSTANT_APP_PACKAGE;
|
||||
final Intent resolverIntent = new Intent(actionName);
|
||||
List<ResolveInfo> resolvers = queryIntentServicesInternal(resolverIntent, null,
|
||||
resolveFlags, UserHandle.USER_SYSTEM, callingUid, false /*includeInstantApps*/);
|
||||
// temporarily look for the old action
|
||||
@@ -3068,7 +3071,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
if (DEBUG_EPHEMERAL) {
|
||||
Slog.d(TAG, "Ephemeral resolver not found with new action; try old one");
|
||||
}
|
||||
resolverIntent.setAction(Intent.ACTION_RESOLVE_EPHEMERAL_PACKAGE);
|
||||
actionName = Intent.ACTION_RESOLVE_EPHEMERAL_PACKAGE;
|
||||
resolverIntent.setAction(actionName);
|
||||
resolvers = queryIntentServicesInternal(resolverIntent, null,
|
||||
resolveFlags, UserHandle.USER_SYSTEM, callingUid, false /*includeInstantApps*/);
|
||||
}
|
||||
@@ -3101,7 +3105,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
Slog.v(TAG, "Ephemeral resolver found;"
|
||||
+ " pkg: " + packageName + ", info:" + info);
|
||||
}
|
||||
return new ComponentName(packageName, info.serviceInfo.name);
|
||||
return new Pair<>(new ComponentName(packageName, info.serviceInfo.name), actionName);
|
||||
}
|
||||
if (DEBUG_EPHEMERAL) {
|
||||
Slog.v(TAG, "Ephemeral resolver NOT found");
|
||||
@@ -3109,7 +3113,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return null;
|
||||
}
|
||||
|
||||
private @Nullable ActivityInfo getEphemeralInstallerLPr() {
|
||||
private @Nullable ActivityInfo getInstantAppInstallerLPr() {
|
||||
final Intent intent = new Intent(Intent.ACTION_INSTALL_INSTANT_APP_PACKAGE);
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
intent.setDataAndType(Uri.fromFile(new File("foo.apk")), PACKAGE_MIME_TYPE);
|
||||
@@ -3151,7 +3155,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable ComponentName getEphemeralResolverSettingsLPr(
|
||||
private @Nullable ComponentName getInstantAppResolverSettingsLPr(
|
||||
@NonNull ComponentName resolver) {
|
||||
final Intent intent = new Intent(Intent.ACTION_INSTANT_APP_RESOLVER_SETTINGS)
|
||||
.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
|
||||
Reference in New Issue
Block a user