I have a large set of devices that I want to add google accounts to. The google accounts are already setup so I just want to add these existing accounts to the devices through a command line script.
There are two possible ways (Non-Root):
#1 Develop an app that implements the Account Manager and facilates the login process.
#2 Use a series of ADB commands to pass the input strings and stimulate the touch events.
ADB Command Example:
Start the native add account settings screen
ADB shell am start -a android.settings.ADD_ACCOUNT_SETTINGS \
-n com.android.settings/.accounts.AddAccountSettings
Select the absolute coordinates of the screen where the Google account is located. Each device has different screen sizes, so you have to figure out the exact position of your device. If you have multiple apps with login accounts they will also appear here. E.g., Microsoft Office, Reddit, and WhatsApp.
adb shell input tap X Y
Tips: You can enable the Show taps and Pointer location from Developer Option. This will give you the precious location of the touch input.
Set the desired input text
adb shell input text "[email protected]"
If you want select a keyboard event, pass the event code from the KeyEvent constants
adb shell input keyevent 66
Here, 66 is the event code of "KEYCODE_ENTER"
Repeat the input/touch process until you successfully login to the system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With