Git Product home page Git Product logo

Comments (23)

tk721 avatar tk721 commented on July 19, 2024 3

Ran into the same issue (Android 7.1.1, Nexus 5X). The behavior of the underlying Android API seems to have changed in 7.1. It used to put the interface into Wi-Fi AP mode, configure it with an IP address, and run a DHCP server. Now it only puts the interface into Wi-Fi AP mode and nothing else.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

Please provide more info.

  • What version of the library is this?

  • Does the hotspot work when started manually?

  • What code are you using to set up the hotspot?

  • Does it only happen in newer Android versions, or also on older ones?

  • Did you check the logcat?

from accesspoint.

compscidr avatar compscidr commented on July 19, 2024

Thanks for the quick feedback - here's the responses to your questions:
What version of the library is this?

  • version 0.2.0
    Does the hotspot work when started manually?
  • yes
    What code are you using to set up the hotspot?
if(!apControl.isEnabled()) {
                WifiConfiguration apConfig = getApConfig();
                wifiManager.setWifiEnabled(false);
                apControl.setEnabled(apConfig, true);
                apControl.enable();
}

Does it only happen in newer Android versions, or also on older ones?

  • Only happens on 7.1 (works on everything else from 4.x to 7.0)
    Did you check the logcat?
  • Logcat was reporting an error with dnsmasq a couple weeks ago, but they have since release another update and there is no longer an error. On the logcat when I create a hotspot manually I see some output from the DHCP server that I don't see when the hotspot is created with the library
  • After the client associates I see a message on logcat, but before it receives a dhcp offer there is a message saying the client disconnected.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

WifiConfiguration apConfig = getApConfig();
wifiManager.setWifiEnabled(false);
apControl.setEnabled(apConfig, true);
apControl.enable();

See what apControl.enable() does; the getApConfig and setEnabled lines are redundant.

Otherwise I can't see anything obviously broken here. Are you on an official 7.1 ROM, or a nightly like cyanogenmod? I am on a cm14.1 nightly as of a couple of days ago, so I will play with it tomorrow to see if it works on my nexus 6.

from accesspoint.

compscidr avatar compscidr commented on July 19, 2024

the getApConfig line just returns a filled in WifiConfiguration as follows:

WifiConfiguration config = new WifiConfiguration();
        config.SSID = "testnetwork";
        config.BSSID = "";
        config.hiddenSSID = false; 
        //the config, we do not do this.
        config.preSharedKey = "testwpa2key";
        config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
        //config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        config.allowedKeyManagement.set(WPA_PSK2);
        config.status = WifiConfiguration.Status.ENABLED;
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
        config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
        config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
        config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);

I'll try removing the redundant enable lines and see if that makes a difference.

Using the stock 7.1 that ships with the pixel. I also have a nexus 6p with 7.0 - it seems to work well still on this device, but for some reason 7.1 is a bit different.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

Use triple backticks for multiline snippets; I've fixed your comments.

I'll try removing the redundant enable lines and see if that makes a difference.

Probably won't, but worth a try.

Using the stock 7.1 that ships with the pixel. I also have a nexus 6p with 7.0 - it seems to work well still on this device, but for some reason 7.1 is a bit different.

Would be helpful if we could see if this is a problem with 7.1 in general or not. Maybe the library needs tweaking to work with this new Android version.

from accesspoint.

cristeab avatar cristeab commented on July 19, 2024

Having the same problem, did anyone find a solution ?

from accesspoint.

compscidr avatar compscidr commented on July 19, 2024

Nothing yet - I tried reporting through the bug reporter on the pixel, turns out that's not a good place for submitting dev related bugs - they didn't know what I was talking about ;)

Probably worth filing a ticket somewhere on their development support but I haven't got around to it. I can't tell if its actually a bug or if they are trying to phase out the ability to create an AP with code.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

The code to start the DHCP server must be in AOSP somewhere. If anyone finds it or has a patch, I'll be happy to help. I'll try to have a look into it soon.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

For the record, lots of people have been looking into this for Tasker, which also has broken tethering on 7.1: https://groups.google.com/forum/#!topic/tasker/Rf75hoZjDTo

