Created
January 31, 2020 07:02
-
-
Save riverfor/b415cd47399180ee04d19eecbf824643 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from androidhelper import Android | |
| import socket | |
| from json import loads | |
| def parseEvent(line): | |
| out = loads(line) | |
| out.update(loads(out["data"])) | |
| return out | |
| ####connected via USB | |
| droid = Android() | |
| ACTION="android.telephony.TelephonyManager.PHONE_STATE" | |
| droid.eventRegisterForBroadcast(ACTION, False) | |
| ####at this line, i can see my Action registred | |
| print droid.eventGetBrodcastCategories() | |
| p=droid.startEventDispatcher().result | |
| ####at this line, i see the Port | |
| print(p) | |
| s=socket.socket() | |
| s.connect(('localhost', p)) | |
| f=s.makefile() | |
| ##Problem | |
| ###when you run this command in this line, the Console depends on | |
| print(f.readline()) | |
| while True: | |
| print('test') | |
| event = parseEvent(f.readline()) | |
| print(event) | |
| droid.log(str(event)) | |
| print("got:"+str(event)) | |
| print(droid.eventUnregisterForBroadcast(ACTION)) | |
| print(droid.eventGetBrodcastCategories()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment