Loading src/com/android/settings/applications/ManageApplications.java +25 −5 Original line number Diff line number Diff line Loading @@ -329,7 +329,8 @@ public class ManageApplications extends InstrumentedPreferenceFragment mApplications.setExtraViewController(new MusicViewHolderController( context, new StorageStatsSource(context), mVolumeUuid)); mVolumeUuid, UserHandle.of(UserHandle.getUserId(mCurrentUid)))); } mListView.setAdapter(mApplications); mListView.setRecyclerListener(mApplications); Loading Loading @@ -870,6 +871,12 @@ public class ManageApplications extends InstrumentedPreferenceFragment public void setExtraViewController(FileViewHolderController extraViewController) { mExtraViewController = extraViewController; mBgHandler.post(() -> { mExtraViewController.queryStats(); mFgHandler.post(() -> { onExtraViewCompleted(); }); }); } public void resume(int sort) { Loading Loading @@ -957,10 +964,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment break; } if (mExtraViewController != null) { mExtraViewController.queryStats(); } filterObj = new CompoundFilter(filterObj, ApplicationsState.FILTER_NOT_HIDE); AppFilter finalFilterObj = filterObj; mBgHandler.post(() -> { Loading Loading @@ -1178,6 +1181,23 @@ public class ManageApplications extends InstrumentedPreferenceFragment } } public void onExtraViewCompleted() { int size = mActive.size(); // If we have no elements, don't do anything. if (size < 1) { return; } AppViewHolder holder = (AppViewHolder) mActive.get(size - 1).getTag(); // HACK: The extra view has no AppEntry -- and should be the only element without one. // Thus, if the last active element has no AppEntry, it is the extra view. if (holder == null || holder.entry != null) { return; } mExtraViewController.setupView(holder); } public int getCount() { if (mEntries == null) { return 0; Loading src/com/android/settings/applications/MusicViewHolderController.java +5 −3 Original line number Diff line number Diff line Loading @@ -38,18 +38,20 @@ public class MusicViewHolderController implements FileViewHolderController { private StorageStatsSource mSource; private String mVolumeUuid; private long mMusicSize; private UserHandle mUser; public MusicViewHolderController( Context context, StorageStatsSource source, String volumeUuid) { Context context, StorageStatsSource source, String volumeUuid, UserHandle user) { mContext = context; mSource = source; mVolumeUuid = volumeUuid; mUser = user; } @Override @WorkerThread public void queryStats() { mMusicSize = mSource.getExternalStorageStats(mVolumeUuid, UserHandle.CURRENT).audioBytes; mMusicSize = mSource.getExternalStorageStats(mVolumeUuid, mUser).audioBytes; } @Override Loading @@ -69,7 +71,7 @@ public class MusicViewHolderController implements FileViewHolderController { Intent intent = new Intent(DocumentsContract.ACTION_BROWSE); intent.setData(DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "audio_root")); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(Intent.EXTRA_USER_ID, UserHandle.CURRENT); intent.putExtra(Intent.EXTRA_USER_ID, mUser); Utils.launchIntent(fragment, intent); } } tests/robotests/src/com/android/settings/applications/MusicViewHolderControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,8 @@ public class MusicViewHolderControllerTest { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; mVolume = new VolumeInfo("id", 0, null, "id"); mController = new MusicViewHolderController(mContext, mSource, mVolume.fsUuid); mController = new MusicViewHolderController(mContext, mSource, mVolume.fsUuid, new UserHandle(0)); LayoutInflater inflater = LayoutInflater.from(mContext); mHolder = AppViewHolder.createOrRecycle(inflater, null); Loading Loading
src/com/android/settings/applications/ManageApplications.java +25 −5 Original line number Diff line number Diff line Loading @@ -329,7 +329,8 @@ public class ManageApplications extends InstrumentedPreferenceFragment mApplications.setExtraViewController(new MusicViewHolderController( context, new StorageStatsSource(context), mVolumeUuid)); mVolumeUuid, UserHandle.of(UserHandle.getUserId(mCurrentUid)))); } mListView.setAdapter(mApplications); mListView.setRecyclerListener(mApplications); Loading Loading @@ -870,6 +871,12 @@ public class ManageApplications extends InstrumentedPreferenceFragment public void setExtraViewController(FileViewHolderController extraViewController) { mExtraViewController = extraViewController; mBgHandler.post(() -> { mExtraViewController.queryStats(); mFgHandler.post(() -> { onExtraViewCompleted(); }); }); } public void resume(int sort) { Loading Loading @@ -957,10 +964,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment break; } if (mExtraViewController != null) { mExtraViewController.queryStats(); } filterObj = new CompoundFilter(filterObj, ApplicationsState.FILTER_NOT_HIDE); AppFilter finalFilterObj = filterObj; mBgHandler.post(() -> { Loading Loading @@ -1178,6 +1181,23 @@ public class ManageApplications extends InstrumentedPreferenceFragment } } public void onExtraViewCompleted() { int size = mActive.size(); // If we have no elements, don't do anything. if (size < 1) { return; } AppViewHolder holder = (AppViewHolder) mActive.get(size - 1).getTag(); // HACK: The extra view has no AppEntry -- and should be the only element without one. // Thus, if the last active element has no AppEntry, it is the extra view. if (holder == null || holder.entry != null) { return; } mExtraViewController.setupView(holder); } public int getCount() { if (mEntries == null) { return 0; Loading
src/com/android/settings/applications/MusicViewHolderController.java +5 −3 Original line number Diff line number Diff line Loading @@ -38,18 +38,20 @@ public class MusicViewHolderController implements FileViewHolderController { private StorageStatsSource mSource; private String mVolumeUuid; private long mMusicSize; private UserHandle mUser; public MusicViewHolderController( Context context, StorageStatsSource source, String volumeUuid) { Context context, StorageStatsSource source, String volumeUuid, UserHandle user) { mContext = context; mSource = source; mVolumeUuid = volumeUuid; mUser = user; } @Override @WorkerThread public void queryStats() { mMusicSize = mSource.getExternalStorageStats(mVolumeUuid, UserHandle.CURRENT).audioBytes; mMusicSize = mSource.getExternalStorageStats(mVolumeUuid, mUser).audioBytes; } @Override Loading @@ -69,7 +71,7 @@ public class MusicViewHolderController implements FileViewHolderController { Intent intent = new Intent(DocumentsContract.ACTION_BROWSE); intent.setData(DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "audio_root")); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(Intent.EXTRA_USER_ID, UserHandle.CURRENT); intent.putExtra(Intent.EXTRA_USER_ID, mUser); Utils.launchIntent(fragment, intent); } }
tests/robotests/src/com/android/settings/applications/MusicViewHolderControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,8 @@ public class MusicViewHolderControllerTest { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; mVolume = new VolumeInfo("id", 0, null, "id"); mController = new MusicViewHolderController(mContext, mSource, mVolume.fsUuid); mController = new MusicViewHolderController(mContext, mSource, mVolume.fsUuid, new UserHandle(0)); LayoutInflater inflater = LayoutInflater.from(mContext); mHolder = AppViewHolder.createOrRecycle(inflater, null); Loading