From bbd66a16f80d38764b5ff38ae0f3356d52b6335b Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Fri, 25 Feb 2022 13:18:49 -0500 Subject: Simplify app prediction service check In support of sharesheet unbundling: This change removes the use of the passed in boolean flag to determine AppPredictionService availability and instead falls back checking for a non null value from PackageManager#getAppPredictionServicePackage() This PackageManager call can now be made directly from outside of system_server, enabling progress towards sharesheet unbundling. Bug: 220895016 Test: Enable unbundled sharesheet; share app content; observe share targets Change-Id: I3bb962dd750dfeb23be7aba668ef7d9de0ef4ce1 --- .../android/intentresolver/ChooserActivity.java | 50 +++------------------- 1 file changed, 5 insertions(+), 45 deletions(-) (limited to 'java') diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index 989b4768..d5dff9ff 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -24,27 +24,12 @@ import android.util.Log; /** * Activity for selecting which application ought to handle an ACTION_SEND intent. - * - * TODO: this temporary implementation inherits from the system-side ChooserActivity to avoid - * duplicating code while we're validating the feasibility of the unbundling plans. Architecturally, - * this is almost exactly equivalent to the "unbundling phase" in which the chooser UI is - * implemented in the new project. Once we can verify that this works at (or near) parity, we can - * copy over the source code of the original ChooserActivity instead of inheriting from it here, and - * then we'll be able to make divergent changes much more quickly. See TODO comments in this file - * for notes on performing that refactoring step. */ public class ChooserActivity extends com.android.internal.app.ChooserActivity { private static final String TAG = "ChooserActivity"; private IBinder mPermissionToken; - private boolean mIsAppPredictionServiceAvailable; - - /* TODO: the first section of this file contains overrides for ChooserActivity methods that need - * to be implemented differently in the delegated version. When the two classes are merged - * together, the implementations given here should replace the originals. Rationales for the - * replacements are provided in implementation comments (which could be removed later). */ - /* The unbundled chooser needs to use the permission-token-based API to start activities. */ @Override public boolean startAsCallerImpl(Intent intent, Bundle options, boolean ignoreTargetSecurity, int userId) { @@ -53,42 +38,17 @@ public class ChooserActivity extends com.android.internal.app.ChooserActivity { return true; } - /* TODO: the remaining methods below include some implementation details specifically related to - * the temporary inheritance-based design, which may need to be removed or adapted when the two - * classes are merged together. */ - @Override protected void onCreate(Bundle savedInstanceState) { - boolean shouldShowUi = processIntent(); - if (shouldShowUi) { - super.onCreate(savedInstanceState); - } else { - super_onCreate(savedInstanceState); // Skip up to Activity::onCreate(). - finish(); - } - } - - @Override - public boolean isAppPredictionServiceAvailable() { - return mIsAppPredictionServiceAvailable; - } - - /** - * Process the intent that was used to launch the unbundled chooser, and return true if the - * chooser should continue to initialize as in the full Sharesheet UI, or false if the activity - * should exit immediately. - */ - private boolean processIntent() { mPermissionToken = getIntent().getExtras().getBinder( ActivityTaskManager.EXTRA_PERMISSION_TOKEN); - mIsAppPredictionServiceAvailable = getIntent().getExtras().getBoolean( - EXTRA_IS_APP_PREDICTION_SERVICE_AVAILABLE); - if (mPermissionToken == null) { + if (mPermissionToken != null) { + super.onCreate(savedInstanceState); + } else { Log.e(TAG, "No permission token to launch activities from chooser"); - return false; + super_onCreate(savedInstanceState); // Skip up to Activity::onCreate(). + finish(); } - - return true; } } -- cgit v1.2.3-59-g8ed1b