Fix label loading on default home setting
Change-Id: Ia7d00eaf48eb703b766c760b6140ea98be5490f1 Fixes: 28668320
This commit is contained in:
@@ -17,9 +17,11 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.AppGlobals;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
@@ -27,6 +29,7 @@ import android.content.res.TypedArray;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -195,15 +198,16 @@ public class AppListPreference extends CustomListPreference {
|
|||||||
int selectedIndex = -1;
|
int selectedIndex = -1;
|
||||||
for (int i = 0; i < componentNames.length; i++) {
|
for (int i = 0; i < componentNames.length; i++) {
|
||||||
try {
|
try {
|
||||||
ApplicationInfo appInfo = pm.getApplicationInfoAsUser(
|
ActivityInfo activityInfo = AppGlobals.getPackageManager().getActivityInfo(
|
||||||
componentNames[i].getPackageName().toString(), 0, mUserId);
|
componentNames[i], 0, mUserId);
|
||||||
applicationNames.add(appInfo.loadLabel(pm));
|
if (activityInfo == null) continue;
|
||||||
|
applicationNames.add(activityInfo.loadLabel(pm));
|
||||||
validatedComponentNames.add(componentNames[i].flattenToString());
|
validatedComponentNames.add(componentNames[i].flattenToString());
|
||||||
entryDrawables.add(appInfo.loadIcon(pm));
|
entryDrawables.add(activityInfo.loadIcon(pm));
|
||||||
if (defaultCN != null && componentNames[i].equals(defaultCN)) {
|
if (defaultCN != null && componentNames[i].equals(defaultCN)) {
|
||||||
selectedIndex = i;
|
selectedIndex = i;
|
||||||
}
|
}
|
||||||
} catch (NameNotFoundException e) {
|
} catch (RemoteException e) {
|
||||||
// Skip unknown packages.
|
// Skip unknown packages.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user