[Tether10]Remove UserManagerInternal usage in Tethering

To be the unbundled application, tethering can not use UserManagerInternal
method anymore. Replace it by listening user restriction change intent.

Also fix some cleanup from
https://android-review.googlesource.com/c/platform/frameworks/base/+/1131002

Bug: 143195885
Test: -build, flash, boot
      -atest TetheringTests
      -manual test. Add a trigger point to call
       UserManager.setUserRestriction(DISALLOW_CONFIG_TETHERING) from
       Settings. Open hotspot -> restrict tethering from new adding trigger
       point -> hotspot is OFF and Tethering settings are not available.

Change-Id: I4ed08d20f8b7476b8ecd5d018b75806dd2f22cc1
Merged-In: I4ed08d20f8b7476b8ecd5d018b75806dd2f22cc1
This commit is contained in:
markchien
2019-11-27 21:20:33 +08:00
committed by Mark Chien
parent ee6ad37837
commit 147186daff
4 changed files with 59 additions and 40 deletions

View File

@@ -17,7 +17,7 @@
package android.net;
/**
* Configuration details for a tethering.
* Configuration details for tethering.
* @hide
*/
parcelable TetheringConfigurationParcel {

View File

@@ -168,11 +168,12 @@ public class TetheringManager {
* #getTetherableIfaces() to ensure corresponding interface is available for
* tethering before calling #tether().
*
* TODO: Deprecate this API. The only usages should be in PanService and Wifi P2P which
* @deprecated The only usages should be in PanService and Wifi P2P which
* need direct access.
*
* {@hide}
*/
@Deprecated
public int tether(@NonNull String iface) {
try {
mConnector.tether(iface);
@@ -185,8 +186,10 @@ public class TetheringManager {
/**
* Stop tethering the named interface.
*
* @deprecated
* {@hide}
*/
@Deprecated
public int untether(@NonNull String iface) {
try {
mConnector.untether(iface);
@@ -202,9 +205,10 @@ public class TetheringManager {
* encapsulate proper entitlement logic. If the API is used and an entitlement check is needed,
* downstream USB tethering will be enabled but will not have any upstream.
*
* @Deprecated
* @deprecated
* {@hide}
*/
@Deprecated
public int setUsbTethering(boolean enable) {
try {
mConnector.setUsbTethering(enable);
@@ -386,8 +390,10 @@ public class TetheringManager {
/**
* Get the set of tethered dhcp ranges.
*
* @deprecated This API just return the default value which is not used in DhcpServer.
* {@hide}
*/
@Deprecated
public @NonNull String[] getTetheredDhcpRanges() {
if (!mCallback.awaitCallbackCreation()) {
throw new NullPointerException("callback was not ready yet");