Merge "Remove remaining references to 'delegate chooser'" into tm-dev
This commit is contained in:
@@ -167,16 +167,6 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
public static final String EXTRA_PRIVATE_RETAIN_IN_ON_STOP
|
public static final String EXTRA_PRIVATE_RETAIN_IN_ON_STOP
|
||||||
= "com.android.internal.app.ChooserActivity.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.
|
* 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
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|||||||
@@ -157,8 +157,6 @@ public class ResolverActivity extends Activity implements
|
|||||||
/** See {@link #setRetainInOnStop}. */
|
/** See {@link #setRetainInOnStop}. */
|
||||||
private boolean mRetainInOnStop;
|
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_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
|
||||||
private static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
|
private static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
|
||||||
private static final String OPEN_LINKS_COMPONENT_KEY = "app_link_state";
|
private static final String OPEN_LINKS_COMPONENT_KEY = "app_link_state";
|
||||||
@@ -1374,18 +1372,6 @@ public class ResolverActivity extends Activity implements
|
|||||||
.write();
|
.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) {
|
public void onActivityStarted(TargetInfo cti) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ import android.annotation.Nullable;
|
|||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
|
import com.android.internal.app.ChooserActivity;
|
||||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.wm.ActivityInterceptorCallback;
|
import com.android.server.wm.ActivityInterceptorCallback;
|
||||||
@@ -35,25 +36,28 @@ import com.android.server.wm.ActivityInterceptorCallback.ActivityInterceptorInfo
|
|||||||
import com.android.server.wm.ActivityTaskManagerInternal;
|
import com.android.server.wm.ActivityTaskManagerInternal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to register an {@code ActivityInterceptorCallback} that modifies any {@code Intent}
|
* Redirects Activity starts for the system bundled {@link ChooserActivity} to an external
|
||||||
* that's being used to launch a user-space {@code ChooserActivity} by setting the destination
|
* Sharesheet implementation by modifying the target component when appropriate.
|
||||||
* component to the delegated 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 {
|
public final class IntentResolverInterceptor {
|
||||||
private static final String TAG = "IntentResolverIntercept";
|
private static final String TAG = "IntentResolverIntercept";
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private boolean mUseDelegateChooser;
|
private final ComponentName mFrameworkChooserComponent;
|
||||||
|
private final ComponentName mUnbundledChooserComponent;
|
||||||
|
private boolean mUseUnbundledSharesheet;
|
||||||
|
|
||||||
private final ActivityInterceptorCallback mActivityInterceptorCallback =
|
private final ActivityInterceptorCallback mActivityInterceptorCallback =
|
||||||
new ActivityInterceptorCallback() {
|
new ActivityInterceptorCallback() {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ActivityInterceptResult intercept(ActivityInterceptorInfo info) {
|
public ActivityInterceptResult intercept(ActivityInterceptorInfo info) {
|
||||||
if (mUseDelegateChooser && isChooserActivity(info)) {
|
if (mUseUnbundledSharesheet && isSystemChooserActivity(info)) {
|
||||||
return new ActivityInterceptResult(
|
Slog.d(TAG, "Redirecting to UNBUNDLED Sharesheet");
|
||||||
modifyChooserIntent(info.intent),
|
info.intent.setComponent(mUnbundledChooserComponent);
|
||||||
info.checkedOptions);
|
return new ActivityInterceptResult(info.intent, info.checkedOptions);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -61,10 +65,13 @@ public final class IntentResolverInterceptor {
|
|||||||
|
|
||||||
public IntentResolverInterceptor(Context context) {
|
public IntentResolverInterceptor(Context context) {
|
||||||
mContext = 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)
|
@RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG)
|
||||||
public void registerListeners() {
|
public void registerListeners() {
|
||||||
@@ -73,36 +80,25 @@ public final class IntentResolverInterceptor {
|
|||||||
mActivityInterceptorCallback);
|
mActivityInterceptorCallback);
|
||||||
|
|
||||||
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
|
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
mContext.getMainExecutor(), properties -> updateUseDelegateChooser());
|
mContext.getMainExecutor(), properties -> updateUseUnbundledSharesheet());
|
||||||
updateUseDelegateChooser();
|
updateUseUnbundledSharesheet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG)
|
@RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG)
|
||||||
private void updateUseDelegateChooser() {
|
private void updateUseUnbundledSharesheet() {
|
||||||
mUseDelegateChooser = DeviceConfig.getBoolean(
|
mUseUnbundledSharesheet = DeviceConfig.getBoolean(
|
||||||
DeviceConfig.NAMESPACE_SYSTEMUI,
|
DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
SystemUiDeviceConfigFlags.USE_UNBUNDLED_SHARESHEET,
|
SystemUiDeviceConfigFlags.USE_UNBUNDLED_SHARESHEET,
|
||||||
false);
|
false);
|
||||||
|
if (mUseUnbundledSharesheet) {
|
||||||
|
Slog.d(TAG, "using UNBUNDLED Sharesheet");
|
||||||
|
} else {
|
||||||
|
Slog.d(TAG, "using FRAMEWORK Sharesheet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent modifyChooserIntent(Intent intent) {
|
private boolean isSystemChooserActivity(ActivityInterceptorInfo info) {
|
||||||
intent.setComponent(getUnbundledChooserComponentName());
|
return mFrameworkChooserComponent.getPackageName().equals(info.aInfo.packageName)
|
||||||
return intent;
|
&& mFrameworkChooserComponent.getClassName().equals(info.aInfo.name);
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user