Git Product home page Git Product logo

accesspoint's People

Contributors

moskvax avatar mvdan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

accesspoint's Issues

Is it possible to support WifiManager.NETWORK_STATE_CHANGED_ACTION?

This may be a long shot, and I am currently not able to think of a specific way to implement this, but can anybody think of a way to support broadcasting a WifiManager.NETWORK_STATE_CHANGED_ACTION intent when the WiFi AP gets enabled or disabled?

This is the way that the WifiManager currently notifies Android apps that they have gained or lost access to a wireless network. It would be extremely helpful to be able to be notified when a WiFi AP is connected to or disconnected from.

There may or may not be some underlying events/broadcasts that can be retrieved via, e.g. BroadcastReceivers or maybe some lower level thing which is only accessible via reflection that I'm unware of.

provide method to get IP address

It would be very useful to be able to get the IP address of the hotspot. I have found that wifiManager.getConnectionInfo() returns 0 for the IP address and WifiStateChangeReceiver thinks there is no connection. But from the command line, I can get the IP address using ifconfig, so there has got to be a way to get it.

Configurations are not applied

Trying to setup an access point on Android 6.0.1, I can start the access point mode but the configurations are not applied correctly, the default network-name and password are set.

DHCP not working on Android 7.1 and later

Have noticed that in 7.1 it still creates the hotspot, but it appears the DHCP server is not starting correctly and IP addresses are not being given out correctly to clients trying to connect. They make it through the authentication phase but then are disconnected.

Remove getInstance() method with no args

I propose removing the WifiApControl.getInstance() method which doesn't take a Context as an argument.

As a general principle, it is a good idea to have code behave in such a way that you don't need to know what has happened in the past. Otherwise, when reading a line of code which invokes this method, a reviewer of the code will have to ask themselves:

"Has something, somewhere in the past, invoked WifiApControl.getInstance(Context)? If so, will this always be the case?"

Given that it is not uncommon in Android development to ask for a Context, I think it is much safer to always ask for a Context in order to get access to a WifiApControl instance. If the consumer of your API does not have access to a Context, that is not the problem of libaccesspoint, but rather the problem of the consumer. They should be responsible for ensuring there is always a Context available at the time they need to get an instance of WifiApControl.getInstance(...).

An API which makes it hard to shoot yourself in the foot is a good API in my book.

Not working on Samsung Galaxy S5 SM-G900V Android 6.0.1

I don't know if it's just a problem of Samsung. I test the same application on a BLU smartphone and the access point was created. On Samsung didn't work. I received this exceptions:
E/WifiApControl: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at cc.mvdan.accesspoint.WifiApControl.invokeQuietly(WifiApControl.java:178)
at cc.mvdan.accesspoint.WifiApControl.setWifiApEnabled(WifiApControl.java:250)
at cc.mvdan.accesspoint.WifiApControl.setEnabled(WifiApControl.java:259)
at cc.mvdan.accesspoint.WifiApControl.enable(WifiApControl.java:264)
at cu.yleyvag.quizzdroid.presentation.ui.InviteActivity.onCreate(InviteActivity.java:47)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10275 nor current process has android.permission.CONNECTIVITY_INTERNAL.
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.net.wifi.IWifiManager$Stub$Proxy.setWifiApEnabled(IWifiManager.java:1964)
at android.net.wifi.WifiManager.setWifiApEnabled(WifiManager.java:2192)
at java.lang.reflect.Method.invoke(Native Method) 
at cc.mvdan.accesspoint.WifiApControl.invokeQuietly(WifiApControl.java:178) 
at cc.mvdan.accesspoint.WifiApControl.setWifiApEnabled(WifiApControl.java:250) 
at cc.mvdan.accesspoint.WifiApControl.setEnabled(WifiApControl.java:259) 
at cc.mvdan.accesspoint.WifiApControl.enable(WifiApControl.java:264) 
at cu.yleyvag.quizzdroid.presentation.ui.InviteActivity.onCreate(InviteActivity.java:47) 
at android.app.Activity.performCreate(Activity.java:6876) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

