Add ACTION_EPHEMERAL_RESOLVER_SETTINGS
This Intent will be used in Settings to show the settings UI for the Ephemeral resolver. Settings can get the correct component to send the Intent to by calling PackageManager.getInstantAppResolverSettingsComponent Bug: 35918998 Test: Boots Change-Id: I0edcf85704f2c19e0ee27f91b6ef057d52e32778
This commit is contained in:
@@ -11171,6 +11171,7 @@ package android.content.pm {
|
||||
method public abstract byte[] getInstantAppCookie();
|
||||
method public abstract int getInstantAppCookieMaxSize();
|
||||
method public abstract android.graphics.drawable.Drawable getInstantAppIcon(java.lang.String);
|
||||
method public abstract android.content.ComponentName getInstantAppResolverSettingsComponent();
|
||||
method public abstract java.util.List<android.content.pm.InstantAppInfo> getInstantApps();
|
||||
method public abstract android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public abstract java.util.List<android.content.pm.IntentFilterVerificationInfo> getIntentFilterVerifications(java.lang.String);
|
||||
@@ -44203,6 +44204,7 @@ package android.test.mock {
|
||||
method public byte[] getInstantAppCookie();
|
||||
method public int getInstantAppCookieMaxSize();
|
||||
method public android.graphics.drawable.Drawable getInstantAppIcon(java.lang.String);
|
||||
method public android.content.ComponentName getInstantAppResolverSettingsComponent();
|
||||
method public java.util.List<android.content.pm.InstantAppInfo> getInstantApps();
|
||||
method public android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public java.util.List<android.content.pm.IntentFilterVerificationInfo> getIntentFilterVerifications(java.lang.String);
|
||||
|
||||
@@ -2630,4 +2630,13 @@ public class ApplicationPackageManager extends PackageManager {
|
||||
throw e.rethrowAsRuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName getInstantAppResolverSettingsComponent() {
|
||||
try {
|
||||
return mPM.getInstantAppResolverSettingsComponent();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowAsRuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1531,6 +1531,19 @@ public class Intent implements Parcelable, Cloneable {
|
||||
public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
|
||||
= "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
|
||||
|
||||
/**
|
||||
* Activity Action: Launch ephemeral settings.
|
||||
*
|
||||
* <p class="note">
|
||||
* This is a protected intent that can only be sent by the system.
|
||||
* </p>
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
||||
public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
|
||||
= "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
|
||||
|
||||
/**
|
||||
* Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
|
||||
* package. Specifies the installer package name; this package will receive the
|
||||
|
||||
@@ -630,4 +630,6 @@ interface IPackageManager {
|
||||
boolean canRequestPackageInstalls(String packageName, int userId);
|
||||
|
||||
void deletePreloadsFileCache();
|
||||
|
||||
ComponentName getInstantAppResolverSettingsComponent();
|
||||
}
|
||||
|
||||
@@ -6233,4 +6233,14 @@ public abstract class PackageManager {
|
||||
* @see {@link android.provider.Settings#ACTION_MANAGE_EXTERNAL_SOURCES}
|
||||
*/
|
||||
public abstract boolean canRequestPackageInstalls();
|
||||
|
||||
/**
|
||||
* Return the {@link ComponentName} of the activity providing Settings for the Instant App
|
||||
* resolver.
|
||||
*
|
||||
* @see {@link android.content.intent#ACTION_EPHEMERAL_RESOLVER_SETTINGS}
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public abstract ComponentName getInstantAppResolverSettingsComponent();
|
||||
}
|
||||
|
||||
@@ -842,6 +842,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
/** Component used to install ephemeral applications */
|
||||
ComponentName mInstantAppInstallerComponent;
|
||||
/** Component used to show resolver settings for Instant Apps */
|
||||
ComponentName mInstantAppResolverSettingsComponent;
|
||||
ActivityInfo mInstantAppInstallerActivity;
|
||||
final ResolveInfo mInstantAppInstallerInfo = new ResolveInfo();
|
||||
|
||||
@@ -2890,6 +2892,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
mInstantAppResolverConnection = null;
|
||||
}
|
||||
updateInstantAppInstallerLocked();
|
||||
mInstantAppResolverSettingsComponent = getEphemeralResolverSettingsLPr();
|
||||
|
||||
// Read and update the usage of dex files.
|
||||
// Do this at the end of PM init so that all the packages have their
|
||||
@@ -3196,6 +3199,37 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable ComponentName getEphemeralResolverSettingsLPr() {
|
||||
final Intent intent = new Intent(Intent.ACTION_EPHEMERAL_RESOLVER_SETTINGS);
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
final int resolveFlags =
|
||||
MATCH_DIRECT_BOOT_AWARE
|
||||
| MATCH_DIRECT_BOOT_UNAWARE
|
||||
| (!Build.IS_DEBUGGABLE ? MATCH_SYSTEM_ONLY : 0);
|
||||
final List<ResolveInfo> matches = queryIntentActivitiesInternal(intent, null,
|
||||
resolveFlags, UserHandle.USER_SYSTEM);
|
||||
Iterator<ResolveInfo> iter = matches.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final ResolveInfo rInfo = iter.next();
|
||||
final PackageSetting ps = mSettings.mPackages.get(rInfo.activityInfo.packageName);
|
||||
if (ps != null) {
|
||||
final PermissionsState permissionsState = ps.getPermissionsState();
|
||||
if (permissionsState.hasPermission(Manifest.permission.ACCESS_INSTANT_APPS, 0)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
iter.remove();
|
||||
}
|
||||
if (matches.size() == 0) {
|
||||
return null;
|
||||
} else if (matches.size() == 1) {
|
||||
return matches.get(0).getComponentInfo().getComponentName();
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
"There must be at most one ephemeral resolver settings; found " + matches);
|
||||
}
|
||||
}
|
||||
|
||||
private void primeDomainVerificationsLPw(int userId) {
|
||||
if (DEBUG_DOMAIN_VERIFICATION) {
|
||||
Slog.d(TAG, "Priming domain verifications in user " + userId);
|
||||
@@ -23313,4 +23347,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
|
||||
}
|
||||
return checkUidPermission(appOpPermission, uid) == PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName getInstantAppResolverSettingsComponent() {
|
||||
return mInstantAppResolverSettingsComponent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,4 +1118,12 @@ public class MockPackageManager extends PackageManager {
|
||||
public int getInstallReason(String packageName, UserHandle user) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public ComponentName getInstantAppResolverSettingsComponent() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,4 +916,9 @@ public class BridgePackageManager extends PackageManager {
|
||||
public boolean canRequestPackageInstalls() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName getInstantAppResolverSettingsComponent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user