7

I've read a lot posts about it like How to turn on the wi-fi hotspot using ADB? but all of them based on "click emulations", but I have root and it doesn't solve my problem.

I've tried VPN Hotspot app and it work perfectly even without root permissions (using only "WRITE_SETTINGS" perm.)

I need to enable it using command line even when phone is locked, something like:

adb shell su -c service call connectivity 24 i32 0 i32 0 i32 0 s16 random

but for Wi-Fi tethering.

I've Android 11 rooted device.

Update

I found that it is possible to do this through a similar command:

service call tethering 4 null s16 random
void startTethering(in TetheringRequestParcel request, String callerPkg, String callingAttributionTag, IIntResultListener receiver);

But first argument null is wrong because here must be this interface:

parcelable TetheringRequestParcel {
    int tetheringType;
    LinkAddress localIPv4Address;
    LinkAddress staticClientAddress;
    boolean exemptFromEntitlementCheck;
    boolean showProvisioningUi;
    int connectivityScope;
}

How to put it instead of null?

1 Answer 1

8

connectivity service does not have a method to start Wi-Fi hotspot. tethering service indirectly calls wifi service which you can call directly.

startSoftAp and startTetheredHotspot methods start the hotspot, and stopSoftAp stops, as the names suggest.

For Android 11, the order of three methods is 47, 48 and 49 respectively. So to start:

~# service call wifi 47

And to stop:

~# service call wifi 49

No configuration argument is required. Android automatically picks the saved AP configuration.

If a package name is required as argument, try to provide an empty string or null or android or com.android.shell.

Check the method number for your Android version in the service interface file: android.net.wifi.IWifiManager.aidl linked above.

All three methods require android.permission.NETWORK_STACK which has a protection level: signature, so won't work without root.


Related:

2
  • Thanks! It works! But I want to know for the feauture, what I should do when I want to call throw service call method where some argument is object like in my case parcelable TetheringRequestParcel. Is it possible to call some methods like it or only simple like wifi?
    – mixalbl4
    Oct 18, 2022 at 7:37
  • 1
    @mixalbl4 you can only pass basic data types from shell like integers or strings. See service -h. Parcel is a Java object, so you need to write Java code. Oct 18, 2022 at 8:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .