huangcm
2025-04-09 02d4ce54b909bd733f12e9f3fa4c1b03cf2d6f45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.DeviceTest;
import java.io.File;
 
import com.DeviceTest.helper.ControlButtonUtil;
import com.DeviceTest.helper.SystemInfoUtil;
import android.view.View;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.StatFs;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.os.SystemProperties;
import android.os.storage.StorageEventListener;
import android.text.format.Formatter;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
import android.view.KeyEvent;
 
import java.io.File;
 
import com.DeviceTest.helper.ControlButtonUtil;
import com.DeviceTest.helper.SystemInfoUtil;
 
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.StatFs;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.os.SystemProperties;
import android.os.storage.StorageEventListener;
import android.text.format.Formatter;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import java.util.Iterator;
import java.util.HashMap;
import java.io.FileReader;
 
 
 
public class RTCTestActivity extends Activity {
   private final static String TAG = "RTCTestActivity";
   private final static int MSG_OK=0;
   private final static int MSG_FAIL=1;
 
   public void onCreate(Bundle paramBundle) {
       super.onCreate(paramBundle);
       setContentView(R.layout.rtctest);
 
       int count = 0;
       String str = null;
       File rtcFile = new File("/sys/class/rtc/");
       File[] list = rtcFile.listFiles();
 
       String rtcStr = "";
       
 
       for (File f: list){
           count ++;
           Log.d("RRRRRRR", "rtc file:" + f.getName());
           char[] buffer = new char[32];
           try {
               FileReader mReader = new FileReader(new File(f.getPath() + "/name"));
               mReader.read(buffer, 0, 32);
               mReader.close();
           } catch (Exception e) {
               e.printStackTrace();
           }
 
           str = new String(buffer).trim();
           if (str.equals("aml_vrtc")){
               //skip
           } else if (str.equals("rk808-rtc rk808-rtc")){
               //skip
               //((TextView) findViewById(R.id.RTCResult)).setText("检测到内部RTC: " + str + "\n" + "请务必确认板子是否有外置RTC芯片!!");
               rtcStr += f.getName() + " :"  + str + "\n";
           } else {
               // count++;
               // if (count > 0) {
               //     ((TextView) findViewById(R.id.RTCResult)).setText("RTC设备数: " + count + ",  RTC型号:" + str);
               //    // handler.sendEmptyMessageDelayed(MSG_OK, 1000);
               // } else {
               //    ((TextView) findViewById(R.id.RTCResult)).setText("没有找到RTC设备.");
               //    // handler.sendEmptyMessageDelayed(MSG_FAIL, 1000);
               //}
               rtcStr += f.getName() + " :" + str + "\n";
           }
       }
       rtcStr = "RTC 设备数量:" + count + "\n" + rtcStr;
       ((TextView) findViewById(R.id.RTCResult)).setText(rtcStr);
 
       ControlButtonUtil.initControlButtonView(this);
   //    findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);     //屏蔽确认按键
   }
 
   private Handler handler=new Handler(){
       @Override
       public void handleMessage(Message msg) {
           switch(msg.what){
               case MSG_OK:
                   ((Button) findViewById(R.id.btn_Pass)).performClick();
               case MSG_FAIL:
                   ((Button) findViewById(R.id.btn_Fail)).performClick();
           }
       }
   };
 
 
   @Override
   protected void onResume() {
       super.onResume();
   }
 
   public void onCancel(DialogInterface dialog) {
       finish();
   }
 
   public boolean dispatchKeyEvent(KeyEvent event) {
       if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
           return false;
       }
       return super.dispatchKeyEvent(event);
   }
 
}