From d34c9af3e2085c938645f1a6e6343b4a75c4b504 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Wed, 27 Jan 2016 14:46:39 -0800 Subject: [PATCH] Created a ACTION_RESTRICT_BACKGROUND_CHANGED intent. This intent will be broadcasted when: - Global restrict background setting is changed (sent to all packages) - An individual uid is added to or removed from the whitelist (sent just to the packages belonging to that uid). This intent is only sent to registered receivers. BUG: 26451391 Change-Id: Ic0a5771f88baa52076ad04764f29098a386463cc --- core/java/android/net/ConnectivityManager.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 92c721bdb0..f7729340ad 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -3215,11 +3215,24 @@ public class ConnectivityManager { /** * Device is restricting metered network activity while application is running on background. + *

* In this state, application should not try to use the network while running on background, * because it would be denied. */ public static final int RESTRICT_BACKGROUND_STATUS_ENABLED = 3; + /** + * A change in the background metered network activity restriction has occurred. + *

+ * Applications should call {@link #getRestrictBackgroundStatus()} to check if the restriction + * applies to them. + *

+ * This is only sent to registered receivers, not manifest receivers. + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_RESTRICT_BACKGROUND_CHANGED = + "android.net.conn.RESTRICT_BACKGROUND_CHANGED"; + /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(flag = false, value = {