Merge "Remove system call to "headless" unbundled chooser" into tm-dev

This commit is contained in:
Matt Casey
2022-02-24 02:43:31 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 46 deletions

View File

@@ -33,7 +33,6 @@ import android.annotation.StringRes;
import android.annotation.UiThread;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.VoiceInteractor.PickOptionRequest;
import android.app.VoiceInteractor.PickOptionRequest.Option;
@@ -54,13 +53,11 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Insets;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PatternMatcher;
import android.os.RemoteException;
import android.os.StrictMode;
@@ -1464,36 +1461,9 @@ public class ResolverActivity extends Activity implements
public boolean startAsCallerImpl(Intent intent, Bundle options, boolean ignoreTargetSecurity,
int userId) {
// Pass intent to delegate chooser activity with permission token.
// TODO: This should move to a trampoline Activity in the system when the ChooserActivity
// moves into systemui
try {
// TODO: Once this is a small springboard activity, it can move off the UI process
// and we can move the request method to ActivityManagerInternal.
final Intent chooserIntent = new Intent();
final ComponentName delegateActivity = ComponentName.unflattenFromString(
Resources.getSystem().getString(R.string.config_chooserActivity));
IBinder permissionToken = ActivityTaskManager.getService()
.requestStartActivityPermissionToken(delegateActivity);
chooserIntent.setClassName(delegateActivity.getPackageName(),
delegateActivity.getClassName());
chooserIntent.putExtra(ActivityTaskManager.EXTRA_PERMISSION_TOKEN, permissionToken);
// TODO: These extras will change as chooser activity moves into systemui
chooserIntent.putExtra(Intent.EXTRA_INTENT, intent);
chooserIntent.putExtra(ActivityTaskManager.EXTRA_OPTIONS, options);
chooserIntent.putExtra(ActivityTaskManager.EXTRA_IGNORE_TARGET_SECURITY,
ignoreTargetSecurity);
chooserIntent.putExtra(Intent.EXTRA_USER_ID, userId);
chooserIntent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
// Don't close until the delegate finishes, or the token will be invalidated.
mAwaitingDelegateResponse = true;
startActivityForResult(chooserIntent, REQUEST_CODE_RETURN_FROM_DELEGATE_CHOOSER);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
// Note: this method will be overridden in the delegate implementation to use the passed-in
// permission token.
startActivityAsCaller(intent, options, null, false, userId);
return true;
}

View File

@@ -30,11 +30,9 @@ import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import com.android.internal.app.ResolverActivity;
import com.android.internal.app.ResolverListAdapter.ResolveInfoPresentationGetter;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import java.util.ArrayList;
import java.util.Arrays;
@@ -45,11 +43,6 @@ import java.util.List;
* resolve it to an activity.
*/
public class DisplayResolveInfo implements TargetInfo, Parcelable {
private final boolean mEnableChooserDelegate =
DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.USE_DELEGATE_CHOOSER,
false);
private final ResolveInfo mResolveInfo;
private CharSequence mDisplayLabel;
private Drawable mDisplayIcon;
@@ -180,12 +173,9 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable {
@Override
public boolean startAsCaller(ResolverActivity activity, Bundle options, int userId) {
if (mEnableChooserDelegate) {
return activity.startAsCallerImpl(mResolvedIntent, options, false, userId);
} else {
activity.startActivityAsCaller(mResolvedIntent, options, null, false, userId);
return true;
}
// TODO: if the start-as-caller API no longer requires a permission token, this can go back
// to inlining the real activity-start call, and we can remove startAsCallerImpl.
return activity.startAsCallerImpl(mResolvedIntent, options, false, userId);
}
@Override