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);
|
}
|
|
}
|