Android Wireless Adaptor Support in Emulator - android

I need to re configure wireless adaptor to setup an adhoc network over android phones. I need a way to test it on emulator but i have heard it doesnt has support to it hence cannot be accessed. Is there any way i can do it ? The reconfiguring is done at runtime by a library file by executing low level commands.
In simpler words i need a way to connect 2 or more android virtual devices using wifi adhoc

The emulator does not emulate any form of WiFi. It emulates a generic Internet connection.
Moreover, as Marvin points out, AFAIK, you cannot do ad-hoc mode with Android except on rooted hardware. Hence, most likely, you will need to purchase two devices that you can root.

Related

Connect an AVD to WiFi instead of 3G [duplicate]

How to enable WiFi on Android emulator? I have tried to find this but everyone is confusing WiFi with 3G.
Wifi is not available on the emulator if you are using below of API level 25.
When using an AVD with API level 25 or higher, the emulator provides a
simulated Wi-Fi access point ("AndroidWifi"), and Android
automatically connects to it.
More Information:
https://developer.android.com/studio/run/emulator.html#wifi
Apparently it does not and I didn't quite expect it would. HOWEVER Ivan brings up a good possibility that has escaped Android people.
What is the purpose of an emulator? to EMULATE, right? I don't see why for testing purposes -provided the tester understands the limitations- the emulator might not add a Wifi emulator.
It could for example emulate WiFi access by using the underlying internet connection of the host. Obviously testing WPA/WEP differencess would not make sense but at least it could toggle access via WiFi.
Or some sort of emulator plugin where there would be a base WiFi emulator that would emulate WiFi access via the underlying connection but then via configuration it could emulate WPA/WEP by providing a list of fake WiFi networks and their corresponding fake passwords that would be matched against a configurable list of credentials.
After all the idea is to do initial testing on the emulator and then move on to the actual device.
As of now, with Revision 26.1.3 of the android emulator, it is finally possible on the image v8 of the API 25.
If the emulator was created before you upgrade to the latest API 25 image, you need to wipe data or simply delete and recreate your image if you prefer.
Added support for Wi-Fi in some system images (currently only API
level 25). An access point called "AndroidWifi" is available and
Android automatically connects to it. Wi-Fi support can be disabled by
running the emulator with the command line parameter -feature -Wifi.
from https://developer.android.com/studio/releases/emulator.html#26-1-3
(Repeating here my answer elsewhere.)
In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network.
It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux.
In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.
The emulator does not provide virtual hardware for Wi-Fi if you use API 24 or earlier. From the Android Developers website:
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
You can disable Wi-Fi in the emulator by running the emulator with the command-line parameter -feature -Wifi.
https://developer.android.com/studio/run/emulator.html#wi-fi
What's not supported
The Android Emulator doesn't include virtual
hardware for the following:
Bluetooth
NFC
SD card insert/eject
Device-attached headphones
USB
The watch emulator for Android Wear doesn't support the Overview (Recent
Apps) button, D-pad, and fingerprint sensor.
(read more at https://developer.android.com/studio/run/emulator.html#about)
https://developer.android.com/studio/run/emulator.html#wi-fi
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
Source : https://developer.android.com/studio/run/emulator.html#wi-fi
If your simulator is not connecting to wifi and your in a mac(I don't know how to add DNS in windows) just go to
Network -> advance -> DNS and add 8.8.8.8 and 8.8.4.4 the close the android simulator, open android studio, select the simulator and click on cold reboot then your simulator will be connected to wifi.

Can I connect two Android devices directly using USB?

I need to write a program that will alow an Android device (running version 2.2) to send data (a simple String) to another device (also running version 2.2) via a USB connection. Are there any libraries to do that?
I believe those devices would have to support USB host mode in hardware. And then one of them would need to be out in storage media mode, then you'd use standard filesystem access functions. But the hardware side needs to be dealt with first. I would check out special USB host cables to see what can be done. Not all Android devices can be put into USB host mode.

how to run wifi peer to peer application in android emulator..?

I am trying to develop an wifi peer to peer application in android(4.+).
The problem here is how to test it.
I tried to run that application in android emulator. there was no option to configure wifi in the settings menu, i also tired to enable wifi using the dev tools application form the emulator but it didn't work, And through all my googling over 3 days and i found that Android emulator is not supported the Wifi.
So i opted for androidx86 4.0eeepc using virtual box and tired to add devices both wifi and bluetooth (my app uses both bluetooth and wifi) but only bluetooth device got added and it did not work. But my virtual box detected the wifi and bluetooth devices. I just couldnt get them work with the virtual machine.
I tried everything like manually adding the addresses using terminal emulator app in androidx86 and used netcfg through the android commandline but neither of them worked.
Please suggest and guide me on the correct path to run these kind of applications that use wifi and bluetooth in android.
Thanks in advance.
First, be sure you enabled WiFi Direct in the Android settings for the two virtualbox instances:
Settings --> Wireless & Networks --> More... --> Wi-Fi direct
It has been stated as working once that hurdle was overcome, and I'm sure many have experienced the same...just be sure to enable wifi direct
I would have tried exactly what you've already tried by naturally moving from the emulator to the androidx86 project. Although unreliable, I'd recommend looking at and finagling this, if you haven't yet seen it: Android: Simulate WiFi in the emulator? and How to disable/enable network, switch to Wifi in Android emulator? most likely wouldn't have full out success but may be enough to let you know that it works or would work.
As far as testing WiFi-Direct/WiFiP2P without you yourself having a device/s, I would recommend:
Trying out some of the fiddling as mentioned above. And read through tons of logs.
You could always crowd source it to friends, or release an apk on a forum for a small group of testers.
Of course, both of those options are not ideal, seamless, or fast. So, I'd definitely hope you get VirtualBox VMs of AndroidX86 4.0 running as it should once you check that setting and pair up the WiFi APs :-)
A near future solution:
This might be something to look into in near future.
Real devices are hosted by Samsung and screens are streamed to your PC.
http://developer.samsung.com/remoteTestLab.do
According to an email responded by samsung, which I sent to them earlier.
They only have 2 devices (Galaxy Nexus) running on Android v4.0 at the moment.
Unfortunately they are not physically close to each other. (One in Korea, One in Poland)
But they are planning to upgrade existing Galaxy S2 to v4.0.
Because recently Samsung have released v4.0 upgrade for S2.
Once they done that, there will be plenty of v4.0 phones.
And you can ask them which 2 phones are physically close so you can test Wifi Direct.
--------------------------- EDIT ---------------------------------
There are plenty of ICS devices there now, which you can test P2P.
Check with them which 2 are physically near to each other.
Per the docs:
Each instance of the emulator runs behind a virtual router/firewall
service that isolates it from your development machine's network
interfaces and settings and from the internet.
You have to use Network Redirection, as described in the Developer Docs. In essence, you forward specific ports using ADB. Therefore you cannot test certain things like broadcast messages.
I have tried doing what you are trying to do, and-- while I won't say it is impossible (anything is possible in computing with enough time, money, and persistence)-- I wasted a lot of time on it. You cannot treat the Android emulator as a normal network peer-to-peer device. As far as I have been able to find, it is a fork of QEMU, and that is just how the QEMU emulator is implemented.
QEMU itself does support TUN/TAP bridging, but I was never able to get it working with the Android emulator. If you want to go that route, you may want to investigate running Android in the QEMU emulator, rather than in the SDK's emulator (I see you are already trying a similar approach with VirtualBox).
Unfortunately the best way to test a peer-to-peer networking program in Android is with physical devices at this time-- unless your app can suffice with the port forwarding method.
See Also: Issue 26:Emulated Androids should be able to communicate via TCP, and Google
(Repeating here my answer elsewhere.)
In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network.
It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux.
In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.

Enabling WiFi on Android Emulator

How to enable WiFi on Android emulator? I have tried to find this but everyone is confusing WiFi with 3G.
Wifi is not available on the emulator if you are using below of API level 25.
When using an AVD with API level 25 or higher, the emulator provides a
simulated Wi-Fi access point ("AndroidWifi"), and Android
automatically connects to it.
More Information:
https://developer.android.com/studio/run/emulator.html#wifi
Apparently it does not and I didn't quite expect it would. HOWEVER Ivan brings up a good possibility that has escaped Android people.
What is the purpose of an emulator? to EMULATE, right? I don't see why for testing purposes -provided the tester understands the limitations- the emulator might not add a Wifi emulator.
It could for example emulate WiFi access by using the underlying internet connection of the host. Obviously testing WPA/WEP differencess would not make sense but at least it could toggle access via WiFi.
Or some sort of emulator plugin where there would be a base WiFi emulator that would emulate WiFi access via the underlying connection but then via configuration it could emulate WPA/WEP by providing a list of fake WiFi networks and their corresponding fake passwords that would be matched against a configurable list of credentials.
After all the idea is to do initial testing on the emulator and then move on to the actual device.
As of now, with Revision 26.1.3 of the android emulator, it is finally possible on the image v8 of the API 25.
If the emulator was created before you upgrade to the latest API 25 image, you need to wipe data or simply delete and recreate your image if you prefer.
Added support for Wi-Fi in some system images (currently only API
level 25). An access point called "AndroidWifi" is available and
Android automatically connects to it. Wi-Fi support can be disabled by
running the emulator with the command line parameter -feature -Wifi.
from https://developer.android.com/studio/releases/emulator.html#26-1-3
(Repeating here my answer elsewhere.)
In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network.
It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux.
In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.
The emulator does not provide virtual hardware for Wi-Fi if you use API 24 or earlier. From the Android Developers website:
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
You can disable Wi-Fi in the emulator by running the emulator with the command-line parameter -feature -Wifi.
https://developer.android.com/studio/run/emulator.html#wi-fi
What's not supported
The Android Emulator doesn't include virtual
hardware for the following:
Bluetooth
NFC
SD card insert/eject
Device-attached headphones
USB
The watch emulator for Android Wear doesn't support the Overview (Recent
Apps) button, D-pad, and fingerprint sensor.
(read more at https://developer.android.com/studio/run/emulator.html#about)
https://developer.android.com/studio/run/emulator.html#wi-fi
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
Source : https://developer.android.com/studio/run/emulator.html#wi-fi
If your simulator is not connecting to wifi and your in a mac(I don't know how to add DNS in windows) just go to
Network -> advance -> DNS and add 8.8.8.8 and 8.8.4.4 the close the android simulator, open android studio, select the simulator and click on cold reboot then your simulator will be connected to wifi.

USB Android I/O

Is it possible to access the USB port on Android phones? (Droid X for example)
Here is my usage case:
Have a USB device attached to the Android phone. The phone listens for data on this USB device. (The USB device is connected to a USB->RS-232 converter that has I/O attached to it)
This would be slick if possible. Does anyone know if this is possible?
Would be slick, yup. Not possible though. There's a feature request for it: http://code.google.com/p/android/issues/detail?id=738
Actually it is possible on a lot of the phones if you are able to install a new kernel with a USB host driver and rig up a custom cabling scheme to provide usb bus power to the device as the phone won't. A few phones even shipped with this capability already live.
I don't know if the Droid X specifically ships with this already, can have it added (if you are able to flash kernels), could have it added but no one has written the host driver yet, or is missing the hardware capability.
You also would need to enable the appropriate usb serial converter device driver (identified by experimenting with the device on a desktop linux box), but that's probably already in the kernel sources and just needs to be selected in the config. You may also need to create a device file for the /dev/ttyUSB0 or whatever and give it permissions appropriate to the application that wants to access it. (This requires root, but if you can reflash the kernel, you can get root)
If you want to pursue this, search the android kernel google group for posts about USB host mode.
One serious downside to putting the USB into host mode is that you loose the adb interface into the phone, which makes working on your projects hard. You'll probably need to either build an adapter for the low voltage debug serial port if there is one (as on G1, mytouch, etc) so you can get a console shell (or just use that instead of USB to talk to your peripheral) or at a minimum set up an ssh and sftp server on the wifi.
Since you want serial anyway, another option people have used is to get a bluetooth-to-serial module from an outfit such as sparkfun.
A bluetooth to serial adapter might solv your problems.
You can find one at https://www.sparkfun.com/products/582. Boards from other companies are also available for example on ebay.

Categories

Resources