package android.net;
import androidx.annotation.NonNull;
import java.util.concurrent.Executor;
* Created by Momin.
* @ProjectName:
* @Package: android.net
* @ClassName: TetheringManager
* @Description: java类作用描述
* @Author:
* @CreateDate:
* @UpdateUser: 更新者
* @UpdateDate: 更新时间
* @UpdateRemark: 更新说明
* @Version: 1.0
publicclassTetheringManager {
public@interface StartTetheringError {
* Callback for use with {@link #startTethering} to find out whether tethering succeeded.
publicinterfaceStartTetheringCallback {
* Called when tethering has been successfully started.
defaultvoidonTetheringStarted() {}
* Called when starting tethering failed.
* @param error The error that caused the failure.
defaultvoidonTetheringFailed(@StartTetheringErrorfinalint error) {}
* Starts tethering and runs tether provisioning for the given type if needed. If provisioning
* fails, stopTethering will be called automatically.
* <p>Without {@link android.Manifest.permission.TETHER_PRIVILEGED} permission, the call will
* fail if a tethering entitlement check is required.
* @param type The tethering type, on of the {@code TetheringManager#TETHERING_*} constants.
* @param executor {@link Executor} to specify the thread upon which the callback of
* TetheringRequest will be invoked.
* @hidepublicvoidstartTethering(int type, @NonNullfinal Executor executor,
@NonNullfinal StartTetheringCallback callback) {
* Starts tethering and runs tether provisioning for the given type if needed. If provisioning
* fails, stopTethering will be called automatically.
* <p>Without {@link android.Manifest.permission.TETHER_PRIVILEGED} permission, the call will
* fail if a tethering entitlement check is required.
* @param type The tethering type, on of the {@code TetheringManager#TETHERING_*} constants.
* @param executor {@link Executor} to specify the thread upon which the callback of
* TetheringRequest will be invoked.
* @hide@RequiresPermission(anyOf = {
android.Manifest.permission.TETHER_PRIVILEGED,
android.Manifest.permission.WRITE_SETTINGS
@SystemApi(client = MODULE_LIBRARIES)publicvoidstartTethering(int type, @NonNullfinal Executor executor,
@NonNullfinal StartTetheringCallback callback) {
startTethering(newTetheringRequest.Builder(type).build(), executor, callback);
参数注释 type : 热点类型, 在 TetheringManager 中有相关类型,有下面8种,意思看注释
* Invalid tethering type.
* @see #startTethering.
publicstaticfinalintTETHERING_INVALID= -1;
* Wifi tethering type.
* @see #startTethering.
publicstaticfinalintTETHERING_WIFI=0;
* USB tethering type.
* @see #startTethering.
publicstaticfinalintTETHERING_USB=1;
* Bluetooth tethering type.
* @see #startTethering.
publicstaticfinalintTETHERING_BLUETOOTH=2;
* Wifi P2p tethering type.
* Wifi P2p tethering is set through events automatically, and don't
* need to start from #startTethering.
publicstaticfinalintTETHERING_WIFI_P2P=3;
* Ncm local tethering type.
* @see #startTethering(TetheringRequest, Executor, StartTetheringCallback)
publicstaticfinalintTETHERING_NCM=4;
* Ethernet tethering type.
* @see #startTethering(TetheringRequest, Executor, StartTetheringCallback)
publicstaticfinalintTETHERING_ETHERNET=5;
* WIGIG tethering type. Use a separate type to prevent
* conflicts with TETHERING_WIFI
* This type is only used internally by the tethering module
* @hidepublicstaticfinalintTETHERING_WIGIG=6;