Remove remaining references to 'delegate chooser'

Clean up some leftover references and simplify
Add positive confirmation of flag changes via logcat

Change-Id: Id21b66953bb3b7c810e9d67809a673862a7ea821
This commit is contained in:
Mark Renouf
2022-03-30 09:56:09 -04:00
parent ca3d495ca6
commit f44e240e95
3 changed files with 36 additions and 58 deletions

View File

@@ -167,16 +167,6 @@ public class ChooserActivity extends ResolverActivity implements
public static final String EXTRA_PRIVATE_RETAIN_IN_ON_STOP
= "com.android.internal.app.ChooserActivity.EXTRA_PRIVATE_RETAIN_IN_ON_STOP";
/**
* Boolean extra added to "unbundled Sharesheet" delegation intents to signal whether the app
* prediction service is available. Our query of the service <em>availability</em> depends on
* privileges that are only available in the system, even though the service itself would then
* be available to the unbundled component. For now, we just include the query result as part of
* the handover intent.
* TODO: investigate whether the privileged query is necessary to determine the availability.
*/
public static final String EXTRA_IS_APP_PREDICTION_SERVICE_AVAILABLE =
"com.android.internal.app.ChooserActivity.EXTRA_IS_APP_PREDICTION_SERVICE_AVAILABLE";
/**
* Transition name for the first image preview.
@@ -984,6 +974,12 @@ public class ChooserActivity extends ResolverActivity implements
}
}
@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "onResume: " + getComponentName().flattenToShortString());
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);

View File

@@ -157,8 +157,6 @@ public class ResolverActivity extends Activity implements
/** See {@link #setRetainInOnStop}. */
private boolean mRetainInOnStop;
protected static final int REQUEST_CODE_RETURN_FROM_DELEGATE_CHOOSER = 20;
private static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
private static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
private static final String OPEN_LINKS_COMPONENT_KEY = "app_link_state";
@@ -1454,18 +1452,6 @@ public class ResolverActivity extends Activity implements
.write();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CODE_RETURN_FROM_DELEGATE_CHOOSER:
// Repeat the delegate's result as our own.
setResult(resultCode, data);
finish();
break;
default:
super.onActivityResult(requestCode, resultCode, data);
}
}
public void onActivityStarted(TargetInfo cti) {
// Do nothing

View File

@@ -23,11 +23,12 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.provider.DeviceConfig;
import android.util.Slog;
import com.android.internal.R;
import com.android.internal.app.ChooserActivity;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.server.LocalServices;
import com.android.server.wm.ActivityInterceptorCallback;
@@ -35,25 +36,28 @@ import com.android.server.wm.ActivityInterceptorCallback.ActivityInterceptorInfo
import com.android.server.wm.ActivityTaskManagerInternal;
/**
* Service to register an {@code ActivityInterceptorCallback} that modifies any {@code Intent}
* that's being used to launch a user-space {@code ChooserActivity} by setting the destination
* component to the delegated component when appropriate.
* Redirects Activity starts for the system bundled {@link ChooserActivity} to an external
* Sharesheet implementation by modifying the target component when appropriate.
* <p>
* Note: config_chooserActivity (Used also by ActivityTaskSupervisor) is already updated to point
* to the new instance. This value is read and used for the new target component.
*/
public final class IntentResolverInterceptor {
private static final String TAG = "IntentResolverIntercept";
private final Context mContext;
private boolean mUseDelegateChooser;
private final ComponentName mFrameworkChooserComponent;
private final ComponentName mUnbundledChooserComponent;
private boolean mUseUnbundledSharesheet;
private final ActivityInterceptorCallback mActivityInterceptorCallback =
new ActivityInterceptorCallback() {
@Nullable
@Override
public ActivityInterceptResult intercept(ActivityInterceptorInfo info) {
if (mUseDelegateChooser && isChooserActivity(info)) {
return new ActivityInterceptResult(
modifyChooserIntent(info.intent),
info.checkedOptions);
if (mUseUnbundledSharesheet && isSystemChooserActivity(info)) {
Slog.d(TAG, "Redirecting to UNBUNDLED Sharesheet");
info.intent.setComponent(mUnbundledChooserComponent);
return new ActivityInterceptResult(info.intent, info.checkedOptions);
}
return null;
}
@@ -61,10 +65,13 @@ public final class IntentResolverInterceptor {
public IntentResolverInterceptor(Context context) {
mContext = context;
mFrameworkChooserComponent = new ComponentName(mContext, ChooserActivity.class);
mUnbundledChooserComponent = ComponentName.unflattenFromString(
Resources.getSystem().getString(R.string.config_chooserActivity));
}
/**
* Start listening for intents and USE_DELEGATE_CHOOSER property changes.
* Start listening for intents and USE_UNBUNDLED_SHARESHEET property changes.
*/
@RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG)
public void registerListeners() {
@@ -73,36 +80,25 @@ public final class IntentResolverInterceptor {
mActivityInterceptorCallback);
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
mContext.getMainExecutor(), properties -> updateUseDelegateChooser());
updateUseDelegateChooser();
mContext.getMainExecutor(), properties -> updateUseUnbundledSharesheet());
updateUseUnbundledSharesheet();
}
@RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG)
private void updateUseDelegateChooser() {
mUseDelegateChooser = DeviceConfig.getBoolean(
private void updateUseUnbundledSharesheet() {
mUseUnbundledSharesheet = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.USE_UNBUNDLED_SHARESHEET,
false);
if (mUseUnbundledSharesheet) {
Slog.d(TAG, "using UNBUNDLED Sharesheet");
} else {
Slog.d(TAG, "using FRAMEWORK Sharesheet");
}
}
private Intent modifyChooserIntent(Intent intent) {
intent.setComponent(getUnbundledChooserComponentName());
return intent;
}
private static boolean isChooserActivity(ActivityInterceptorInfo info) {
ComponentName targetComponent = new ComponentName(info.aInfo.packageName, info.aInfo.name);
return targetComponent.equals(getSystemChooserComponentName())
|| targetComponent.equals(getUnbundledChooserComponentName());
}
private static ComponentName getSystemChooserComponentName() {
return new ComponentName("android", "com.android.internal.app.ChooserActivity");
}
private static ComponentName getUnbundledChooserComponentName() {
return ComponentName.unflattenFromString(
Resources.getSystem().getString(R.string.config_chooserActivity));
private boolean isSystemChooserActivity(ActivityInterceptorInfo info) {
return mFrameworkChooserComponent.getPackageName().equals(info.aInfo.packageName)
&& mFrameworkChooserComponent.getClassName().equals(info.aInfo.name);
}
}