Loading core/java/com/android/internal/app/ChooserActivity.java +37 −2 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.app.prediction.AppPredictionContext; import android.app.prediction.AppPredictionManager; import android.app.prediction.AppPredictionManager; import android.app.prediction.AppPredictor; import android.app.prediction.AppPredictor; import android.app.prediction.AppTarget; import android.app.prediction.AppTarget; import android.app.prediction.AppTargetEvent; import android.app.prediction.AppTargetId; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; Loading Loading @@ -111,6 +113,7 @@ public class ChooserActivity extends ResolverActivity { private static final boolean USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS = false; private static final boolean USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS = false; // TODO(b/123088566) Share these in a better way. // TODO(b/123088566) Share these in a better way. private static final String APP_PREDICTION_SHARE_UI_SURFACE = "share"; 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; 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 AppPredictor mAppPredictor; private AppPredictor mAppPredictor; Loading Loading @@ -787,9 +790,11 @@ public class ChooserActivity extends ResolverActivity { // Do nothing. We'll send the voice stuff ourselves. // Do nothing. We'll send the voice stuff ourselves. } } // TODO(b/123377860) Send clicked ShortcutInfo to mAppPredictor void updateModelAndChooserCounts(TargetInfo info) { void updateModelAndChooserCounts(TargetInfo info) { if (info != null) { if (info != null) { if (USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS) { sendClickToAppPredictor(info); } final ResolveInfo ri = info.getResolveInfo(); final ResolveInfo ri = info.getResolveInfo(); Intent targetIntent = getTargetIntent(); Intent targetIntent = getTargetIntent(); if (ri != null && ri.activityInfo != null && targetIntent != null) { if (ri != null && ri.activityInfo != null && targetIntent != null) { Loading @@ -809,6 +814,32 @@ public class ChooserActivity extends ResolverActivity { mIsSuccessfullySelected = true; 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) { void onRefinementResult(TargetInfo selectedTarget, Intent matchingIntent) { if (mRefinementResultReceiver != null) { if (mRefinementResultReceiver != null) { mRefinementResultReceiver.destroy(); mRefinementResultReceiver.destroy(); Loading Loading @@ -1128,6 +1159,10 @@ public class ChooserActivity extends ResolverActivity { return mBadgeContentDescription; return mBadgeContentDescription; } } public ChooserTarget getChooserTarget() { return mChooserTarget; } @Override @Override public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) { public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) { return new ChooserTargetInfo(this, fillInIntent, flags); return new ChooserTargetInfo(this, fillInIntent, flags); Loading Loading
core/java/com/android/internal/app/ChooserActivity.java +37 −2 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.app.prediction.AppPredictionContext; import android.app.prediction.AppPredictionManager; import android.app.prediction.AppPredictionManager; import android.app.prediction.AppPredictor; import android.app.prediction.AppPredictor; import android.app.prediction.AppTarget; import android.app.prediction.AppTarget; import android.app.prediction.AppTargetEvent; import android.app.prediction.AppTargetId; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; Loading Loading @@ -111,6 +113,7 @@ public class ChooserActivity extends ResolverActivity { private static final boolean USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS = false; private static final boolean USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS = false; // TODO(b/123088566) Share these in a better way. // TODO(b/123088566) Share these in a better way. private static final String APP_PREDICTION_SHARE_UI_SURFACE = "share"; 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; 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 AppPredictor mAppPredictor; private AppPredictor mAppPredictor; Loading Loading @@ -787,9 +790,11 @@ public class ChooserActivity extends ResolverActivity { // Do nothing. We'll send the voice stuff ourselves. // Do nothing. We'll send the voice stuff ourselves. } } // TODO(b/123377860) Send clicked ShortcutInfo to mAppPredictor void updateModelAndChooserCounts(TargetInfo info) { void updateModelAndChooserCounts(TargetInfo info) { if (info != null) { if (info != null) { if (USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS) { sendClickToAppPredictor(info); } final ResolveInfo ri = info.getResolveInfo(); final ResolveInfo ri = info.getResolveInfo(); Intent targetIntent = getTargetIntent(); Intent targetIntent = getTargetIntent(); if (ri != null && ri.activityInfo != null && targetIntent != null) { if (ri != null && ri.activityInfo != null && targetIntent != null) { Loading @@ -809,6 +814,32 @@ public class ChooserActivity extends ResolverActivity { mIsSuccessfullySelected = true; 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) { void onRefinementResult(TargetInfo selectedTarget, Intent matchingIntent) { if (mRefinementResultReceiver != null) { if (mRefinementResultReceiver != null) { mRefinementResultReceiver.destroy(); mRefinementResultReceiver.destroy(); Loading Loading @@ -1128,6 +1159,10 @@ public class ChooserActivity extends ResolverActivity { return mBadgeContentDescription; return mBadgeContentDescription; } } public ChooserTarget getChooserTarget() { return mChooserTarget; } @Override @Override public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) { public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) { return new ChooserTargetInfo(this, fillInIntent, flags); return new ChooserTargetInfo(this, fillInIntent, flags); Loading