Loading packages/SystemUI/src/com/android/systemui/chooser/ChooserActivity.java→core/java/com/android/internal/app/ChooserActivity.java +10 −55 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.systemui.chooser; package com.android.internal.app; import android.animation.ObjectAnimator; import android.annotation.NonNull; Loading @@ -25,7 +25,6 @@ import android.content.Intent; import android.content.IntentSender; import android.content.IntentSender.SendIntentException; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.LabeledIntent; import android.content.pm.PackageManager; Loading @@ -36,7 +35,6 @@ import android.graphics.Color; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.IBinder; import android.os.Message; Loading Loading @@ -67,12 +65,9 @@ import android.widget.AbsListView; import android.widget.BaseAdapter; import android.widget.ListView; import com.android.internal.R; import com.android.internal.app.IntentForwarderActivity; import com.android.internal.app.ResolverActivity; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsProto.MetricsEvent; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; Loading @@ -96,11 +91,6 @@ public class ChooserActivity extends ResolverActivity { private ChooserListAdapter mChooserListAdapter; private ChooserRowAdapter mChooserRowAdapter; private SharedPreferences mPinnedSharedPrefs; private static final float PINNED_TARGET_SCORE_BOOST = 1000.f; private static final String PINNED_SHARED_PREFS_NAME = "chooser_pin_settings"; private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment"; private final List<ChooserTargetServiceConnection> mServiceConnections = new ArrayList<>(); private static final int CHOOSER_TARGET_SERVICE_RESULT = 1; Loading Loading @@ -217,18 +207,12 @@ public class ChooserActivity extends ResolverActivity { mRefinementIntentSender = intent.getParcelableExtra( Intent.EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER); setSafeForwardingMode(true); mPinnedSharedPrefs = getPinnedSharedPrefs(this); super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents, null, false); MetricsLogger.action(this, MetricsEvent.ACTION_ACTIVITY_CHOOSER_SHOWN); } static SharedPreferences getPinnedSharedPrefs(Context context) { return context.getSharedPreferences(PINNED_SHARED_PREFS_NAME, MODE_PRIVATE); } @Override protected void onDestroy() { super.onDestroy(); Loading Loading @@ -259,7 +243,7 @@ public class ChooserActivity extends ResolverActivity { } @Override public void onActivityStarted(TargetInfo cti) { void onActivityStarted(TargetInfo cti) { if (mChosenComponentSender != null) { final ComponentName target = cti.getResolvedComponentName(); if (target != null) { Loading @@ -275,7 +259,7 @@ public class ChooserActivity extends ResolverActivity { } @Override public void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, boolean alwaysUseOption) { final ListView listView = adapterView instanceof ListView ? (ListView) adapterView : null; mChooserListAdapter = (ChooserListAdapter) adapter; Loading @@ -288,17 +272,17 @@ public class ChooserActivity extends ResolverActivity { } @Override public int getLayoutResource() { int getLayoutResource() { return R.layout.chooser_grid; } @Override public boolean shouldGetActivityMetadata() { boolean shouldGetActivityMetadata() { return true; } @Override public boolean shouldAutoLaunchSingleChoice(TargetInfo target) { boolean shouldAutoLaunchSingleChoice(TargetInfo target) { final Intent intent = target.getResolvedIntent(); final ResolveInfo resolve = target.getResolveInfo(); Loading @@ -315,16 +299,6 @@ public class ChooserActivity extends ResolverActivity { return false; } @Override public void showTargetDetails(ResolveInfo ri) { ComponentName name = ri.activityInfo.getComponentName(); boolean pinned = mPinnedSharedPrefs.getBoolean(name.flattenToString(), false); ResolverTargetActionsDialogFragment f = new ResolverTargetActionsDialogFragment(ri.loadLabel(getPackageManager()), name, pinned); f.show(getFragmentManager(), TARGET_DETAILS_FRAGMENT_TAG); } private void modifyTargetIntent(Intent in) { final String action = in.getAction(); if (Intent.ACTION_SEND.equals(action) || Loading Loading @@ -366,7 +340,7 @@ public class ChooserActivity extends ResolverActivity { } @Override public void startSelected(int which, boolean always, boolean filtered) { void startSelected(int which, boolean always, boolean filtered) { super.startSelected(which, always, filtered); if (mChooserListAdapter != null) { Loading Loading @@ -497,7 +471,7 @@ public class ChooserActivity extends ResolverActivity { mChooserHandler.removeMessages(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT); } public void onSetupVoiceInteraction() { void onSetupVoiceInteraction() { // Do nothing. We'll send the voice stuff ourselves. } Loading Loading @@ -569,7 +543,7 @@ public class ChooserActivity extends ResolverActivity { } @Override public ResolveListAdapter createAdapter(Context context, List<Intent> payloadIntents, ResolveListAdapter createAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, int launchedFromUid, boolean filterLastUsed) { final ChooserListAdapter adapter = new ChooserListAdapter(context, payloadIntents, Loading Loading @@ -737,11 +711,6 @@ public class ChooserActivity extends ResolverActivity { } return results; } @Override public boolean isPinned() { return mSourceInfo != null ? mSourceInfo.isPinned() : false; } } public class ChooserListAdapter extends ResolveListAdapter { Loading Loading @@ -807,20 +776,6 @@ public class ChooserActivity extends ResolverActivity { return false; } @Override public boolean isComponentPinned(ComponentName name) { return mPinnedSharedPrefs.getBoolean(name.flattenToString(), false); } @Override public float getScore(DisplayResolveInfo target) { float score = super.getScore(target); if (target.isPinned()) { score += PINNED_TARGET_SCORE_BOOST; } return score; } @Override public View onCreateView(ViewGroup parent) { return mInflater.inflate( Loading Loading @@ -1166,7 +1121,7 @@ public class ChooserActivity extends ResolverActivity { v.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { showTargetDetails( showAppDetails( mChooserListAdapter.resolveInfoForPosition( holder.itemIndices[column], true)); return true; Loading core/java/com/android/internal/app/IntentForwarderActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public class IntentForwarderActivity extends Activity { final boolean shouldShowDisclosure = ri == null || ri.activityInfo == null || !"android".equals(ri.activityInfo.packageName) || !(ResolverActivity.class.getName().equals(ri.activityInfo.name) || "com.android.systemui.chooser.ChooserActivity".equals(ri.activityInfo.name)); || ChooserActivity.class.getName().equals(ri.activityInfo.name)); try { startActivityAsCaller(newIntent, null, false, targetUserId); Loading core/java/com/android/internal/app/ResolverActivity.java +34 −69 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.app.ActivityThread; import android.app.VoiceInteractor.PickOptionRequest; import android.app.VoiceInteractor.PickOptionRequest.Option; import android.app.VoiceInteractor.Prompt; import android.content.pm.ComponentInfo; import android.os.AsyncTask; import android.provider.Settings; import android.text.TextUtils; Loading Loading @@ -337,12 +336,12 @@ public class ResolverActivity extends Activity { /** * Perform any initialization needed for voice interaction. */ public void onSetupVoiceInteraction() { void onSetupVoiceInteraction() { // Do it right now. Subclasses may delay this and send it later. sendVoiceChoicesIfNeeded(); } public void sendVoiceChoicesIfNeeded() { void sendVoiceChoicesIfNeeded() { if (!isVoiceInteraction()) { // Clearly not needed. return; Loading Loading @@ -383,7 +382,7 @@ public class ResolverActivity extends Activity { return null; } public int getLayoutResource() { int getLayoutResource() { return R.layout.resolver_list; } Loading Loading @@ -592,7 +591,7 @@ public class ResolverActivity extends Activity { mAlwaysUseOption); } public void startSelected(int which, boolean always, boolean filtered) { void startSelected(int which, boolean always, boolean filtered) { if (isFinishing()) { return; } Loading Loading @@ -762,7 +761,7 @@ public class ResolverActivity extends Activity { return true; } public void safelyStartActivity(TargetInfo cti) { void safelyStartActivity(TargetInfo cti) { // If needed, show that intent is forwarded // from managed profile to owner or other way around. if (mProfileSwitchMessageId != -1) { Loading Loading @@ -792,26 +791,26 @@ public class ResolverActivity extends Activity { } } public void onActivityStarted(TargetInfo cti) { void onActivityStarted(TargetInfo cti) { // Do nothing } public boolean shouldGetActivityMetadata() { boolean shouldGetActivityMetadata() { return false; } public boolean shouldAutoLaunchSingleChoice(TargetInfo target) { boolean shouldAutoLaunchSingleChoice(TargetInfo target) { return true; } public void showTargetDetails(ResolveInfo ri) { void showAppDetails(ResolveInfo ri) { Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) .setData(Uri.fromParts("package", ri.activityInfo.packageName, null)) .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); startActivity(in); } public ResolveListAdapter createAdapter(Context context, List<Intent> payloadIntents, ResolveListAdapter createAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, int launchedFromUid, boolean filterLastUsed) { return new ResolveListAdapter(context, payloadIntents, initialIntents, rList, Loading @@ -821,7 +820,7 @@ public class ResolverActivity extends Activity { /** * Returns true if the activity is finishing and creation should halt */ public boolean configureContentView(List<Intent> payloadIntents, Intent[] initialIntents, boolean configureContentView(List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) { // The last argument of createAdapter is whether to do special handling // of the last used choice to highlight it in the list. We need to always Loading Loading @@ -868,7 +867,7 @@ public class ResolverActivity extends Activity { return false; } public void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, boolean alwaysUseOption) { final boolean useHeader = adapter.hasFilteredItem(); final ListView listView = adapterView instanceof ListView ? (ListView) adapterView : null; Loading Loading @@ -899,7 +898,7 @@ public class ResolverActivity extends Activity { && Objects.equals(lhs.activityInfo.packageName, rhs.activityInfo.packageName); } public final class DisplayResolveInfo implements TargetInfo { final class DisplayResolveInfo implements TargetInfo { private final ResolveInfo mResolveInfo; private final CharSequence mDisplayLabel; private Drawable mDisplayIcon; Loading @@ -907,9 +906,8 @@ public class ResolverActivity extends Activity { private final CharSequence mExtendedInfo; private final Intent mResolvedIntent; private final List<Intent> mSourceIntents = new ArrayList<>(); private boolean mPinned; public DisplayResolveInfo(Intent originalIntent, ResolveInfo pri, CharSequence pLabel, DisplayResolveInfo(Intent originalIntent, ResolveInfo pri, CharSequence pLabel, CharSequence pInfo, Intent pOrigIntent) { mSourceIntents.add(originalIntent); mResolveInfo = pri; Loading @@ -934,7 +932,6 @@ public class ResolverActivity extends Activity { mExtendedInfo = other.mExtendedInfo; mResolvedIntent = new Intent(other.mResolvedIntent); mResolvedIntent.fillIn(fillInIntent, flags); mPinned = other.mPinned; } public ResolveInfo getResolveInfo() { Loading Loading @@ -1029,15 +1026,6 @@ public class ResolverActivity extends Activity { activity.startActivityAsUser(mResolvedIntent, options, user); return false; } @Override public boolean isPinned() { return mPinned; } public void setPinned(boolean pinned) { mPinned = pinned; } } /** Loading @@ -1051,7 +1039,7 @@ public class ResolverActivity extends Activity { * * @return the resolved intent for this target */ Intent getResolvedIntent(); public Intent getResolvedIntent(); /** * Get the resolved component name that represents this target. Note that this may not Loading @@ -1060,7 +1048,7 @@ public class ResolverActivity extends Activity { * * @return the resolved ComponentName for this target */ ComponentName getResolvedComponentName(); public ComponentName getResolvedComponentName(); /** * Start the activity referenced by this target. Loading @@ -1069,7 +1057,7 @@ public class ResolverActivity extends Activity { * @param options ActivityOptions bundle * @return true if the start completed successfully */ boolean start(Activity activity, Bundle options); public boolean start(Activity activity, Bundle options); /** * Start the activity referenced by this target as if the ResolverActivity's caller Loading @@ -1080,7 +1068,7 @@ public class ResolverActivity extends Activity { * @param userId userId to start as or {@link UserHandle#USER_NULL} for activity's caller * @return true if the start completed successfully */ boolean startAsCaller(Activity activity, Bundle options, int userId); public boolean startAsCaller(Activity activity, Bundle options, int userId); /** * Start the activity referenced by this target as a given user. Loading @@ -1090,7 +1078,7 @@ public class ResolverActivity extends Activity { * @param user handle for the user to start the activity as * @return true if the start completed successfully */ boolean startAsUser(Activity activity, Bundle options, UserHandle user); public boolean startAsUser(Activity activity, Bundle options, UserHandle user); /** * Return the ResolveInfo about how and why this target matched the original query Loading @@ -1098,14 +1086,14 @@ public class ResolverActivity extends Activity { * * @return ResolveInfo representing this target's match */ ResolveInfo getResolveInfo(); public ResolveInfo getResolveInfo(); /** * Return the human-readable text label for this target. * * @return user-visible target label */ CharSequence getDisplayLabel(); public CharSequence getDisplayLabel(); /** * Return any extended info for this target. This may be used to disambiguate Loading @@ -1113,40 +1101,35 @@ public class ResolverActivity extends Activity { * * @return human-readable disambig string or null if none present */ CharSequence getExtendedInfo(); public CharSequence getExtendedInfo(); /** * @return The drawable that should be used to represent this target */ Drawable getDisplayIcon(); public Drawable getDisplayIcon(); /** * @return The (small) icon to badge the target with */ Drawable getBadgeIcon(); public Drawable getBadgeIcon(); /** * @return The content description for the badge icon */ CharSequence getBadgeContentDescription(); public CharSequence getBadgeContentDescription(); /** * Clone this target with the given fill-in information. */ TargetInfo cloneFilledIn(Intent fillInIntent, int flags); public TargetInfo cloneFilledIn(Intent fillInIntent, int flags); /** * @return the list of supported source intents deduped against this single target */ List<Intent> getAllSourceIntents(); /** * @return true if this target should be pinned to the front by the request of the user */ boolean isPinned(); public List<Intent> getAllSourceIntents(); } public class ResolveListAdapter extends BaseAdapter { class ResolveListAdapter extends BaseAdapter { private final List<Intent> mIntents; private final Intent[] mInitialIntents; private final List<ResolveInfo> mBaseResolveList; Loading Loading @@ -1393,12 +1376,9 @@ public class ResolverActivity extends Activity { } } if (!found) { final ComponentName name = new ComponentName( newInfo.activityInfo.packageName, newInfo.activityInfo.name); final ResolvedComponentInfo rci = new ResolvedComponentInfo(name, intent, newInfo); rci.setPinned(isComponentPinned(name)); into.add(rci); into.add(new ResolvedComponentInfo(new ComponentName( newInfo.activityInfo.packageName, newInfo.activityInfo.name), intent, newInfo)); } } } Loading Loading @@ -1474,8 +1454,6 @@ public class ResolverActivity extends Activity { final Intent replaceIntent = getReplacementIntent(add.activityInfo, intent); final DisplayResolveInfo dri = new DisplayResolveInfo(intent, add, roLabel, extraInfo, replaceIntent); final ComponentInfo ci = add.getComponentInfo(); dri.setPinned(rci.isPinned()); addResolveInfo(dri); if (replaceIntent == intent) { // Only add alternates if we didn't get a specific replacement from Loading Loading @@ -1559,11 +1537,11 @@ public class ResolverActivity extends Activity { return false; } public int getDisplayResolveInfoCount() { protected int getDisplayResolveInfoCount() { return mDisplayList.size(); } public DisplayResolveInfo getDisplayResolveInfo(int index) { protected DisplayResolveInfo getDisplayResolveInfo(int index) { // Used to query services. We only query services for primary targets, not alternates. return mDisplayList.get(index); } Loading Loading @@ -1593,10 +1571,6 @@ public class ResolverActivity extends Activity { return !TextUtils.isEmpty(info.getExtendedInfo()); } public boolean isComponentPinned(ComponentName name) { return false; } public final void bindView(int position, View view) { onBindView(view, getItem(position)); } Loading Loading @@ -1633,7 +1607,6 @@ public class ResolverActivity extends Activity { static final class ResolvedComponentInfo { public final ComponentName name; private boolean mPinned; private final List<Intent> mIntents = new ArrayList<>(); private final List<ResolveInfo> mResolveInfos = new ArrayList<>(); Loading Loading @@ -1676,14 +1649,6 @@ public class ResolverActivity extends Activity { } return -1; } public boolean isPinned() { return mPinned; } public void setPinned(boolean pinned) { mPinned = pinned; } } static class ViewHolder { Loading Loading @@ -1737,7 +1702,7 @@ public class ResolverActivity extends Activity { return false; } ResolveInfo ri = mAdapter.resolveInfoForPosition(position, true); showTargetDetails(ri); showAppDetails(ri); return true; } Loading core/java/com/android/internal/app/ResolverComparator.java +9 −21 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> { private static final boolean DEBUG = false; // Two weeks private static final long USAGE_STATS_PERIOD = 1000 * 60 * 60 * 24 * 7; private static final long USAGE_STATS_PERIOD = 1000 * 60 * 60 * 24 * 14; private static final long RECENCY_TIME_PERIOD = 1000 * 60 * 60 * 12; Loading Loading @@ -171,17 +171,6 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> { } } final boolean lPinned = lhsp.isPinned(); final boolean rPinned = rhsp.isPinned(); if (lPinned && !rPinned) { return -1; } else if (!lPinned && rPinned) { return 1; } // Pinned items stay stable within a normal lexical sort and ignore scoring. if (!lPinned && !rPinned) { if (mStats != null) { final ScoredTarget lhsTarget = mScoredTargets.get(new ComponentName( lhs.activityInfo.packageName, lhs.activityInfo.name)); Loading @@ -193,7 +182,6 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> { return diff > 0 ? 1 : -1; } } } CharSequence sa = lhs.loadLabel(mPm); if (sa == null) sa = lhs.activityInfo.name; Loading core/res/AndroidManifest.xml +13 −0 Original line number Diff line number Diff line Loading @@ -2887,6 +2887,19 @@ android:theme="@style/Theme.Material.DayNight.DarkActionBar" android:forceDeviceEncrypted="true" android:encryptionAware="true"> <activity android:name="com.android.internal.app.ChooserActivity" android:theme="@style/Theme.DeviceDefault.Resolver" android:finishOnCloseSystemDialogs="true" android:excludeFromRecents="true" android:documentLaunchMode="never" android:relinquishTaskIdentity="true" android:process=":ui"> <intent-filter> <action android:name="android.intent.action.CHOOSER" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> </activity> <activity android:name="com.android.internal.app.IntentForwarderActivity" android:finishOnCloseSystemDialogs="true" android:theme="@style/Theme.NoDisplay" Loading Loading
packages/SystemUI/src/com/android/systemui/chooser/ChooserActivity.java→core/java/com/android/internal/app/ChooserActivity.java +10 −55 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.systemui.chooser; package com.android.internal.app; import android.animation.ObjectAnimator; import android.annotation.NonNull; Loading @@ -25,7 +25,6 @@ import android.content.Intent; import android.content.IntentSender; import android.content.IntentSender.SendIntentException; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.LabeledIntent; import android.content.pm.PackageManager; Loading @@ -36,7 +35,6 @@ import android.graphics.Color; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.IBinder; import android.os.Message; Loading Loading @@ -67,12 +65,9 @@ import android.widget.AbsListView; import android.widget.BaseAdapter; import android.widget.ListView; import com.android.internal.R; import com.android.internal.app.IntentForwarderActivity; import com.android.internal.app.ResolverActivity; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsProto.MetricsEvent; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; Loading @@ -96,11 +91,6 @@ public class ChooserActivity extends ResolverActivity { private ChooserListAdapter mChooserListAdapter; private ChooserRowAdapter mChooserRowAdapter; private SharedPreferences mPinnedSharedPrefs; private static final float PINNED_TARGET_SCORE_BOOST = 1000.f; private static final String PINNED_SHARED_PREFS_NAME = "chooser_pin_settings"; private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment"; private final List<ChooserTargetServiceConnection> mServiceConnections = new ArrayList<>(); private static final int CHOOSER_TARGET_SERVICE_RESULT = 1; Loading Loading @@ -217,18 +207,12 @@ public class ChooserActivity extends ResolverActivity { mRefinementIntentSender = intent.getParcelableExtra( Intent.EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER); setSafeForwardingMode(true); mPinnedSharedPrefs = getPinnedSharedPrefs(this); super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents, null, false); MetricsLogger.action(this, MetricsEvent.ACTION_ACTIVITY_CHOOSER_SHOWN); } static SharedPreferences getPinnedSharedPrefs(Context context) { return context.getSharedPreferences(PINNED_SHARED_PREFS_NAME, MODE_PRIVATE); } @Override protected void onDestroy() { super.onDestroy(); Loading Loading @@ -259,7 +243,7 @@ public class ChooserActivity extends ResolverActivity { } @Override public void onActivityStarted(TargetInfo cti) { void onActivityStarted(TargetInfo cti) { if (mChosenComponentSender != null) { final ComponentName target = cti.getResolvedComponentName(); if (target != null) { Loading @@ -275,7 +259,7 @@ public class ChooserActivity extends ResolverActivity { } @Override public void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, boolean alwaysUseOption) { final ListView listView = adapterView instanceof ListView ? (ListView) adapterView : null; mChooserListAdapter = (ChooserListAdapter) adapter; Loading @@ -288,17 +272,17 @@ public class ChooserActivity extends ResolverActivity { } @Override public int getLayoutResource() { int getLayoutResource() { return R.layout.chooser_grid; } @Override public boolean shouldGetActivityMetadata() { boolean shouldGetActivityMetadata() { return true; } @Override public boolean shouldAutoLaunchSingleChoice(TargetInfo target) { boolean shouldAutoLaunchSingleChoice(TargetInfo target) { final Intent intent = target.getResolvedIntent(); final ResolveInfo resolve = target.getResolveInfo(); Loading @@ -315,16 +299,6 @@ public class ChooserActivity extends ResolverActivity { return false; } @Override public void showTargetDetails(ResolveInfo ri) { ComponentName name = ri.activityInfo.getComponentName(); boolean pinned = mPinnedSharedPrefs.getBoolean(name.flattenToString(), false); ResolverTargetActionsDialogFragment f = new ResolverTargetActionsDialogFragment(ri.loadLabel(getPackageManager()), name, pinned); f.show(getFragmentManager(), TARGET_DETAILS_FRAGMENT_TAG); } private void modifyTargetIntent(Intent in) { final String action = in.getAction(); if (Intent.ACTION_SEND.equals(action) || Loading Loading @@ -366,7 +340,7 @@ public class ChooserActivity extends ResolverActivity { } @Override public void startSelected(int which, boolean always, boolean filtered) { void startSelected(int which, boolean always, boolean filtered) { super.startSelected(which, always, filtered); if (mChooserListAdapter != null) { Loading Loading @@ -497,7 +471,7 @@ public class ChooserActivity extends ResolverActivity { mChooserHandler.removeMessages(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT); } public void onSetupVoiceInteraction() { void onSetupVoiceInteraction() { // Do nothing. We'll send the voice stuff ourselves. } Loading Loading @@ -569,7 +543,7 @@ public class ChooserActivity extends ResolverActivity { } @Override public ResolveListAdapter createAdapter(Context context, List<Intent> payloadIntents, ResolveListAdapter createAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, int launchedFromUid, boolean filterLastUsed) { final ChooserListAdapter adapter = new ChooserListAdapter(context, payloadIntents, Loading Loading @@ -737,11 +711,6 @@ public class ChooserActivity extends ResolverActivity { } return results; } @Override public boolean isPinned() { return mSourceInfo != null ? mSourceInfo.isPinned() : false; } } public class ChooserListAdapter extends ResolveListAdapter { Loading Loading @@ -807,20 +776,6 @@ public class ChooserActivity extends ResolverActivity { return false; } @Override public boolean isComponentPinned(ComponentName name) { return mPinnedSharedPrefs.getBoolean(name.flattenToString(), false); } @Override public float getScore(DisplayResolveInfo target) { float score = super.getScore(target); if (target.isPinned()) { score += PINNED_TARGET_SCORE_BOOST; } return score; } @Override public View onCreateView(ViewGroup parent) { return mInflater.inflate( Loading Loading @@ -1166,7 +1121,7 @@ public class ChooserActivity extends ResolverActivity { v.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { showTargetDetails( showAppDetails( mChooserListAdapter.resolveInfoForPosition( holder.itemIndices[column], true)); return true; Loading
core/java/com/android/internal/app/IntentForwarderActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public class IntentForwarderActivity extends Activity { final boolean shouldShowDisclosure = ri == null || ri.activityInfo == null || !"android".equals(ri.activityInfo.packageName) || !(ResolverActivity.class.getName().equals(ri.activityInfo.name) || "com.android.systemui.chooser.ChooserActivity".equals(ri.activityInfo.name)); || ChooserActivity.class.getName().equals(ri.activityInfo.name)); try { startActivityAsCaller(newIntent, null, false, targetUserId); Loading
core/java/com/android/internal/app/ResolverActivity.java +34 −69 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.app.ActivityThread; import android.app.VoiceInteractor.PickOptionRequest; import android.app.VoiceInteractor.PickOptionRequest.Option; import android.app.VoiceInteractor.Prompt; import android.content.pm.ComponentInfo; import android.os.AsyncTask; import android.provider.Settings; import android.text.TextUtils; Loading Loading @@ -337,12 +336,12 @@ public class ResolverActivity extends Activity { /** * Perform any initialization needed for voice interaction. */ public void onSetupVoiceInteraction() { void onSetupVoiceInteraction() { // Do it right now. Subclasses may delay this and send it later. sendVoiceChoicesIfNeeded(); } public void sendVoiceChoicesIfNeeded() { void sendVoiceChoicesIfNeeded() { if (!isVoiceInteraction()) { // Clearly not needed. return; Loading Loading @@ -383,7 +382,7 @@ public class ResolverActivity extends Activity { return null; } public int getLayoutResource() { int getLayoutResource() { return R.layout.resolver_list; } Loading Loading @@ -592,7 +591,7 @@ public class ResolverActivity extends Activity { mAlwaysUseOption); } public void startSelected(int which, boolean always, boolean filtered) { void startSelected(int which, boolean always, boolean filtered) { if (isFinishing()) { return; } Loading Loading @@ -762,7 +761,7 @@ public class ResolverActivity extends Activity { return true; } public void safelyStartActivity(TargetInfo cti) { void safelyStartActivity(TargetInfo cti) { // If needed, show that intent is forwarded // from managed profile to owner or other way around. if (mProfileSwitchMessageId != -1) { Loading Loading @@ -792,26 +791,26 @@ public class ResolverActivity extends Activity { } } public void onActivityStarted(TargetInfo cti) { void onActivityStarted(TargetInfo cti) { // Do nothing } public boolean shouldGetActivityMetadata() { boolean shouldGetActivityMetadata() { return false; } public boolean shouldAutoLaunchSingleChoice(TargetInfo target) { boolean shouldAutoLaunchSingleChoice(TargetInfo target) { return true; } public void showTargetDetails(ResolveInfo ri) { void showAppDetails(ResolveInfo ri) { Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) .setData(Uri.fromParts("package", ri.activityInfo.packageName, null)) .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); startActivity(in); } public ResolveListAdapter createAdapter(Context context, List<Intent> payloadIntents, ResolveListAdapter createAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, int launchedFromUid, boolean filterLastUsed) { return new ResolveListAdapter(context, payloadIntents, initialIntents, rList, Loading @@ -821,7 +820,7 @@ public class ResolverActivity extends Activity { /** * Returns true if the activity is finishing and creation should halt */ public boolean configureContentView(List<Intent> payloadIntents, Intent[] initialIntents, boolean configureContentView(List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) { // The last argument of createAdapter is whether to do special handling // of the last used choice to highlight it in the list. We need to always Loading Loading @@ -868,7 +867,7 @@ public class ResolverActivity extends Activity { return false; } public void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, boolean alwaysUseOption) { final boolean useHeader = adapter.hasFilteredItem(); final ListView listView = adapterView instanceof ListView ? (ListView) adapterView : null; Loading Loading @@ -899,7 +898,7 @@ public class ResolverActivity extends Activity { && Objects.equals(lhs.activityInfo.packageName, rhs.activityInfo.packageName); } public final class DisplayResolveInfo implements TargetInfo { final class DisplayResolveInfo implements TargetInfo { private final ResolveInfo mResolveInfo; private final CharSequence mDisplayLabel; private Drawable mDisplayIcon; Loading @@ -907,9 +906,8 @@ public class ResolverActivity extends Activity { private final CharSequence mExtendedInfo; private final Intent mResolvedIntent; private final List<Intent> mSourceIntents = new ArrayList<>(); private boolean mPinned; public DisplayResolveInfo(Intent originalIntent, ResolveInfo pri, CharSequence pLabel, DisplayResolveInfo(Intent originalIntent, ResolveInfo pri, CharSequence pLabel, CharSequence pInfo, Intent pOrigIntent) { mSourceIntents.add(originalIntent); mResolveInfo = pri; Loading @@ -934,7 +932,6 @@ public class ResolverActivity extends Activity { mExtendedInfo = other.mExtendedInfo; mResolvedIntent = new Intent(other.mResolvedIntent); mResolvedIntent.fillIn(fillInIntent, flags); mPinned = other.mPinned; } public ResolveInfo getResolveInfo() { Loading Loading @@ -1029,15 +1026,6 @@ public class ResolverActivity extends Activity { activity.startActivityAsUser(mResolvedIntent, options, user); return false; } @Override public boolean isPinned() { return mPinned; } public void setPinned(boolean pinned) { mPinned = pinned; } } /** Loading @@ -1051,7 +1039,7 @@ public class ResolverActivity extends Activity { * * @return the resolved intent for this target */ Intent getResolvedIntent(); public Intent getResolvedIntent(); /** * Get the resolved component name that represents this target. Note that this may not Loading @@ -1060,7 +1048,7 @@ public class ResolverActivity extends Activity { * * @return the resolved ComponentName for this target */ ComponentName getResolvedComponentName(); public ComponentName getResolvedComponentName(); /** * Start the activity referenced by this target. Loading @@ -1069,7 +1057,7 @@ public class ResolverActivity extends Activity { * @param options ActivityOptions bundle * @return true if the start completed successfully */ boolean start(Activity activity, Bundle options); public boolean start(Activity activity, Bundle options); /** * Start the activity referenced by this target as if the ResolverActivity's caller Loading @@ -1080,7 +1068,7 @@ public class ResolverActivity extends Activity { * @param userId userId to start as or {@link UserHandle#USER_NULL} for activity's caller * @return true if the start completed successfully */ boolean startAsCaller(Activity activity, Bundle options, int userId); public boolean startAsCaller(Activity activity, Bundle options, int userId); /** * Start the activity referenced by this target as a given user. Loading @@ -1090,7 +1078,7 @@ public class ResolverActivity extends Activity { * @param user handle for the user to start the activity as * @return true if the start completed successfully */ boolean startAsUser(Activity activity, Bundle options, UserHandle user); public boolean startAsUser(Activity activity, Bundle options, UserHandle user); /** * Return the ResolveInfo about how and why this target matched the original query Loading @@ -1098,14 +1086,14 @@ public class ResolverActivity extends Activity { * * @return ResolveInfo representing this target's match */ ResolveInfo getResolveInfo(); public ResolveInfo getResolveInfo(); /** * Return the human-readable text label for this target. * * @return user-visible target label */ CharSequence getDisplayLabel(); public CharSequence getDisplayLabel(); /** * Return any extended info for this target. This may be used to disambiguate Loading @@ -1113,40 +1101,35 @@ public class ResolverActivity extends Activity { * * @return human-readable disambig string or null if none present */ CharSequence getExtendedInfo(); public CharSequence getExtendedInfo(); /** * @return The drawable that should be used to represent this target */ Drawable getDisplayIcon(); public Drawable getDisplayIcon(); /** * @return The (small) icon to badge the target with */ Drawable getBadgeIcon(); public Drawable getBadgeIcon(); /** * @return The content description for the badge icon */ CharSequence getBadgeContentDescription(); public CharSequence getBadgeContentDescription(); /** * Clone this target with the given fill-in information. */ TargetInfo cloneFilledIn(Intent fillInIntent, int flags); public TargetInfo cloneFilledIn(Intent fillInIntent, int flags); /** * @return the list of supported source intents deduped against this single target */ List<Intent> getAllSourceIntents(); /** * @return true if this target should be pinned to the front by the request of the user */ boolean isPinned(); public List<Intent> getAllSourceIntents(); } public class ResolveListAdapter extends BaseAdapter { class ResolveListAdapter extends BaseAdapter { private final List<Intent> mIntents; private final Intent[] mInitialIntents; private final List<ResolveInfo> mBaseResolveList; Loading Loading @@ -1393,12 +1376,9 @@ public class ResolverActivity extends Activity { } } if (!found) { final ComponentName name = new ComponentName( newInfo.activityInfo.packageName, newInfo.activityInfo.name); final ResolvedComponentInfo rci = new ResolvedComponentInfo(name, intent, newInfo); rci.setPinned(isComponentPinned(name)); into.add(rci); into.add(new ResolvedComponentInfo(new ComponentName( newInfo.activityInfo.packageName, newInfo.activityInfo.name), intent, newInfo)); } } } Loading Loading @@ -1474,8 +1454,6 @@ public class ResolverActivity extends Activity { final Intent replaceIntent = getReplacementIntent(add.activityInfo, intent); final DisplayResolveInfo dri = new DisplayResolveInfo(intent, add, roLabel, extraInfo, replaceIntent); final ComponentInfo ci = add.getComponentInfo(); dri.setPinned(rci.isPinned()); addResolveInfo(dri); if (replaceIntent == intent) { // Only add alternates if we didn't get a specific replacement from Loading Loading @@ -1559,11 +1537,11 @@ public class ResolverActivity extends Activity { return false; } public int getDisplayResolveInfoCount() { protected int getDisplayResolveInfoCount() { return mDisplayList.size(); } public DisplayResolveInfo getDisplayResolveInfo(int index) { protected DisplayResolveInfo getDisplayResolveInfo(int index) { // Used to query services. We only query services for primary targets, not alternates. return mDisplayList.get(index); } Loading Loading @@ -1593,10 +1571,6 @@ public class ResolverActivity extends Activity { return !TextUtils.isEmpty(info.getExtendedInfo()); } public boolean isComponentPinned(ComponentName name) { return false; } public final void bindView(int position, View view) { onBindView(view, getItem(position)); } Loading Loading @@ -1633,7 +1607,6 @@ public class ResolverActivity extends Activity { static final class ResolvedComponentInfo { public final ComponentName name; private boolean mPinned; private final List<Intent> mIntents = new ArrayList<>(); private final List<ResolveInfo> mResolveInfos = new ArrayList<>(); Loading Loading @@ -1676,14 +1649,6 @@ public class ResolverActivity extends Activity { } return -1; } public boolean isPinned() { return mPinned; } public void setPinned(boolean pinned) { mPinned = pinned; } } static class ViewHolder { Loading Loading @@ -1737,7 +1702,7 @@ public class ResolverActivity extends Activity { return false; } ResolveInfo ri = mAdapter.resolveInfoForPosition(position, true); showTargetDetails(ri); showAppDetails(ri); return true; } Loading
core/java/com/android/internal/app/ResolverComparator.java +9 −21 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> { private static final boolean DEBUG = false; // Two weeks private static final long USAGE_STATS_PERIOD = 1000 * 60 * 60 * 24 * 7; private static final long USAGE_STATS_PERIOD = 1000 * 60 * 60 * 24 * 14; private static final long RECENCY_TIME_PERIOD = 1000 * 60 * 60 * 12; Loading Loading @@ -171,17 +171,6 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> { } } final boolean lPinned = lhsp.isPinned(); final boolean rPinned = rhsp.isPinned(); if (lPinned && !rPinned) { return -1; } else if (!lPinned && rPinned) { return 1; } // Pinned items stay stable within a normal lexical sort and ignore scoring. if (!lPinned && !rPinned) { if (mStats != null) { final ScoredTarget lhsTarget = mScoredTargets.get(new ComponentName( lhs.activityInfo.packageName, lhs.activityInfo.name)); Loading @@ -193,7 +182,6 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> { return diff > 0 ? 1 : -1; } } } CharSequence sa = lhs.loadLabel(mPm); if (sa == null) sa = lhs.activityInfo.name; Loading
core/res/AndroidManifest.xml +13 −0 Original line number Diff line number Diff line Loading @@ -2887,6 +2887,19 @@ android:theme="@style/Theme.Material.DayNight.DarkActionBar" android:forceDeviceEncrypted="true" android:encryptionAware="true"> <activity android:name="com.android.internal.app.ChooserActivity" android:theme="@style/Theme.DeviceDefault.Resolver" android:finishOnCloseSystemDialogs="true" android:excludeFromRecents="true" android:documentLaunchMode="never" android:relinquishTaskIdentity="true" android:process=":ui"> <intent-filter> <action android:name="android.intent.action.CHOOSER" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> </activity> <activity android:name="com.android.internal.app.IntentForwarderActivity" android:finishOnCloseSystemDialogs="true" android:theme="@style/Theme.NoDisplay" Loading