Merge "Pass shared text content from ChooserActivity to AppPredictionService" into tm-dev am: d581c08704

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18356488

Change-Id: I725dc30ae7933aae657e059a2df5bddcf7dda0d3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Song Hu
2022-05-13 21:37:13 +00:00
committed by Automerger Merge Worker

View File

@@ -190,6 +190,7 @@ public class ChooserActivity extends ResolverActivity implements
private static final String SHORTCUT_TARGET = "shortcut_target"; private static final String SHORTCUT_TARGET = "shortcut_target";
private static final int APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT = 20; private static final int APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT = 20;
public static final String APP_PREDICTION_INTENT_FILTER_KEY = "intent_filter"; public static final String APP_PREDICTION_INTENT_FILTER_KEY = "intent_filter";
private static final String SHARED_TEXT_KEY = "shared_text";
private static final String PLURALS_COUNT = "count"; private static final String PLURALS_COUNT = "count";
private static final String PLURALS_FILE_NAME = "file_name"; private static final String PLURALS_FILE_NAME = "file_name";
@@ -2201,6 +2202,7 @@ public class ChooserActivity extends ResolverActivity implements
final IntentFilter filter = getTargetIntentFilter(); final IntentFilter filter = getTargetIntentFilter();
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putParcelable(APP_PREDICTION_INTENT_FILTER_KEY, filter); extras.putParcelable(APP_PREDICTION_INTENT_FILTER_KEY, filter);
populateTextContent(extras);
AppPredictionContext appPredictionContext = new AppPredictionContext.Builder(contextAsUser) AppPredictionContext appPredictionContext = new AppPredictionContext.Builder(contextAsUser)
.setUiSurface(APP_PREDICTION_SHARE_UI_SURFACE) .setUiSurface(APP_PREDICTION_SHARE_UI_SURFACE)
.setPredictedTargetCount(APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT) .setPredictedTargetCount(APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT)
@@ -2219,6 +2221,12 @@ public class ChooserActivity extends ResolverActivity implements
return appPredictionSession; return appPredictionSession;
} }
private void populateTextContent(Bundle extras) {
final Intent intent = getTargetIntent();
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
extras.putString(SHARED_TEXT_KEY, sharedText);
}
/** /**
* This will return an app predictor if it is enabled for direct share sorting * This will return an app predictor if it is enabled for direct share sorting
* and if one exists. Otherwise, it returns null. * and if one exists. Otherwise, it returns null.