ohmae / dms-explorer

DLNA Player for Android
MIT License
181 stars 31 forks source link

Hotspot mode #62

Open dhanar10 opened 6 years ago

dhanar10 commented 6 years ago

Hi,

Is it possible to make the app working when the android is in hotspot mode? I get a message that i need to turn on wifi on my phone.

Thank you

ohmae commented 6 years ago

In the wifi hotspot, I think that this app will not work because there are restrictions on network by security. (e.g. perhaps multicast does not allowed...🤔) And I think that it is meaningless even if this app works because there is no DLNA server...

dhanar10 commented 6 years ago

Well, it is possible that the client which connect to the hotspot actually has DLNA server running on it (yes, i know this is a weird case)

I just found out that DMS Player as it is on Lenovo K4 Note can run in hotspot mode normally :D but it does not work on Xiaomi Redmi 4X.

According to https://stackoverflow.com/questions/15388300/wifi-hotspot-multicast-broadcast , it seems like hotspot probably has support for multicast.

The simplest way to test it is probably in AndroidLan.java, change

public boolean hasAvailableInterface() {
        final NetworkInfo ni = mConnectivityManager.getActiveNetworkInfo();
        return ni != null && ni.isConnected()
                && (ni.getType() == ConnectivityManager.TYPE_WIFI
                || ni.getType() == ConnectivityManager.TYPE_ETHERNET);
    }

to

public boolean hasAvailableInterface() {
        final NetworkInfo ni = mConnectivityManager.getActiveNetworkInfo();
        return ni != null && ni.isConnected();
    }
ohmae commented 6 years ago

Since I can not reproduce it in my environment, could you tell me the value of ni.getType() in that case? The reason why I am checking ni.getType(), I want to check if there is a local network connection. I want to avoid to send problematic packet to the global network.

ohmae commented 6 years ago

I just noticed... [NetworkInfo#getType()](https://developer.android.com/reference/android/net/NetworkInfo#getType()) was deprecated in API level P. :scream:

dhanar10 commented 6 years ago

I just noticed... NetworkInfo#getType() was deprecated in API level P. 😱

Time to update the implementation then :D

could you tell me the value of ni.getType() in that case?

Let see what I can do to get it. I am a noob when it comes to android app development. :D