Fix NPE when tapping on Add Network in Settings > WiFi
Bug:20542955 Change-Id: I06cfc21f906f94b2b61f2121c22c3d3318c9e65b
This commit is contained in:
@@ -508,29 +508,31 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showDialog(AccessPoint accessPoint, boolean edit) {
|
private void showDialog(AccessPoint accessPoint, boolean edit) {
|
||||||
WifiConfiguration config = accessPoint.getConfig();
|
if (accessPoint != null) {
|
||||||
if (isCreatorDeviceOwner(getActivity(), config) && accessPoint.isActive()) {
|
WifiConfiguration config = accessPoint.getConfig();
|
||||||
final int userId = UserHandle.getUserId(config.creatorUid);
|
if (isCreatorDeviceOwner(getActivity(), config) && accessPoint.isActive()) {
|
||||||
final PackageManager pm = getActivity().getPackageManager();
|
final int userId = UserHandle.getUserId(config.creatorUid);
|
||||||
final IPackageManager ipm = AppGlobals.getPackageManager();
|
final PackageManager pm = getActivity().getPackageManager();
|
||||||
String appName = pm.getNameForUid(config.creatorUid);
|
final IPackageManager ipm = AppGlobals.getPackageManager();
|
||||||
try {
|
String appName = pm.getNameForUid(config.creatorUid);
|
||||||
final ApplicationInfo appInfo = ipm.getApplicationInfo(appName, /* flags */ 0,
|
try {
|
||||||
userId);
|
final ApplicationInfo appInfo = ipm.getApplicationInfo(appName, /* flags */ 0,
|
||||||
final CharSequence label = pm.getApplicationLabel(appInfo);
|
userId);
|
||||||
if (label != null) {
|
final CharSequence label = pm.getApplicationLabel(appInfo);
|
||||||
appName = label.toString();
|
if (label != null) {
|
||||||
|
appName = label.toString();
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
// leave appName as packageName
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
// leave appName as packageName
|
builder.setTitle(accessPoint.getSsid())
|
||||||
|
.setMessage(getString(R.string.wifi_alert_lockdown_by_device_owner,
|
||||||
|
appName))
|
||||||
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
|
.show();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
|
||||||
builder.setTitle(accessPoint.getSsid())
|
|
||||||
.setMessage(getString(R.string.wifi_alert_lockdown_by_device_owner,
|
|
||||||
appName))
|
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
|
||||||
.show();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDialog != null) {
|
if (mDialog != null) {
|
||||||
@@ -561,10 +563,11 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
// If it's null, fine, it's for Add Network
|
// If it's null, fine, it's for Add Network
|
||||||
mSelectedAccessPoint = ap;
|
mSelectedAccessPoint = ap;
|
||||||
|
final boolean hideForget = (ap == null || isCreatorDeviceOwner(getActivity(),
|
||||||
|
ap.getConfig()));
|
||||||
mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit,
|
mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit,
|
||||||
/* no hide submit/connect */ false,
|
/* no hide submit/connect */ false,
|
||||||
/* hide forget if config locked down */ isCreatorDeviceOwner(getActivity(),
|
/* hide forget if config locked down */ hideForget);
|
||||||
ap.getConfig()));
|
|
||||||
return mDialog;
|
return mDialog;
|
||||||
case WPS_PBC_DIALOG_ID:
|
case WPS_PBC_DIALOG_ID:
|
||||||
return new WpsDialog(getActivity(), WpsInfo.PBC);
|
return new WpsDialog(getActivity(), WpsInfo.PBC);
|
||||||
|
Reference in New Issue
Block a user