Loading src/com/android/settings/network/TetherProvisioningActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ public class TetherProvisioningActivity extends Activity { final int tetherSubId = getIntent().getIntExtra(EXTRA_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); final int subId = SubscriptionManager.getDefaultDataSubscriptionId(); final int subId = SubscriptionManager.getActiveDataSubscriptionId(); if (tetherSubId != subId) { Log.e(TAG, "This Provisioning request is outdated, current subId: " + subId); return; Loading @@ -67,6 +67,7 @@ public class TetherProvisioningActivity extends Activity { final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClassName(provisionApp[0], provisionApp[1]); intent.putExtra(EXTRA_TETHER_TYPE, tetherType); intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); if (DEBUG) { Log.d(TAG, "Starting provisioning app: " + provisionApp[0] + "." + provisionApp[1]); } Loading src/com/android/settings/wifi/tether/TetherService.java +11 −9 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ public class TetherService extends Service { public void onCreate() { super.onCreate(); if (DEBUG) Log.d(TAG, "Creating TetherService"); String provisionResponse = getResourceForDefaultDataSubId().getString( String provisionResponse = getResourceForActiveDataSubId().getString( com.android.internal.R.string.config_mobile_hotspot_provision_response); registerReceiver(mReceiver, new IntentFilter(provisionResponse), android.Manifest.permission.CONNECTIVITY_INTERNAL, null); Loading @@ -105,7 +105,7 @@ public class TetherService extends Service { if (intent.hasExtra(EXTRA_SUBID)) { final int tetherSubId = intent.getIntExtra(EXTRA_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); final int subId = getTetherServiceWrapper().getDefaultDataSubscriptionId(); final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId(); if (tetherSubId != subId) { Log.e(TAG, "This Provisioning request is outdated, current subId: " + subId); if (!mInProvisionCheck) { Loading Loading @@ -273,11 +273,13 @@ public class TetherService extends Service { } private Intent getProvisionBroadcastIntent(int index) { String provisionAction = getResourceForDefaultDataSubId().getString( String provisionAction = getResourceForActiveDataSubId().getString( com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui); final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId(); Intent intent = new Intent(provisionAction); int type = mCurrentTethers.get(index); intent.putExtra(TETHER_CHOICE, type); intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); Loading Loading @@ -309,7 +311,7 @@ public class TetherService extends Service { PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); int period = getResourceForDefaultDataSubId().getInteger( int period = getResourceForActiveDataSubId().getInteger( com.android.internal.R.integer.config_mobile_hotspot_provision_check_period); long periodMs = period * MS_PER_HOUR; long firstTime = SystemClock.elapsedRealtime() + periodMs; Loading Loading @@ -362,7 +364,7 @@ public class TetherService extends Service { @Override public void onReceive(Context context, Intent intent) { if (DEBUG) Log.d(TAG, "Got provision result " + intent); String provisionResponse = getResourceForDefaultDataSubId().getString( String provisionResponse = getResourceForActiveDataSubId().getString( com.android.internal.R.string.config_mobile_hotspot_provision_response); if (provisionResponse.equals(intent.getAction())) { Loading Loading @@ -429,14 +431,14 @@ public class TetherService extends Service { mUsageStatsManager.setAppInactive(packageName, isInactive); } int getDefaultDataSubscriptionId() { return SubscriptionManager.getDefaultDataSubscriptionId(); int getActiveDataSubscriptionId() { return SubscriptionManager.getActiveDataSubscriptionId(); } } @VisibleForTesting Resources getResourceForDefaultDataSubId() { final int subId = getTetherServiceWrapper().getDefaultDataSubscriptionId(); Resources getResourceForActiveDataSubId() { final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId(); return Utils.getResourcesForSubId(this, subId); } } tests/unit/src/com/android/settings/wifi/tether/TetherServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -458,7 +458,7 @@ public class TetherServiceTest extends ServiceTestCase<TetherService> { } @Override int getDefaultDataSubscriptionId() { int getActiveDataSubscriptionId() { return INVALID_SUBSCRIPTION_ID; } } Loading Loading
src/com/android/settings/network/TetherProvisioningActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ public class TetherProvisioningActivity extends Activity { final int tetherSubId = getIntent().getIntExtra(EXTRA_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); final int subId = SubscriptionManager.getDefaultDataSubscriptionId(); final int subId = SubscriptionManager.getActiveDataSubscriptionId(); if (tetherSubId != subId) { Log.e(TAG, "This Provisioning request is outdated, current subId: " + subId); return; Loading @@ -67,6 +67,7 @@ public class TetherProvisioningActivity extends Activity { final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClassName(provisionApp[0], provisionApp[1]); intent.putExtra(EXTRA_TETHER_TYPE, tetherType); intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); if (DEBUG) { Log.d(TAG, "Starting provisioning app: " + provisionApp[0] + "." + provisionApp[1]); } Loading
src/com/android/settings/wifi/tether/TetherService.java +11 −9 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ public class TetherService extends Service { public void onCreate() { super.onCreate(); if (DEBUG) Log.d(TAG, "Creating TetherService"); String provisionResponse = getResourceForDefaultDataSubId().getString( String provisionResponse = getResourceForActiveDataSubId().getString( com.android.internal.R.string.config_mobile_hotspot_provision_response); registerReceiver(mReceiver, new IntentFilter(provisionResponse), android.Manifest.permission.CONNECTIVITY_INTERNAL, null); Loading @@ -105,7 +105,7 @@ public class TetherService extends Service { if (intent.hasExtra(EXTRA_SUBID)) { final int tetherSubId = intent.getIntExtra(EXTRA_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); final int subId = getTetherServiceWrapper().getDefaultDataSubscriptionId(); final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId(); if (tetherSubId != subId) { Log.e(TAG, "This Provisioning request is outdated, current subId: " + subId); if (!mInProvisionCheck) { Loading Loading @@ -273,11 +273,13 @@ public class TetherService extends Service { } private Intent getProvisionBroadcastIntent(int index) { String provisionAction = getResourceForDefaultDataSubId().getString( String provisionAction = getResourceForActiveDataSubId().getString( com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui); final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId(); Intent intent = new Intent(provisionAction); int type = mCurrentTethers.get(index); intent.putExtra(TETHER_CHOICE, type); intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); Loading Loading @@ -309,7 +311,7 @@ public class TetherService extends Service { PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); int period = getResourceForDefaultDataSubId().getInteger( int period = getResourceForActiveDataSubId().getInteger( com.android.internal.R.integer.config_mobile_hotspot_provision_check_period); long periodMs = period * MS_PER_HOUR; long firstTime = SystemClock.elapsedRealtime() + periodMs; Loading Loading @@ -362,7 +364,7 @@ public class TetherService extends Service { @Override public void onReceive(Context context, Intent intent) { if (DEBUG) Log.d(TAG, "Got provision result " + intent); String provisionResponse = getResourceForDefaultDataSubId().getString( String provisionResponse = getResourceForActiveDataSubId().getString( com.android.internal.R.string.config_mobile_hotspot_provision_response); if (provisionResponse.equals(intent.getAction())) { Loading Loading @@ -429,14 +431,14 @@ public class TetherService extends Service { mUsageStatsManager.setAppInactive(packageName, isInactive); } int getDefaultDataSubscriptionId() { return SubscriptionManager.getDefaultDataSubscriptionId(); int getActiveDataSubscriptionId() { return SubscriptionManager.getActiveDataSubscriptionId(); } } @VisibleForTesting Resources getResourceForDefaultDataSubId() { final int subId = getTetherServiceWrapper().getDefaultDataSubscriptionId(); Resources getResourceForActiveDataSubId() { final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId(); return Utils.getResourcesForSubId(this, subId); } }
tests/unit/src/com/android/settings/wifi/tether/TetherServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -458,7 +458,7 @@ public class TetherServiceTest extends ServiceTestCase<TetherService> { } @Override int getDefaultDataSubscriptionId() { int getActiveDataSubscriptionId() { return INVALID_SUBSCRIPTION_ID; } } Loading