Merge "Check NPE beforehand instead of catching it at runtime" into cw-e-dev am: e56f7b0d1d am: bef0525c38 am: e4db3f0757

am: d7b61ca662

* commit 'd7b61ca6620565cad00de91284ecdfb93ddfbd50':
  Check NPE beforehand instead of catching it at runtime
This commit is contained in:
Chenjie Luo
2015-12-08 00:02:55 +00:00
committed by android-build-merger

View File

@@ -673,12 +673,15 @@ public class CarrierConfigManager {
@Nullable
public PersistableBundle getConfigForSubId(int subId) {
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) {
Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": "
+ ex.toString());
} catch (NullPointerException ex) {
Rlog.e(TAG, "Error getting config for subId " + Integer.toString(subId) + ": "
Rlog.e(TAG, "Error getting config for subId " + subId + ": "
+ ex.toString());
}
return null;
@@ -714,11 +717,15 @@ public class CarrierConfigManager {
*/
public void notifyConfigChangedForSubId(int subId) {
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) {
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());
}
}
@@ -734,11 +741,15 @@ public class CarrierConfigManager {
@SystemApi
public void updateConfigForPhoneId(int phoneId, String simState) {
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) {
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());
}
}
@@ -754,6 +765,7 @@ public class CarrierConfigManager {
}
/** @hide */
@Nullable
private ICarrierConfigLoader getICarrierConfigLoader() {
return ICarrierConfigLoader.Stub
.asInterface(ServiceManager.getService(Context.CARRIER_CONFIG_SERVICE));