1./usr/smdt/self6000/android/packages/apps/Settings/res/xml/device_info_settings.xml
中增加节点:
<!-- Detailed build version-->
<Preference android:key="build_number"
style="?android:preferenceInformationStyle"
android:title="@string/build_number"
android:summary="@string/device_info_default"/>
<!-- Device test -->
<Preference android:key="device_test"
style="?android:preferenceInformationStyle"
android:title="@string/device_test"
android:summary="@string/device_func_test"/>
<!-- Laohua test -->
<Preference android:key="laohua_test"
style="?android:preferenceInformationStyle"
android:title="@string/laohua_test"
android:summary="@string/laohua_func_test"/>
<!—Device NO -->
<Preference android:key="device_no"
style="?android:preferenceInformationStyle"
android:title="@string/device_no"
android:summary="@string/device_esn_no"/>
2. /usr/smdt/self6000/android/packages/apps/Settings/res/values/strings.xml
增加
<string name="kernel_version">Kernel version</string>
<!-- About phone screen, setting option name-->
<string name="build_number">Build number</string>
<string name="device_test">"functiontest"</string>
<stringname="device_func_test">"functiontest"</string>
<stringname="laohua_test">"old test"</string>
<stringname="laohua_func_test">"old test"</string>
<string name="device_no">"devicenumber"</string>
<string name="device_esn_no">"device esn no"</string>
3./usr/smdt/self6000/android/packages/apps/Settings/res/values-zh-rCN/strings.xml
增加:
<string name="kernel_version"msgid="9192574954196167602">"内核版本"</string>
<string name="build_number" msgid="3075795840572241758">"版本号"</string>
<stringname="device_test">"功能测试"</string>
<string name="device_func_test">"设备功能测试"</string>
<string name="laohua_test">"老化测试"</string>
<string name="laohua_func_test">"老化测试"</string>
<string name="device_no">"设备编号"</string>
<string name="device_esn_no">"设备编号"</string>
4./usr/smdt/self6000/android/packages/apps/Settings/src/com/android/settings/DeviceInfoSettings.java
修改:private staticfinalString KEY_EQUIPMENT_ID = "fcc_equipment_id";
privatestaticfinalString PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
privatestatic final String KEY_DEVICE_TEST ="device_test";
private static final String KEY_LAOHUA_TEST = "laohua_test";
private static final String KEY_DEVICE_NO = "device_no";
static final int TAPS_TO_BE_A_DEVELOPER = 7;
onCreate方法增加:
setStringSummary(KEY_BUILD_NUMBER,Build.DISPLAY);
findPreference(KEY_BUILD_NUMBER).setEnabled(true);
findPreference(KEY_DEVICE_TEST).setEnabled(true);
findPreference(KEY_LAOHUA_TEST).setEnabled(true);
findPreference(KEY_DEVICE_NO).setEnabled(true);
setStringSummary(KEY_DEVICE_NO,getCPUSerial());
findPreference(KEY_KERNEL_VERSION).setSummary(getFormattedKernelVersion());
onPreferenceTreeClick方法:
publicbooleanonPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
Log.i(LOG_TAG, "=========="+preference.getKey());
if (preference.getKey().equals(KEY_FIRMWARE_VERSION)) {
System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
mHits[mHits.length-1]= SystemClock.uptimeMillis();
if (mHits[0] >= (SystemClock.uptimeMillis()-500)) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("android",
com.android.internal.app.PlatLogoActivity.class.getName());
try {
startActivity(intent);
} catch (Exception e) {
Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
}
}
} else if (preference.getKey().equals(KEY_BUILD_NUMBER)){
if (mDevHitCountdown > 0) {
mDevHitCountdown--;
if (mDevHitCountdown == 0) {
getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE,
Context.MODE_PRIVATE).edit().putBoolean(
DevelopmentSettings.PREF_SHOW, true).apply();
if (mDevHitToast!= null){
mDevHitToast.cancel();
}
mDevHitToast = Toast.makeText(getActivity(),R.string.show_dev_on,
Toast.LENGTH_LONG);
mDevHitToast.show();
} else if (mDevHitCountdown> 0
&& mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER-2)){
if (mDevHitToast != null){
mDevHitToast.cancel();
}
mDevHitToast = Toast.makeText(getActivity(),getResources().getQuantityString(
R.plurals.show_dev_countdown,mDevHitCountdown,mDevHitCountdown),
Toast.LENGTH_SHORT);
mDevHitToast.show();
}
} else if (mDevHitCountdown< 0) {
if (mDevHitToast != null){
mDevHitToast.cancel();
}
mDevHitToast = Toast.makeText(getActivity(),R.string.show_dev_already,
Toast.LENGTH_LONG);
mDevHitToast.show();
}
}else if(preference.getKey().equals(KEY_DEVICE_TEST)){
doStartApplicationWithPackageName("com.smdt.test.basic");
}else if(preference.getKey().equals(KEY_LAOHUA_TEST)){
doStartApplicationWithPackageName("com.into.stability");}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
增加doStartApplicationWithPackageName方法:
private voiddoStartApplicationWithPackageName(String packagename) {
// 通过包名获取此APP详细信息,包括Activities、services、versioncode、name等等
PackageInfo packageinfo = null;
try {
packageinfo =getPackageManager().getPackageInfo(packagename, 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
if (packageinfo == null){
return;
}
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
resolveIntent.setPackage(packageinfo.packageName);
// 通过getPackageManager()的queryIntentActivities方法遍历
List<ResolveInfo> resolveinfoList =getPackageManager()
.queryIntentActivities(resolveIntent, 0);
ResolveInfo resolveinfo = resolveinfoList.iterator().next();
if (resolveinfo != null){
// packagename = 参数packname
String packageName = resolveinfo.activityInfo.packageName;
// 这个就是我们要找的该APP的LAUNCHER的Activity[组织形式:packagename.mainActivityname]
String className = resolveinfo.activityInfo.name;
// LAUNCHER Intent
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// 设置ComponentName参数1:packagename参数2:MainActivity路径
ComponentName cn = new ComponentName(packageName, className);
intent.setComponent(cn);
startActivity(intent);
}
}
增加获取cpu序列号的方法:
/**
* 获取CPU序列号
*
* @return CPU序列号(16位)
* 读取失败为"0000000000000000"
*/
publicstaticString getCPUSerial() {
String str= "",strCPU = "", cpuAddress = "0000000000000000";
try{
//读取CPU信息
Process pp = Runtime.getRuntime().exec("cat /proc/cpuinfo");
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
//查找CPU序列号
for (int i = 1; i < 100; i++) {
str = input.readLine();
if (str != null){
//查找到序列号所在行
if (str.indexOf("Serial")> -1) {
//提取序列号
strCPU = str.substring(str.indexOf(":") + 1,
str.length());
//去空格
cpuAddress = strCPU.trim();
break;
}
}else{
//文件结尾
break;
}
}
} catch(IOException ex) {
//赋予默认值
ex.printStackTrace();
}
returncpuAddress;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/wlwl0071986/article/details/47805163