diff options
-rw-r--r-- | core/java/android/net/NetworkPolicyManager.java | 23 | ||||
-rw-r--r-- | services/java/com/android/server/net/NetworkPolicyManagerService.java | 26 |
2 files changed, 38 insertions, 11 deletions
diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index e9d65e6..538a06e 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -19,6 +19,7 @@ package android.net; import static android.text.format.Time.MONTH_DAY; import android.content.Context; +import android.content.Intent; import android.os.RemoteException; import android.text.format.Time; @@ -41,6 +42,28 @@ public class NetworkPolicyManager { /** Reject traffic on paid networks. */ public static final int RULE_REJECT_PAID = 0x1; + /** + * {@link Intent} action launched when user selects {@link NetworkPolicy} + * warning notification. + */ + public static final String ACTION_DATA_USAGE_WARNING = + "android.intent.action.DATA_USAGE_WARNING"; + + /** + * {@link Intent} action launched when user selects {@link NetworkPolicy} + * limit notification. + */ + public static final String ACTION_DATA_USAGE_LIMIT = + "android.intent.action.DATA_USAGE_LIMIT"; + + /** + * {@link Intent} extra included in {@link #ACTION_DATA_USAGE_WARNING} and + * {@link #ACTION_DATA_USAGE_LIMIT} to indicate which + * {@link NetworkPolicy#networkTemplate} it applies to. + */ + public static final String EXTRA_NETWORK_TEMPLATE = + "android.intent.extra.NETWORK_TEMPLATE"; + private INetworkPolicyManager mService; public NetworkPolicyManager(INetworkPolicyManager service) { diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java index 2164334..dac0044 100644 --- a/services/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java @@ -25,6 +25,9 @@ import static android.Manifest.permission.READ_PHONE_STATE; import static android.net.ConnectivityManager.CONNECTIVITY_ACTION; import static android.net.NetworkPolicy.LIMIT_DISABLED; import static android.net.NetworkPolicy.WARNING_DISABLED; +import static android.net.NetworkPolicyManager.ACTION_DATA_USAGE_LIMIT; +import static android.net.NetworkPolicyManager.ACTION_DATA_USAGE_WARNING; +import static android.net.NetworkPolicyManager.EXTRA_NETWORK_TEMPLATE; import static android.net.NetworkPolicyManager.POLICY_NONE; import static android.net.NetworkPolicyManager.POLICY_REJECT_PAID_BACKGROUND; import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL; @@ -138,11 +141,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private static final String ATTR_UID = "uid"; private static final String ATTR_POLICY = "policy"; - public static final String ACTION_DATA_USAGE_WARNING = - "android.intent.action.DATA_USAGE_WARNING"; - public static final String ACTION_DATA_USAGE_LIMIT = - "android.intent.action.DATA_USAGE_LIMIT"; - private static final long TIME_CACHE_MAX_AGE = DAY_IN_MILLIS; private final Context mContext; @@ -402,9 +400,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { builder.setTicker(title); builder.setContentTitle(title); builder.setContentText(body); - builder.setContentIntent(PendingIntent.getActivity(mContext, 0, - new Intent(ACTION_DATA_USAGE_WARNING), - PendingIntent.FLAG_UPDATE_CURRENT)); + + final Intent intent = new Intent(ACTION_DATA_USAGE_WARNING); + intent.addCategory(Intent.CATEGORY_DEFAULT); + intent.putExtra(EXTRA_NETWORK_TEMPLATE, policy.networkTemplate); + builder.setContentIntent(PendingIntent.getActivity( + mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); break; } case TYPE_LIMIT: { @@ -426,9 +427,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { builder.setTicker(title); builder.setContentTitle(title); builder.setContentText(body); - builder.setContentIntent(PendingIntent.getActivity(mContext, 0, - new Intent(ACTION_DATA_USAGE_LIMIT), - PendingIntent.FLAG_UPDATE_CURRENT)); + + final Intent intent = new Intent(ACTION_DATA_USAGE_LIMIT); + intent.addCategory(Intent.CATEGORY_DEFAULT); + intent.putExtra(EXTRA_NETWORK_TEMPLATE, policy.networkTemplate); + builder.setContentIntent(PendingIntent.getActivity( + mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); break; } } |