Skip to content

Commit 04f2b5e

Browse files
Move tone generator and screen on/off flag to host activity
1 parent 143d0e9 commit 04f2b5e

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

app/src/main/java/net/zetetic/activities/TestSuiteBehaviorsActivity.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package net.zetetic.activities;
22

33
import android.app.Activity;
4+
import android.media.AudioManager;
5+
import android.media.ToneGenerator;
46
import android.os.Bundle;
57
import android.util.Log;
68
import android.view.View;
9+
import android.view.WindowManager;
710
import android.widget.ArrayAdapter;
811
import android.widget.HeaderViewListAdapter;
912
import android.widget.ListView;
@@ -21,6 +24,7 @@
2124
import java.io.FileOutputStream;
2225
import java.util.ArrayList;
2326
import java.util.List;
27+
import java.util.Locale;
2428

2529
public class TestSuiteBehaviorsActivity extends Activity implements ResultNotifier {
2630
static final String EXTRA_IS_SUPPORT = "isSupport";
@@ -49,9 +53,9 @@ public void onButtonClick(View view) {
4953
results.clear();
5054
hideStats();
5155
findViewById(R.id.executeSuite).setEnabled(false);
52-
resultsView = (ListView) findViewById(R.id.test_suite_results);
56+
resultsView = findViewById(R.id.test_suite_results);
5357
ZeteticApplication.getInstance().setCurrentActivity(this);
54-
58+
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
5559
if (getIntent().getBooleanExtra(EXTRA_IS_SUPPORT, false)) {
5660
new SupportSuiteRunner(this).execute(this);
5761
}
@@ -80,7 +84,7 @@ public void send(TestResult result) {
8084
@Override
8185
public void complete() {
8286

83-
TextView stats = (TextView) statsView.findViewById(R.id.stats);
87+
TextView stats = statsView.findViewById(R.id.stats);
8488
int successCount = 0;
8589
List<String> failedTests = new ArrayList<String>();
8690
for(TestResult result : results){
@@ -90,15 +94,14 @@ public void complete() {
9094
failedTests.add(result.getName());
9195
}
9296
}
93-
String message = String.format("Passed: %d Failed: %d", successCount, results.size() - successCount);
97+
String message = String.format(Locale.getDefault(),
98+
"Passed: %d Failed: %d", successCount, results.size() - successCount);
9499
deleteTestResultsLog();
95100
try {
96101
FileOutputStream resultStream = new FileOutputStream(testResults);
97102
resultStream.write(String.format("%s\n", message).getBytes());
98-
if(failedTests != null){
99-
for(String test : failedTests){
100-
resultStream.write(test.getBytes());
101-
}
103+
for(String test : failedTests){
104+
resultStream.write(test.getBytes());
102105
}
103106
resultStream.flush();
104107
resultStream.close();
@@ -109,6 +112,9 @@ public void complete() {
109112
stats.setText(message);
110113
stats.setVisibility(View.VISIBLE);
111114
findViewById(R.id.executeSuite).setEnabled(true);
115+
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
116+
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
117+
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
112118
}
113119

114120
private void deleteTestResultsLog(){

app/src/main/java/net/zetetic/tests/TestSuiteRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private List<SQLCipherTest> getTestsToRun() {
109109
tests.add(new TransactionWithListenerTest());
110110
tests.add(new LargeDatabaseCursorAccessTest());
111111

112-
//// tests.add(new TimeLargeByteArrayQueryTest());
112+
tests.add(new TimeLargeByteArrayQueryTest());
113113

114114
tests.add(new QueryLimitTest());
115115
tests.add(new RTreeTest());

app/src/main/java/net/zetetic/tests/support/SupportSuiteRunner.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ public class SupportSuiteRunner extends AsyncTask<ResultNotifier, TestResult, Vo
2424

2525
public SupportSuiteRunner(Activity activity) {
2626
this.activity = activity;
27-
if (this.activity != null) {
28-
this.activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
29-
}
3027
}
3128

3229
@Override
@@ -45,12 +42,6 @@ protected void onProgressUpdate(TestResult... values) {
4542
@Override
4643
protected void onPostExecute(Void aVoid) {
4744
notifier.complete();
48-
if (this.activity != null) {
49-
this.activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
50-
}
51-
52-
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
53-
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
5445
}
5546

5647
private void runSuite() {

0 commit comments

Comments
 (0)