diff options
| author | 2019-01-25 12:43:54 -0800 | |
|---|---|---|
| committer | 2019-01-28 17:46:17 +0000 | |
| commit | f2b0d34ee948858b73c293777da9a4be37854a9e (patch) | |
| tree | 4e271fa71dc05b8748e6af21d1865e2ea5f9874a | |
| parent | a28d9144578f6e6f1771cce91f8a40e1ca63a03a (diff) | |
Send share events to App Predictor.
Bug: 123377860
Test: Checked logs that the shortcutIds and ComponentNames
match in convertToChooserTargets and sendClickToAppPredictor.
Change-Id: I25ae43d1c26ef41ba1076a7648be35ecc04b664d
| -rw-r--r-- | core/java/com/android/internal/app/ChooserActivity.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index 803462d59fad..299801a1b8fc 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -22,6 +22,8 @@ import android.app.prediction.AppPredictionContext; import android.app.prediction.AppPredictionManager; import android.app.prediction.AppPredictor; import android.app.prediction.AppTarget; +import android.app.prediction.AppTargetEvent; +import android.app.prediction.AppTargetId; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -111,6 +113,7 @@ public class ChooserActivity extends ResolverActivity { private static final boolean USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS = false; // TODO(b/123088566) Share these in a better way. private static final String APP_PREDICTION_SHARE_UI_SURFACE = "share"; + public static final String LAUNCH_LOCATON_DIRECT_SHARE = "direct_share"; private static final int APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT = 20; public static final String APP_PREDICTION_INTENT_FILTER_KEY = "intent_filter"; private AppPredictor mAppPredictor; @@ -787,9 +790,11 @@ public class ChooserActivity extends ResolverActivity { // Do nothing. We'll send the voice stuff ourselves. } - // TODO(b/123377860) Send clicked ShortcutInfo to mAppPredictor void updateModelAndChooserCounts(TargetInfo info) { if (info != null) { + if (USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS) { + sendClickToAppPredictor(info); + } final ResolveInfo ri = info.getResolveInfo(); Intent targetIntent = getTargetIntent(); if (ri != null && ri.activityInfo != null && targetIntent != null) { @@ -802,13 +807,39 @@ public class ChooserActivity extends ResolverActivity { Log.d(TAG, "ResolveInfo Package is " + ri.activityInfo.packageName); Log.d(TAG, "Action to be updated is " + targetIntent.getAction()); } - } else if(DEBUG) { + } else if (DEBUG) { Log.d(TAG, "Can not log Chooser Counts of null ResovleInfo"); } } mIsSuccessfullySelected = true; } + private void sendClickToAppPredictor(TargetInfo targetInfo) { + if (!(targetInfo instanceof ChooserTargetInfo)) { + return; + } + ChooserTarget chooserTarget = ((ChooserTargetInfo) targetInfo).getChooserTarget(); + ComponentName componentName = chooserTarget.getComponentName(); + Bundle extras = chooserTarget.getIntentExtras(); + if (extras == null) { + return; + } + String shortcutId = extras.getString(Intent.EXTRA_SHORTCUT_ID); + if (shortcutId == null) { + return; + } + mAppPredictor.notifyAppTargetEvent( + new AppTargetEvent.Builder( + new AppTarget( + new AppTargetId(shortcutId), + componentName.getPackageName(), + componentName.getClassName(), + getUser()), + AppTargetEvent.ACTION_LAUNCH + ).setLaunchLocation(LAUNCH_LOCATON_DIRECT_SHARE) + .build()); + } + void onRefinementResult(TargetInfo selectedTarget, Intent matchingIntent) { if (mRefinementResultReceiver != null) { mRefinementResultReceiver.destroy(); @@ -1128,6 +1159,10 @@ public class ChooserActivity extends ResolverActivity { return mBadgeContentDescription; } + public ChooserTarget getChooserTarget() { + return mChooserTarget; + } + @Override public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) { return new ChooserTargetInfo(this, fillInIntent, flags); |