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
package com.DeviceTest;
import java.io.File;
import java.io.FilenameFilter;
 
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 android.telephony.TelephonyManager;
 
public class MobileNetTestActivity extends Activity {
   private final static String TAG = "MobileNetTestActivity";
   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.mobilenettest);
       int simTestResult = 0;
       int moduleTestResult = 0;
 
       TextView simView = (TextView) findViewById(R.id.simView);
       TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
       String imsi = mTelephonyMgr.getSubscriberId();
 
       if (imsi == null) {
           simView.setText("Cann't get IMSI!");
 
       } else {
           simView.setText("IMSI:" + imsi);
           simTestResult = 1;
       }
 
       TextView moduleView = (TextView) findViewById(R.id.moduleView);
 
       String directoryPath = "/dev";
       File directory = new File(directoryPath);
       File[] ttyUSBFiles = directory.listFiles(new FilenameFilter() {
           @Override
           public boolean accept(File dir, String name) {
               return name.startsWith("ttyUSB");
           }
       });
 
       if (ttyUSBFiles != null) {
           int count = ttyUSBFiles.length;
           if (count < 2){
               moduleView.setText("4G Module check fail");
           }else {
               moduleView.setText("4G Module check OK");
               moduleTestResult = 1;
           }
       } else {
           moduleView.setText("4G Module check fail");
       }
 
       ControlButtonUtil.initControlButtonView(this);
       findViewById(R.id.btn_Pass).setVisibility(View.INVISIBLE);
       //if (simTestResult == 1 && moduleTestResult == 1) {
       // only check 4G module
       if (moduleTestResult == 1) {
           handler.sendEmptyMessageDelayed(MSG_OK, 2000);
       } else {
           handler.sendEmptyMessageDelayed(MSG_FAIL, 2000);
       }
   }
 
   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);
   }
 
}