Loading Android.bp +18 −0 Original line number Diff line number Diff line Loading @@ -266,6 +266,7 @@ filegroup { name: "framework-updatable-sources", srcs: [ ":framework-sdkext-sources", ":framework-tethering-srcs", ":updatable-media-srcs", ] } Loading Loading @@ -370,6 +371,7 @@ java_defaults { "ext", "unsupportedappusage", "updatable_media_stubs", "framework-tethering", ], jarjar_rules: ":framework-jarjar-rules", Loading Loading @@ -605,10 +607,26 @@ filegroup { ], } // keep these files in sync with the package/Tethering/jarjar-rules.txt for the tethering module. filegroup { name: "framework-tethering-shared-srcs", srcs: [ "core/java/android/util/LocalLog.java", "core/java/com/android/internal/util/BitUtils.java", "core/java/com/android/internal/util/IndentingPrintWriter.java", "core/java/com/android/internal/util/IState.java", "core/java/com/android/internal/util/MessageUtils.java", "core/java/com/android/internal/util/Preconditions.java", "core/java/com/android/internal/util/State.java", "core/java/com/android/internal/util/StateMachine.java", ], } filegroup { name: "framework-tethering-annotations", srcs: [ "core/java/android/annotation/NonNull.java", "core/java/android/annotation/SystemApi.java", ], } // Build ext.jar Loading api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -1554,6 +1554,7 @@ package android.content { field public static final String SYSTEM_UPDATE_SERVICE = "system_update"; field public static final String TELEPHONY_IMS_SERVICE = "telephony_ims"; field public static final String TELEPHONY_REGISTRY_SERVICE = "telephony_registry"; field public static final String TETHERING_SERVICE = "tethering"; field public static final String VR_SERVICE = "vrmanager"; field @Deprecated public static final String WIFI_RTT_SERVICE = "rttmanager"; field public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; Loading Loading @@ -6644,6 +6645,7 @@ package android.provider { field public static final String INSTALL_CARRIER_APP_NOTIFICATION_SLEEP_MILLIS = "install_carrier_app_notification_sleep_millis"; field public static final String OTA_DISABLE_AUTOMATIC_UPDATE = "ota_disable_automatic_update"; field public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt"; field public static final String TETHER_SUPPORTED = "tether_supported"; field public static final String THEATER_MODE_ON = "theater_mode_on"; field public static final String WEBVIEW_MULTIPROCESS = "webview_multiprocess"; field public static final String WIFI_BADGING_THRESHOLDS = "wifi_badging_thresholds"; Loading core/java/android/app/SystemServiceRegistry.java +12 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,7 @@ import android.net.NetworkPolicyManager; import android.net.NetworkScoreManager; import android.net.NetworkWatchlistManager; import android.net.TestNetworkManager; import android.net.TetheringManager; import android.net.lowpan.ILowpanManager; import android.net.lowpan.LowpanManager; import android.net.nsd.INsdManager; Loading Loading @@ -340,6 +341,17 @@ final class SystemServiceRegistry { } }); registerService(Context.TETHERING_SERVICE, TetheringManager.class, new CachedServiceFetcher<TetheringManager>() { @Override public TetheringManager createService(ContextImpl ctx) throws ServiceNotFoundException { IBinder b = ServiceManager.getService(Context.TETHERING_SERVICE); if (b == null) return null; return new TetheringManager(ctx, b); }}); registerService(Context.IPSEC_SERVICE, IpSecManager.class, new CachedServiceFetcher<IpSecManager>() { @Override Loading core/java/android/content/Context.java +9 −0 Original line number Diff line number Diff line Loading @@ -3857,6 +3857,15 @@ public abstract class Context { */ public static final String NETWORK_STACK_SERVICE = "network_stack"; /** * Use with {@link android.os.ServiceManager.getService()} to retrieve a * {@link ITetheringConnector} IBinder for communicating with the tethering service * @hide * @see TetheringClient */ @SystemApi public static final String TETHERING_SERVICE = "tethering"; /** * Use with {@link #getSystemService(String)} to retrieve a * {@link android.net.IpSecManager} for encrypting Sockets or Networks with Loading core/java/android/net/ConnectivityManager.java +43 −131 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; import android.os.ServiceSpecificException; import android.os.SystemClock; import android.provider.Settings; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading @@ -57,7 +58,6 @@ import android.util.ArrayMap; import android.util.Log; import android.util.SparseIntArray; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.Preconditions; import com.android.internal.util.Protocol; Loading Loading @@ -802,6 +802,7 @@ public class ConnectivityManager { private INetworkManagementService mNMService; private INetworkPolicyManager mNPManager; private TetheringManager mTetheringManager; /** * Tests if a given integer represents a valid network type. Loading Loading @@ -2340,6 +2341,28 @@ public class ConnectivityManager { return getInstanceOrNull(); } private static final int TETHERING_TIMEOUT_MS = 60_000; private final Object mTetheringLock = new Object(); private TetheringManager getTetheringManager() { synchronized (mTetheringLock) { if (mTetheringManager != null) { return mTetheringManager; } final long before = System.currentTimeMillis(); while ((mTetheringManager = (TetheringManager) mContext.getSystemService( Context.TETHERING_SERVICE)) == null) { if (System.currentTimeMillis() - before > TETHERING_TIMEOUT_MS) { Log.e(TAG, "Timeout waiting tethering service not ready yet"); throw new IllegalStateException("No tethering service yet"); } SystemClock.sleep(100); } return mTetheringManager; } } /** * Get the set of tetherable, available interfaces. This list is limited by * device configuration and current interface existence. Loading @@ -2351,11 +2374,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetherableIfaces() { try { return mService.getTetherableIfaces(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetherableIfaces(); } /** Loading @@ -2368,11 +2387,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetheredIfaces() { try { return mService.getTetheredIfaces(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetheredIfaces(); } /** Loading @@ -2391,11 +2406,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetheringErroredIfaces() { try { return mService.getTetheringErroredIfaces(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetheringErroredIfaces(); } /** Loading @@ -2406,11 +2417,7 @@ public class ConnectivityManager { */ @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public String[] getTetheredDhcpRanges() { try { return mService.getTetheredDhcpRanges(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetheredDhcpRanges(); } /** Loading Loading @@ -2439,13 +2446,7 @@ public class ConnectivityManager { */ @UnsupportedAppUsage public int tether(String iface) { try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "tether caller:" + pkgName); return mService.tether(iface, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().tether(iface); } /** Loading @@ -2468,13 +2469,7 @@ public class ConnectivityManager { */ @UnsupportedAppUsage public int untether(String iface) { try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "untether caller:" + pkgName); return mService.untether(iface, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().untether(iface); } /** Loading @@ -2499,16 +2494,7 @@ public class ConnectivityManager { @RequiresPermission(anyOf = {android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public boolean isTetheringSupported() { String pkgName = mContext.getOpPackageName(); try { return mService.isTetheringSupported(pkgName); } catch (SecurityException e) { // This API is not available to this caller, but for backward-compatibility // this will just return false instead of throwing. return false; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().isTetheringSupported(); } /** Loading Loading @@ -2577,14 +2563,7 @@ public class ConnectivityManager { } }; try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "startTethering caller:" + pkgName); mService.startTethering(type, wrappedCallback, showProvisioningUi, pkgName); } catch (RemoteException e) { Log.e(TAG, "Exception trying to start tethering.", e); wrappedCallback.send(TETHER_ERROR_SERVICE_UNAVAIL, null); } getTetheringManager().startTethering(type, wrappedCallback, showProvisioningUi); } /** Loading @@ -2600,13 +2579,7 @@ public class ConnectivityManager { @SystemApi @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void stopTethering(int type) { try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "stopTethering caller:" + pkgName); mService.stopTethering(type, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } getTetheringManager().stopTethering(type); } /** Loading @@ -2628,10 +2601,6 @@ public class ConnectivityManager { public void onUpstreamChanged(@Nullable Network network) {} } @GuardedBy("mTetheringEventCallbacks") private final ArrayMap<OnTetheringEventCallback, ITetheringEventCallback> mTetheringEventCallbacks = new ArrayMap<>(); /** * Start listening to tethering change events. Any new added callback will receive the last * tethering status right away. If callback is registered when tethering has no upstream or Loading @@ -2649,27 +2618,7 @@ public class ConnectivityManager { @NonNull final OnTetheringEventCallback callback) { Preconditions.checkNotNull(callback, "OnTetheringEventCallback cannot be null."); synchronized (mTetheringEventCallbacks) { Preconditions.checkArgument(!mTetheringEventCallbacks.containsKey(callback), "callback was already registered."); ITetheringEventCallback remoteCallback = new ITetheringEventCallback.Stub() { @Override public void onUpstreamChanged(Network network) throws RemoteException { Binder.withCleanCallingIdentity(() -> executor.execute(() -> { callback.onUpstreamChanged(network); })); } }; try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "registerTetheringUpstreamCallback:" + pkgName); mService.registerTetheringEventCallback(remoteCallback, pkgName); mTetheringEventCallbacks.put(callback, remoteCallback); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } getTetheringManager().registerTetheringEventCallback(executor, callback); } /** Loading @@ -2683,17 +2632,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void unregisterTetheringEventCallback( @NonNull final OnTetheringEventCallback callback) { synchronized (mTetheringEventCallbacks) { ITetheringEventCallback remoteCallback = mTetheringEventCallbacks.remove(callback); Preconditions.checkNotNull(remoteCallback, "callback was not registered."); try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "unregisterTetheringEventCallback:" + pkgName); mService.unregisterTetheringEventCallback(remoteCallback, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } getTetheringManager().unregisterTetheringEventCallback(callback); } Loading @@ -2710,11 +2649,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetherableUsbRegexs() { try { return mService.getTetherableUsbRegexs(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetherableUsbRegexs(); } /** Loading @@ -2730,11 +2665,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetherableWifiRegexs() { try { return mService.getTetherableWifiRegexs(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetherableWifiRegexs(); } /** Loading @@ -2750,11 +2681,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetherableBluetoothRegexs() { try { return mService.getTetherableBluetoothRegexs(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetherableBluetoothRegexs(); } /** Loading @@ -2776,13 +2703,7 @@ public class ConnectivityManager { */ @UnsupportedAppUsage public int setUsbTethering(boolean enable) { try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "setUsbTethering caller:" + pkgName); return mService.setUsbTethering(enable, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().setUsbTethering(enable); } /** {@hide} */ Loading Loading @@ -2830,11 +2751,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public int getLastTetherError(String iface) { try { return mService.getLastTetherError(iface); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getLastTetherError(iface); } /** @hide */ Loading Loading @@ -2900,14 +2817,8 @@ public class ConnectivityManager { } }; try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "getLatestTetheringEntitlementResult:" + pkgName); mService.getLatestTetheringEntitlementResult(type, wrappedListener, showEntitlementUi, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } getTetheringManager().requestLatestTetheringEntitlementResult(type, wrappedListener, showEntitlementUi); } /** Loading Loading @@ -4332,6 +4243,7 @@ public class ConnectivityManager { public void factoryReset() { try { mService.factoryReset(); getTetheringManager().stopAllTethering(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading
Android.bp +18 −0 Original line number Diff line number Diff line Loading @@ -266,6 +266,7 @@ filegroup { name: "framework-updatable-sources", srcs: [ ":framework-sdkext-sources", ":framework-tethering-srcs", ":updatable-media-srcs", ] } Loading Loading @@ -370,6 +371,7 @@ java_defaults { "ext", "unsupportedappusage", "updatable_media_stubs", "framework-tethering", ], jarjar_rules: ":framework-jarjar-rules", Loading Loading @@ -605,10 +607,26 @@ filegroup { ], } // keep these files in sync with the package/Tethering/jarjar-rules.txt for the tethering module. filegroup { name: "framework-tethering-shared-srcs", srcs: [ "core/java/android/util/LocalLog.java", "core/java/com/android/internal/util/BitUtils.java", "core/java/com/android/internal/util/IndentingPrintWriter.java", "core/java/com/android/internal/util/IState.java", "core/java/com/android/internal/util/MessageUtils.java", "core/java/com/android/internal/util/Preconditions.java", "core/java/com/android/internal/util/State.java", "core/java/com/android/internal/util/StateMachine.java", ], } filegroup { name: "framework-tethering-annotations", srcs: [ "core/java/android/annotation/NonNull.java", "core/java/android/annotation/SystemApi.java", ], } // Build ext.jar Loading
api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -1554,6 +1554,7 @@ package android.content { field public static final String SYSTEM_UPDATE_SERVICE = "system_update"; field public static final String TELEPHONY_IMS_SERVICE = "telephony_ims"; field public static final String TELEPHONY_REGISTRY_SERVICE = "telephony_registry"; field public static final String TETHERING_SERVICE = "tethering"; field public static final String VR_SERVICE = "vrmanager"; field @Deprecated public static final String WIFI_RTT_SERVICE = "rttmanager"; field public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; Loading Loading @@ -6644,6 +6645,7 @@ package android.provider { field public static final String INSTALL_CARRIER_APP_NOTIFICATION_SLEEP_MILLIS = "install_carrier_app_notification_sleep_millis"; field public static final String OTA_DISABLE_AUTOMATIC_UPDATE = "ota_disable_automatic_update"; field public static final String REQUIRE_PASSWORD_TO_DECRYPT = "require_password_to_decrypt"; field public static final String TETHER_SUPPORTED = "tether_supported"; field public static final String THEATER_MODE_ON = "theater_mode_on"; field public static final String WEBVIEW_MULTIPROCESS = "webview_multiprocess"; field public static final String WIFI_BADGING_THRESHOLDS = "wifi_badging_thresholds"; Loading
core/java/android/app/SystemServiceRegistry.java +12 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,7 @@ import android.net.NetworkPolicyManager; import android.net.NetworkScoreManager; import android.net.NetworkWatchlistManager; import android.net.TestNetworkManager; import android.net.TetheringManager; import android.net.lowpan.ILowpanManager; import android.net.lowpan.LowpanManager; import android.net.nsd.INsdManager; Loading Loading @@ -340,6 +341,17 @@ final class SystemServiceRegistry { } }); registerService(Context.TETHERING_SERVICE, TetheringManager.class, new CachedServiceFetcher<TetheringManager>() { @Override public TetheringManager createService(ContextImpl ctx) throws ServiceNotFoundException { IBinder b = ServiceManager.getService(Context.TETHERING_SERVICE); if (b == null) return null; return new TetheringManager(ctx, b); }}); registerService(Context.IPSEC_SERVICE, IpSecManager.class, new CachedServiceFetcher<IpSecManager>() { @Override Loading
core/java/android/content/Context.java +9 −0 Original line number Diff line number Diff line Loading @@ -3857,6 +3857,15 @@ public abstract class Context { */ public static final String NETWORK_STACK_SERVICE = "network_stack"; /** * Use with {@link android.os.ServiceManager.getService()} to retrieve a * {@link ITetheringConnector} IBinder for communicating with the tethering service * @hide * @see TetheringClient */ @SystemApi public static final String TETHERING_SERVICE = "tethering"; /** * Use with {@link #getSystemService(String)} to retrieve a * {@link android.net.IpSecManager} for encrypting Sockets or Networks with Loading
core/java/android/net/ConnectivityManager.java +43 −131 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; import android.os.ServiceSpecificException; import android.os.SystemClock; import android.provider.Settings; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading @@ -57,7 +58,6 @@ import android.util.ArrayMap; import android.util.Log; import android.util.SparseIntArray; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.Preconditions; import com.android.internal.util.Protocol; Loading Loading @@ -802,6 +802,7 @@ public class ConnectivityManager { private INetworkManagementService mNMService; private INetworkPolicyManager mNPManager; private TetheringManager mTetheringManager; /** * Tests if a given integer represents a valid network type. Loading Loading @@ -2340,6 +2341,28 @@ public class ConnectivityManager { return getInstanceOrNull(); } private static final int TETHERING_TIMEOUT_MS = 60_000; private final Object mTetheringLock = new Object(); private TetheringManager getTetheringManager() { synchronized (mTetheringLock) { if (mTetheringManager != null) { return mTetheringManager; } final long before = System.currentTimeMillis(); while ((mTetheringManager = (TetheringManager) mContext.getSystemService( Context.TETHERING_SERVICE)) == null) { if (System.currentTimeMillis() - before > TETHERING_TIMEOUT_MS) { Log.e(TAG, "Timeout waiting tethering service not ready yet"); throw new IllegalStateException("No tethering service yet"); } SystemClock.sleep(100); } return mTetheringManager; } } /** * Get the set of tetherable, available interfaces. This list is limited by * device configuration and current interface existence. Loading @@ -2351,11 +2374,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetherableIfaces() { try { return mService.getTetherableIfaces(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetherableIfaces(); } /** Loading @@ -2368,11 +2387,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetheredIfaces() { try { return mService.getTetheredIfaces(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetheredIfaces(); } /** Loading @@ -2391,11 +2406,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetheringErroredIfaces() { try { return mService.getTetheringErroredIfaces(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetheringErroredIfaces(); } /** Loading @@ -2406,11 +2417,7 @@ public class ConnectivityManager { */ @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public String[] getTetheredDhcpRanges() { try { return mService.getTetheredDhcpRanges(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetheredDhcpRanges(); } /** Loading Loading @@ -2439,13 +2446,7 @@ public class ConnectivityManager { */ @UnsupportedAppUsage public int tether(String iface) { try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "tether caller:" + pkgName); return mService.tether(iface, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().tether(iface); } /** Loading @@ -2468,13 +2469,7 @@ public class ConnectivityManager { */ @UnsupportedAppUsage public int untether(String iface) { try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "untether caller:" + pkgName); return mService.untether(iface, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().untether(iface); } /** Loading @@ -2499,16 +2494,7 @@ public class ConnectivityManager { @RequiresPermission(anyOf = {android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public boolean isTetheringSupported() { String pkgName = mContext.getOpPackageName(); try { return mService.isTetheringSupported(pkgName); } catch (SecurityException e) { // This API is not available to this caller, but for backward-compatibility // this will just return false instead of throwing. return false; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().isTetheringSupported(); } /** Loading Loading @@ -2577,14 +2563,7 @@ public class ConnectivityManager { } }; try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "startTethering caller:" + pkgName); mService.startTethering(type, wrappedCallback, showProvisioningUi, pkgName); } catch (RemoteException e) { Log.e(TAG, "Exception trying to start tethering.", e); wrappedCallback.send(TETHER_ERROR_SERVICE_UNAVAIL, null); } getTetheringManager().startTethering(type, wrappedCallback, showProvisioningUi); } /** Loading @@ -2600,13 +2579,7 @@ public class ConnectivityManager { @SystemApi @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void stopTethering(int type) { try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "stopTethering caller:" + pkgName); mService.stopTethering(type, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } getTetheringManager().stopTethering(type); } /** Loading @@ -2628,10 +2601,6 @@ public class ConnectivityManager { public void onUpstreamChanged(@Nullable Network network) {} } @GuardedBy("mTetheringEventCallbacks") private final ArrayMap<OnTetheringEventCallback, ITetheringEventCallback> mTetheringEventCallbacks = new ArrayMap<>(); /** * Start listening to tethering change events. Any new added callback will receive the last * tethering status right away. If callback is registered when tethering has no upstream or Loading @@ -2649,27 +2618,7 @@ public class ConnectivityManager { @NonNull final OnTetheringEventCallback callback) { Preconditions.checkNotNull(callback, "OnTetheringEventCallback cannot be null."); synchronized (mTetheringEventCallbacks) { Preconditions.checkArgument(!mTetheringEventCallbacks.containsKey(callback), "callback was already registered."); ITetheringEventCallback remoteCallback = new ITetheringEventCallback.Stub() { @Override public void onUpstreamChanged(Network network) throws RemoteException { Binder.withCleanCallingIdentity(() -> executor.execute(() -> { callback.onUpstreamChanged(network); })); } }; try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "registerTetheringUpstreamCallback:" + pkgName); mService.registerTetheringEventCallback(remoteCallback, pkgName); mTetheringEventCallbacks.put(callback, remoteCallback); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } getTetheringManager().registerTetheringEventCallback(executor, callback); } /** Loading @@ -2683,17 +2632,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void unregisterTetheringEventCallback( @NonNull final OnTetheringEventCallback callback) { synchronized (mTetheringEventCallbacks) { ITetheringEventCallback remoteCallback = mTetheringEventCallbacks.remove(callback); Preconditions.checkNotNull(remoteCallback, "callback was not registered."); try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "unregisterTetheringEventCallback:" + pkgName); mService.unregisterTetheringEventCallback(remoteCallback, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } getTetheringManager().unregisterTetheringEventCallback(callback); } Loading @@ -2710,11 +2649,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetherableUsbRegexs() { try { return mService.getTetherableUsbRegexs(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetherableUsbRegexs(); } /** Loading @@ -2730,11 +2665,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetherableWifiRegexs() { try { return mService.getTetherableWifiRegexs(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetherableWifiRegexs(); } /** Loading @@ -2750,11 +2681,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public String[] getTetherableBluetoothRegexs() { try { return mService.getTetherableBluetoothRegexs(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getTetherableBluetoothRegexs(); } /** Loading @@ -2776,13 +2703,7 @@ public class ConnectivityManager { */ @UnsupportedAppUsage public int setUsbTethering(boolean enable) { try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "setUsbTethering caller:" + pkgName); return mService.setUsbTethering(enable, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().setUsbTethering(enable); } /** {@hide} */ Loading Loading @@ -2830,11 +2751,7 @@ public class ConnectivityManager { @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @UnsupportedAppUsage public int getLastTetherError(String iface) { try { return mService.getLastTetherError(iface); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } return getTetheringManager().getLastTetherError(iface); } /** @hide */ Loading Loading @@ -2900,14 +2817,8 @@ public class ConnectivityManager { } }; try { String pkgName = mContext.getOpPackageName(); Log.i(TAG, "getLatestTetheringEntitlementResult:" + pkgName); mService.getLatestTetheringEntitlementResult(type, wrappedListener, showEntitlementUi, pkgName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } getTetheringManager().requestLatestTetheringEntitlementResult(type, wrappedListener, showEntitlementUi); } /** Loading Loading @@ -4332,6 +4243,7 @@ public class ConnectivityManager { public void factoryReset() { try { mService.factoryReset(); getTetheringManager().stopAllTethering(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading