Merge "Avoid data usage notifications in airplane mode."

This commit is contained in:
Jeff Sharkey
2012-03-20 17:49:52 -07:00
committed by Android (Google) Code Review

View File

@@ -524,6 +524,11 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
case MATCH_MOBILE_3G_LOWER:
case MATCH_MOBILE_4G:
case MATCH_MOBILE_ALL:
// mobile templates aren't relevant in airplane mode
if (isAirplaneModeOn(mContext)) {
return false;
}
// mobile templates are relevant when subscriberid is active
return Objects.equal(getActiveSubscriberId(), template.getSubscriberId());
}
@@ -1723,6 +1728,11 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
mHandler.getLooper().getQueue().addIdleHandler(handler);
}
public static boolean isAirplaneModeOn(Context context) {
return Settings.System.getInt(
context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;
}
private static void collectKeys(SparseIntArray source, SparseBooleanArray target) {
final int size = source.size();
for (int i = 0; i < size; i++) {