Merge "Check NPE beforehand instead of catching it at runtime" into cw-e-dev
This commit is contained in:
@@ -612,12 +612,15 @@ public class CarrierConfigManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public PersistableBundle getConfigForSubId(int subId) {
|
public PersistableBundle getConfigForSubId(int subId) {
|
||||||
try {
|
try {
|
||||||
return getICarrierConfigLoader().getConfigForSubId(subId);
|
ICarrierConfigLoader loader = getICarrierConfigLoader();
|
||||||
|
if (loader == null) {
|
||||||
|
Rlog.w(TAG, "Error getting config for subId " + subId
|
||||||
|
+ " ICarrierConfigLoader is null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return loader.getConfigForSubId(subId);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": "
|
Rlog.e(TAG, "Error getting config for subId " + subId + ": "
|
||||||
+ ex.toString());
|
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": "
|
|
||||||
+ ex.toString());
|
+ ex.toString());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -653,11 +656,15 @@ public class CarrierConfigManager {
|
|||||||
*/
|
*/
|
||||||
public void notifyConfigChangedForSubId(int subId) {
|
public void notifyConfigChangedForSubId(int subId) {
|
||||||
try {
|
try {
|
||||||
getICarrierConfigLoader().notifyConfigChangedForSubId(subId);
|
ICarrierConfigLoader loader = getICarrierConfigLoader();
|
||||||
|
if (loader == null) {
|
||||||
|
Rlog.w(TAG, "Error reloading config for subId=" + subId
|
||||||
|
+ " ICarrierConfigLoader is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loader.notifyConfigChangedForSubId(subId);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString());
|
Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString());
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
Rlog.e(TAG, "Error reloading config for subId=" + subId + ": " + ex.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,11 +680,15 @@ public class CarrierConfigManager {
|
|||||||
@SystemApi
|
@SystemApi
|
||||||
public void updateConfigForPhoneId(int phoneId, String simState) {
|
public void updateConfigForPhoneId(int phoneId, String simState) {
|
||||||
try {
|
try {
|
||||||
getICarrierConfigLoader().updateConfigForPhoneId(phoneId, simState);
|
ICarrierConfigLoader loader = getICarrierConfigLoader();
|
||||||
|
if (loader == null) {
|
||||||
|
Rlog.w(TAG, "Error updating config for phoneId=" + phoneId
|
||||||
|
+ " ICarrierConfigLoader is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loader.updateConfigForPhoneId(phoneId, simState);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString());
|
Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString());
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
Rlog.e(TAG, "Error updating config for phoneId=" + phoneId + ": " + ex.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,6 +704,7 @@ public class CarrierConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
|
@Nullable
|
||||||
private ICarrierConfigLoader getICarrierConfigLoader() {
|
private ICarrierConfigLoader getICarrierConfigLoader() {
|
||||||
return ICarrierConfigLoader.Stub
|
return ICarrierConfigLoader.Stub
|
||||||
.asInterface(ServiceManager.getService(Context.CARRIER_CONFIG_SERVICE));
|
.asInterface(ServiceManager.getService(Context.CARRIER_CONFIG_SERVICE));
|
||||||
|
|||||||
Reference in New Issue
Block a user