1
1
package net .zetetic .activities ;
2
2
3
3
import android .app .Activity ;
4
+ import android .media .AudioManager ;
5
+ import android .media .ToneGenerator ;
4
6
import android .os .Bundle ;
5
7
import android .util .Log ;
6
8
import android .view .View ;
9
+ import android .view .WindowManager ;
7
10
import android .widget .ArrayAdapter ;
8
11
import android .widget .HeaderViewListAdapter ;
9
12
import android .widget .ListView ;
21
24
import java .io .FileOutputStream ;
22
25
import java .util .ArrayList ;
23
26
import java .util .List ;
27
+ import java .util .Locale ;
24
28
25
29
public class TestSuiteBehaviorsActivity extends Activity implements ResultNotifier {
26
30
static final String EXTRA_IS_SUPPORT = "isSupport" ;
@@ -49,9 +53,9 @@ public void onButtonClick(View view) {
49
53
results .clear ();
50
54
hideStats ();
51
55
findViewById (R .id .executeSuite ).setEnabled (false );
52
- resultsView = ( ListView ) findViewById (R .id .test_suite_results );
56
+ resultsView = findViewById (R .id .test_suite_results );
53
57
ZeteticApplication .getInstance ().setCurrentActivity (this );
54
-
58
+ this . getWindow (). addFlags ( WindowManager . LayoutParams . FLAG_KEEP_SCREEN_ON );
55
59
if (getIntent ().getBooleanExtra (EXTRA_IS_SUPPORT , false )) {
56
60
new SupportSuiteRunner (this ).execute (this );
57
61
}
@@ -80,7 +84,7 @@ public void send(TestResult result) {
80
84
@ Override
81
85
public void complete () {
82
86
83
- TextView stats = ( TextView ) statsView .findViewById (R .id .stats );
87
+ TextView stats = statsView .findViewById (R .id .stats );
84
88
int successCount = 0 ;
85
89
List <String > failedTests = new ArrayList <String >();
86
90
for (TestResult result : results ){
@@ -90,15 +94,14 @@ public void complete() {
90
94
failedTests .add (result .getName ());
91
95
}
92
96
}
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 );
94
99
deleteTestResultsLog ();
95
100
try {
96
101
FileOutputStream resultStream = new FileOutputStream (testResults );
97
102
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 ());
102
105
}
103
106
resultStream .flush ();
104
107
resultStream .close ();
@@ -109,6 +112,9 @@ public void complete() {
109
112
stats .setText (message );
110
113
stats .setVisibility (View .VISIBLE );
111
114
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 );
112
118
}
113
119
114
120
private void deleteTestResultsLog (){
0 commit comments