diff options
author | Glenn Kasten <gkasten@google.com> | 2016-03-25 15:59:11 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2016-03-25 15:59:11 -0700 |
commit | 6050c236b01e2a2058b4489fc41628598fdd0574 (patch) | |
tree | e305dcb465a510582b23a69098a4a76859c6f0ed /LoopbackApp | |
parent | c2485a223ff13085337865dd81ccda7063431203 (diff) | |
download | drrickorang-6050c236b01e2a2058b4489fc41628598fdd0574.tar.gz |
Snap to commit 5daae470b620e4779de52cb734d9bffad1ae3a7f
Diffstat (limited to 'LoopbackApp')
4 files changed, 55 insertions, 14 deletions
diff --git a/LoopbackApp/app/src/main/Android.mk b/LoopbackApp/app/src/main/Android.mk new file mode 100644 index 0000000..23b50d2 --- /dev/null +++ b/LoopbackApp/app/src/main/Android.mk @@ -0,0 +1,26 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_JNI_SHARED_LIBRARIES := libloopback + +LOCAL_PACKAGE_NAME := Loopback + +LOCAL_CERTIFICATE := platform + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \ + frameworks/support/v7/appcompat/res + +LOCAL_AAPT_FLAGS := --auto-add-overlay \ + --extra-packages android.support.v4 + +LOCAL_STATIC_JAVA_LIBRARIES := \ + android-support-v4 + +include $(BUILD_PACKAGE) + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java b/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java index 36fbe71..c0f4bcb 100644 --- a/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java +++ b/LoopbackApp/app/src/main/java/org/drrickorang/loopback/LoopbackActivity.java @@ -86,7 +86,8 @@ public class LoopbackActivity extends Activity private static final int THREAD_SLEEP_DURATION_MS = 200; private static final int PERMISSIONS_REQUEST_RECORD_AUDIO_LATENCY = 201; private static final int PERMISSIONS_REQUEST_RECORD_AUDIO_BUFFER = 202; - private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 203; + private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_RESULTS = 203; + private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_SCRIPT = 204; private static final int LATENCY_TEST_STARTED = 300; private static final int LATENCY_TEST_ENDED = 301; private static final int BUFFER_TEST_STARTED = 302; @@ -425,11 +426,18 @@ public class LoopbackActivity extends Activity View view = getLayoutInflater().inflate(R.layout.main_activity, null); setContentView(view); - boolean successfulWrite = AtraceScriptsWriter.writeScriptsToFile(this); - if(!successfulWrite) { - showToast("Unable to write loopback_listener script to device"); + // TODO: Write script to file at more appropriate time, from settings activity or intent + // TODO: Respond to failure with more than just a toast + if (hasWriteFilePermission()){ + boolean successfulWrite = AtraceScriptsWriter.writeScriptsToFile(this); + if(!successfulWrite) { + showToast("Unable to write loopback_listener script to device"); + } + } else { + requestWriteFilePermission(PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_SCRIPT); } + mTextInfo = (TextView) findViewById(R.id.textInfo); mBarMasterLevel = (SeekBar) findViewById(R.id.BarMasterLevel); @@ -1073,7 +1081,7 @@ public class LoopbackActivity extends Activity public void saveAllTo(String fileName) { if (!hasWriteFilePermission()) { - requestWriteFilePermission(); + requestWriteFilePermission(PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_RESULTS); return; } @@ -1564,7 +1572,7 @@ public class LoopbackActivity extends Activity public void showToast(String msg) { if (mToast == null) { - mToast = Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT); + mToast = Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG); } else { mToast.setText(msg); } @@ -2058,8 +2066,10 @@ public class LoopbackActivity extends Activity // Save all files or run requested test after being granted permissions if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - if (requestCode == PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE ) { + if (requestCode == PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_RESULTS ) { saveAllTo(getFileNamePrefix()); + } else if (requestCode == PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_SCRIPT ) { + AtraceScriptsWriter.writeScriptsToFile(this); } else if (requestCode == PERMISSIONS_REQUEST_RECORD_AUDIO_BUFFER) { startBufferTest(); } else if (requestCode == PERMISSIONS_REQUEST_RECORD_AUDIO_LATENCY) { @@ -2084,14 +2094,12 @@ public class LoopbackActivity extends Activity /** * Requests the WRITE_EXTERNAL_STORAGE permission from the user */ - private void requestWriteFilePermission() { + private void requestWriteFilePermission(int requestCode) { String requiredPermission = Manifest.permission.WRITE_EXTERNAL_STORAGE; // request the permission. - ActivityCompat.requestPermissions(this, - new String[]{requiredPermission}, - PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); + ActivityCompat.requestPermissions(this, new String[]{requiredPermission}, requestCode); } /** diff --git a/LoopbackApp/app/src/main/res/raw/loopback_listener b/LoopbackApp/app/src/main/res/raw/loopback_listener index 030f594..22fdecd 100644 --- a/LoopbackApp/app/src/main/res/raw/loopback_listener +++ b/LoopbackApp/app/src/main/res/raw/loopback_listener @@ -10,7 +10,7 @@ SYSTRACE_SUFFIX=".trace"; BUGREPORT_SUFFIX="_bugreport.txt.gz"; TERMINATE_SIGNAL="QUIT"; SIGNAL_FILE="/sdcard/Loopback/loopback_signal" -TRACE_CATEGORIES="sched audio" +TRACE_CATEGORIES="sched audio $@" BUFFER_KB="8000" function exitListener { diff --git a/LoopbackApp/app/src/main/res/values/strings.xml b/LoopbackApp/app/src/main/res/values/strings.xml index 13577fb..279181a 100644 --- a/LoopbackApp/app/src/main/res/values/strings.xml +++ b/LoopbackApp/app/src/main/res/values/strings.xml @@ -148,7 +148,7 @@ <string name="systraceHelp"> To use this feature it is necessary to launch a shell script on the Android device using ADB - shell. This script is responsible for launching an asynchronous systrace and writing its + shell. This script is responsible for launching an asynchronous Systrace and writing its buffer to file when signaled by the Loopback App. \n\n At the completion of the audio glitch/buffer test the Loopback App will signal the script to @@ -158,7 +158,14 @@ \n /sdcard/Loopback/loopback_listener \n\n + + Trace Categories: The loopback_listener script takes as arguments the categories to be + tracked in the Systrace. By default the sched and audio categories are included. For a list + of available categories see\n + developer.android.com/tools/help/systrace.html + \n\n + Example invocation:\n - adb shell \"sh /sdcard/Loopback/loopback_listener\" + adb shell \"sh /sdcard/Loopback/loopback_listener load am\" </string> </resources> |