Loading core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java +21 −3 Original line number Diff line number Diff line Loading @@ -156,14 +156,32 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { @VisibleForTesting public abstract Object getAdapterForIndex(int pageIndex); /** * Returns the {@link ResolverListAdapter} instance of the profile that represents * <code>userHandle</code>. If there is no such adapter for the specified * <code>userHandle</code>, returns {@code null}. * <p>For example, if there is a work profile on the device with user id 10, calling this method * with <code>UserHandle.of(10)</code> returns the work profile {@link ResolverListAdapter}. */ @Nullable abstract ResolverListAdapter getListAdapterForUserHandle(UserHandle userHandle); /** * Returns the {@link ResolverListAdapter} instance of the profile that is currently visible * to the user. * <p>For example, if the user is viewing the work tab in the share sheet, this method returns * the work profile {@link ResolverListAdapter}. * @see #getInactiveListAdapter() */ @VisibleForTesting public abstract ResolverListAdapter getActiveListAdapter(); /** * If this is a device with a work profile, returns the {@link ResolverListAdapter} instance * of the profile that is not the active one. Otherwise returns {@code null}. For example, * if the share sheet is launched in the work profile, this method returns the personal * profile {@link ResolverListAdapter}. * of the profile that is <b><i>not</i></b> currently visible to the user. Otherwise returns * {@code null}. * <p>For example, if the user is viewing the work tab in the share sheet, this method returns * the personal profile {@link ResolverListAdapter}. * @see #getActiveListAdapter() */ @VisibleForTesting Loading core/java/com/android/internal/app/ChooserActivity.java +174 −102 File changed.Preview size limit exceeded, changes collapsed. Show changes core/java/com/android/internal/app/ChooserListAdapter.java +34 −5 Original line number Diff line number Diff line Loading @@ -19,7 +19,9 @@ package com.android.internal.app; import static com.android.internal.app.ChooserActivity.TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE; import static com.android.internal.app.ChooserActivity.TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.prediction.AppPredictor; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading @@ -27,7 +29,9 @@ import android.content.pm.ActivityInfo; import android.content.pm.LabeledIntent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; import android.os.AsyncTask; import android.os.UserHandle; import android.os.UserManager; import android.service.chooser.ChooserTarget; import android.util.Log; Loading Loading @@ -90,6 +94,8 @@ public class ChooserListAdapter extends ResolverListAdapter { // Sorted list of DisplayResolveInfos for the alphabetical app section. private List<DisplayResolveInfo> mSortedList = new ArrayList<>(); private AppPredictor mAppPredictor; private AppPredictor.Callback mAppPredictorCallback; public ChooserListAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, Loading Loading @@ -160,6 +166,10 @@ public class ChooserListAdapter extends ResolverListAdapter { } } AppPredictor getAppPredictor() { return mAppPredictor; } @Override public void handlePackagesChanged() { if (DEBUG) { Loading @@ -173,7 +183,7 @@ public class ChooserListAdapter extends ResolverListAdapter { @Override public void notifyDataSetChanged() { if (!mListViewDataChanged) { mChooserListCommunicator.sendListViewUpdateMessage(); mChooserListCommunicator.sendListViewUpdateMessage(getUserHandle()); mListViewDataChanged = true; } } Loading Loading @@ -383,7 +393,8 @@ public class ChooserListAdapter extends ResolverListAdapter { * if score is too low. */ public void addServiceResults(DisplayResolveInfo origTarget, List<ChooserTarget> targets, @ChooserActivity.ShareTargetType int targetType) { @ChooserActivity.ShareTargetType int targetType, Map<ChooserTarget, ShortcutInfo> directShareToShortcutInfos) { if (DEBUG) { Log.d(TAG, "addServiceResults " + origTarget + ", " + targets.size() + " targets"); Loading Loading @@ -412,8 +423,11 @@ public class ChooserListAdapter extends ResolverListAdapter { // This incents ChooserTargetServices to define what's truly better. targetScore = lastScore * 0.95f; } boolean isInserted = insertServiceTarget(new SelectableTargetInfo( mContext, origTarget, target, targetScore, mSelectableTargetInfoComunicator)); UserHandle userHandle = getUserHandle(); Context contextAsUser = mContext.createContextAsUser(userHandle, 0 /* flags */); boolean isInserted = insertServiceTarget(new SelectableTargetInfo(contextAsUser, origTarget, target, targetScore, mSelectableTargetInfoComunicator, (isShortcutResult ? directShareToShortcutInfos.get(target) : null))); if (isInserted && isShortcutResult) { mNumShortcutResults++; Loading Loading @@ -547,6 +561,21 @@ public class ChooserListAdapter extends ResolverListAdapter { }; } public void setAppPredictor(AppPredictor appPredictor) { mAppPredictor = appPredictor; } public void setAppPredictorCallback(AppPredictor.Callback appPredictorCallback) { mAppPredictorCallback = appPredictorCallback; } public void destroyAppPredictor() { if (getAppPredictor() != null) { getAppPredictor().unregisterPredictionUpdates(mAppPredictorCallback); getAppPredictor().destroy(); } } /** * Necessary methods to communicate between {@link ChooserListAdapter} * and {@link ChooserActivity}. Loading @@ -555,7 +584,7 @@ public class ChooserListAdapter extends ResolverListAdapter { int getMaxRankedTargets(); void sendListViewUpdateMessage(); void sendListViewUpdateMessage(UserHandle userHandle); boolean isSendAction(Intent targetIntent); } Loading core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java +13 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.app; import android.annotation.Nullable; import android.content.Context; import android.os.UserHandle; import android.view.LayoutInflater; import android.view.ViewGroup; Loading Loading @@ -83,6 +84,18 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd return mItems[pageIndex].chooserGridAdapter; } @Override @Nullable ChooserListAdapter getListAdapterForUserHandle(UserHandle userHandle) { if (getActiveListAdapter().getUserHandle() == userHandle) { return getActiveListAdapter(); } else if (getInactiveListAdapter() != null && getInactiveListAdapter().getUserHandle() == userHandle) { return getInactiveListAdapter(); } return null; } @Override void setupListAdapter(int pageIndex) { final RecyclerView recyclerView = getItem(pageIndex).recyclerView; Loading core/java/com/android/internal/app/ResolverActivity.java +3 −0 Original line number Diff line number Diff line Loading @@ -543,6 +543,9 @@ public class ResolverActivity extends Activity implements public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mMultiProfilePagerAdapter.getActiveListAdapter().handlePackagesChanged(); if (mMultiProfilePagerAdapter.getInactiveListAdapter() != null) { mMultiProfilePagerAdapter.getInactiveListAdapter().handlePackagesChanged(); } if (mSystemWindowInsets != null) { mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top, Loading Loading
core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java +21 −3 Original line number Diff line number Diff line Loading @@ -156,14 +156,32 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { @VisibleForTesting public abstract Object getAdapterForIndex(int pageIndex); /** * Returns the {@link ResolverListAdapter} instance of the profile that represents * <code>userHandle</code>. If there is no such adapter for the specified * <code>userHandle</code>, returns {@code null}. * <p>For example, if there is a work profile on the device with user id 10, calling this method * with <code>UserHandle.of(10)</code> returns the work profile {@link ResolverListAdapter}. */ @Nullable abstract ResolverListAdapter getListAdapterForUserHandle(UserHandle userHandle); /** * Returns the {@link ResolverListAdapter} instance of the profile that is currently visible * to the user. * <p>For example, if the user is viewing the work tab in the share sheet, this method returns * the work profile {@link ResolverListAdapter}. * @see #getInactiveListAdapter() */ @VisibleForTesting public abstract ResolverListAdapter getActiveListAdapter(); /** * If this is a device with a work profile, returns the {@link ResolverListAdapter} instance * of the profile that is not the active one. Otherwise returns {@code null}. For example, * if the share sheet is launched in the work profile, this method returns the personal * profile {@link ResolverListAdapter}. * of the profile that is <b><i>not</i></b> currently visible to the user. Otherwise returns * {@code null}. * <p>For example, if the user is viewing the work tab in the share sheet, this method returns * the personal profile {@link ResolverListAdapter}. * @see #getActiveListAdapter() */ @VisibleForTesting Loading
core/java/com/android/internal/app/ChooserActivity.java +174 −102 File changed.Preview size limit exceeded, changes collapsed. Show changes
core/java/com/android/internal/app/ChooserListAdapter.java +34 −5 Original line number Diff line number Diff line Loading @@ -19,7 +19,9 @@ package com.android.internal.app; import static com.android.internal.app.ChooserActivity.TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE; import static com.android.internal.app.ChooserActivity.TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.prediction.AppPredictor; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading @@ -27,7 +29,9 @@ import android.content.pm.ActivityInfo; import android.content.pm.LabeledIntent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; import android.os.AsyncTask; import android.os.UserHandle; import android.os.UserManager; import android.service.chooser.ChooserTarget; import android.util.Log; Loading Loading @@ -90,6 +94,8 @@ public class ChooserListAdapter extends ResolverListAdapter { // Sorted list of DisplayResolveInfos for the alphabetical app section. private List<DisplayResolveInfo> mSortedList = new ArrayList<>(); private AppPredictor mAppPredictor; private AppPredictor.Callback mAppPredictorCallback; public ChooserListAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, Loading Loading @@ -160,6 +166,10 @@ public class ChooserListAdapter extends ResolverListAdapter { } } AppPredictor getAppPredictor() { return mAppPredictor; } @Override public void handlePackagesChanged() { if (DEBUG) { Loading @@ -173,7 +183,7 @@ public class ChooserListAdapter extends ResolverListAdapter { @Override public void notifyDataSetChanged() { if (!mListViewDataChanged) { mChooserListCommunicator.sendListViewUpdateMessage(); mChooserListCommunicator.sendListViewUpdateMessage(getUserHandle()); mListViewDataChanged = true; } } Loading Loading @@ -383,7 +393,8 @@ public class ChooserListAdapter extends ResolverListAdapter { * if score is too low. */ public void addServiceResults(DisplayResolveInfo origTarget, List<ChooserTarget> targets, @ChooserActivity.ShareTargetType int targetType) { @ChooserActivity.ShareTargetType int targetType, Map<ChooserTarget, ShortcutInfo> directShareToShortcutInfos) { if (DEBUG) { Log.d(TAG, "addServiceResults " + origTarget + ", " + targets.size() + " targets"); Loading Loading @@ -412,8 +423,11 @@ public class ChooserListAdapter extends ResolverListAdapter { // This incents ChooserTargetServices to define what's truly better. targetScore = lastScore * 0.95f; } boolean isInserted = insertServiceTarget(new SelectableTargetInfo( mContext, origTarget, target, targetScore, mSelectableTargetInfoComunicator)); UserHandle userHandle = getUserHandle(); Context contextAsUser = mContext.createContextAsUser(userHandle, 0 /* flags */); boolean isInserted = insertServiceTarget(new SelectableTargetInfo(contextAsUser, origTarget, target, targetScore, mSelectableTargetInfoComunicator, (isShortcutResult ? directShareToShortcutInfos.get(target) : null))); if (isInserted && isShortcutResult) { mNumShortcutResults++; Loading Loading @@ -547,6 +561,21 @@ public class ChooserListAdapter extends ResolverListAdapter { }; } public void setAppPredictor(AppPredictor appPredictor) { mAppPredictor = appPredictor; } public void setAppPredictorCallback(AppPredictor.Callback appPredictorCallback) { mAppPredictorCallback = appPredictorCallback; } public void destroyAppPredictor() { if (getAppPredictor() != null) { getAppPredictor().unregisterPredictionUpdates(mAppPredictorCallback); getAppPredictor().destroy(); } } /** * Necessary methods to communicate between {@link ChooserListAdapter} * and {@link ChooserActivity}. Loading @@ -555,7 +584,7 @@ public class ChooserListAdapter extends ResolverListAdapter { int getMaxRankedTargets(); void sendListViewUpdateMessage(); void sendListViewUpdateMessage(UserHandle userHandle); boolean isSendAction(Intent targetIntent); } Loading
core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java +13 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.app; import android.annotation.Nullable; import android.content.Context; import android.os.UserHandle; import android.view.LayoutInflater; import android.view.ViewGroup; Loading Loading @@ -83,6 +84,18 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd return mItems[pageIndex].chooserGridAdapter; } @Override @Nullable ChooserListAdapter getListAdapterForUserHandle(UserHandle userHandle) { if (getActiveListAdapter().getUserHandle() == userHandle) { return getActiveListAdapter(); } else if (getInactiveListAdapter() != null && getInactiveListAdapter().getUserHandle() == userHandle) { return getInactiveListAdapter(); } return null; } @Override void setupListAdapter(int pageIndex) { final RecyclerView recyclerView = getItem(pageIndex).recyclerView; Loading
core/java/com/android/internal/app/ResolverActivity.java +3 −0 Original line number Diff line number Diff line Loading @@ -543,6 +543,9 @@ public class ResolverActivity extends Activity implements public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mMultiProfilePagerAdapter.getActiveListAdapter().handlePackagesChanged(); if (mMultiProfilePagerAdapter.getInactiveListAdapter() != null) { mMultiProfilePagerAdapter.getInactiveListAdapter().handlePackagesChanged(); } if (mSystemWindowInsets != null) { mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top, Loading