How to change usb number? - android

I'm going to let my GPS and 4G module worked.
My 4G module will using ttyACM0~5.
My GPS is using ttyACMX.
Here is the problem, 4G module need to be using on ttyACM0~5.
But if GPS power on first then it will take ttyACM0 and will cause my 4G module can't worked.
So I'm trying to let GPS tied on ttyACM6 when booting but I don't know how to do it.
Which driver should I modify or any other methods can get this worked?

if you have i.e. vendor id and product id of your GPS and 4G device you can assign static device nodes in linux using udev rules
this is described in https://unix.stackexchange.com/questions/66901/how-to-bind-usb-device-under-a-static-name and http://www.thelinuxdaily.com/2010/01/statically-assign-dev-nodes-to-hardware-devices-in-linux/
the name of the static device node can be chosen in the SYMLINK+="..." field
you can get vendor id and product id of your devices with lsusb or lsusb -v when your devices are plugged in ...

Related

How to access single USB devices of a Composite USB device?

I would like to send data from my Windows computer to my Android Mobile.
For this, I need to activate the Accessory mode of the Android device and the USB Host mode on the Windows device.
On my Windows computer, I have a USB Composite device for the Android Mobile. This Composite USB device bundles several interfaces: Enumeration of USB Composite Devices.
Unfortunately, I can't find information how I can access the single devices of a Composite device.
I want to get a device id / path, which I can open with CreateFile to use the created HANDLE for opening a WinUsb handle with WinUsb_Initialize.
But if I try to open a Composite USB device with CreateFile, I get a ERROR_NOT_ENOUGH_MEMORY result.
I'm using this code:
_deviceHandle = CreateFile(
deviceId, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_NONE, NULL,
OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
... with the filename "\?\USB#VID_04E8&PID_6864#RF8NB0NMT0X#{a5dcbf10-6530-11d2-901f-00c04fb951ed}"
It's a GUID_DEVINTERFACE_USB_DEVICE device id for a Samsung Galaxy mobile with enabled USB debugging.
As the driver Windows uses ssudbus2.sys, Version 2.17.16.0 (2021-09-14) from Samsung Electronics Co. Ltd.
The app MyPhoneExplorer can access to my mobile. So it a solution without a special driver must be possible.
How can I get this device id / path of the single USB devices inside a Composite USB device?
The filename you are using represents the overall USB device; it doesn't represent any particular instance. A filename that represents interface will have something like &mi_01 right after the product name, where 1 is the 0-based interface number.
You might be able to just insert the appropriate &mi_xx string into your filename at the appropriate place and get it work. I think you'd also need to modify the GUID at the end of the string, which is the device interface GUID.
The more standard way to find the filename in code is to use the SetupAPI and the configuration manager (CM) API to iterate through all the child devices of your USB device. Look for a child whose device instance ID (retrieved with CM_Get_Device_ID) contains MI_xx where xx is the two-digit interface number you are looking for.
It takes a lot of effort to write up this code in standalone form, and test it, and debug it, so I will not be presenting you with a working code example. Instead, I encourage you to look at the working code in the get_interface_composite function of libusbp which does what you need to do:
https://github.com/pololu/libusbp/blob/759f48d/src/windows/interface_windows.c#L86
There are some more steps to get the path of that device node. And then the code that actually calls CreateFile and WinUsb_Initialize is here:
https://github.com/pololu/libusbp/blob/759f48d/src/windows/generic_handle_windows.c#L56-L77

Changing the Wifi name for a Virtual Android Device

The Android Virtual Device is connected by defualt to a wifi network called "AndroidWifi". I am working with an app that expects to be connected to a wifi network with a particular name.
How can I change the name of the wifi network from "AndroidWifi"?
Try something more pragmatic:
String getExpectedId() {
String ssid = this.getResources().getString(R.string.default_ssid);
if(Build.FINGERPRINT.contains("generic")) {ssid = "AndroidWifi";}
return ssid;
}
because you won't change the SSID (service set identifier) of the emulator's WiFi.
Despite there's adb commands alike svc wifi enable and svc wifi disable, the password for the default network likely is unknown in /data/misc/wifi/wpa_supplicant.conf; see Connecting to WiFi using adb shell. Since the emulator is rooted, one can generally configure any network alike that, while it is accessible (which the regular WiFi, which is exists in reality, obviously isn't). I think the first one approach is better, because editing emulator images isn't too portable.
AVD manager doesn't provide any ways to customize the simulated Wi-Fi access point AndroidWifi .
You may have to disable it and use another wifi simulator such as this one. It does need the Xposed framework in order to function. Here is how you can configure it.
You can modify the hostapd.conf file in your device (/data/vendor/wifi/hostapd/hostapd.conf). It will allow you to set ssid (ssid=) or even to set a password (wpa_passphrase). You will need a root access to do that.
More details at https://wiki.gentoo.org/wiki/Hostapd#WiFi_Technology

Getting Manufacturer Vendor ID for ADB

