Merge "[Panlingual] Adds log and have small refactor."
This commit is contained in:
committed by
Android (Google) Code Review
commit
139331e47f
@@ -42,9 +42,15 @@ public class AppLocaleUtil {
|
||||
@NonNull Context context,
|
||||
@NonNull String packageName,
|
||||
@NonNull List<ResolveInfo> infos) {
|
||||
return !isDisallowedPackage(context, packageName)
|
||||
&& !isSignedWithPlatformKey(context, packageName)
|
||||
&& hasLauncherEntry(packageName, infos);
|
||||
boolean isDisallowedPackage = isDisallowedPackage(context, packageName);
|
||||
boolean hasLauncherEntry = hasLauncherEntry(packageName, infos);
|
||||
boolean isSignedWithPlatformKey = isSignedWithPlatformKey(context, packageName);
|
||||
Log.i(TAG, "Can display preference - [" + packageName + "] :"
|
||||
+ " isDisallowedPackage : " + isDisallowedPackage
|
||||
+ " / isSignedWithPlatformKey : " + isSignedWithPlatformKey
|
||||
+ " / hasLauncherEntry : " + hasLauncherEntry);
|
||||
|
||||
return !isDisallowedPackage && !isSignedWithPlatformKey && hasLauncherEntry;
|
||||
}
|
||||
|
||||
private static boolean isDisallowedPackage(Context context, String packageName) {
|
||||
|
@@ -325,7 +325,6 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
||||
@VisibleForTesting
|
||||
void handleSupportedLocales() {
|
||||
mProcessedSupportedLocales.addAll(mAppSupportedLocales);
|
||||
|
||||
if (mProcessedSuggestedLocales != null || !mProcessedSuggestedLocales.isEmpty()) {
|
||||
mProcessedSuggestedLocales.retainAll(mProcessedSupportedLocales);
|
||||
mProcessedSupportedLocales.removeAll(mProcessedSuggestedLocales);
|
||||
@@ -399,9 +398,19 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
||||
String[] getAssetLocales() {
|
||||
try {
|
||||
PackageManager packageManager = mContext.getPackageManager();
|
||||
return packageManager.getResourcesForApplication(
|
||||
String[] locales = packageManager.getResourcesForApplication(
|
||||
packageManager.getPackageInfo(mPackageName, PackageManager.MATCH_ALL)
|
||||
.applicationInfo).getAssets().getNonSystemLocales();
|
||||
if (locales == null) {
|
||||
Log.i(TAG, "[" + mPackageName + "] locales are null.");
|
||||
}
|
||||
if (locales.length <= 0) {
|
||||
Log.i(TAG, "[" + mPackageName + "] locales length is 0.");
|
||||
return new String[0];
|
||||
}
|
||||
String locale = locales[0];
|
||||
Log.i(TAG, "First asset locale - [" + mPackageName + "] " + locale);
|
||||
return locales;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.w(TAG, "Can not found the package name : " + mPackageName + " / " + e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user