Logo offer for Accesspoint

Hi sir. I'm graphics designer. I have studied your work. I think a new logo will make you more visible. I would like to offer logo. I can give you all the formats of the design free.

Best regard
Famil

java.lang.NumberFormatException

Caused by java.lang.NumberFormatException: Invalid int: "0x080027C446C0"
at java.lang.Integer.invalidInt(Integer.java:137)
at java.lang.Integer.parse(Integer.java:377)
at java.lang.Integer.decode(Integer.java:187)
at cc.mvdan.accesspoint.WifiApControl.macAddressToByteArray(WifiApControl.java:171)
at cc.mvdan.accesspoint.WifiApControl.getDeviceName(WifiApControl.java:147)
at cc.mvdan.accesspoint.WifiApControl.(WifiApControl.java)
at cc.mvdan.accesspoint.WifiApControl.getInstance(WifiApControl.java:126)

Broken on 6.0+

When attempting to use the library on several 6.0 Nexus 5 the access point is neither configured or enabled.

The following error is seen in logcat:

'W/WifiApControl: None found - falling back to the default device name: wlan0'

Got a bunch of 5.1.1 devices that this works on without issue.

Android 7.1: Access point created but no internet connection

Hi,

I tried to manage my accesspoint with your library on a OnePlus3 running android 7.1. To avoid any mistakes in my implementation I tested your sample app.

Enabling a hotspot works fine. Also another wireless device is able to find the hotspot and connect to it. Unfortunately the device says that there is no connection to the internet. If I manually enable the hotspot through android settings the internet connection works fine.

Can I do something about it or is this a bug related to android 7.1 or my OnePlus 3?

Is this issue caused for the same reason as in this post ?

Automatically detect WLAN device name on newer devices

When I tested with this nice library on the LG phone, all the things work like a charm. If I switch to Samsung S7, the getClients function seems broken. I tried to dig into the code. It seems that the devicename for the AP on S7 is swlan0. But the devicename was fallback to wlan0 because it is Marshmallow.

Can we specify the devicename explicitly instead?

Only catch reflection exceptions

With regards to the API design, I'd suggest only catching the most specific exceptions that are relevant to you. For example, most of the methods which invoke methods via reflection do it like so:

public boolean isWifiApEnabled() {
    try {
        return (Boolean) isWifiApEnabled.invoke(wm);
    } catch (Exception e) {
        Log.e(TAG, "", e);
    }
    return false;
}

I'd suggest only catching the exceptions to do with reflection. That way, if a genuine exception occurs inside one of the hidden API methods, then it will get thrown to the consumer of your API.

The tricky part is trying to identify if there are any checked exceptions (ones which must be caught or thrown in the hidden API, because it may well differ depending on the version of Android which provides the API.

I'm happy to submit pull requests for this and other issues I'll submit, just documenting now for prosterity.

Support for band and channel selection.

Please add support for band and channel selection, which can be done through reflection over wificonfiguration

/**
     * 2GHz band.
     * @hide
     */
    public static final int AP_BAND_2GHZ = 0;

    /**
     * 5GHz band.
     * @hide
     */
    public static final int AP_BAND_5GHZ = 1;

    /**
     * The band which AP resides on
     * 0-2G  1-5G
     * By default, 2G is chosen
     * @hide
     */
    public int apBand = AP_BAND_2GHZ;

    /**
     * The channel which AP resides on,currently, US only
     * 2G  1-11
     * 5G  36,40,44,48,149,153,157,161,165
     * 0 - find a random available channel according to the apBand
     * @hide
     */
    public int apChannel = 0;

Thanks :)

About AP's password

Thank you for the sharing.
I have a question, is it possible to set AP's password?

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.