Update use of android.webkit.UserPackage.

UserPackage no longer stores a UserInfo, only a UserHandle, to aid in
mainline modularization. Update Settings to fetch the UserInfo itself
when it needs to show the user name.

Bug: 310653407
Test: atest WebViewAppPickerTest
Flag: NONE cannot flag changed types in method signatures
Change-Id: I0e6f58e6b6a353171ddf923279ff08a92e2f040a
This commit is contained in:
Torne (Richard Coles)
2024-09-09 17:58:03 -04:00
parent 7db5b7a084
commit c82baecc32
2 changed files with 25 additions and 19 deletions

View File

@@ -26,6 +26,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.os.UserManager;
import android.text.TextUtils;
import android.webkit.UserPackage;
@@ -149,17 +150,20 @@ public class WebViewAppPicker extends DefaultAppPickerFragment {
@VisibleForTesting
String getDisabledReason(WebViewUpdateServiceWrapper webviewUpdateServiceWrapper,
Context context, String packageName) {
UserManager userManager = context.getSystemService(UserManager.class);
List<UserPackage> userPackages =
webviewUpdateServiceWrapper.getPackageInfosAllUsers(context, packageName);
for (UserPackage userPackage : userPackages) {
if (!userPackage.isInstalledPackage()) {
// Package uninstalled/hidden
return context.getString(
R.string.webview_uninstalled_for_user, userPackage.getUserInfo().name);
R.string.webview_uninstalled_for_user,
userManager.getUserInfo(userPackage.getUser().getIdentifier()).name);
} else if (!userPackage.isEnabledPackage()) {
// Package disabled
return context.getString(
R.string.webview_disabled_for_user, userPackage.getUserInfo().name);
R.string.webview_disabled_for_user,
userManager.getUserInfo(userPackage.getUser().getIdentifier()).name);
}
}
return null;