From 546cb7712364618490f508659a9ce557276b6d1b Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 21 Jul 2016 16:19:01 -0700 Subject: [PATCH] Make NetworkOverLimitActivity and DataUsageSummaryActivity configurable b/23120366 Change-Id: I9176482ea15ee1fd0baa0958c582cb342dcd1b79 --- core/res/res/values/config.xml | 3 +++ core/res/res/values/symbols.xml | 4 ++++ .../server/net/NetworkPolicyManagerService.java | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 2835c6f5fa0a..018072b0ea94 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2513,4 +2513,7 @@ Note: Also update appropriate overlay files. --> + + com.android.systemui/com.android.systemui.net.NetworkOverLimitActivity + com.android.settings/com.android.settings.Settings$DataUsageSummaryActivity diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 2a40c0836ae5..e97ee8e8c4ea 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2646,6 +2646,10 @@ + + + + diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java index b22a08484b8a..d484628d5451 100644 --- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java @@ -1035,7 +1035,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { */ private void notifyOverLimitNL(NetworkTemplate template) { if (!mOverLimitNotified.contains(template)) { - mContext.startActivity(buildNetworkOverLimitIntent(template)); + mContext.startActivity(buildNetworkOverLimitIntent(mContext.getResources(), template)); mOverLimitNotified.add(template); } } @@ -1079,7 +1079,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { builder.setDeleteIntent(PendingIntent.getBroadcast( mContext, 0, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT)); - final Intent viewIntent = buildViewDataUsageIntent(policy.template); + final Intent viewIntent = buildViewDataUsageIntent(res, policy.template); builder.setContentIntent(PendingIntent.getActivity( mContext, 0, viewIntent, PendingIntent.FLAG_UPDATE_CURRENT)); @@ -1115,7 +1115,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { builder.setContentTitle(title); builder.setContentText(body); - final Intent intent = buildNetworkOverLimitIntent(policy.template); + final Intent intent = buildNetworkOverLimitIntent(res, policy.template); builder.setContentIntent(PendingIntent.getActivity( mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); break; @@ -1150,7 +1150,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { builder.setContentTitle(title); builder.setContentText(body); - final Intent intent = buildViewDataUsageIntent(policy.template); + final Intent intent = buildViewDataUsageIntent(res, policy.template); builder.setContentIntent(PendingIntent.getActivity( mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); break; @@ -3519,19 +3519,19 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { return intent; } - private static Intent buildNetworkOverLimitIntent(NetworkTemplate template) { + private static Intent buildNetworkOverLimitIntent(Resources res, NetworkTemplate template) { final Intent intent = new Intent(); - intent.setComponent(new ComponentName( - "com.android.systemui", "com.android.systemui.net.NetworkOverLimitActivity")); + intent.setComponent(ComponentName.unflattenFromString( + res.getString(R.string.config_networkOverLimitComponent))); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(EXTRA_NETWORK_TEMPLATE, template); return intent; } - private static Intent buildViewDataUsageIntent(NetworkTemplate template) { + private static Intent buildViewDataUsageIntent(Resources res, NetworkTemplate template) { final Intent intent = new Intent(); - intent.setComponent(new ComponentName( - "com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity")); + intent.setComponent(ComponentName.unflattenFromString( + res.getString(R.string.config_dataUsageSummaryComponent))); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(EXTRA_NETWORK_TEMPLATE, template); return intent; -- 2.11.0