Merge "Fix NPE for WifiConfiguration in AccessPoint." into nyc-dev
This commit is contained in:
@@ -360,17 +360,18 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getSavedNetworkSummary() {
|
public String getSavedNetworkSummary() {
|
||||||
if (mConfig != null) {
|
WifiConfiguration config = mConfig;
|
||||||
|
if (config != null) {
|
||||||
PackageManager pm = mContext.getPackageManager();
|
PackageManager pm = mContext.getPackageManager();
|
||||||
String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
|
String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
|
||||||
int userId = UserHandle.getUserId(mConfig.creatorUid);
|
int userId = UserHandle.getUserId(config.creatorUid);
|
||||||
ApplicationInfo appInfo = null;
|
ApplicationInfo appInfo = null;
|
||||||
if (mConfig.creatorName != null && mConfig.creatorName.equals(systemName)) {
|
if (config.creatorName != null && config.creatorName.equals(systemName)) {
|
||||||
appInfo = mContext.getApplicationInfo();
|
appInfo = mContext.getApplicationInfo();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
IPackageManager ipm = AppGlobals.getPackageManager();
|
IPackageManager ipm = AppGlobals.getPackageManager();
|
||||||
appInfo = ipm.getApplicationInfo(mConfig.creatorName, 0 /* flags */, userId);
|
appInfo = ipm.getApplicationInfo(config.creatorName, 0 /* flags */, userId);
|
||||||
} catch (RemoteException rex) {
|
} catch (RemoteException rex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -385,29 +386,33 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
return getSettingsSummary();
|
return getSettingsSummary(mConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSettingsSummary() {
|
public String getSettingsSummary() {
|
||||||
|
return getSettingsSummary(mConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSettingsSummary(WifiConfiguration config) {
|
||||||
// Update to new summary
|
// Update to new summary
|
||||||
StringBuilder summary = new StringBuilder();
|
StringBuilder summary = new StringBuilder();
|
||||||
|
|
||||||
if (isActive() && mConfig != null && mConfig.isPasspoint()) {
|
if (isActive() && config != null && config.isPasspoint()) {
|
||||||
// This is the active connection on passpoint
|
// This is the active connection on passpoint
|
||||||
summary.append(getSummary(mContext, getDetailedState(),
|
summary.append(getSummary(mContext, getDetailedState(),
|
||||||
false, mConfig.providerFriendlyName));
|
false, config.providerFriendlyName));
|
||||||
} else if (isActive()) {
|
} else if (isActive()) {
|
||||||
// This is the active connection on non-passpoint network
|
// This is the active connection on non-passpoint network
|
||||||
summary.append(getSummary(mContext, getDetailedState(),
|
summary.append(getSummary(mContext, getDetailedState(),
|
||||||
mInfo != null && mInfo.isEphemeral()));
|
mInfo != null && mInfo.isEphemeral()));
|
||||||
} else if (mConfig != null && mConfig.isPasspoint()) {
|
} else if (config != null && config.isPasspoint()) {
|
||||||
String format = mContext.getString(R.string.available_via_passpoint);
|
String format = mContext.getString(R.string.available_via_passpoint);
|
||||||
summary.append(String.format(format, mConfig.providerFriendlyName));
|
summary.append(String.format(format, config.providerFriendlyName));
|
||||||
} else if (mConfig != null && mConfig.hasNoInternetAccess()) {
|
} else if (config != null && config.hasNoInternetAccess()) {
|
||||||
summary.append(mContext.getString(R.string.wifi_no_internet));
|
summary.append(mContext.getString(R.string.wifi_no_internet));
|
||||||
} else if (mConfig != null && !mConfig.getNetworkSelectionStatus().isNetworkEnabled()) {
|
} else if (config != null && !config.getNetworkSelectionStatus().isNetworkEnabled()) {
|
||||||
WifiConfiguration.NetworkSelectionStatus networkStatus =
|
WifiConfiguration.NetworkSelectionStatus networkStatus =
|
||||||
mConfig.getNetworkSelectionStatus();
|
config.getNetworkSelectionStatus();
|
||||||
switch (networkStatus.getNetworkSelectionDisableReason()) {
|
switch (networkStatus.getNetworkSelectionDisableReason()) {
|
||||||
case WifiConfiguration.NetworkSelectionStatus.DISABLED_AUTHENTICATION_FAILURE:
|
case WifiConfiguration.NetworkSelectionStatus.DISABLED_AUTHENTICATION_FAILURE:
|
||||||
summary.append(mContext.getString(R.string.wifi_disabled_password_failure));
|
summary.append(mContext.getString(R.string.wifi_disabled_password_failure));
|
||||||
@@ -423,7 +428,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
|
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
|
||||||
summary.append(mContext.getString(R.string.wifi_not_in_range));
|
summary.append(mContext.getString(R.string.wifi_not_in_range));
|
||||||
} else { // In range, not disabled.
|
} else { // In range, not disabled.
|
||||||
if (mConfig != null) { // Is saved network
|
if (config != null) { // Is saved network
|
||||||
summary.append(mContext.getString(R.string.wifi_remembered));
|
summary.append(mContext.getString(R.string.wifi_remembered));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,11 +440,11 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
summary.append(" f=" + Integer.toString(mInfo.getFrequency()));
|
summary.append(" f=" + Integer.toString(mInfo.getFrequency()));
|
||||||
}
|
}
|
||||||
summary.append(" " + getVisibilityStatus());
|
summary.append(" " + getVisibilityStatus());
|
||||||
if (mConfig != null && !mConfig.getNetworkSelectionStatus().isNetworkEnabled()) {
|
if (config != null && !config.getNetworkSelectionStatus().isNetworkEnabled()) {
|
||||||
summary.append(" (" + mConfig.getNetworkSelectionStatus().getNetworkStatusString());
|
summary.append(" (" + config.getNetworkSelectionStatus().getNetworkStatusString());
|
||||||
if (mConfig.getNetworkSelectionStatus().getDisableTime() > 0) {
|
if (config.getNetworkSelectionStatus().getDisableTime() > 0) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long diff = (now - mConfig.getNetworkSelectionStatus().getDisableTime()) / 1000;
|
long diff = (now - config.getNetworkSelectionStatus().getDisableTime()) / 1000;
|
||||||
long sec = diff%60; //seconds
|
long sec = diff%60; //seconds
|
||||||
long min = (diff/60)%60; //minutes
|
long min = (diff/60)%60; //minutes
|
||||||
long hour = (min/60)%60; //hours
|
long hour = (min/60)%60; //hours
|
||||||
@@ -451,9 +456,9 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
summary.append(")");
|
summary.append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mConfig != null) {
|
if (config != null) {
|
||||||
WifiConfiguration.NetworkSelectionStatus networkStatus =
|
WifiConfiguration.NetworkSelectionStatus networkStatus =
|
||||||
mConfig.getNetworkSelectionStatus();
|
config.getNetworkSelectionStatus();
|
||||||
for (int index = WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLE;
|
for (int index = WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLE;
|
||||||
index < WifiConfiguration.NetworkSelectionStatus
|
index < WifiConfiguration.NetworkSelectionStatus
|
||||||
.NETWORK_SELECTION_DISABLED_MAX; index++) {
|
.NETWORK_SELECTION_DISABLED_MAX; index++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user