It includes people trying static IPs and ipv4 forwarding (which doesn't seem to work) and system-level permission usage (which does seem to work).

We won't use system-level permissions though, as that would mean the library would be useless unless the app using it is a privileged system app.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

Some bits of info:

  • The example seems to look OK on my 7.1 device, but as you guys say, devices won't connect to the AP even though they see it.
  • The WiFi tethering icon is visible in the status bar, but if I go to "Tethering & portable hotspot" the "Portable Wi-Fi hotspot" is off. I don't know if this used to be like this on older Android versions, and can't check.
  • Funnily enough, I can't properly set up a Wi-Fi AP on the phone after trying out the example app. Not even a full reboot on the phone fixes it. On my laptop, I see:
wlp3s0: authenticate with 92:68:c3:f5:49:97
wlp3s0: send auth to xx:xx:xx:xx:xx:xx (try 1/3)
wlp3s0: authenticated
wlp3s0: associate with xx:xx:xx:xx:xx:xx (try 1/3)
wlp3s0: RX AssocResp from xx:xx:xx:xx:xx:xx (capab=0x11 status=0 aid=1)
wlp3s0: associated
wlp3s0: deauthenticating from 92:68:c3:f8:a3:ac by local choice (Reason: 1=UNSPECIFIED)

The same three times, until it gives up. Pretty sure it's not the laptop, as I've used Wi-Fi tethering with my phone before, and it connects to the home network just fine.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

Also, this is a shot in the dark, but please try a build from master: library.zip

I bumped the target SDK from 23 to 25 and updated a couple of other things. I don't expect this to fix the issue, but worth a try.

from accesspoint.

ariqbanihardi avatar ariqbanihardi commented on July 19, 2024

Hey guys. Is there any solution about this issue,. I have a same problem and have not found it's solution

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

I'm afraid noone here has found the solution either. As far as we know, there isn't a way to achieve the old behavior in newer Android versions unless you have root or install the app as a system app.

from accesspoint.

ariqbanihardi avatar ariqbanihardi commented on July 19, 2024

Hi @mvdan . Thank's for your great library. when I creat AP and I try to setup some parameter like SSID, channel, security, it really created with that parameters setted too. But the AP didn't give IP address. In some forum they said maybe this was issue on AOSP 7.1. if I have root my device, how can I solve this problem?

from accesspoint.

Sachin-Radhakrishnan avatar Sachin-Radhakrishnan commented on July 19, 2024

Hi @mvdan : I'm trying to use your library to enable the HotSpot on Nexus 6.

I'm able to turn on the hotspot with the specific ssid and password but then when I try to connect another device to my AP it's impossible to establish a connection.It got stuck at "Obtaining IP address ..."

When i manually go and change the toggle status of the hotspot,it works fine...

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

Yes, that is exactly what this issue is about. Please only post here if you have any new information about the issue or how to fix it.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

Again, please don't comment on this thread unless you have something to add. Repeating that DHCP doesn't work is just going to spam and annoy everyone subscribed to the issue. I'm going to start deleting comments if it keeps happening.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

A couple of people had already mentioned that manually starting the hotspot did work. They didn't mention the system interface nor the settings though, so perhaps that's why you didn't find it.

The original poster reported that it worked on a 7.0 device, so I'm not going to change the title for now - at least not until we have more information.

from accesspoint.

geekywoman avatar geekywoman commented on July 19, 2024

Hi everyone,

I ran into this problem as many of you here, and after many (painful) days of investigation I have found something that might be of some help. The solution is to actually completely ignore the hotspot feature from the Android SDK :) Who would have guessed? Well apparently shinilms is part of the people who figured this out. Huge thanks to him!

Here is a no-root solution from shinilms:
https://github.com/shinilms/direct-net-share
(it enables the hotspot and requires the user to setup a proxy on his phone)

And here is my small contribution:
https://github.com/geekywoman/direct-net-share
We take advantage of the root rights to do the magic with the DHCP so the user does not need to setup any proxy manually.

Hope it helps!

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

Thanks for the information, @geekywoman! I'll gladly deprecate this project in favor of a newer one that actually works on newer Android versions. Does that method work on older versions too?

Which one should I link to at the top of the README here - the original repo, or your fork? I presume that you'd want to upstream the root capabilities, as an optional feature.

from accesspoint.

geekywoman avatar geekywoman commented on July 19, 2024

I tested my fork on 7.1.1 and on 6.0.0 versions, everything works fine :)

For the link on top of the README, it is up to you, whatever you think is best! I guess you would like to advertise the original repo from shinilms has there is no need for root.
My fork works with both actually. Without root, one will need to setup the proxy into settings manually as advertised in shinilms repo. If root rights are granted, one will be connected to this alternative hotspot right away ;)

Another alternative that could interest people: https://github.com/aegis1980/WifiHotSpot I have tested on Oreo and it works great! Unfortunately it is not working on 7.1.1. This is why I ended with the previous solution I shared with you. But I am sharing it here just in case people are looking for another alternative.

from accesspoint.

mvdan avatar mvdan commented on July 19, 2024

@geekywoman thank you - I've clarified that the project is abandoned, and linked to all three projects in the README. If the list ever needs updating, just send a pull request to update the markdown file.

from accesspoint.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.