Issue
I am trying to automate system alert closing through adb. I am using some external camera hardware connected to target Android device. When the camera gets connected, the following prompt appears:
Main App
Open Main App to handle Camera ?
Always open Main App to handle when Camera is connected
CANCEL / OK
I would like to close the prompt without having to use the screen. Is it possible to do so using adb shell or bash script ?
Solution
I think you can try the following:
- use UI Automator Viewer, navigate into the layout tree and get the
resource-id
corresponding to the cancel button. - install the AndroidViewClient library
- use the following python script to automatically click the cancel button from the bash
#! /usr/bin/env python import sys import os try: sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')) except: pass from com.dtmilano.android.viewclient import ViewClient vc = ViewClient(*ViewClient.connectToDeviceOrExit()) #replace your-resource-id with the cancel button resource id view = vc.findViewById("your-resource-id") if view: print view.__tinyStr__() view.touch()
Answered By - Lino
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.