Merge "Add extra null checks" into udc-dev am: 598ff21b78
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23214089 Change-Id: I4d7e0d6fb8e547794694dcd931c88a7f224b382d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -51,7 +51,7 @@ public final class CombinedProviderInfo {
|
|||||||
@Nullable List<CredentialProviderInfo> cpis,
|
@Nullable List<CredentialProviderInfo> cpis,
|
||||||
@Nullable AutofillServiceInfo asi,
|
@Nullable AutofillServiceInfo asi,
|
||||||
boolean isDefaultAutofillProvider,
|
boolean isDefaultAutofillProvider,
|
||||||
boolean IsPrimaryCredmanProvider) {
|
boolean isPrimaryCredmanProvider) {
|
||||||
if (cpis == null) {
|
if (cpis == null) {
|
||||||
mCredentialProviderInfos = new ArrayList<>();
|
mCredentialProviderInfos = new ArrayList<>();
|
||||||
} else {
|
} else {
|
||||||
@@ -59,11 +59,11 @@ public final class CombinedProviderInfo {
|
|||||||
}
|
}
|
||||||
mAutofillServiceInfo = asi;
|
mAutofillServiceInfo = asi;
|
||||||
mIsDefaultAutofillProvider = isDefaultAutofillProvider;
|
mIsDefaultAutofillProvider = isDefaultAutofillProvider;
|
||||||
mIsPrimaryCredmanProvider = IsPrimaryCredmanProvider;
|
mIsPrimaryCredmanProvider = isPrimaryCredmanProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the credential provider info. */
|
/** Returns the credential provider info. */
|
||||||
@Nullable
|
@NonNull
|
||||||
public List<CredentialProviderInfo> getCredentialProviderInfos() {
|
public List<CredentialProviderInfo> getCredentialProviderInfos() {
|
||||||
return mCredentialProviderInfos;
|
return mCredentialProviderInfos;
|
||||||
}
|
}
|
||||||
@@ -85,11 +85,13 @@ public final class CombinedProviderInfo {
|
|||||||
/** Returns the app icon. */
|
/** Returns the app icon. */
|
||||||
@Nullable
|
@Nullable
|
||||||
public Drawable getAppIcon(@NonNull Context context, int userId) {
|
public Drawable getAppIcon(@NonNull Context context, int userId) {
|
||||||
IconDrawableFactory factory = IconDrawableFactory.newInstance(context);
|
final IconDrawableFactory factory = IconDrawableFactory.newInstance(context);
|
||||||
|
final ServiceInfo brandingService = getBrandingService();
|
||||||
|
final ApplicationInfo appInfo = getApplicationInfo();
|
||||||
|
|
||||||
Drawable icon = null;
|
Drawable icon = null;
|
||||||
ServiceInfo brandingService = getBrandingService();
|
if (brandingService != null && appInfo != null) {
|
||||||
if (brandingService != null) {
|
icon = factory.getBadgedIcon(brandingService, appInfo, userId);
|
||||||
icon = factory.getBadgedIcon(brandingService, getApplicationInfo(), userId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the branding service gave us a icon then use that.
|
// If the branding service gave us a icon then use that.
|
||||||
@@ -98,7 +100,10 @@ public final class CombinedProviderInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise fallback to the app icon and then the package name.
|
// Otherwise fallback to the app icon and then the package name.
|
||||||
return factory.getBadgedIcon(getApplicationInfo(), userId);
|
if (appInfo != null) {
|
||||||
|
return factory.getBadgedIcon(appInfo, userId);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the app name. */
|
/** Returns the app name. */
|
||||||
@@ -116,11 +121,14 @@ public final class CombinedProviderInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise fallback to the app label and then the package name.
|
// Otherwise fallback to the app label and then the package name.
|
||||||
name = getApplicationInfo().loadLabel(context.getPackageManager());
|
final ApplicationInfo appInfo = getApplicationInfo();
|
||||||
|
if (appInfo != null) {
|
||||||
|
name = appInfo.loadLabel(context.getPackageManager());
|
||||||
if (TextUtils.isEmpty(name)) {
|
if (TextUtils.isEmpty(name)) {
|
||||||
name = getApplicationInfo().packageName;
|
return appInfo.packageName;
|
||||||
}
|
}
|
||||||
return name;
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the service to use for branding (name, icons). */
|
/** Gets the service to use for branding (name, icons). */
|
||||||
@@ -245,8 +253,10 @@ public final class CombinedProviderInfo {
|
|||||||
// Now go through and build the joint datasets.
|
// Now go through and build the joint datasets.
|
||||||
List<CombinedProviderInfo> cmpi = new ArrayList<>();
|
List<CombinedProviderInfo> cmpi = new ArrayList<>();
|
||||||
for (String packageName : packageNames) {
|
for (String packageName : packageNames) {
|
||||||
List<AutofillServiceInfo> asi = autofillServices.get(packageName);
|
List<AutofillServiceInfo> asi =
|
||||||
List<CredentialProviderInfo> cpi = credmanServices.get(packageName);
|
autofillServices.getOrDefault(packageName, new ArrayList<>());
|
||||||
|
List<CredentialProviderInfo> cpi =
|
||||||
|
credmanServices.getOrDefault(packageName, new ArrayList<>());
|
||||||
|
|
||||||
// If there are multiple autofill services then pick the first one.
|
// If there are multiple autofill services then pick the first one.
|
||||||
AutofillServiceInfo selectedAsi = null;
|
AutofillServiceInfo selectedAsi = null;
|
||||||
|
@@ -35,6 +35,7 @@ import android.view.autofill.AutofillManager;
|
|||||||
import com.android.settings.applications.defaultapps.DefaultAppPreferenceController;
|
import com.android.settings.applications.defaultapps.DefaultAppPreferenceController;
|
||||||
import com.android.settingslib.applications.DefaultAppInfo;
|
import com.android.settingslib.applications.DefaultAppInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DefaultCombinedPreferenceController extends DefaultAppPreferenceController {
|
public class DefaultCombinedPreferenceController extends DefaultAppPreferenceController {
|
||||||
@@ -110,15 +111,19 @@ public class DefaultCombinedPreferenceController extends DefaultAppPreferenceCon
|
|||||||
private List<CombinedProviderInfo> getAllProviders(int userId) {
|
private List<CombinedProviderInfo> getAllProviders(int userId) {
|
||||||
final List<AutofillServiceInfo> autofillProviders =
|
final List<AutofillServiceInfo> autofillProviders =
|
||||||
AutofillServiceInfo.getAvailableServices(mContext, userId);
|
AutofillServiceInfo.getAvailableServices(mContext, userId);
|
||||||
final List<CredentialProviderInfo> credManProviders =
|
|
||||||
mCredentialManager.getCredentialProviderServices(
|
|
||||||
userId, CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY);
|
|
||||||
final String selectedAutofillProvider =
|
final String selectedAutofillProvider =
|
||||||
Settings.Secure.getStringForUser(
|
Settings.Secure.getStringForUser(
|
||||||
mContext.getContentResolver(),
|
mContext.getContentResolver(),
|
||||||
DefaultCombinedPicker.AUTOFILL_SETTING,
|
DefaultCombinedPicker.AUTOFILL_SETTING,
|
||||||
userId);
|
userId);
|
||||||
|
|
||||||
|
final List<CredentialProviderInfo> credManProviders = new ArrayList<>();
|
||||||
|
if (mCredentialManager != null) {
|
||||||
|
credManProviders.addAll(
|
||||||
|
mCredentialManager.getCredentialProviderServices(
|
||||||
|
userId, CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY));
|
||||||
|
}
|
||||||
|
|
||||||
return CombinedProviderInfo.buildMergedList(
|
return CombinedProviderInfo.buildMergedList(
|
||||||
autofillProviders, credManProviders, selectedAutofillProvider);
|
autofillProviders, credManProviders, selectedAutofillProvider);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user