Fix no action in Settings storage

- Pass wrong user id in view holder

Fixes: 149028747
Test: 1. Add new user, and change th new user
      2. Take a camera shot under the new user
      3. go to Settings -> Storage -> photo & video -> Image
      4. Should open file brower

Change-Id: I0af532748ec19f62897911b1bb6ece9b21b844c3
This commit is contained in:
Raff Tsai
2020-02-12 13:15:46 +08:00
parent cc781a38ef
commit a2e77a0e85
2 changed files with 2 additions and 21 deletions

View File

@@ -410,7 +410,7 @@ public class ManageApplications extends InstrumentedFragment
mApplications.mHasReceivedBridgeCallback = mApplications.mHasReceivedBridgeCallback =
savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false); savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
} }
int userId = mIsWorkOnly ? mWorkUserId : UserHandle.getUserId(mCurrentUid); int userId = mIsWorkOnly ? mWorkUserId : UserHandle.myUserId();
if (mStorageType == STORAGE_TYPE_MUSIC) { if (mStorageType == STORAGE_TYPE_MUSIC) {
Context context = getContext(); Context context = getContext();
mApplications.setExtraViewController( mApplications.setExtraViewController(

View File

@@ -20,7 +20,6 @@ import static com.android.settings.dashboard.profileselector.ProfileSelectFragme
import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB; import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.TypedArray; import android.content.res.TypedArray;
@@ -173,7 +172,7 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
if (intent != null) { if (intent != null) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
launchIntent(intent); Utils.launchIntent(mFragment, intent);
return true; return true;
} }
@@ -467,24 +466,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
} }
} }
private void launchIntent(Intent intent) {
try {
final int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, -1);
// b/33117269: Note that launchIntent may launch activity in different task which set
// different launchMode (e.g. Files), using startActivityForesult to set task as
// source task, and set requestCode as 0 means don't care about returnCode currently.
if (userId == -1) {
mFragment.startActivityForResult(intent, 0 /* requestCode not used */);
} else {
mFragment.getActivity().startActivityForResultAsUser(intent,
0 /* requestCode not used */, new UserHandle(userId));
}
} catch (ActivityNotFoundException e) {
Log.w(TAG, "No activity found for " + intent);
}
}
private static long totalValues(StorageMeasurement.MeasurementDetails details, int userId, private static long totalValues(StorageMeasurement.MeasurementDetails details, int userId,
String... keys) { String... keys) {
long total = 0; long total = 0;