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
package com.DeviceTest;
 
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.StatFs;
import android.os.SystemProperties;
import android.view.KeyEvent;
import android.widget.TextView;
 
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
 
 
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
import com.DeviceTest.helper.ControlButtonUtil;
 
public class VersionTestActivity extends Activity
{
  private String getFormattedKernelVersion() {
      String procVersionStr;
 
      try {
          BufferedReader reader = new BufferedReader(new FileReader("/proc/version"), 256);
          try {
              procVersionStr = reader.readLine();
          } finally {
              reader.close();
          }
 
          final String PROC_VERSION_REGEX =
              "\\w+\\s+" + /* ignore: Linux */
              "\\w+\\s+" + /* ignore: version */
              "([^\\s]+)\\s+" + /* group 1: 2.6.22-omap1 */
              "\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+" + /* group 2: (xxxxxx@xxxxx.constant) */
              "\\((?:[^(]*\\([^)]*\\))?[^)]*\\)\\s+" + /* ignore: (gcc ..) */
              "([^\\s]+)\\s+" + /* group 3: #26 */
              "(?:PREEMPT\\s+)?" + /* ignore: PREEMPT (optional) */
              "(.+)"; /* group 4: date */
 
          Pattern p = Pattern.compile(PROC_VERSION_REGEX);
          Matcher m = p.matcher(procVersionStr);
 
          if (!m.matches()) {
 
              return "Unavailable";
          } else if (m.groupCount() < 4) {
 
              return "Unavailable";
          } else {
              return (new StringBuilder(m.group(1)).append("\n").append(
                      m.group(2)).append(" ").append(m.group(3)).append("\n")
                      .append(m.group(4))).toString();
          }
      } catch (IOException e) {
 
 
          return "Unavailable";
          }
  }
  @Override
  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
 
    
    setContentView(R.layout.versiontest);
    
 
    
    TextView firmwareTextView = (TextView)findViewById(R.id.TextFirmwareversion);
    firmwareTextView.setText(Build.VERSION.RELEASE);
    
    TextView kernelTextView = (TextView)findViewById(R.id.TextKernelversion);
    kernelTextView.setText(getFormattedKernelVersion());
    
 
    
    TextView buildTextView = (TextView)findViewById(R.id.TextBuildversion);
    buildTextView.setText(Build.DISPLAY);
    
    TextView localTextView5 = (TextView)findViewById(R.id.TextBasebandversion);
    String str4 = SystemProperties.get("gsm.version.baseband", "Unavailable");
    localTextView5.setText(str4);
    
//    checkFlashSize();
    
    ControlButtonUtil.initControlButtonView(this);
  }
   public boolean dispatchKeyEvent(KeyEvent event) {
       if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
           return false;
       }
       return super.dispatchKeyEvent(event);
   }
  
  
/* Flash test Used for mid
 * 
  public void checkFlashSize() {
      TextView flashsizeView = (TextView)findViewById(R.id.FlashSize);
      
      String path = getDirectory("FLASH_STORAGE", "/flash").getPath();
      StatFs stat = new StatFs(path);
      long blockSize = stat.getBlockSize();        
      long availableBlocks = stat.getAvailableBlocks();
      long availableSize = (availableBlocks * blockSize)/(1024 * 1024); //MBtye
      long freeBlocks = stat.getFreeBlocks();
      long freeSize = (freeBlocks * blockSize)/(1024 * 1024); //MBtye
      
      flashsizeView.setText(String.valueOf(availableSize)+" MB");
  }
  
  static File getDirectory(String variableName, String defaultPath) {
      String path = System.getenv(variableName);
      return path == null ? new File(defaultPath) : new File(path);
  }
  
  */
  
}