Merge "Remove usage of hidden API PhoneConstants.SUBSCRIPTION_KEY"

This commit is contained in:
Meng Wang
2019-12-06 19:35:12 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 12 deletions

View File

@@ -222,7 +222,6 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ConcurrentUtils;
import com.android.internal.util.DumpUtils;
@@ -1656,10 +1655,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
// No need to do a permission check, because the ACTION_CARRIER_CONFIG_CHANGED
// broadcast is protected and can't be spoofed. Runs on a background handler thread.
if (!intent.hasExtra(PhoneConstants.SUBSCRIPTION_KEY)) {
if (!intent.hasExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX)) {
return;
}
final int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, -1);
final int subId = intent.getIntExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, -1);
// Get all of our cross-process communication with telephony out of
// the way before we acquire internal locks.

View File

@@ -138,7 +138,6 @@ import android.util.RecurrenceRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.test.BroadcastInterceptingContext;
import com.android.internal.util.test.BroadcastInterceptingContext.FutureIntent;
import com.android.server.DeviceIdleInternal;
@@ -1484,7 +1483,7 @@ public class NetworkPolicyManagerServiceTest {
// smoke test to make sure no errors are raised
mServiceContext.sendBroadcast(
new Intent(ACTION_CARRIER_CONFIG_CHANGED)
.putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, FAKE_SUB_ID)
);
assertNetworkPolicyEquals(DEFAULT_CYCLE_DAY, mDefaultWarningBytes, mDefaultLimitBytes,
true);
@@ -1499,7 +1498,7 @@ public class NetworkPolicyManagerServiceTest {
bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG, -100);
mServiceContext.sendBroadcast(
new Intent(ACTION_CARRIER_CONFIG_CHANGED)
.putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, FAKE_SUB_ID)
);
assertNetworkPolicyEquals(DEFAULT_CYCLE_DAY, mDefaultWarningBytes, mDefaultLimitBytes,
@@ -1518,7 +1517,7 @@ public class NetworkPolicyManagerServiceTest {
DATA_CYCLE_USE_PLATFORM_DEFAULT);
mServiceContext.sendBroadcast(
new Intent(ACTION_CARRIER_CONFIG_CHANGED)
.putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, FAKE_SUB_ID)
);
assertNetworkPolicyEquals(DEFAULT_CYCLE_DAY, mDefaultWarningBytes, mDefaultLimitBytes,
@@ -1540,7 +1539,7 @@ public class NetworkPolicyManagerServiceTest {
DATA_CYCLE_THRESHOLD_DISABLED);
mServiceContext.sendBroadcast(
new Intent(ACTION_CARRIER_CONFIG_CHANGED)
.putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, FAKE_SUB_ID)
);
// The policy still shouldn't change, because we don't want to overwrite user settings.
@@ -1557,7 +1556,7 @@ public class NetworkPolicyManagerServiceTest {
bundle.putLong(CarrierConfigManager.KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG, 9999);
mServiceContext.sendBroadcast(
new Intent(ACTION_CARRIER_CONFIG_CHANGED)
.putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, FAKE_SUB_ID)
);
assertNetworkPolicyEquals(31, 9999, 9999, true);
@@ -1574,7 +1573,7 @@ public class NetworkPolicyManagerServiceTest {
DATA_CYCLE_THRESHOLD_DISABLED);
mServiceContext.sendBroadcast(
new Intent(ACTION_CARRIER_CONFIG_CHANGED)
.putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, FAKE_SUB_ID)
);
assertNetworkPolicyEquals(31, WARNING_DISABLED, LIMIT_DISABLED, true);
@@ -1591,7 +1590,7 @@ public class NetworkPolicyManagerServiceTest {
DATA_CYCLE_THRESHOLD_DISABLED);
mServiceContext.sendBroadcast(
new Intent(ACTION_CARRIER_CONFIG_CHANGED)
.putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, FAKE_SUB_ID)
);
assertNetworkPolicyEquals(31, WARNING_DISABLED, LIMIT_DISABLED, true);
@@ -1606,7 +1605,7 @@ public class NetworkPolicyManagerServiceTest {
DATA_CYCLE_USE_PLATFORM_DEFAULT);
mServiceContext.sendBroadcast(
new Intent(ACTION_CARRIER_CONFIG_CHANGED)
.putExtra(PhoneConstants.SUBSCRIPTION_KEY, FAKE_SUB_ID)
.putExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, FAKE_SUB_ID)
);
assertNetworkPolicyEquals(31, mDefaultWarningBytes, mDefaultLimitBytes,