diff options
author | markchien <markchien@google.com> | 2020-06-07 17:40:56 +0800 |
---|---|---|
committer | markchien <markchien@google.com> | 2020-06-11 23:36:59 +0800 |
commit | 17feecffaeab005ce0833180b6c9702ca35d6086 (patch) | |
tree | 402f39df36487593e44a9940030190f2b8184648 /src/com/android/settings/network | |
parent | 257b9bcdfaeb9b0eb54adebcb17771517167a38d (diff) | |
download | packages_apps_Settings-17feecffaeab005ce0833180b6c9702ca35d6086.tar.gz packages_apps_Settings-17feecffaeab005ce0833180b6c9702ca35d6086.tar.bz2 packages_apps_Settings-17feecffaeab005ce0833180b6c9702ca35d6086.zip |
Replace ConnectivityManager as TetheringManager
Tethering APIs are all move to TetheringManager from Android R.
1. Replace ConnectivityManager tethering API usage as TetheringManager.
2. Use TetheringManager#stopTethering to disable usb tethering instead
of using deprecated ConnectivityService#setUsbTethering
3. Use TetheringManager#stopTethering to disable bluetooth tethering
instead of directly use BluetoothPan#setBlueoothTethering. So bluetooth
getProfileProxy is not needed in TetherService because tethering would
do that when calling #stopTethering.
4. Also support TETHERING_ETHERNET entitlement check that
TETHERING_ETHERNET is new added from Android R.
Bug: 146918263
Test: atest TetherServiceTest
Change-Id: Id969f29d7210f2ee32719c76439049bbc86cd4f6
Diffstat (limited to 'src/com/android/settings/network')
-rw-r--r-- | src/com/android/settings/network/TetherProvisioningActivity.java | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/com/android/settings/network/TetherProvisioningActivity.java b/src/com/android/settings/network/TetherProvisioningActivity.java index 09efe482e6..bb61546594 100644 --- a/src/com/android/settings/network/TetherProvisioningActivity.java +++ b/src/com/android/settings/network/TetherProvisioningActivity.java @@ -16,13 +16,19 @@ package com.android.settings.network; +import static android.net.TetheringConstants.EXTRA_ADD_TETHER_TYPE; +import static android.net.TetheringConstants.EXTRA_PROVISION_CALLBACK; +import static android.net.TetheringConstants.EXTRA_RUN_PROVISION; +import static android.net.TetheringManager.TETHERING_INVALID; +import static android.net.TetheringManager.TETHER_ERROR_NO_ERROR; +import static android.net.TetheringManager.TETHER_ERROR_PROVISIONING_FAILED; +import static android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX; +import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; + import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Resources; -import android.net.ConnectivityManager; -import android.net.TetheringConstants; -import android.net.TetheringManager; import android.os.Bundle; import android.os.ResultReceiver; import android.os.UserHandle; @@ -52,23 +58,19 @@ public class TetherProvisioningActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mResultReceiver = (ResultReceiver)getIntent().getParcelableExtra( - ConnectivityManager.EXTRA_PROVISION_CALLBACK); + mResultReceiver = (ResultReceiver) getIntent().getParcelableExtra(EXTRA_PROVISION_CALLBACK); - final int tetherType = getIntent().getIntExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE, - ConnectivityManager.TETHERING_INVALID); + final int tetherType = getIntent().getIntExtra(EXTRA_ADD_TETHER_TYPE, TETHERING_INVALID); - final int tetherSubId = getIntent().getIntExtra(EXTRA_SUBID, - SubscriptionManager.INVALID_SUBSCRIPTION_ID); + final int tetherSubId = getIntent().getIntExtra(EXTRA_SUBID, INVALID_SUBSCRIPTION_ID); final int subId = SubscriptionManager.getActiveDataSubscriptionId(); if (tetherSubId != subId) { Log.e(TAG, "This Provisioning request is outdated, current subId: " + subId); - mResultReceiver.send(TetheringManager.TETHER_ERROR_PROVISIONING_FAILED, null); + mResultReceiver.send(TETHER_ERROR_PROVISIONING_FAILED, null); finish(); return; } - String[] provisionApp = getIntent().getStringArrayExtra( - TetheringConstants.EXTRA_RUN_PROVISION); + String[] provisionApp = getIntent().getStringArrayExtra(EXTRA_RUN_PROVISION); if (provisionApp == null || provisionApp.length < 2) { final Resources res = Utils.getResourcesForSubId(this, subId); provisionApp = res.getStringArray( @@ -77,8 +79,8 @@ 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); - intent.putExtra(ConnectivityManager.EXTRA_PROVISION_CALLBACK, mResultReceiver); + intent.putExtra(EXTRA_SUBSCRIPTION_INDEX, subId); + intent.putExtra(EXTRA_PROVISION_CALLBACK, mResultReceiver); if (DEBUG) { Log.d(TAG, "Starting provisioning app: " + provisionApp[0] + "." + provisionApp[1]); } @@ -86,7 +88,7 @@ public class TetherProvisioningActivity extends Activity { if (getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) { Log.e(TAG, "Provisioning app is configured, but not available."); - mResultReceiver.send(TetheringManager.TETHER_ERROR_PROVISIONING_FAILED, null); + mResultReceiver.send(TETHER_ERROR_PROVISIONING_FAILED, null); finish(); return; } @@ -99,9 +101,8 @@ public class TetherProvisioningActivity extends Activity { super.onActivityResult(requestCode, resultCode, intent); if (requestCode == PROVISION_REQUEST) { if (DEBUG) Log.d(TAG, "Got result from app: " + resultCode); - int result = resultCode == Activity.RESULT_OK ? - TetheringManager.TETHER_ERROR_NO_ERROR : - TetheringManager.TETHER_ERROR_PROVISIONING_FAILED; + int result = resultCode == Activity.RESULT_OK + ? TETHER_ERROR_NO_ERROR : TETHER_ERROR_PROVISIONING_FAILED; mResultReceiver.send(result, null); finish(); } |