I have 3-4 android devices connected to my laptop (with working ADB on windows). Now I want to trigger Youtube app on all these devices simultaneously and run that for a certain duration at a given time. The script will read the devices connected and trigger the app on it's own.
Requirement:
Is there a way I can take out the Unique Device ID and store it somewhere and use it for my rest of the programming?
For example:
C:\Users\Arka.B>adb devices
List of devices attached
94e38259 device
94e38260 device 2
94e38261 device 3
94e38262 device 4
Questions:
How do I take out this unique device id (94e38259, 94e38260, etc in this case) from each of these devices and trigger some other actions like launching an app or installing an APK?
You can store the device ids using following script:
my $output = `adb devices`;
my #devices = split("\n", $output);
my #deviceids;
foreach(#devices){
chomp($_);
push(#deviceids, $1) if($_ =~ /(.+)\s+device$/);
}
Related
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
I need serial number or something that works similarly because our company creates applications for VR and I create web API that must recognize a specific device in several applications, because we assign subscriptions to the customer per device.
SystemInfo.deviceUniqueIdentifier can't be because it generates a different id for each application.
So far I have used this:
AndroidJavaObject jo = new AndroidJavaObject("android.os.Build");
string serial = jo.GetStatic<string>("SERIAL");
return serial;
but on android 10 it stops working and for HTC VIVE Focus HMD this function does not work at all.
Perfectly, I would use some id that is invariant for a given device if it's possible. I also allow the use of some id that will be created for the user and removed when the device is reset to initial state.
I am Testing an android app on multiple real devices like the Samsung S6 and S7 and both are connected to the machine at the same time.
Using Appium library within Robot Framework; Open Application keyword always opens the application which comes first in the list of "adb devices".
Key word used :
Open Application ${APPIUM_SERVER_URL} alias=MyMv1 platformName=${PLATFORM_NAME} platformVersion=${PLATFORM_VERSION} deviceName=${DEVICE_NAME} appPackage=${app_package_name} appActivity=${activity} automationName=appium
It seems deviceName is not working, and I can give any value to it.
Library Version Used :
robotframework==3.0.2
robotframework-appiumlibrary==1.4.3
We are creating an app for android watch (in my case sony 3) that needs a kiosk mode.
Using
adb shell
dpm set-device-owner com.example/.MyDeviveAdminReceiver
I get
Can't set package com.example as device owner.
using
db shell pm list features
I get
feature:reqGlEsVersion=0x20000
feature:android.hardware.bluetooth
feature:android.hardware.bluetooth_le
feature:android.hardware.faketouch
feature:android.hardware.location
feature:android.hardware.location.gps
feature:android.hardware.microphone
feature:android.hardware.screen.portrait
feature:android.hardware.sensor.accelerometer
feature:android.hardware.sensor.compass
feature:android.hardware.sensor.gyroscope
feature:android.hardware.sensor.light
feature:android.hardware.sensor.stepcounter
feature:android.hardware.sensor.stepdetector
feature:android.hardware.touchscreen
feature:android.hardware.touchscreen.multitouch
feature:android.hardware.type.watch
feature:android.hardware.usb.accessory
feature:android.hardware.wifi
feature:android.software.home_screen
feature:android.software.live_wallpaper
feature:android.software.voice_recognizers
feature:com.sonymobile.watch
Does anyone has an experiance own creating a device owner app for android wear watch ?
Haven't tried this with wearables, but most of the times I got errors setting up DeviceOwner through adb was due to an existing google account on the device, meaning it is already provisioned. Device Owner setup requires the device to not be fully provisioned.
More on this: How do you un-provision a device in order to set the Device Owner?
I'm working on a client-server Android application and trying to figure out how to identify different phones/users to the server unambiguously. My first attempt would be to use the phone number on the SIM card. Although now that I think about it, how common is it these days that your phone number changes when you e.g. change carrier? I guess it depends from country to country etc.
Anyway, I've been trying to figure out, since I don't have actual Android phones, how to change the phone number of the emulator phone to simulate different users. Is it possible or should I just think about alternative ways of identification?
The android_id is supposed to uniquely identify the device, however, it has been noted that the id can be changed if you know how Spoofing android_id
import android.provider.Settings.System;
String android_id = System.getString(this.getContentResolver(), System.ANDROID_ID);
In the emulator, the android_id does not have a value, so you will need to put a debugging routine in to assign a value yourself.
However, if you want to identify the user, and let the user access your service from different devices with one user id you are better off assigning them a user id and having them authenticate to your service using this user id as their credential. This would let them use their id's on many different devices, unless you used it in conjunction with the android_id (and the android_id wasn't spoofed) then you could limit them to one device.
You should use the number present by the emulator. Eg. usually first emulator that is running has number 5554, second 5555, and so on.
You can use these numbers to make calls, send text messages from emulator to emulator. This, I think, simulates different numbers/users for your purposes.
The SIM card info is hard-coded into the emulator-arm and emulator-x86 binaries. Changing the phone number (MSISDN) is detailed at the end of this blog post: new link, web archive
The SIM card stores the phone number with each 2 digits swapped. So (the first 7 of the phone number) 1555521 becomes 515525%d1 in the binary. While a little tedious, patching it for each test isn't the end of the world. You could also use sed:
cd path/to/android-sdk-linux/tools/
cp emulator-arm emulator-arm.backup
sed -i 's/515525%d1/816745%d3/g' emulator-arm
That will change the number to 1-876-543-[PORT NUMBER]. Details on why are in the linked blog post.