平台 | 内核版本 | 安卓版本 |
---|---|---|
RK3399 | Linux4.4 | Android7.1 |
目录:\sample\src\com\ztemt\test\basic\TestApp.java
Android App
运行时,会首先自动创建Application
类并实例化Application
对象,且只有一个。即 Application
类 是单例模式(singleton
)类。
也可通过 继承 Application
· 类自定义Application
类和实例。
Android
系统的入口是Application
类的 onCreate()
,默认为空实现。
package com.ztemt.test.basic;
import android.app.Application;
public class TestApp extends Application {
@Override
public void onCreate() {
super.onCreate();
// Update test items when the app starts.
TestList.updateItems(getBaseContext());
}
}
TestList
package com.ztemt.test.basic;
import android.content.Context;
import com.ztemt.test.basic.item.BacklightTest;
import com.ztemt.test.basic.item.BaseTest;
import com.ztemt.test.basic.item.BoardInfoTest;
import com.ztemt.test.basic.item.ChargerTest;
import com.ztemt.test.basic.item.CompassAK09911Test;
import com.ztemt.test.basic.item.EarphoneTest2;
import com.ztemt.test.basic.item.EthernetTest;
import com.ztemt.test.basic.item.GSensorTest;
import com.ztemt.test.basic.item.HallSensorTest;
import com.ztemt.test.basic.item.KeyTest;
import com.ztemt.test.basic.item.LCDTest;
import com.ztemt.test.basic.item.LightSensorCM32181Test;
import com.ztemt.test.basic.item.LoopbackTest;
import com.ztemt.test.basic.item.SpdifTest;
import com.ztemt.test.basic.item.SpeakerTest;
import com.ztemt.test.basic.item.TouchTest;
import com.ztemt.test.basic.item.UnknownTest;
import com.ztemt.test.basic.item.VersionTest;
public class TestList {
// Add new test item here
private static final BaseTest[] ALL_ITEMS = {
//版本测试
new VersionTest(),
//硬件测试
new BoardInfoTest(),
//喇叭测试
new SpeakerTest(),
//耳机测试
//new EarphoneTest(), //带Mic的四段式耳机回环测试
new EarphoneTest2(), //普通耳机测试
// Spdif
new SpdifTest(),
// MIC回环测试
new LoopbackTest(),
//FM收音机
//new FmRadioTest(),
//按键测试
new KeyTest(),
//震动测试
//new VibratorTest(),
//传感器测试
//重力加速度传感器
new GSensorTest(),
//电子罗盘 AK09911
new CompassAK09911Test(),
//LightSensor IIO Sensor CM32181
new LightSensorCM32181Test(),
// Hall Sensor
new HallSensorTest(),
// 充电
new ChargerTest(),
// 以太网测试
new EthernetTest(),
//LCD屏幕测试
new LCDTest(),
//背光测试
new BacklightTest(),
//触摸屏
new TouchTest(),
};
// Need to test items
private static BaseTest[] sItems;
// Unknown test item
private static BaseTest sUnknownTest = new UnknownTest();
static void updateItems(Context context) {
sUnknownTest.setContext(context);
int size = 0;
for (BaseTest t : ALL_ITEMS) {
t.setContext(context);
if (t.isNeedTest()) {
size++;
}
}
sItems = new BaseTest[size];
int i = 0;
for (BaseTest t : ALL_ITEMS) {
if (t.isNeedTest()) {
sItems[i] = t;
i++;
}
}
}
static int getCount() {
return sItems.length;
}
static BaseTest get(int position) {
if (position >= 0 && position < getCount()) {
return sItems[position];
} else {
return sUnknownTest;
}
}
}
接下来就要看各个硬件的测试程序了:
目录在:sample\src\com\ztemt\test\basic\item
中