Is there any "universal" vendor ID that I can use so that ADB can detect my China-made Tablet? I can't find the vendor ID of the manufacturer. When I look into Device Manager in Windows the Vendor is a string and not a number. The device is a Cherry Mobile Fusion Bolt tablet.
Try this tool if you are on a windows machine- lsusb Link
If you are on a linux machine, you can run the lsusb command.
The tool is for windows platform. Run it while your tablet is connected through a USB. It may show your Vendor ID. If it does, you can try manually adding it to [USER_DIRECTORY] / .android / adb_usb.ini.
The vendor ID of the device can not be modified without replacing the software on the device (read a new AOSP installation). To use the Google driver, the Vendor ID of the product needs to be known.
Finding Vendor ID in Windows
Start Device Manager
In the Hardware tree, right-click the hardware entry for the device for which the Vendor ID is to be determined.
On the Details tab, set the property drop-down to be "Hardware Ids". The Vendor ID is the 4 character hexadecimal number following the letters VID_. In the case below, the Vendor ID is 18D1:
The PID_, which follows, is the Product ID. It also has a 4-digit hexadecimal number.

How to get Vendor ID of an Android-powered device via adb?

I have a problem with how to get vendor ID and product ID of an Android-powered device.
Are there any commands of adb that can do this?
I can get vendor id and product id while device inserted, but after installing windows drivers, I could not tell apart the real vendor id if I insert two devices at on time. So I need to find out the vendor ID via ADB or any other connections between the hardware device and the android device.
If you are running Ubuntu/Linux Just Key in
lsusb -v
and press enter.
It will bring out details of all USB devices.
Check for a field called "idVendor" in the results and find your device.
Eg: My Motorola Defy[vendor id = 22b8] gives,
" idVendor 0x22b8 Motorola PCS"
i don't know whether you got the solution but connecting my phone via USB cable to my computer and typing the below line of code on ubuntu terminal i was able to get Vendor ID
lsusb
For example, if you had a Nexus One connected you would get:
Bus 002 Device 004: ID 18d1:4e12
In this case the Vendor Id is “18d1″ and the Product ID is “4e12″. (we are interested in vendor id of course)
ADB itself will not help find the Vendor ID of a connected piece of hardware, indeed (for the Google ADB driver) it's necessary to have the Vendor ID set up in advance of it working with ADB.
Fortunately, there's an easy way to find the Vendor ID (and Product ID) of any device connected to a Windows PC. The device doesn't even need drivers for this approach to work:
Start Device Manager
In the Hardware tree, right-click the hardware entry for the device for which the Vendor ID is to be determined.
On the Details tab, set the property drop-down to be "Hardware Ids". The Vendor ID is the 4 character hexadecimal number following the letters VID_. In the case below, the Vendor ID is 18D1:
The PID_, which follows, is the Product ID. It also has a 4-digit hexadecimal number.
if you want to get in your android application you can use following code
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
while (deviceIterator.hasNext()) {
UsbDevice device = deviceIterator.next();
Log.e("DB", gson.toJson(device));
}
Hope this link help you
-s serialNumber is the adb command that give you a specific emulator/device instance, referred to by its adb-assigned serial number (such as "emulator-5556").I think this is the adb command that you are looking for.

Set Data roaming on/off

How could I programmatically set data roaming on/off in my android application ?
Apologies in advance for reopening a dead post but I have managed to achieve it by calling this executable:
su -c settings put global data_roaming0 1
Also to get the roaming setting for first SIM card:
su -c settings get global data_roaming0
If your app is signatureOrSystem/Privileged app (app resides in /system/priv-app) and your have valid android.permission.WRITE_SECURE_SETTINGS permission in system/etc/permissions. Then you can do it as below.
Enable :
Settings.Global.putInt(context.getContentResolver(), Settings.Global.DATA_ROAMING, 1)
Disable :
Settings.Global.putInt(context.getContentResolver(), Settings.Global.DATA_ROAMING, 0)
I hope that it's not possible to turn on data roaming programmatically as this would be a serious security issue from my point of view ...
Data roaming (i.e. UMTS data transfer via a foreign network) may result in a huge bill from your network provider - at least in europe.
If data roaming is currently on, then I think you can manipulate the Access Points Names in order to make it appear that a data service isn't available. See this post which also links to apndroid. You could browse their source and see the approach they have taken.
If data roaming has been set to off by the user, then this approach won't work. Though you could prompt users to turn it on as part of your install/setup process, which is the route apndroid take.
apndroid also provide an API for changing these kind of settings, which might be more convenient than reimplementing the same functionality.
On rooted devices when using su to enable data roaming, on multi sim devices the data roaming setting is sim specific.
So you need to get the sim number that is active for data calls
sim_num = settings get global multi_sim_data_call
and use this in the data_roaming + sim_num setting. EG sim_num 3
settings get global data_roaming3
if this is null then not multi sim device and use data_roaming otherwise use
settings put global data_roaming3
I was able to enable data roaming on my dual sim Motorola G8 without the need to root it via ADB. I'm posting here the procedure, because the phone has a bug that prevents data roaming from being enabled normally.
You need a computer and to install ADB installed
Enable developer mode and USB debugging in your phone
Connect the phone to the computer via USB and accept the debugging connection.
Start an "adb shell", be sure that it is correctly connected to your phone.
Issue the command
settings put global data_roaming1 1
to enable data roaming for SIM card 1, or
settings put global data_roaming2 1
to enable it for SIM 2
Note: if you do not have the USB cable, this can be done via wifi, but the pairing process is a bit complicated and version dependent.
If you do not have a computer, it may be possible to run the commands directly on the phone using a "local adb" app (there are a few on the play store), but I have not tested any.

Categories

Resources