11package net .zetetic .activities ;
22
33import android .app .Activity ;
4+ import android .media .AudioManager ;
5+ import android .media .ToneGenerator ;
46import android .os .Bundle ;
57import android .util .Log ;
68import android .view .View ;
9+ import android .view .WindowManager ;
710import android .widget .ArrayAdapter ;
811import android .widget .HeaderViewListAdapter ;
912import android .widget .ListView ;
2124import java .io .FileOutputStream ;
2225import java .util .ArrayList ;
2326import java .util .List ;
27+ import java .util .Locale ;
2428
2529public 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 (){
0 commit comments