summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
author Mark Renouf <mrenouf@google.com> 2022-02-25 13:18:49 -0500
committer Mark Renouf <mrenouf@google.com> 2022-02-25 18:35:03 +0000
commitbbd66a16f80d38764b5ff38ae0f3356d52b6335b (patch)
tree8d6eca5d0bcac07e817197f107d95ede9bf938b9 /java
parent923cf11e01f87bc26fc43f9a7e94527fe4e564b9 (diff)
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
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/intentresolver/ChooserActivity.java50
1 files changed, 5 insertions, 45 deletions
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;
}
}