hw-lee / audioautotest Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
In audiofunction.py
class ToneDetectorForDeviceThread(ToneDetectorThread):
def __init__(self, serialno, target_freq, callback):
super(ToneDetectorForDeviceThread, self).__init__(target_freq=target_freq, callback=callback)
self.serialno = serialno
............
def run(self):
LogcatListener.init(self.serialno)
............
while not self.stoprequest.isSet():
os.system("adb -s {} shell am broadcast -a audio.htc.com.intent.print.properties > /dev/null".format(self.serialno))
# TODO: it seems that the Adb APIs probably should not be called constantly during a short period
# therefore, using the primary os.system is preferred currently
# Adb.execute(cmd=["shell", "am", "broadcast", "-a", "audio.htc.com.intent.print.properties"], serialno=self.serialno, tolog=False)
time.sleep(0.01)
LogcatListener.unregister_event(serialno=self.serialno, logcat_event=logcat_event)
The windows does not have /dev/null
.
In logcatlistener.py
class LogcatOutputThread(threading.Thread):
def __init__(self, serialno):
super(LogcatOutputThread, self).__init__()
self.serialno = serialno
self.daemon = True
self.msg_q = queue.Queue()
self.listeners = {}
self.stoprequest = threading.Event()
self.proc = None
............
def run(self):
self.proc = subprocess.Popen(["adb", "-s", self.serialno, "logcat"], stdout=subprocess.PIPE, preexec_fn=os.setsid)
while not self.stoprequest.isSet():
if self.proc.poll() != None:
break
line = self.proc.stdout.readline()
self._handle_logcat_msg(line)
os.killpg(os.getpgid(self.proc.pid), signal.SIGTERM)
The python does not support os.setsid
in windows.
In ssr_test.py
def push_files_if_needed(serialno):
out, _ = Adb.execute(cmd=["shell", "ls", DEVICE_MUSIC_DIR], serialno=serialno)
# The command "adb shell ls" might return several lines of strings where each line lists multiple file names
# Then the result should be handled line by line:
# map function for split with spaces and reduce function for concatenate the results of each line
files = reduce(lambda x, y: x+y, map(lambda s: s.split(), out.splitlines())) if out else []
for file_to_pushed in FILE_NAMES:
if file_to_pushed in files:
continue
out, _ = subprocess.Popen(["find", ROOT_DIR, "-name", file_to_pushed], stdout=subprocess.PIPE).communicate()
file_path = out.splitlines()[0] if out else None
if file_path:
os.system("adb -s {} push {} {} > /dev/null".format(serialno, file_path, DEVICE_MUSIC_DIR))
else:
raise ValueError("Cannot find the file \"{}\", please place it under the project tree.".format(file_to_pushed))
The linux command find
is different from that in windows.
out, _ = subprocess.Popen(["find", ROOT_DIR, "-name", file_to_pushed], stdout=subprocess.PIPE).communicate()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.