Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Scripting Windows freeware "adb" (Android Debug Bridge)

3 views
Skip to first unread message

Scott Lurndal

unread,
Sep 25, 2021, 2:27:21 PM9/25/21
to
Does anyone know the command line command that I can put in a batch file to
allow a Windows freeware adb script to open a specific unique settings page
on Android (aka, an "Activity"), and then to press a button on that page?

There are probably hundreds of Android pages inside of Android applications
that we might want to interact with from Windows so let's just try one.

A simple example is the "reset advertising id" Android settings page.
<https://www.ghacks.net/2015/04/20/how-to-reset-your-advertising-id-on-android/>

While the ultimate goal is to be able to reset the Android Advertising ID
automatically (e.g., every time the phone is connected to Windows over USB
or Wi-Fi), the baby steps are to manually reset the Advertising ID on
Android but doing that from the Windows command line whenever you want to.

I'm almost there... as I can bring up the "Reset Advertising ID" Activity
from a Windows 10 command line, but I can't yet _press_ the "reset" button!

Does anyone know how to _press_ that reset button from a Windows script?
--
This is the method I used on Windows to bring up the reset adid Activity.
[Note that I am not rooted and that I'm using Windows 10 & Android 11.]

1. Install & test adb on Windows as per instructions here.
<https://www.xda-developers.com/install-adb-windows-macos-linux/>
<https://dl.google.com/android/repository/platform-tools_r31.0.3-windows.zip>

2. Connect your phone & run a quick test that you have a connection.
C:\> adb pull /system/etc/hosts .\hosts.txt
[That should copy the Android hosts file over to your Windows machine.]

Find the number of packages you have which have "google" in the name.
C:\> adb shell pm list packages google | find /c /v ""

3. Now bring up the gms "Reset AD ID" Activity on Android from Windows:
C:\> adb shell am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity
That should pop up the "Reset AD ID" settings page on your phone.
[GMS is a set of "google mobile services" products native on Android.]

You can close that page on Android from Windows by running this:
C:\> adb shell am force-stop com.google.android.gms
Which you can put into a "closegms.bat" one-line file for convenience.

The missing next step is how to _press_ that "Reset" button on the Activity
0 new messages