Loading core/java/com/android/internal/app/ResolverActivity.java +25 −8 Original line number Diff line number Diff line Loading @@ -1278,10 +1278,9 @@ public class ResolverActivity extends Activity implements throw new IllegalStateException("mMultiProfilePagerAdapter.getCurrentListAdapter() " + "cannot be null."); } boolean rebuildCompleted = mMultiProfilePagerAdapter.rebuildActiveTab(true); // We partially rebuild the inactive adapter to determine if we should auto launch mMultiProfilePagerAdapter.rebuildInactiveTab(false); boolean rebuildActiveCompleted = mMultiProfilePagerAdapter.rebuildActiveTab(true); boolean rebuildInactiveCompleted = mMultiProfilePagerAdapter.rebuildInactiveTab(false); if (useLayoutWithDefault()) { mLayoutId = R.layout.resolver_list_with_default; Loading @@ -1290,7 +1289,7 @@ public class ResolverActivity extends Activity implements } setContentView(mLayoutId); mMultiProfilePagerAdapter.setupViewPager(findViewById(R.id.profile_pager)); return postRebuildList(rebuildCompleted); return postRebuildList(rebuildActiveCompleted && rebuildInactiveCompleted); } /** Loading Loading @@ -1338,10 +1337,11 @@ public class ResolverActivity extends Activity implements int numberOfProfiles = mMultiProfilePagerAdapter.getItemCount(); if (numberOfProfiles == 1 && maybeAutolaunchIfSingleTarget()) { return true; } else if (numberOfProfiles == 2 && maybeAutolaunchIfCrossProfileSupported()) { // note that autolaunching when we have 2 profiles, 1 resolved target on the active // tab and 0 resolved targets on the inactive tab, is already handled before launching // ResolverActivity } else if (numberOfProfiles == 2 && mMultiProfilePagerAdapter.getActiveListAdapter().isListLoaded() && mMultiProfilePagerAdapter.getInactiveListAdapter().isListLoaded() && (maybeAutolaunchIfNoAppsOnInactiveTab() || maybeAutolaunchIfCrossProfileSupported())) { return true; } return false; Loading @@ -1364,6 +1364,23 @@ public class ResolverActivity extends Activity implements return false; } private boolean maybeAutolaunchIfNoAppsOnInactiveTab() { int count = mMultiProfilePagerAdapter.getActiveListAdapter().getUnfilteredCount(); if (count != 1) { return false; } ResolverListAdapter inactiveListAdapter = mMultiProfilePagerAdapter.getInactiveListAdapter(); if (inactiveListAdapter.getUnfilteredCount() != 0) { return false; } TargetInfo target = mMultiProfilePagerAdapter.getActiveListAdapter() .targetInfoForPosition(0, false); safelyStartActivity(target); finish(); return true; } /** * When we have a personal and a work profile, we auto launch in the following scenario: * - There is 1 resolved target on each profile Loading core/java/com/android/internal/app/ResolverListAdapter.java +7 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class ResolverListAdapter extends BaseAdapter { private final ResolverListCommunicator mResolverListCommunicator; private Runnable mPostListReadyRunnable; private final boolean mIsAudioCaptureDevice; private boolean mIsListLoaded; public ResolverListAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, Loading Loading @@ -191,6 +192,7 @@ public class ResolverListAdapter extends BaseAdapter { mLastChosenPosition = -1; mAllTargetsAreBrowsers = false; mDisplayList.clear(); mIsListLoaded = false; if (mBaseResolveList != null) { currentResolveList = mUnfilteredResolveList = new ArrayList<>(); Loading Loading @@ -352,6 +354,7 @@ public class ResolverListAdapter extends BaseAdapter { mResolverListCommunicator.sendVoiceChoicesIfNeeded(); postListReadyRunnable(doPostProcessing); mIsListLoaded = true; } /** Loading Loading @@ -611,6 +614,10 @@ public class ResolverListAdapter extends BaseAdapter { return mIntents; } protected boolean isListLoaded() { return mIsListLoaded; } /** * Necessary methods to communicate between {@link ResolverListAdapter} * and {@link ResolverActivity}. Loading Loading
core/java/com/android/internal/app/ResolverActivity.java +25 −8 Original line number Diff line number Diff line Loading @@ -1278,10 +1278,9 @@ public class ResolverActivity extends Activity implements throw new IllegalStateException("mMultiProfilePagerAdapter.getCurrentListAdapter() " + "cannot be null."); } boolean rebuildCompleted = mMultiProfilePagerAdapter.rebuildActiveTab(true); // We partially rebuild the inactive adapter to determine if we should auto launch mMultiProfilePagerAdapter.rebuildInactiveTab(false); boolean rebuildActiveCompleted = mMultiProfilePagerAdapter.rebuildActiveTab(true); boolean rebuildInactiveCompleted = mMultiProfilePagerAdapter.rebuildInactiveTab(false); if (useLayoutWithDefault()) { mLayoutId = R.layout.resolver_list_with_default; Loading @@ -1290,7 +1289,7 @@ public class ResolverActivity extends Activity implements } setContentView(mLayoutId); mMultiProfilePagerAdapter.setupViewPager(findViewById(R.id.profile_pager)); return postRebuildList(rebuildCompleted); return postRebuildList(rebuildActiveCompleted && rebuildInactiveCompleted); } /** Loading Loading @@ -1338,10 +1337,11 @@ public class ResolverActivity extends Activity implements int numberOfProfiles = mMultiProfilePagerAdapter.getItemCount(); if (numberOfProfiles == 1 && maybeAutolaunchIfSingleTarget()) { return true; } else if (numberOfProfiles == 2 && maybeAutolaunchIfCrossProfileSupported()) { // note that autolaunching when we have 2 profiles, 1 resolved target on the active // tab and 0 resolved targets on the inactive tab, is already handled before launching // ResolverActivity } else if (numberOfProfiles == 2 && mMultiProfilePagerAdapter.getActiveListAdapter().isListLoaded() && mMultiProfilePagerAdapter.getInactiveListAdapter().isListLoaded() && (maybeAutolaunchIfNoAppsOnInactiveTab() || maybeAutolaunchIfCrossProfileSupported())) { return true; } return false; Loading @@ -1364,6 +1364,23 @@ public class ResolverActivity extends Activity implements return false; } private boolean maybeAutolaunchIfNoAppsOnInactiveTab() { int count = mMultiProfilePagerAdapter.getActiveListAdapter().getUnfilteredCount(); if (count != 1) { return false; } ResolverListAdapter inactiveListAdapter = mMultiProfilePagerAdapter.getInactiveListAdapter(); if (inactiveListAdapter.getUnfilteredCount() != 0) { return false; } TargetInfo target = mMultiProfilePagerAdapter.getActiveListAdapter() .targetInfoForPosition(0, false); safelyStartActivity(target); finish(); return true; } /** * When we have a personal and a work profile, we auto launch in the following scenario: * - There is 1 resolved target on each profile Loading
core/java/com/android/internal/app/ResolverListAdapter.java +7 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class ResolverListAdapter extends BaseAdapter { private final ResolverListCommunicator mResolverListCommunicator; private Runnable mPostListReadyRunnable; private final boolean mIsAudioCaptureDevice; private boolean mIsListLoaded; public ResolverListAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, Loading Loading @@ -191,6 +192,7 @@ public class ResolverListAdapter extends BaseAdapter { mLastChosenPosition = -1; mAllTargetsAreBrowsers = false; mDisplayList.clear(); mIsListLoaded = false; if (mBaseResolveList != null) { currentResolveList = mUnfilteredResolveList = new ArrayList<>(); Loading Loading @@ -352,6 +354,7 @@ public class ResolverListAdapter extends BaseAdapter { mResolverListCommunicator.sendVoiceChoicesIfNeeded(); postListReadyRunnable(doPostProcessing); mIsListLoaded = true; } /** Loading Loading @@ -611,6 +614,10 @@ public class ResolverListAdapter extends BaseAdapter { return mIntents; } protected boolean isListLoaded() { return mIsListLoaded; } /** * Necessary methods to communicate between {@link ResolverListAdapter} * and {@link ResolverActivity}. Loading