From: snickersun Date: Mon, 21 Dec 2020 10:07:00 +0000 (+0800) Subject: release V57 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.js?a=commitdiff_plain;h=2b05f9086af499d93b2350acf402822755dfd2cf;p=factoryMode.git release V57 修复S123 无 camera和震动测试问题 添加 Gt09测试支持(暂时还不完整) --- diff --git a/app/build.gradle b/app/build.gradle index e613210..bd7851d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,120 +1,125 @@ -apply plugin: 'com.android.application' -// APK 名称 -static def getApkBaseName() { - return "FactoryMode" -} - -def getVersionCode() { - def versionCodeFile = file('version_code.properties') - if (versionCodeFile.canRead()) { - Properties properties = new Properties() - properties.load(new FileInputStream(versionCodeFile)) - def versionCode = properties['VERSION_CODE'].toInteger()//读取version_code.properties文件存放的版本号。 - def runTasks = gradle.startParameter.taskNames - def task = ':app:assembleRelease' - if (task in runTasks) { - properties['VERSION_CODE'] = (++versionCode).toString() - properties.store(versionCodeFile.newWriter(), null) - } - - return versionCode - } else { - throw new GradleException("无法读取version_code.properties文件!") - } -} - -def releaseTime() { - - return new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("GMT+08:00")) - -} -android { - signingConfigs { - key { - storeFile file("AndroidSystem.jks") - storePassword "android123456" - keyAlias "android" - keyPassword "android123456" - } - } - lintOptions { - checkReleaseBuilds false - abortOnError false - } - compileSdkVersion 27 - - def currentVersionCode = getVersionCode() - def currentVersionName = releaseTime() - - defaultConfig { - applicationId "mobile.miki" - minSdkVersion 19 - targetSdkVersion 19 - versionCode currentVersionCode - versionName "${currentVersionName}" - } - buildTypes { - release { - minifyEnabled false - signingConfig signingConfigs.key - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' - } - debug { - signingConfig signingConfigs.key - } - } - //打包后应用名称 - android.applicationVariants.all { variant -> - variant.outputs.all { - if (variant.buildType.name == "release") { - outputFileName = "${getApkBaseName()}_V${currentVersionCode}_${currentVersionName}_release.apk" - } else { - outputFileName = "${getApkBaseName()}_V${currentVersionCode}_${currentVersionName}_debug.apk" - } - } - } -// buildToolsVersion '20.0.3' - - sourceSets { - main { - jni.srcDirs = [] - } - } - compileOptions { - sourceCompatibility = 1.7 - targetCompatibility = 1.7 - } -} - -dependencies { - compileOnly files ('libs/frameworks-full-debug.jar') - provided files ('libs/telephony_common-full-debug.jar') - implementation 'com.squareup.okhttp3:okhttp:3.4.1' - implementation 'io.reactivex:rxandroid:1.2.1' - implementation 'com.liulishuo.filedownloader:library:1.6.3' - compileOnly files('libs/IAtChannel_classes.jar') - implementation files('libs/LineWrapContainer.aar') - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:recyclerview-v7:27.1.1' -// implementation 'com.android.support:recyclerview-v7:20.0.0' - -} -preBuild { - - doLast { - def imlFile = file( project.name + ".iml") - println 'Change ' + project.name + '.iml order' - try { - def parsedXml = (new XmlParser()).parse(imlFile) - def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } - parsedXml.component[1].remove(jdkNode) - def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" - println 'what' + sdkString - new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) - groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) - } catch (FileNotFoundException e) { - // nop, iml not found - println "no iml found" - } - } +apply plugin: 'com.android.application' +// APK 名称 +static def getApkBaseName() { + return "FactoryMode" +} + +def getVersionCode() { + def versionCodeFile = file('version_code.properties') + if (versionCodeFile.canRead()) { + Properties properties = new Properties() + properties.load(new FileInputStream(versionCodeFile)) + def versionCode = properties['VERSION_CODE'].toInteger()//读取version_code.properties文件存放的版本号。 + def runTasks = gradle.startParameter.taskNames + def task = ':app:assembleRelease' + if (task in runTasks) { + properties['VERSION_CODE'] = (++versionCode).toString() + properties.store(versionCodeFile.newWriter(), null) + } + + return versionCode + } else { + throw new GradleException("无法读取version_code.properties文件!") + } +} + +def releaseTime() { + + return new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("GMT+08:00")) + +} +android { + signingConfigs { + key { + storeFile file("AndroidSystem.jks") + storePassword "android123456" + keyAlias "android" + keyPassword "android123456" + } + } + lintOptions { + checkReleaseBuilds false + abortOnError false + } + compileSdkVersion 27 + + def currentVersionCode = getVersionCode() + def currentVersionName = releaseTime() + + defaultConfig { + applicationId "mobile.miki" + minSdkVersion 19 + targetSdkVersion 19 + versionCode currentVersionCode + versionName "${currentVersionName}" + } + buildTypes { + release { + minifyEnabled false + signingConfig signingConfigs.key + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + debug { + signingConfig signingConfigs.key + } + } + //打包后应用名称 + android.applicationVariants.all { variant -> + variant.outputs.all { + if (variant.buildType.name == "release") { + outputFileName = "${getApkBaseName()}_V${currentVersionCode}_${currentVersionName}_release.apk" + } else { + outputFileName = "${getApkBaseName()}_V${currentVersionCode}_${currentVersionName}_debug.apk" + } + } + } +// buildToolsVersion '20.0.3' + + sourceSets { + main { + jni.srcDirs = [] + } + } + compileOptions { + sourceCompatibility = 1.7 + targetCompatibility = 1.7 + } + ndkVersion '20.1.5948944' + sourceSets.main { + jniLibs.srcDir 'src/main/libs' + jni.srcDirs = [] //disable automatic ndk-build call + } +} + +dependencies { + compileOnly files ('libs/frameworks-full-debug.jar') + provided files ('libs/telephony_common-full-debug.jar') + implementation 'com.squareup.okhttp3:okhttp:3.4.1' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'com.liulishuo.filedownloader:library:1.6.3' + compileOnly files('libs/IAtChannel_classes.jar') + implementation files('libs/LineWrapContainer.aar') + implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:recyclerview-v7:27.1.1' +// implementation 'com.android.support:recyclerview-v7:20.0.0' + +} +preBuild { + + doLast { + def imlFile = file( project.name + ".iml") + println 'Change ' + project.name + '.iml order' + try { + def parsedXml = (new XmlParser()).parse(imlFile) + def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } + parsedXml.component[1].remove(jdkNode) + def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" + println 'what' + sdkString + new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) + groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) + } catch (FileNotFoundException e) { + // nop, iml not found + println "no iml found" + } + } } \ No newline at end of file diff --git a/app/release/FactoryMode_V55_202011302225_release.apk b/app/release/FactoryMode_V57_202012211803_release.apk similarity index 82% rename from app/release/FactoryMode_V55_202011302225_release.apk rename to app/release/FactoryMode_V57_202012211803_release.apk index a07b371..24f3925 100644 Binary files a/app/release/FactoryMode_V55_202011302225_release.apk and b/app/release/FactoryMode_V57_202012211803_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index a283ab4..3867591 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":56,"versionName":"202012031753","enabled":true,"outputFile":"FactoryMode_V56_202012031753_release.apk","fullName":"release","baseName":"release"},"path":"FactoryMode_V56_202012031753_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":57,"versionName":"202012211803","enabled":true,"outputFile":"FactoryMode_V57_202012211803_release.apk","fullName":"release","baseName":"release"},"path":"FactoryMode_V57_202012211803_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/ic/jni/ag3335m_jni.java b/app/src/main/java/com/ic/jni/ag3335m_jni.java new file mode 100644 index 0000000..8d7d4f3 --- /dev/null +++ b/app/src/main/java/com/ic/jni/ag3335m_jni.java @@ -0,0 +1,10 @@ +package com.ic.jni; + +public class ag3335m_jni { + static { + System.loadLibrary("ag3335m_jni"); + } + public static native int setTTYS2(); //config GPS serial port + public static native int resetPower(); // HW reset GPS + +} diff --git a/app/src/main/java/mobile/miki/BaseActivity.java b/app/src/main/java/mobile/miki/BaseActivity.java index 8c3e3ba..183bdfd 100644 --- a/app/src/main/java/mobile/miki/BaseActivity.java +++ b/app/src/main/java/mobile/miki/BaseActivity.java @@ -1,127 +1,127 @@ -package mobile.miki; - -import android.app.Activity; -import android.app.Service; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.os.Handler; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock; -import android.os.SystemProperties; -import android.util.Log; -import android.view.Display; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; - -import mobile.miki.util.FTUtils; - -public class BaseActivity extends Activity { - private static final String TAG = "BaseActivity"; - private WakeLock wakeLock = null; - private PowerManager powerManager = null; - - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - powerManager = (PowerManager) this.getSystemService(Service.POWER_SERVICE); - wakeLock = this.powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "FactoryMode"); - IntentFilter homeFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); - registerReceiver(homePressReceiver, homeFilter); - if(wakeLock != null) { - //是否需计算锁的数量 - wakeLock.setReferenceCounted(false); - //请求屏幕常亮,onResume()方法中执行 - wakeLock.acquire(); - handler.postDelayed(runnable, 1000 * 60 * 30); //30分钟不灭屏 - - } - resizewindow(); - } - - private void resizewindow(){ - if(FTUtils.isA9()) { - Display display = getWindowManager().getDefaultDisplay(); // 为获取屏幕宽、高 - Window window = getWindow(); - ViewGroup.LayoutParams windowLayoutParams = window.getAttributes(); // 获取对话框当前的参数值 - windowLayoutParams.width = 170;//(int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95 - windowLayoutParams.height = 170;//(int) (display.getHeight() * 0.6); // 高度设置为屏幕的0.6 - }else if(FTUtils.isV20()){ - Display display = getWindowManager().getDefaultDisplay(); // 为获取屏幕宽、高 - Window window = getWindow(); - ViewGroup.LayoutParams windowLayoutParams = window.getAttributes(); // 获取对话框当前的参数值 - windowLayoutParams.width = 280;//(int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95 - windowLayoutParams.height = 280;//(int) (display.getHeight() * 0.6); // 高度设置为屏幕的0.6 - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if(wakeLock != null) { - //取消屏幕常亮,onPause()方法中执行 - wakeLock.release(); - wakeLock = null; - } - if(handler != null) { - handler.removeCallbacks(runnable); - } - - if (homePressReceiver != null) { - unregisterReceiver(homePressReceiver); - } - } - - Handler handler=new Handler(); - Runnable runnable=new Runnable() { - @Override - public void run() { - if(wakeLock != null) { - //取消屏幕常亮,onPause()方法中执行 - wakeLock.release(); - wakeLock = null; - } - - } - }; - - - //HOME键监听 - private BroadcastReceiver homePressReceiver = new BroadcastReceiver() { - final String SYSTEM_DIALOG_REASON_KEY = "reason"; - final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; - @Override - public void onReceive(Context context, Intent intent) { - // TODO Auto-generated method stub - String action = intent.getAction(); - if(action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)){ - String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY); - if(reason!=null&&reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)){ - if(handler != null) { - handler.removeCallbacks(runnable); - } - if(wakeLock != null) { - //取消屏幕常亮,onPause()方法中执行 - wakeLock.release(); - wakeLock = null; - } - } - } - } - }; - - public void testSuccess(View view) { - Log.i("BaseActivity", "testSuccess"); - sendBroadcast(new Intent("mobile.miki.testsuccess")); - } - - public void testFail(View view) { - Log.i("BaseActivity", "testFail"); - sendBroadcast(new Intent("mobile.miki.testfail")); - } - - - -} +package mobile.miki; + +import android.app.Activity; +import android.app.Service; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Bundle; +import android.os.Handler; +import android.os.PowerManager; +import android.os.PowerManager.WakeLock; +import android.os.SystemProperties; +import android.util.Log; +import android.view.Display; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; + +import mobile.miki.util.FTUtils; + +public class BaseActivity extends Activity { + private static final String TAG = "BaseActivity"; + private WakeLock wakeLock = null; + private PowerManager powerManager = null; + + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + powerManager = (PowerManager) this.getSystemService(Service.POWER_SERVICE); + wakeLock = this.powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "FactoryMode"); + IntentFilter homeFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); + registerReceiver(homePressReceiver, homeFilter); + if(wakeLock != null) { + //是否需计算锁的数量 + wakeLock.setReferenceCounted(false); + //请求屏幕常亮,onResume()方法中执行 + wakeLock.acquire(); + handler.postDelayed(runnable, 1000 * 60 * 30); //30分钟不灭屏 + + } + resizewindow(); + } + + private void resizewindow(){ + if(FTUtils.isA9()) { + Display display = getWindowManager().getDefaultDisplay(); // 为获取屏幕宽、高 + Window window = getWindow(); + ViewGroup.LayoutParams windowLayoutParams = window.getAttributes(); // 获取对话框当前的参数值 + windowLayoutParams.width = 170;//(int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95 + windowLayoutParams.height = 170;//(int) (display.getHeight() * 0.6); // 高度设置为屏幕的0.6 + }else if(FTUtils.isV20() || FTUtils.isGT09()){ + Display display = getWindowManager().getDefaultDisplay(); // 为获取屏幕宽、高 + Window window = getWindow(); + ViewGroup.LayoutParams windowLayoutParams = window.getAttributes(); // 获取对话框当前的参数值 + windowLayoutParams.width = 280;//(int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95 + windowLayoutParams.height = 280;//(int) (display.getHeight() * 0.6); // 高度设置为屏幕的0.6 + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + if(wakeLock != null) { + //取消屏幕常亮,onPause()方法中执行 + wakeLock.release(); + wakeLock = null; + } + if(handler != null) { + handler.removeCallbacks(runnable); + } + + if (homePressReceiver != null) { + unregisterReceiver(homePressReceiver); + } + } + + Handler handler=new Handler(); + Runnable runnable=new Runnable() { + @Override + public void run() { + if(wakeLock != null) { + //取消屏幕常亮,onPause()方法中执行 + wakeLock.release(); + wakeLock = null; + } + + } + }; + + + //HOME键监听 + private BroadcastReceiver homePressReceiver = new BroadcastReceiver() { + final String SYSTEM_DIALOG_REASON_KEY = "reason"; + final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; + @Override + public void onReceive(Context context, Intent intent) { + // TODO Auto-generated method stub + String action = intent.getAction(); + if(action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)){ + String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY); + if(reason!=null&&reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)){ + if(handler != null) { + handler.removeCallbacks(runnable); + } + if(wakeLock != null) { + //取消屏幕常亮,onPause()方法中执行 + wakeLock.release(); + wakeLock = null; + } + } + } + } + }; + + public void testSuccess(View view) { + Log.i("BaseActivity", "testSuccess"); + sendBroadcast(new Intent("mobile.miki.testsuccess")); + } + + public void testFail(View view) { + Log.i("BaseActivity", "testFail"); + sendBroadcast(new Intent("mobile.miki.testfail")); + } + + + +} diff --git a/app/src/main/java/mobile/miki/GPSActivity.java b/app/src/main/java/mobile/miki/GPSActivity.java index 4b412b3..20481b2 100644 --- a/app/src/main/java/mobile/miki/GPSActivity.java +++ b/app/src/main/java/mobile/miki/GPSActivity.java @@ -1,536 +1,685 @@ -package mobile.miki; - -import android.content.Context; -import android.content.Intent; -import android.graphics.Color; -import android.graphics.Rect; -import android.location.Criteria; -import android.location.GpsStatus; -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.PowerManager; -import android.provider.Settings; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.View; -import android.widget.TextView; - - -import java.io.File; -import java.io.FileOutputStream; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Timer; - -import mobile.miki.util.FTUtils; -import mobile.miki.util.Logger; - -import static android.location.LocationManager.GPS_PROVIDER; - -public class GPSActivity extends BaseActivity { - - private RecyclerView mRv; - - private TextView mFix; - private TextView mStar; - private TextView mHoop; - private TextView mSearchCount; - private boolean showmessage=false; - private Timer timer; - final LocationSnrAdapter adapter = new LocationSnrAdapter(testSnrEntriyDate(null)); - private final String ttyDialogPort="/dev/ttyGS1"; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.gps_full_test_activity); - - mRv = (RecyclerView)findViewById(R.id.app_list); - - mFix=(TextView)findViewById(R.id.ic_lc_fix_value); - mStar =(TextView) findViewById(R.id.ic_lc_star_value); - mHoop = (TextView)findViewById(R.id.ic_lc_hoop_value); - mSearchCount= (TextView)findViewById(R.id.ic_lc_searchCount_value); - mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); - - mRv.addItemDecoration(new SpacesItemDecoration(10)); - mRv.setAdapter(adapter); - - mFix.setText("notFixed"); - mStar.setText("0 in 0/ inMap 0"); - mHoop.setText("0.0ç±³"); - mSearchCount.setText("0秒"); - locationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE); - if (FTUtils.isA9()){ - mFix.setTextSize(15); - mStar.setTextSize(15); - mHoop.setTextSize(15); - mSearchCount.setTextSize(15); - } - startListen(); - } - - - public void on_locating_changed(GPS_locationStatus gps_status) { - - gps_status_show.numSatelliteList.clear(); - gps_status_show.hdop=gps_status.hdop; - gps_status_show.locating_status=gps_status.locating_status; - gps_status_show.satlite_numbss=gps_status.satlite_numbss; - gps_status_show.search_time_cost=gps_status.search_time_cost; - gps_status_show.used_gps_numbs=gps_status.used_gps_numbs; -// gps_status_show.numSatelliteList=gps_status.numSatelliteList; - for (int i=0;i numSatelliteList = new ArrayList(); // 卫星信号 - public int used_gps_numbs; - public float hdop; - public int satlite_numbss; - public int search_time_cost; - public int locating_status; - } - public ArrayList testSnrEntriyDate(List gpslist) { - ArrayList entity = new ArrayList<>(); - - if (gpslist!=null) { - for (int i = 0; i < gpslist.size(); i++) { - - float snr=gpslist.get(i).getSnr(); - int prn=gpslist.get(i).getPrn(); - Logger.d("testSnrEntriyDate snr="+snr+",prn="+prn); - SnrEntriy info = new SnrEntriy(snr,prn , (snr>=40? Color.GREEN:((snr>=25&&snr<40)? Color.YELLOW: Color.RED))); - entity.add(info); - } - } - return entity; - } - PowerManager.WakeLock screenOnWakelock=null; - @Override - protected void onResume() { - super.onResume(); - if (screenOnWakelock==null) - screenOnWakelock = getScreenOnWakeLock(this,GPSActivity.class.getSimpleName()); - - } - public static PowerManager.WakeLock getScreenOnWakeLock(Context context, String tag) { - PowerManager.WakeLock wakeLock = ((PowerManager)(context.getSystemService(Context.POWER_SERVICE))).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, tag); - wakeLock.acquire(); - return wakeLock; - } - @Override - protected void onPause() { - super.onPause(); - if(screenOnWakelock!=null) { - if (screenOnWakelock.isHeld()) { - screenOnWakelock.release(); - } - screenOnWakelock=null; - } - - - } - - @Override - protected void onDestroy(){ - super.onDestroy(); - stopListen(); - - } - - private class myGpsListener implements GpsStatus.NmeaListener, LocationListener{ - - @Override - public void onNmeaReceived(long l, String s) { - mOnNmeaReceived(l,s); - } - - @Override - public void onLocationChanged(Location location) { - - } - - @Override - public void onStatusChanged(String s, int i, Bundle bundle) { - - } - - @Override - public void onProviderEnabled(String s) { - - } - - @Override - public void onProviderDisabled(String s) { - - } - } - - Handler mHandler=new Handler(new Handler.Callback() { - @Override - public boolean handleMessage(Message message) { - - List gpslist =gps_status_show.numSatelliteList; - adapter.updateLocationValue(testSnrEntriyDate(gpslist)); - String fixed=new StringBuilder().append(gps_status_show.locating_status>0? - "Fixed ":"notFixed ").append(getLocalTime2()).toString(); - String satlites=new StringBuilder("used ").append(gps_status_show.used_gps_numbs).append(" in ") - .append(gps_status_show.numSatelliteList.size()).append("/ inMap ").append(gps_status_show.satlite_numbss).toString(); - String locationTime=new StringBuilder().append(gps_status_show.search_time_cost).append(" ").append(getResources().getString(R.string.seconds)).toString(); - String hdop=new StringBuilder().append(String.valueOf(gps_status_show.hdop)).append(" ").append(getResources().getString(R.string.meter)).toString(); - mFix.setText(fixed); - if (mFix.getText().toString().contains("notFixed")){ - mFix.setBackgroundColor(Color.RED); - mFix.setTextColor(Color.WHITE); - }else{ - mFix.setBackgroundColor(Color.GREEN); - mFix.setTextColor(Color.BLACK); - } - mStar.setText(satlites); - mHoop.setText(hdop); - mSearchCount.setText(locationTime); - - return false; - } - }); - myGpsListener gpsListener=new myGpsListener(); - private boolean listening=false; - public boolean startListen() { - - if (this.listening == false) { - Settings.Secure.setLocationProviderEnabled(this.getContentResolver(), GPS_PROVIDER, true); - - - Criteria criteria = new Criteria(); - criteria.setAccuracy(Criteria.ACCURACY_FINE);// 设置为最大精度 - criteria.setAltitudeRequired(false);//不要求海拔信息 - criteria.setBearingRequired(false);// 不要求方位信息 - criteria.setCostAllowed(true);//是否允许付费 - criteria.setPowerRequirement(Criteria.POWER_LOW);// 对电量的要求 - - String provider = locationManager.getBestProvider(criteria, true); - - Logger.d("GPS StartListen with Provider " + provider); - this.locationManager.requestLocationUpdates(provider, 0L, 0.0F, gpsListener); - this.listening = true; - longitude = 0; - latitude = 0; - searchCout = 0; - locationFixedCount=0; - -// locationManager.addGpsStatusListener(statusListener);//监听搜星状态 - locationManager.addNmeaListener(gpsListener); //监听NMEA 协议数据。 - - //做个热启动 - return true;//gpsHotStart(); - }else{ - Logger.d(" location listening, skip !"); - return true; - } - } - - private static String ACTION_GPSCMD="com.enqualcomm.support.gps"; - public void stopListen() { - this.locationManager.removeNmeaListener(gpsListener); - this.locationManager.removeUpdates(gpsListener); - this.listening = false; - Logger.d("stopListen 定位 "); - - Settings.Secure.setLocationProviderEnabled(this.getContentResolver(), GPS_PROVIDER, false); - sendBroadcast(); - } - public void sendBroadcast() { - Intent intent = new Intent(); - intent.setAction(ACTION_GPSCMD); - intent.putExtra("status", "needReopen"); - this.sendBroadcast(intent); - } - private LocationManager locationManager; - private double longitude; - private double latitude; - - private int searchCout=0; - - private GPS_locationStatus gps_status = new GPS_locationStatus(); - private GPS_locationStatus gps_status_show = new GPS_locationStatus(); - - private void write_nmea_to_tty(String nmeastr){ - try { - File ttyout=new File(this.ttyDialogPort); - FileOutputStream fos_tty = new FileOutputStream(ttyout); - fos_tty.write(nmeastr.getBytes()); - fos_tty.close(); - }catch ( Exception e){ - e.printStackTrace(); - } - - } - private static int locationFixedCount=0; - static int satindex=0; - public void mOnNmeaReceived(long paramLong, String nmeastr) { -// EqcAlgorithmNative.native_EqcAlgorithmMethod5(paramString); -// ICLogger.i("Nmea :"+nmeastr+" "+paramLong); - //write_nmea_to_tty(nmeastr); - if(nmeastr.startsWith("$RD_RSSI")) { - - searchCout++; - on_locating_changed(gps_status); - gps_status.numSatelliteList.clear(); - gps_status.search_time_cost=searchCout; - } - - - if (nmeastr.startsWith("$GPGLL,")){ - String tmplist[]=nmeastr.split(","); -// GPGLL编辑 -//(地理定位信息) -// 例:$GPGLL,4250.5589,S,14718.5084,E,092204.999,A*2D -// 字段0:$GPGLL,语句ID,表明该语句为Geographic Position(GLL)地理定位信息 -// 字段1:纬度ddmm.mmmm,度分格式(前导位数不足则补0) -// 字段2:纬度N(北纬)或S(南纬) -// 字段3:经度dddmm.mmmm,度分格式(前导位数不足则补0) -// 字段4:经度E(东经)或W(西经) -// 字段5:UTC时间,hhmmss.sss格式 -// 字段6:状态,A=定位,V=未定位 -// 字段7:校验值($与*之间的数异或后的值) - String Lat=tmplist[1]; - String lon=tmplist[3]; - String fixed=tmplist[6]; -// ICLogger.i("GPGLL Lat="+Lat+",Lon="+lon+",fixed="+fixed); - - }else if (nmeastr.startsWith("$GPRMC,")) { -// GPRMC编辑 -//(推荐定位信息数据格式) -// 例:$GPRMC,024813.640,A,3158.4608,N,11848.3737,E,10.05,324.27,150706,,,A*50 -// 字段0:$GPRMC,语句ID,表明该语句为Recommended Minimum Specific GPS/TRANSIT Data(RMC)推荐最小定位信息 -// 字段1:UTC时间,hhmmss.sss格式 -// 字段2:状态,A=定位,V=未定位 -// 字段3:纬度ddmm.mmmm,度分格式(前导位数不足则补0) -// 字段4:纬度N(北纬)或S(南纬) -// 字段5:经度dddmm.mmmm,度分格式(前导位数不足则补0) -// 字段6:经度E(东经)或W(西经) -// 字段7:速度,节,Knots -// 字段8:方位角,度 -// 字段9:UTC日期,DDMMYY格式 -// 字段10:磁偏角,(000 - 180)度(前导位数不足则补0) -// 字段11:磁偏角方向,E=东W=西 -// 字段12:模式,A=自动,D=差分,E=估测,N=数据无效(3.0协议内容) -// 字段13:校验值($与*之间的数异或后的值) - String tmplist[]=nmeastr.split(","); - String utctime=tmplist[1]; - String Lat=tmplist[3]; - String lon=tmplist[5]; - String fixed=tmplist[2]; - String speed=tmplist[7]; -// ICLogger.i("GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed); -// if (Config.LOG_TOFILE) -// FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed); - if (fixed.trim().equals("A")) { - if (speed.trim().isEmpty()) speed = "0.0"; - } - - - }else if (nmeastr.startsWith("$GPGSV,")) { - -// GPGSV编辑 -// (可见卫星信息) -// 例:$GPGSV,3,1,10,20,78,331,45,01,59,235,47,22,41,069,,13,32,252,45*70 -// 字段0:$GPGSV,语句ID,表明该语句为GPS Satellites in View(GSV)可见卫星信息 -// 字段1:本次GSV语句的总数目(1 - 3) -// 字段2:本条GSV语句是本次GSV语句的第几条(1 - 3) -// 字段3:当前可见卫星总数(00 - 12)(前导位数不足则补0) -// 字段4:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) -// 字段5:卫星仰角(00 - 90)度(前导位数不足则补0) -// 字段6:卫星方位角(00 - 359)度(前导位数不足则补0) -// 字段7:信噪比(00-99)dbHz -// 字段8:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) -// 字段9:卫星仰角(00 - 90)度(前导位数不足则补0) -// 字段10:卫星方位角(00 - 359)度(前导位数不足则补0) -// 字段11:信噪比(00-99)dbHz -// 字段12:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) -// 字段13:卫星仰角(00 - 90)度(前导位数不足则补0) -//// 字段14:卫星方位角(00 - 359)度(前导位数不足则补0) -//// 字段15:信噪比(00-99)dbHz -// 字段16:校验值($与*之间的数异或后的值) - - String tmplist[]=nmeastr.split(","); - int maxPageCount= Integer.valueOf(tmplist[1]); - int currentPage= Integer.valueOf(tmplist[2]); - int SatlitesCount= Integer.valueOf(tmplist[3]); - if (maxPageCount>0 && currentPage==1){ - //第一页把数组初始化一遍。 - satindex=0; - gps_status.satlite_numbss=SatlitesCount; - } - int satcount=(tmplist.length-4)/4; -// ICLogger.i("Nmea :"+nmeastr+" "+satcount); - for (int i=0;i0] ="+ gps_status.numSatelliteList.size()); - - Logger.d( sb.toString()); - - } - }else if (nmeastr.startsWith("$GPGGA,")) { - -// GPGGA编辑 -//(定位信息) -// 例:$GPGGA,092204.999,4250.5589,S,14718.5084,E,1,04,24.4,12.2,M,19.7,M,,0000*1F -// 字段0:$GPGGA,语句ID,表明该语句为Global Positioning System Fix Data(GGA)GPS定位信息 -// 字段1:UTC 时间,hhmmss.sss,时分秒格式 -// 字段2:纬度ddmm.mmmm,度分格式(前导位数不足则补0) -// 字段3:纬度N(北纬)或S(南纬) -// 字段4:经度dddmm.mmmm,度分格式(前导位数不足则补0) -// 字段5:经度E(东经)或W(西经) -// 字段6:GPS状态,0=不可用(FIX NOT valid),1=单点定位(GPS FIX),2=差分定位(DGPS),3=无效PPS,4=实时差分定位(RTK FIX),5=RTK FLOAT,6=正在估算 -// 字段7:正在使用的卫星数量(00 - 12)(前导位数不足则补0) -// 字段8:HDOP水平精度因子(0.5 - 99.9) -// 字段9:海拔高度(-9999.9 - 99999.9) -// 字段10:单位:M(米) -// 字段11:地球椭球面相对大地水准面的高度 WGS84水准面划分 -// 字段12:WGS84水准面划分单位:M(米) -// 字段13:差分时间(从接收到差分信号开始的秒数,如果不是差分定位将为空) -// 字段14:差分站ID号0000 - 1023(前导位数不足则补0,如果不是差分定位将为空) -// 字段15:校验值($与*之间的数异或后的值) - - String tmplist[]=nmeastr.split(","); - String utctime=tmplist[1]; - String Lat=tmplist[2]; - String lon=tmplist[4]; - String fixed=tmplist[6]; - String usedStarts=tmplist[7]; - String hdop=tmplist[8]; - - - if ( (fixed.trim().equals("1"))||(fixed.trim().equals("2"))||(fixed.trim().equals("6"))){ - - - // 转换GPS坐标为度,以便在各种应用中可以方便查找。 - latitude= Double.valueOf(Lat); - longitude= Double.valueOf(lon); - // 转换单位,从分转换到度 - - double intdu= (int)(longitude /100f); //小数转换到分为单位 - double du=(longitude - intdu*100)/60f; - double last= intdu+du; - longitude =last; - intdu= (int)(latitude /100f); //小数转换到分为单位 - du=(latitude - intdu*100)/60f; - last= intdu+du; - latitude=last; - - // 经纬度 保留4位小数点 - DecimalFormat df = new DecimalFormat("#.000000"); - String strLatitude = df.format(latitude); - String strLongitude = df.format(longitude); - - //定位 - StringBuilder sb=new StringBuilder(); - sb.append("GPGGA, location time= " + getLocalTime2() + ", FixedCount=" + locationFixedCount + ", GPSTime="+utctime+", Lat="+Lat+" ("+strLatitude+"), Lon="+lon+" ("+strLongitude+"), fixed="+fixed+", hdop="+hdop+", usedStarts="+usedStarts); - Logger.d(sb.toString()); - - gps_status.locating_status=1; //fixed - }else{ - gps_status.locating_status=0; //notfixed - } - gps_status.hdop= Float.valueOf(hdop.trim()); - gps_status.used_gps_numbs= Integer.valueOf(usedStarts.trim()); - - - }else if (nmeastr.startsWith("$GPGSA,")) { - -// GPGSA编辑 -//( 当前卫星信息) -// 例:$GPGSA,A,3,01,20,19,13,,,,,,,,,40.4,24.4,32.2*0A -// 字段0:$GPGSA,语句ID,表明该语句为GPS DOP and Active Satellites(GSA)当前卫星信息 -// 字段1:定位模式(选择2D/3D),A=自动选择,M=手动选择 -// 字段2:定位类型,1=未定位,2=2D定位,3=3D定位 -// 字段3:PRN码(伪随机噪声码),第1信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段4:PRN码(伪随机噪声码),第2信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段5:PRN码(伪随机噪声码),第3信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段6:PRN码(伪随机噪声码),第4信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段7:PRN码(伪随机噪声码),第5信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段8:PRN码(伪随机噪声码),第6信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段9:PRN码(伪随机噪声码),第7信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段10:PRN码(伪随机噪声码),第8信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段11:PRN码(伪随机噪声码),第9信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段12:PRN码(伪随机噪声码),第10信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段13:PRN码(伪随机噪声码),第11信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段14:PRN码(伪随机噪声码),第12信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) -// 字段15:PDOP综合位置精度因子(0.5 - 99.9) -// 字段16:HDOP水平精度因子(0.5 - 99.9) -// 字段17:VDOP垂直精度因子(0.5 - 99.9) -// 字段18:校验值($与*之间的数异或后的值) - -// String tmplist[]=nmeastr.split(","); -// String locationmod=tmplist[1]; -// String fixed=tmplist[2]; -// String hdop=tmplist[16]; -// if (!fixed.trim().equals("1")){ -// //定位 -// ICLogger.i("GPGSA fixed="+fixed+",hdop="+hdop); -// } - } - } - -} +package mobile.miki; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.graphics.Rect; +import android.location.Criteria; +import android.location.GpsStatus; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.PowerManager; +import android.provider.Settings; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.util.Log; +import android.view.View; +import android.widget.TextView; + + +import com.ic.jni.ag3335m_jni; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Timer; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import mobile.miki.util.FTUtils; +import mobile.miki.util.Logger; + +import static android.location.LocationManager.GPS_PROVIDER; + +public class GPSActivity extends BaseActivity { + + private RecyclerView mRv; + + private TextView mFix; + private TextView mStar; + private TextView mHoop; + private TextView mSearchCount; + private boolean showmessage=false; + private Timer timer; + final LocationSnrAdapter adapter = new LocationSnrAdapter(testSnrEntriyDate(null)); + private final String ttyDialogPort="/dev/ttyGS3"; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if(FTUtils.isGT09()){ + setContentView(R.layout.gps_full_test_activity_280); + }else { + setContentView(R.layout.gps_full_test_activity); + } + mRv = (RecyclerView)findViewById(R.id.app_list); + + mFix=(TextView)findViewById(R.id.ic_lc_fix_value); + mStar =(TextView) findViewById(R.id.ic_lc_star_value); + mHoop = (TextView)findViewById(R.id.ic_lc_hoop_value); + mSearchCount= (TextView)findViewById(R.id.ic_lc_searchCount_value); + mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); + + mRv.addItemDecoration(new SpacesItemDecoration(10)); + mRv.setAdapter(adapter); + + mFix.setText("notFixed"); + mStar.setText("0 in 0/ inMap 0"); + mHoop.setText("0.0ç±³"); + mSearchCount.setText("0秒"); + locationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE); + if (FTUtils.isA9() ){ + mFix.setTextSize(15); + mStar.setTextSize(15); + mHoop.setTextSize(15); + mSearchCount.setTextSize(15); + } + startListen(); + } + + + public void on_locating_changed(GPS_locationStatus gps_status) { + + gps_status_show.numSatelliteList.clear(); + gps_status_show.hdop=gps_status.hdop; + gps_status_show.locating_status=gps_status.locating_status; + gps_status_show.satlite_numbss=gps_status.satlite_numbss; + gps_status_show.search_time_cost=gps_status.search_time_cost; + gps_status_show.used_gps_numbs=gps_status.used_gps_numbs; +// gps_status_show.numSatelliteList=gps_status.numSatelliteList; + for (int i=0;i numSatelliteList = new ArrayList(); // 卫星信号 + public int used_gps_numbs; + public float hdop; + public int satlite_numbss; + public int search_time_cost; + public int locating_status; + } + public ArrayList testSnrEntriyDate(List gpslist) { + ArrayList entity = new ArrayList<>(); + + if (gpslist!=null) { + for (int i = 0; i < gpslist.size(); i++) { + + float snr=gpslist.get(i).getSnr(); + int prn=gpslist.get(i).getPrn(); + Logger.d("testSnrEntriyDate snr="+snr+",prn="+prn); + SnrEntriy info = new SnrEntriy(snr,prn , (snr>=40? Color.GREEN:((snr>=25&&snr<40)? Color.YELLOW: Color.RED))); + entity.add(info); + } + } + return entity; + } + PowerManager.WakeLock screenOnWakelock=null; + @Override + protected void onResume() { + super.onResume(); + if (screenOnWakelock==null) + screenOnWakelock = getScreenOnWakeLock(this,GPSActivity.class.getSimpleName()); + + } + public static PowerManager.WakeLock getScreenOnWakeLock(Context context, String tag) { + PowerManager.WakeLock wakeLock = ((PowerManager)(context.getSystemService(Context.POWER_SERVICE))).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, tag); + wakeLock.acquire(); + return wakeLock; + } + @Override + protected void onPause() { + super.onPause(); + if(screenOnWakelock!=null) { + if (screenOnWakelock.isHeld()) { + screenOnWakelock.release(); + } + screenOnWakelock=null; + } + + + } + + @Override + protected void onDestroy(){ + super.onDestroy(); + stopListen(); + + } + + private class myGpsListener implements GpsStatus.NmeaListener, LocationListener{ + + @Override + public void onNmeaReceived(long l, String s) { + mOnNmeaReceived(l,s); + } + + @Override + public void onLocationChanged(Location location) { + + } + + @Override + public void onStatusChanged(String s, int i, Bundle bundle) { + + } + + @Override + public void onProviderEnabled(String s) { + + } + + @Override + public void onProviderDisabled(String s) { + + } + } + + Handler mHandler=new Handler(new Handler.Callback() { + @Override + public boolean handleMessage(Message message) { + + List gpslist =gps_status_show.numSatelliteList; + adapter.updateLocationValue(testSnrEntriyDate(gpslist)); + String fixed=new StringBuilder().append(gps_status_show.locating_status>0? + "Fixed ":"notFixed ").append(getLocalTime2()).toString(); + String satlites=new StringBuilder("used ").append(gps_status_show.used_gps_numbs).append(" in ") + .append(gps_status_show.numSatelliteList.size()).append("/ inMap ").append(gps_status_show.satlite_numbss).toString(); + String locationTime=new StringBuilder().append(gps_status_show.search_time_cost).append(" ").append(getResources().getString(R.string.seconds)).toString(); + String hdop=new StringBuilder().append(String.valueOf(gps_status_show.hdop)).append(" ").append(getResources().getString(R.string.meter)).toString(); + mFix.setText(fixed); + if (mFix.getText().toString().contains("notFixed")){ + mFix.setBackgroundColor(Color.RED); + mFix.setTextColor(Color.WHITE); + }else{ + mFix.setBackgroundColor(Color.GREEN); + mFix.setTextColor(Color.BLACK); + } + mStar.setText(satlites); + mHoop.setText(hdop); + mSearchCount.setText(locationTime); + + return false; + } + }); + myGpsListener gpsListener=new myGpsListener(); + private boolean listening=false; + public boolean startListen() { + if(FTUtils.isGT09()) + { + enableAG3335M(true); + return true; + }else{ + if (this.listening == false) { + Settings.Secure.setLocationProviderEnabled(this.getContentResolver(), GPS_PROVIDER, true); + + + Criteria criteria = new Criteria(); + criteria.setAccuracy(Criteria.ACCURACY_FINE);// 设置为最大精度 + criteria.setAltitudeRequired(false);//不要求海拔信息 + criteria.setBearingRequired(false);// 不要求方位信息 + criteria.setCostAllowed(true);//是否允许付费 + criteria.setPowerRequirement(Criteria.POWER_LOW);// 对电量的要求 + + String provider = locationManager.getBestProvider(criteria, true); + + Logger.d("GPS StartListen with Provider " + provider); + this.locationManager.requestLocationUpdates(provider, 0L, 0.0F, gpsListener); + this.listening = true; + longitude = 0; + latitude = 0; + searchCout = 0; + locationFixedCount=0; + +// locationManager.addGpsStatusListener(statusListener);//监听搜星状态 + locationManager.addNmeaListener(gpsListener); //监听NMEA 协议数据。 + + //做个热启动 + return true;//gpsHotStart(); + }else{ + Logger.d(" location listening, skip !"); + return true; + } + } + } + + + public static ExecutorService executor= Executors.newCachedThreadPool(); + public static Future trans=null; + static volatile boolean serial_thread_running=false; + public final String GPS_SERIAL_DEVICE = "/dev/ttyS2"; + public final String USB_SERIAL_DEVICE = "/dev/ttyGS3"; + + public void enableAG3335M(boolean enable){ + if(enable==true) { + + //first init TTY devices + ag3335m_jni.setTTYS2(); + + + //create thread reading GPS data and send to USB SerialPort named " SPRD WCN DIAG " + //you can get GPS NMEA data in this thread + if(serial_thread_running==false) { + if (trans==null) { + trans = executor.submit(thransferGPSdata); + }else if ( trans.isDone() || trans.isCancelled()){ + trans = executor.submit(thransferGPSdata); + } + } + + + + // HW reset the GPS , you can do or not do it as you need. + ag3335m_jni.resetPower(); + + }else { + serial_thread_running = false; + trans.cancel(true); + + } + } + public Runnable thransferGPSdata=new Runnable() { + + @Override + public void run() { + FileInputStream fs=null; + Log.i("trans","ttyS2 start"); + serial_thread_running=true; + if(fs==null) { + try { + fs=new FileInputStream(new File(GPS_SERIAL_DEVICE)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + byte[] buf=new byte[4096]; + int l=0; + while (serial_thread_running){ + if(fs!=null){ + try { + l=fs.read(buf); + if(l>0 ){ + String[] list=new String(buf,0,l).split("\r\n"); + for( int i=0; i< list.length;i++) { + int idx=list[i].indexOf("*"); + if(idx>0 && list[i].startsWith("$")) { + mOnNmeaReceived(list[i].length(), list[i].substring(0,idx)); + } + } + }else{ + Thread.sleep(100); + } + } catch (Exception e) { + e.printStackTrace(); + try { + fs.close(); + } catch (IOException ioException) { + ioException.printStackTrace(); + }finally { + fs=null; + } + + } + }else{ + break; + } + } + try { + fs.close(); + } catch (IOException e) { + e.printStackTrace(); + }finally { + fs=null; + } + + + Log.i("trans","ttyS2 done"); + } + }; + private static String ACTION_GPSCMD="com.enqualcomm.support.gps"; + public void stopListen() { + if(FTUtils.isGT09()) + { + enableAG3335M(false); + }else { + this.locationManager.removeNmeaListener(gpsListener); + this.locationManager.removeUpdates(gpsListener); + this.listening = false; + Logger.d("stopListen 定位 "); + + Settings.Secure.setLocationProviderEnabled(this.getContentResolver(), GPS_PROVIDER, false); + sendBroadcast(); + } + } + public void sendBroadcast() { + Intent intent = new Intent(); + intent.setAction(ACTION_GPSCMD); + intent.putExtra("status", "needReopen"); + this.sendBroadcast(intent); + } + private LocationManager locationManager; + private double longitude; + private double latitude; + + private int searchCout=0; + + private GPS_locationStatus gps_status = new GPS_locationStatus(); + private GPS_locationStatus gps_status_show = new GPS_locationStatus(); + + private void write_nmea_to_tty(String nmeastr){ + try { + File ttyout=new File(this.ttyDialogPort); + FileOutputStream fos_tty = new FileOutputStream(ttyout); + fos_tty.write(nmeastr.getBytes()); + fos_tty.close(); + }catch ( Exception e){ + e.printStackTrace(); + } + + } + private static int locationFixedCount=0; + static int satindex=0; + public void mOnNmeaReceived(long paramLong, String nmeastr) { +// EqcAlgorithmNative.native_EqcAlgorithmMethod5(paramString); + Logger.d("Nmea :"+nmeastr+" "+paramLong); + //write_nmea_to_tty(nmeastr); + if(nmeastr.startsWith("$RD_RSSI") ||nmeastr.startsWith("$GNGGA")) { + + searchCout++; + on_locating_changed(gps_status); + gps_status.numSatelliteList.clear(); + gps_status.search_time_cost=searchCout; + } + + + if (nmeastr.startsWith("$GPGLL,")||nmeastr.startsWith("$GNGLL,")){ + String tmplist[]=nmeastr.split(","); +// GPGLL编辑 +//(地理定位信息) +// 例:$GPGLL,4250.5589,S,14718.5084,E,092204.999,A*2D +// 字段0:$GPGLL,语句ID,表明该语句为Geographic Position(GLL)地理定位信息 +// 字段1:纬度ddmm.mmmm,度分格式(前导位数不足则补0) +// 字段2:纬度N(北纬)或S(南纬) +// 字段3:经度dddmm.mmmm,度分格式(前导位数不足则补0) +// 字段4:经度E(东经)或W(西经) +// 字段5:UTC时间,hhmmss.sss格式 +// 字段6:状态,A=定位,V=未定位 +// 字段7:校验值($与*之间的数异或后的值) + if(tmplist.length>6) { + String Lat = tmplist[1]; + String lon = tmplist[3]; + String fixed = tmplist[6]; +// ICLogger.i("GPGLL Lat="+Lat+",Lon="+lon+",fixed="+fixed); + } + }else if (nmeastr.startsWith("$GPRMC,")||nmeastr.startsWith("$GNRMC,")) { +// GPRMC编辑 +//(推荐定位信息数据格式) +// 例:$GPRMC,024813.640,A,3158.4608,N,11848.3737,E,10.05,324.27,150706,,,A*50 +// 字段0:$GPRMC,语句ID,表明该语句为Recommended Minimum Specific GPS/TRANSIT Data(RMC)推荐最小定位信息 +// 字段1:UTC时间,hhmmss.sss格式 +// 字段2:状态,A=定位,V=未定位 +// 字段3:纬度ddmm.mmmm,度分格式(前导位数不足则补0) +// 字段4:纬度N(北纬)或S(南纬) +// 字段5:经度dddmm.mmmm,度分格式(前导位数不足则补0) +// 字段6:经度E(东经)或W(西经) +// 字段7:速度,节,Knots +// 字段8:方位角,度 +// 字段9:UTC日期,DDMMYY格式 +// 字段10:磁偏角,(000 - 180)度(前导位数不足则补0) +// 字段11:磁偏角方向,E=东W=西 +// 字段12:模式,A=自动,D=差分,E=估测,N=数据无效(3.0协议内容) +// 字段13:校验值($与*之间的数异或后的值) + String tmplist[]=nmeastr.split(","); + if(tmplist.length>7) { + String utctime = tmplist[1]; + String Lat = tmplist[3]; + String lon = tmplist[5]; + String fixed = tmplist[2]; + String speed = tmplist[7]; +// ICLogger.i("GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed); +// if (Config.LOG_TOFILE) +// FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed); + if (fixed.trim().equals("A")) { + if (speed.trim().isEmpty()) speed = "0.0"; + } + + } + + }else if (nmeastr.startsWith("$GPGSV,") ||nmeastr.startsWith("$GLGSV,")||nmeastr.startsWith("$GAGSV,")||nmeastr.startsWith("$GBGSV,")) { + +// GPGSV编辑 +// (可见卫星信息) +// 例:$GPGSV,3,1,10,20,78,331,45,01,59,235,47,22,41,069,,13,32,252,45*70 +// 字段0:$GPGSV,语句ID,表明该语句为GPS Satellites in View(GSV)可见卫星信息 +// 字段1:本次GSV语句的总数目(1 - 3) +// 字段2:本条GSV语句是本次GSV语句的第几条(1 - 3) +// 字段3:当前可见卫星总数(00 - 12)(前导位数不足则补0) +// 字段4:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) +// 字段5:卫星仰角(00 - 90)度(前导位数不足则补0) +// 字段6:卫星方位角(00 - 359)度(前导位数不足则补0) +// 字段7:信噪比(00-99)dbHz +// 字段8:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) +// 字段9:卫星仰角(00 - 90)度(前导位数不足则补0) +// 字段10:卫星方位角(00 - 359)度(前导位数不足则补0) +// 字段11:信噪比(00-99)dbHz +// 字段12:PRN 码(伪随机噪声码)(01 - 32)(前导位数不足则补0) +// 字段13:卫星仰角(00 - 90)度(前导位数不足则补0) +//// 字段14:卫星方位角(00 - 359)度(前导位数不足则补0) +//// 字段15:信噪比(00-99)dbHz +// 字段16:校验值($与*之间的数异或后的值) + + String tmplist[]=nmeastr.split(","); + if(tmplist.length>3) { + int maxPageCount = 0; + int currentPage = 0; + int SatlitesCount = 0; + + try { + maxPageCount = Integer.valueOf(tmplist[1]); + } catch (Exception e) { + } + try { + currentPage = Integer.valueOf(tmplist[2]); + } catch (Exception e) { + } + try { + SatlitesCount = Integer.valueOf(tmplist[3]); + } catch (Exception e) { + } + if (maxPageCount > 0 && currentPage == 1) { + //第一页把数组初始化一遍。 + satindex = 0; + gps_status.satlite_numbss = SatlitesCount; + } + int satcount = (tmplist.length - 4) / 4; +// ICLogger.i("Nmea :"+nmeastr+" "+satcount); + for (int i = 0; i < satcount; i++) { + satindex++; + String prn = tmplist[i * 4 + 4]; + String snr = tmplist[i * 4 + 4 + 3]; + if (snr.contains("*")) { + snr = snr.substring(0, snr.indexOf("*")); + } + if (snr.trim().isEmpty()) { + snr = "0"; + } + Logger.d("Sat=" + satindex + ",prn=" + prn + ",snr=" + snr); + + int intprn = 0; + try { + intprn = Integer.valueOf(prn); + } catch (Exception e) { + } + float floatsnr = 0; + try { + floatsnr = Float.valueOf(snr); + } catch (Exception e) { + } + if (floatsnr > 0) { + gps_status.numSatelliteList.add(new GpsSatellitePriv(intprn, floatsnr)); + } + } + + if (maxPageCount == currentPage) { + //最后一页,打印搜星情况,并作一些判断。 + StringBuilder sb = new StringBuilder(); + sb.append("搜索" + searchCout + "次,搜索到卫星个数" + SatlitesCount + ", [SNR>0] =" + gps_status.numSatelliteList.size()); + + Logger.d(sb.toString()); + + } + } + }else if (nmeastr.startsWith("$GPGGA,")||nmeastr.startsWith("$GNGGA,")) { + +// GPGGA编辑 +//(定位信息) +// 例:$GPGGA,092204.999,4250.5589,S,14718.5084,E,1,04,24.4,12.2,M,19.7,M,,0000*1F +// 字段0:$GPGGA,语句ID,表明该语句为Global Positioning System Fix Data(GGA)GPS定位信息 +// 字段1:UTC 时间,hhmmss.sss,时分秒格式 +// 字段2:纬度ddmm.mmmm,度分格式(前导位数不足则补0) +// 字段3:纬度N(北纬)或S(南纬) +// 字段4:经度dddmm.mmmm,度分格式(前导位数不足则补0) +// 字段5:经度E(东经)或W(西经) +// 字段6:GPS状态,0=不可用(FIX NOT valid),1=单点定位(GPS FIX),2=差分定位(DGPS),3=无效PPS,4=实时差分定位(RTK FIX),5=RTK FLOAT,6=正在估算 +// 字段7:正在使用的卫星数量(00 - 12)(前导位数不足则补0) +// 字段8:HDOP水平精度因子(0.5 - 99.9) +// 字段9:海拔高度(-9999.9 - 99999.9) +// 字段10:单位:M(米) +// 字段11:地球椭球面相对大地水准面的高度 WGS84水准面划分 +// 字段12:WGS84水准面划分单位:M(米) +// 字段13:差分时间(从接收到差分信号开始的秒数,如果不是差分定位将为空) +// 字段14:差分站ID号0000 - 1023(前导位数不足则补0,如果不是差分定位将为空) +// 字段15:校验值($与*之间的数异或后的值) + + String tmplist[]=nmeastr.split(","); + if (tmplist.length>8) { + String utctime = tmplist[1]; + String Lat = tmplist[2]; + String lon = tmplist[4]; + String fixed = tmplist[6]; + String usedStarts = tmplist[7]; + String hdop = tmplist[8]; + + + if ((fixed.trim().equals("1")) || (fixed.trim().equals("2")) || (fixed.trim().equals("6"))) { + + + // 转换GPS坐标为度,以便在各种应用中可以方便查找。 + try { + latitude = Double.valueOf(Lat); + longitude = Double.valueOf(lon); + } catch (Exception e) { + } + // 转换单位,从分转换到度 + + double intdu = (int) (longitude / 100f); //小数转换到分为单位 + double du = (longitude - intdu * 100) / 60f; + double last = intdu + du; + longitude = last; + intdu = (int) (latitude / 100f); //小数转换到分为单位 + du = (latitude - intdu * 100) / 60f; + last = intdu + du; + latitude = last; + + // 经纬度 保留4位小数点 + DecimalFormat df = new DecimalFormat("#.000000"); + String strLatitude = df.format(latitude); + String strLongitude = df.format(longitude); + + //定位 + StringBuilder sb = new StringBuilder(); + sb.append("GPGGA, location time= " + getLocalTime2() + ", FixedCount=" + locationFixedCount + ", GPSTime=" + utctime + ", Lat=" + Lat + " (" + strLatitude + "), Lon=" + lon + " (" + strLongitude + "), fixed=" + fixed + ", hdop=" + hdop + ", usedStarts=" + usedStarts); + Logger.d(sb.toString()); + + gps_status.locating_status = 1; //fixed + } else { + gps_status.locating_status = 0; //notfixed + } + try { + gps_status.hdop = Float.valueOf(hdop.trim()); + gps_status.used_gps_numbs = Integer.valueOf(usedStarts.trim()); + } catch (Exception e) { + } + + } + }else if (nmeastr.startsWith("$GPGSA,")||nmeastr.startsWith("$GNGSA,")) { + +// GPGSA编辑 +//( 当前卫星信息) +// 例:$GPGSA,A,3,01,20,19,13,,,,,,,,,40.4,24.4,32.2*0A +// 字段0:$GPGSA,语句ID,表明该语句为GPS DOP and Active Satellites(GSA)当前卫星信息 +// 字段1:定位模式(选择2D/3D),A=自动选择,M=手动选择 +// 字段2:定位类型,1=未定位,2=2D定位,3=3D定位 +// 字段3:PRN码(伪随机噪声码),第1信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段4:PRN码(伪随机噪声码),第2信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段5:PRN码(伪随机噪声码),第3信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段6:PRN码(伪随机噪声码),第4信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段7:PRN码(伪随机噪声码),第5信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段8:PRN码(伪随机噪声码),第6信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段9:PRN码(伪随机噪声码),第7信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段10:PRN码(伪随机噪声码),第8信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段11:PRN码(伪随机噪声码),第9信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段12:PRN码(伪随机噪声码),第10信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段13:PRN码(伪随机噪声码),第11信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段14:PRN码(伪随机噪声码),第12信道正在使用的卫星PRN码编号(00)(前导位数不足则补0) +// 字段15:PDOP综合位置精度因子(0.5 - 99.9) +// 字段16:HDOP水平精度因子(0.5 - 99.9) +// 字段17:VDOP垂直精度因子(0.5 - 99.9) +// 字段18:校验值($与*之间的数异或后的值) + +// String tmplist[]=nmeastr.split(","); +// String locationmod=tmplist[1]; +// String fixed=tmplist[2]; +// String hdop=tmplist[16]; +// if (!fixed.trim().equals("1")){ +// //定位 +// ICLogger.i("GPGSA fixed="+fixed+",hdop="+hdop); +// } + } + } + +} diff --git a/app/src/main/java/mobile/miki/GpsTest.java b/app/src/main/java/mobile/miki/GpsTest.java index 0379ae6..6883a3b 100644 --- a/app/src/main/java/mobile/miki/GpsTest.java +++ b/app/src/main/java/mobile/miki/GpsTest.java @@ -1,545 +1,545 @@ -package mobile.miki; - -import android.content.Context; -import android.content.Intent; -import android.location.GpsSatellite; -import android.location.GpsStatus; -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.preference.PreferenceManager; -import android.provider.Settings; -import android.text.TextUtils; -import android.util.Log; -import android.view.Display; -import android.view.View; -import android.widget.TextView; -import android.widget.Toast; - -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import mobile.miki.mainui.ButtonViewTwo; -import mobile.miki.mainui.TestMainActivity; -import mobile.miki.mainui.TestMainList; -import mobile.miki.util.Config; -import mobile.miki.util.FTUtils; - -public class GpsTest extends BaseActivity implements - android.view.View.OnClickListener { - private LocationManager locationManager; - Location location; - - private String locationInfo; - private List numSatelliteList = new ArrayList(); // 卫星信号 - private List max3Satellite = new ArrayList(); // 卫星信号 - private int satelliteInfo = 0; - - private TextView tvGps; - private TextView tvResult; - private TextView tv_satellites; - private ButtonViewTwo buttonView; - boolean running; - boolean pcbatest; - - private ReadGpsThread readGpsThread; - private double longitude; - private double latitude; - - int gpsMode; - int numberOfSatellites; - - @Override - protected void onCreate(Bundle arg0) { - // TODO Auto-generated method stub - super.onCreate(arg0); - MyApplication.getInstance().addActivity(this); - setContentView(R.layout.gps_test_new); -// initGPS(); - //打开gps开关 - gpsMode = Settings.Secure.getInt(this.getContentResolver(), Settings.Secure.LOCATION_MODE, - Settings.Secure.LOCATION_MODE_OFF); - if (gpsMode != Settings.Secure.LOCATION_MODE_HIGH_ACCURACY) { - Settings.Secure.putInt(this.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); - } - - Intent intent = getIntent(); - running = false; - pcbatest = false; - if (intent != null) { - running = intent.getBooleanExtra("running", false); - pcbatest = intent.getBooleanExtra("pcbatest", false); - } - buttonView = (ButtonViewTwo) findViewById(R.id.btn_set); - buttonView.btn_left.setOnClickListener(this); - buttonView.btn_right.setOnClickListener(this); - buttonView.btn_left.setClickable(false); - tvGps = (TextView) findViewById(R.id.tv_gps); - tvResult = (TextView) findViewById(R.id.tv_result); - tvResult.setText(getResources().getString(R.string.gps_searching)); - tv_satellites = (TextView)findViewById(R.id.tv_satellites); - // 获取location对象 - locationManager = (LocationManager) this - .getSystemService(Context.LOCATION_SERVICE); - readGpsThread = new ReadGpsThread(); - readGpsThread.start(); - locationManager.addGpsStatusListener(statusListener);//搜星 - if(running){ - if(pcbatest){ - tvGps.setText(getString(R.string.pcbatest_gps_pass_rules)); - }else{ - tvGps.setText(getString(R.string.ageing_gps_pass_rules)); - } - }else{ - tvGps.setText(getString(R.string.gps_pass_rules)); - } - getLocationInfo(); //设定GPS优先 - - if(FTUtils.isA9()){ - tvGps.setTextSize(15); - tvResult.setTextSize(15); - tv_satellites.setTextSize(15); - } - } - - public String getLocationInfo() { - - location = getBestLocation(locationManager); - // locationInfo = updateView(location); - locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, - 3000, 8, locationListener); - // 定位成功返回数据 -// tvGps.setText(locationInfo); -// if (!"".equals(locationInfo)) { -// pass(); -// } - - return locationInfo; - } - - boolean isFrist = true; - - private String updateView(Location location) { - - if (location != null) { - longitude = location.getLongitude(); - latitude = location.getLatitude(); - if (longitude > 0 && latitude > 0) { - tvResult.setText(getResources().getString( - R.string.location_sucess)); - if (readGpsThread != null) { - readGpsThread.endThread(); - } - if (isFrist) { - isFrist = false; - pass();// 定位成功,自动跳转2016.9.19 tyy - } - - } else { - tvResult.setText(getResources().getString( - R.string.location_fail)); - } - - long gpsTime = location.getTime(); - - double altitude = location.getAltitude();// 海拔 - - // 速度 - float speed = location.getSpeed();// 速度 单位 m/s - speed = (speed * 60) / 1000; // 单位转换 km/h - // 保留一位小数点 - DecimalFormat dfSpeed = new DecimalFormat("#.0"); - String strSpeed = dfSpeed.format(speed); - speed = Float.parseFloat(strSpeed); - int intSpeed = (int) (speed * 10); - // SimpleLogger.d("intSpeed:"+intSpeed); - - // 经纬度 保留6位小数点 - DecimalFormat df = new DecimalFormat("#.000000"); - String strLatitude = df.format(latitude); - String strLongitude = df.format(longitude); - - StringBuffer sb = new StringBuffer(); - String string = getResources().getString(R.string.longitude); - String string2 = getResources().getString(R.string.latitude); - sb.append(string + strLongitude + "\n" + string2 + strLatitude); - // SimpleLogger.d("satelliteInfo:"+satelliteInfo); - return sb.toString(); - } else { - // textView.setText(""); - return ""; - } - } - - public double[] getGpsInfo() { - String tude = locationInfo; - if (!TextUtils.isEmpty(tude)) { - String[] longitudeAndLatitude = tude.split(" "); - String longitude = longitudeAndLatitude[0]; - String latitude = longitudeAndLatitude[1]; - - return new double[]{Double.parseDouble(latitude), - Double.parseDouble(longitude)}; - } - return null; - } - - /** - * 获取location对象,优先以GPS_PROVIDER获取location对象,当以GPS_PROVIDER获取到的locaiton为null时 - * ,则以NETWORK_PROVIDER获取location对象,这样可保证在室内开启网络连接的状态下获取到的location对象不为空 - * - * @param locationManager - * @return - */ - private Location getBestLocation(LocationManager locationManager) { - Location result = null; - if (locationManager != null) { - result = locationManager - .getLastKnownLocation(LocationManager.GPS_PROVIDER); - if (result != null) { - - return result; - } else { - result = locationManager - .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); - return result; - } - } - return result; - } - - class ReadGpsThread extends Thread { - private boolean isRunning = false; - private int DELAY_MS = 1000; - private int count = 0; - - public ReadGpsThread() { - isRunning = true; - } - - public void endThread() { - isRunning = false; - readGpsThread = null; - } - - @Override - public void run() { - while (isRunning) { - count++; - if (numberOfSatellites >= 3) { - return; - } - // 15秒没定位成功,则失败 - if (count == 120) { - Message msg = new Message(); - temHandler.sendMessage(msg); - if (readGpsThread != null) { - endThread(); - return; - } - } - try { - Thread.sleep(DELAY_MS); - } catch (Exception e) { - // TODO: handle exception - } - } - super.run(); - } - } - - Handler temHandler = new Handler(new Handler.Callback() { - @Override - public boolean handleMessage(Message message) { - tvResult.setText(getResources().getString( - R.string.location_fail)); - if (readGpsThread != null) { - readGpsThread.endThread(); - } - return false; - } - }); - - @Override - protected void onDestroy() { - super.onDestroy(); - if (readGpsThread != null) { - readGpsThread.endThread(); - } - isFrist = false; - flag = false; - if (locationManager != null) { - locationManager.removeUpdates(locationListener); - locationManager.removeGpsStatusListener(statusListener); - } - if (locationListener != null) { - locationListener = null; - } - if (statusListener != null) { - statusListener = null; - } - - //还原gps状态 - Settings.Secure.putInt(this.getContentResolver(), Settings.Secure.LOCATION_MODE, gpsMode); - sendBroadcast(); - } - private static String ACTION_GPSCMD="com.enqualcomm.support.gps"; - public void sendBroadcast() { - Intent intent = new Intent(); - intent.setAction(ACTION_GPSCMD); - intent.putExtra("status", "needReopen"); - this.sendBroadcast(intent); - } - - @Override - public void onClick(View arg0) { - Display myDisplay = getWindowManager().getDefaultDisplay(); - Intent intent; - intent = Config.getNextTestIntent(this,this.getClass());//new Intent(this, RingtoneActivity.class); - - intent.putExtra("running", true); - intent.putExtra("pcbatest",pcbatest); - Intent intent1 = new Intent(this, TestMainActivity.class); - // TestResult testResult = (TestResult) getApplicationContext(); - switch (arg0.getId()) { - - case R.id.btn_two_left: - if (!running) { - startActivity(intent1); - } else { - startActivity(intent); - } - PreferenceManager - .getDefaultSharedPreferences(getApplicationContext()) - .edit().putString("gps", "true").commit(); - finish(); - break; - case R.id.btn_two_right: - if (!running) { - startActivity(intent1); - } else { - startActivity(intent); - } - PreferenceManager - .getDefaultSharedPreferences(getApplicationContext()) - .edit().putString("gps", "false").commit(); - finish(); - break; - } - } - - public void pass() { - Toast.makeText(getApplicationContext(), - getResources().getString(R.string.ins_gsensor_toast), - Toast.LENGTH_SHORT).show(); - buttonView.setSuccessColor(); - - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) - .edit().putString("gps", "true").commit(); - if (running) { - new Handler() { - @Override - public void handleMessage(Message msg) { - super.handleMessage(msg); - switch (msg.what) { - case 0: - - Intent intent; - intent = Config.getNextTestIntent(GpsTest.this,GpsTest.this.getClass());//new Intent(GpsTest.this, RingtoneActivity.class); - intent.putExtra("running", true); - intent.putExtra("pcbatest", pcbatest); - startActivity(intent); - GpsTest.this.finish(); - break; - default: - break; - } - } - - }.sendEmptyMessageDelayed(0, 1000); - } else { - buttonView.btn_left.setClickable(true); - } - - - } - - @Override - public void onBackPressed() { - // super.onBackPressed(); - if (running) { - Intent intent = new Intent(this, TestMainList.class); - startActivity(intent); - finish(); - } else { - finish(); - } - } - - - LocationListener locationListener = new LocationListener() { - - @Override - public void onStatusChanged(String provider, int status, - Bundle extras) { - } - - @Override - public void onProviderEnabled(String provider) { -// locationInfo = updateView(locationManager -// .getLastKnownLocation(provider)); - } - - @Override - public void onProviderDisabled(String provider) { -// locationInfo = updateView(null); - } - - @Override - public void onLocationChanged(Location location) { - location = getBestLocation(locationManager);// 每次都去获取GPS_PROVIDER优先的location对象 -// locationInfo = updateView(location); - } - }; - - - /////////////////搜索卫星数 - boolean flag = true;//只操作一次pass - private GpsStatus.Listener statusListener = new GpsStatus.Listener() { - public void onGpsStatusChanged(int event) { // GPS状态变化时的回调,如卫星数 - GpsStatus status = locationManager.getGpsStatus(null); //取当前状态 - updateGpsStatus(event, status); //只更新状态 - numberOfSatellites = numSatelliteList.size(); - - switch (event){ - case GpsStatus.GPS_EVENT_SATELLITE_STATUS: - - if (running && !pcbatest){ - //如果是自动测试,则有3颗大于20的就算通过 - if (max3Satellite.size() >= 3 && max3Satellite.get(2).getSnr()>=30) { - tvResult.setText(getResources().getString( - R.string.location_sucess)); - if (readGpsThread != null) { - readGpsThread.endThread(); - } - if (flag) { - flag = false; - pass(); - } - } - } - if (running && pcbatest){ - //如果是pcba测试,则只要有一颗大于30的星就算通过。 - if (max3Satellite.size() > 0 && max3Satellite.get(0).getSnr()>=30) { - tvResult.setText(getResources().getString( - R.string.location_sucess)); - if (readGpsThread != null) { - readGpsThread.endThread(); - } - if (flag) { - flag = false; - pass(); - } - } - } - - break; - case GpsStatus.GPS_EVENT_FIRST_FIX: - //普通测试,必须定位才算通过 - tvResult.setText(getResources().getString( - R.string.location_sucess)+" cost "+status.getTimeToFirstFix()+"ms"); - - if (readGpsThread != null) { - readGpsThread.endThread(); - } - if (flag) { - flag = false; - pass(); - } - break; - case GpsStatus.GPS_EVENT_STARTED: - // tvGps.setText("GPS_EVENT_STARTED"); - break; - case GpsStatus.GPS_EVENT_STOPPED: - // tvGps.setText("GPS_EVENT_STOPPED"); - break; - default: - break; - } - - - - - } - }; - - private void get3MaxSnrSatellite(GpsSatellite gst){ - - float snr = gst.getSnr(); - for (int k=0;k3){ //超过三个,谁小就删掉 - max3Satellite.remove(3); - } - - } - private int updateGpsStatus(int event, GpsStatus status) { - StringBuilder sb2 = new StringBuilder(""); - float strengh = 0; - if (status == null) { - sb2.append("搜索到卫星个数:" + 0); - } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { - int maxSatellites = status.getMaxSatellites(); - Iterator it = status.getSatellites().iterator(); - numSatelliteList.clear(); - int count = 0; - while (it.hasNext() && count <= maxSatellites) { - GpsSatellite s = it.next(); - float snr = s.getSnr(); - if (snr > 0) {//只有信躁比不为0的时候才算搜到了星 - strengh = snr; -// Toast.makeText(this, "信躁比大于20", Toast.LENGTH_LONG).show(); - //排序取得最大3个SNR - get3MaxSnrSatellite(s); - numSatelliteList.add(s); - } - - count++; - } - sb2.append("搜索到卫星个数(SNR>0):" + numSatelliteList.size()+" \n Max 3 SNRs[ " ); - for (int i=0;i numSatelliteList = new ArrayList(); // 卫星信号 + private List max3Satellite = new ArrayList(); // 卫星信号 + private int satelliteInfo = 0; + + private TextView tvGps; + private TextView tvResult; + private TextView tv_satellites; + private ButtonViewTwo buttonView; + boolean running; + boolean pcbatest; + + private ReadGpsThread readGpsThread; + private double longitude; + private double latitude; + + int gpsMode; + int numberOfSatellites; + + @Override + protected void onCreate(Bundle arg0) { + // TODO Auto-generated method stub + super.onCreate(arg0); + MyApplication.getInstance().addActivity(this); + setContentView(R.layout.gps_test_new); +// initGPS(); + //打开gps开关 + gpsMode = Settings.Secure.getInt(this.getContentResolver(), Settings.Secure.LOCATION_MODE, + Settings.Secure.LOCATION_MODE_OFF); + if (gpsMode != Settings.Secure.LOCATION_MODE_HIGH_ACCURACY) { + Settings.Secure.putInt(this.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); + } + + Intent intent = getIntent(); + running = false; + pcbatest = false; + if (intent != null) { + running = intent.getBooleanExtra("running", false); + pcbatest = intent.getBooleanExtra("pcbatest", false); + } + buttonView = (ButtonViewTwo) findViewById(R.id.btn_set); + buttonView.btn_left.setOnClickListener(this); + buttonView.btn_right.setOnClickListener(this); + buttonView.btn_left.setClickable(false); + tvGps = (TextView) findViewById(R.id.tv_gps); + tvResult = (TextView) findViewById(R.id.tv_result); + tvResult.setText(getResources().getString(R.string.gps_searching)); + tv_satellites = (TextView)findViewById(R.id.tv_satellites); + // 获取location对象 + locationManager = (LocationManager) this + .getSystemService(Context.LOCATION_SERVICE); + readGpsThread = new ReadGpsThread(); + readGpsThread.start(); + locationManager.addGpsStatusListener(statusListener);//搜星 + if(running){ + if(pcbatest){ + tvGps.setText(getString(R.string.pcbatest_gps_pass_rules)); + }else{ + tvGps.setText(getString(R.string.ageing_gps_pass_rules)); + } + }else{ + tvGps.setText(getString(R.string.gps_pass_rules)); + } + getLocationInfo(); //设定GPS优先 + + if(FTUtils.isA9()&&FTUtils.isGT09()){ + tvGps.setTextSize(15); + tvResult.setTextSize(15); + tv_satellites.setTextSize(15); + } + } + + public String getLocationInfo() { + + location = getBestLocation(locationManager); + // locationInfo = updateView(location); + locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, + 3000, 8, locationListener); + // 定位成功返回数据 +// tvGps.setText(locationInfo); +// if (!"".equals(locationInfo)) { +// pass(); +// } + + return locationInfo; + } + + boolean isFrist = true; + + private String updateView(Location location) { + + if (location != null) { + longitude = location.getLongitude(); + latitude = location.getLatitude(); + if (longitude > 0 && latitude > 0) { + tvResult.setText(getResources().getString( + R.string.location_sucess)); + if (readGpsThread != null) { + readGpsThread.endThread(); + } + if (isFrist) { + isFrist = false; + pass();// 定位成功,自动跳转2016.9.19 tyy + } + + } else { + tvResult.setText(getResources().getString( + R.string.location_fail)); + } + + long gpsTime = location.getTime(); + + double altitude = location.getAltitude();// 海拔 + + // 速度 + float speed = location.getSpeed();// 速度 单位 m/s + speed = (speed * 60) / 1000; // 单位转换 km/h + // 保留一位小数点 + DecimalFormat dfSpeed = new DecimalFormat("#.0"); + String strSpeed = dfSpeed.format(speed); + speed = Float.parseFloat(strSpeed); + int intSpeed = (int) (speed * 10); + // SimpleLogger.d("intSpeed:"+intSpeed); + + // 经纬度 保留6位小数点 + DecimalFormat df = new DecimalFormat("#.000000"); + String strLatitude = df.format(latitude); + String strLongitude = df.format(longitude); + + StringBuffer sb = new StringBuffer(); + String string = getResources().getString(R.string.longitude); + String string2 = getResources().getString(R.string.latitude); + sb.append(string + strLongitude + "\n" + string2 + strLatitude); + // SimpleLogger.d("satelliteInfo:"+satelliteInfo); + return sb.toString(); + } else { + // textView.setText(""); + return ""; + } + } + + public double[] getGpsInfo() { + String tude = locationInfo; + if (!TextUtils.isEmpty(tude)) { + String[] longitudeAndLatitude = tude.split(" "); + String longitude = longitudeAndLatitude[0]; + String latitude = longitudeAndLatitude[1]; + + return new double[]{Double.parseDouble(latitude), + Double.parseDouble(longitude)}; + } + return null; + } + + /** + * 获取location对象,优先以GPS_PROVIDER获取location对象,当以GPS_PROVIDER获取到的locaiton为null时 + * ,则以NETWORK_PROVIDER获取location对象,这样可保证在室内开启网络连接的状态下获取到的location对象不为空 + * + * @param locationManager + * @return + */ + private Location getBestLocation(LocationManager locationManager) { + Location result = null; + if (locationManager != null) { + result = locationManager + .getLastKnownLocation(LocationManager.GPS_PROVIDER); + if (result != null) { + + return result; + } else { + result = locationManager + .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + return result; + } + } + return result; + } + + class ReadGpsThread extends Thread { + private boolean isRunning = false; + private int DELAY_MS = 1000; + private int count = 0; + + public ReadGpsThread() { + isRunning = true; + } + + public void endThread() { + isRunning = false; + readGpsThread = null; + } + + @Override + public void run() { + while (isRunning) { + count++; + if (numberOfSatellites >= 3) { + return; + } + // 15秒没定位成功,则失败 + if (count == 120) { + Message msg = new Message(); + temHandler.sendMessage(msg); + if (readGpsThread != null) { + endThread(); + return; + } + } + try { + Thread.sleep(DELAY_MS); + } catch (Exception e) { + // TODO: handle exception + } + } + super.run(); + } + } + + Handler temHandler = new Handler(new Handler.Callback() { + @Override + public boolean handleMessage(Message message) { + tvResult.setText(getResources().getString( + R.string.location_fail)); + if (readGpsThread != null) { + readGpsThread.endThread(); + } + return false; + } + }); + + @Override + protected void onDestroy() { + super.onDestroy(); + if (readGpsThread != null) { + readGpsThread.endThread(); + } + isFrist = false; + flag = false; + if (locationManager != null) { + locationManager.removeUpdates(locationListener); + locationManager.removeGpsStatusListener(statusListener); + } + if (locationListener != null) { + locationListener = null; + } + if (statusListener != null) { + statusListener = null; + } + + //还原gps状态 + Settings.Secure.putInt(this.getContentResolver(), Settings.Secure.LOCATION_MODE, gpsMode); + sendBroadcast(); + } + private static String ACTION_GPSCMD="com.enqualcomm.support.gps"; + public void sendBroadcast() { + Intent intent = new Intent(); + intent.setAction(ACTION_GPSCMD); + intent.putExtra("status", "needReopen"); + this.sendBroadcast(intent); + } + + @Override + public void onClick(View arg0) { + Display myDisplay = getWindowManager().getDefaultDisplay(); + Intent intent; + intent = Config.getNextTestIntent(this,this.getClass());//new Intent(this, RingtoneActivity.class); + + intent.putExtra("running", true); + intent.putExtra("pcbatest",pcbatest); + Intent intent1 = new Intent(this, TestMainActivity.class); + // TestResult testResult = (TestResult) getApplicationContext(); + switch (arg0.getId()) { + + case R.id.btn_two_left: + if (!running) { + startActivity(intent1); + } else { + startActivity(intent); + } + PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()) + .edit().putString("gps", "true").commit(); + finish(); + break; + case R.id.btn_two_right: + if (!running) { + startActivity(intent1); + } else { + startActivity(intent); + } + PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()) + .edit().putString("gps", "false").commit(); + finish(); + break; + } + } + + public void pass() { + Toast.makeText(getApplicationContext(), + getResources().getString(R.string.ins_gsensor_toast), + Toast.LENGTH_SHORT).show(); + buttonView.setSuccessColor(); + + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) + .edit().putString("gps", "true").commit(); + if (running) { + new Handler() { + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what) { + case 0: + + Intent intent; + intent = Config.getNextTestIntent(GpsTest.this,GpsTest.this.getClass());//new Intent(GpsTest.this, RingtoneActivity.class); + intent.putExtra("running", true); + intent.putExtra("pcbatest", pcbatest); + startActivity(intent); + GpsTest.this.finish(); + break; + default: + break; + } + } + + }.sendEmptyMessageDelayed(0, 1000); + } else { + buttonView.btn_left.setClickable(true); + } + + + } + + @Override + public void onBackPressed() { + // super.onBackPressed(); + if (running) { + Intent intent = new Intent(this, TestMainList.class); + startActivity(intent); + finish(); + } else { + finish(); + } + } + + + LocationListener locationListener = new LocationListener() { + + @Override + public void onStatusChanged(String provider, int status, + Bundle extras) { + } + + @Override + public void onProviderEnabled(String provider) { +// locationInfo = updateView(locationManager +// .getLastKnownLocation(provider)); + } + + @Override + public void onProviderDisabled(String provider) { +// locationInfo = updateView(null); + } + + @Override + public void onLocationChanged(Location location) { + location = getBestLocation(locationManager);// 每次都去获取GPS_PROVIDER优先的location对象 +// locationInfo = updateView(location); + } + }; + + + /////////////////搜索卫星数 + boolean flag = true;//只操作一次pass + private GpsStatus.Listener statusListener = new GpsStatus.Listener() { + public void onGpsStatusChanged(int event) { // GPS状态变化时的回调,如卫星数 + GpsStatus status = locationManager.getGpsStatus(null); //取当前状态 + updateGpsStatus(event, status); //只更新状态 + numberOfSatellites = numSatelliteList.size(); + + switch (event){ + case GpsStatus.GPS_EVENT_SATELLITE_STATUS: + + if (running && !pcbatest){ + //如果是自动测试,则有3颗大于20的就算通过 + if (max3Satellite.size() >= 3 && max3Satellite.get(2).getSnr()>=30) { + tvResult.setText(getResources().getString( + R.string.location_sucess)); + if (readGpsThread != null) { + readGpsThread.endThread(); + } + if (flag) { + flag = false; + pass(); + } + } + } + if (running && pcbatest){ + //如果是pcba测试,则只要有一颗大于30的星就算通过。 + if (max3Satellite.size() > 0 && max3Satellite.get(0).getSnr()>=30) { + tvResult.setText(getResources().getString( + R.string.location_sucess)); + if (readGpsThread != null) { + readGpsThread.endThread(); + } + if (flag) { + flag = false; + pass(); + } + } + } + + break; + case GpsStatus.GPS_EVENT_FIRST_FIX: + //普通测试,必须定位才算通过 + tvResult.setText(getResources().getString( + R.string.location_sucess)+" cost "+status.getTimeToFirstFix()+"ms"); + + if (readGpsThread != null) { + readGpsThread.endThread(); + } + if (flag) { + flag = false; + pass(); + } + break; + case GpsStatus.GPS_EVENT_STARTED: + // tvGps.setText("GPS_EVENT_STARTED"); + break; + case GpsStatus.GPS_EVENT_STOPPED: + // tvGps.setText("GPS_EVENT_STOPPED"); + break; + default: + break; + } + + + + + } + }; + + private void get3MaxSnrSatellite(GpsSatellite gst){ + + float snr = gst.getSnr(); + for (int k=0;k3){ //超过三个,谁小就删掉 + max3Satellite.remove(3); + } + + } + private int updateGpsStatus(int event, GpsStatus status) { + StringBuilder sb2 = new StringBuilder(""); + float strengh = 0; + if (status == null) { + sb2.append("搜索到卫星个数:" + 0); + } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { + int maxSatellites = status.getMaxSatellites(); + Iterator it = status.getSatellites().iterator(); + numSatelliteList.clear(); + int count = 0; + while (it.hasNext() && count <= maxSatellites) { + GpsSatellite s = it.next(); + float snr = s.getSnr(); + if (snr > 0) {//只有信躁比不为0的时候才算搜到了星 + strengh = snr; +// Toast.makeText(this, "信躁比大于20", Toast.LENGTH_LONG).show(); + //排序取得最大3个SNR + get3MaxSnrSatellite(s); + numSatelliteList.add(s); + } + + count++; + } + sb2.append("搜索到卫星个数(SNR>0):" + numSatelliteList.size()+" \n Max 3 SNRs[ " ); + for (int i=0;i rectList; - private static int numX = 4; - private static int numY = 7; - private int mDisplayWidth = 320; - private int mDisplayHeight = 320; - private int absX; - private int absY; - boolean running; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - MyApplication.getInstance().addActivity(this); - if (mDebug) - Log.v(TAG, "start TouchpanelTest"); - getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - requestWindowFeature(Window.FEATURE_NO_TITLE); - // 发送广播给systemUI全屏显示 - Intent systemuiIntent = new Intent(); - systemuiIntent.setAction("mobile.miki.touchscreen.TouchScreen_Activity"); - systemuiIntent.putExtra("close", true); - sendBroadcast(systemuiIntent); - // end - initRec(); - Toast.makeText(this, /*"请进行触摸屏测试"*/this.getResources().getString(R.string.touchtest_toast), Toast.LENGTH_LONG).show(); - tpView = new TPTestView(this); - setContentView(tpView); - Intent intent = getIntent(); - running = false; - if (intent != null) { - running = intent.getBooleanExtra("running", false); - } - - } - - private void initRec() { - - Display myDisplay = getWindowManager().getDefaultDisplay(); - - - if (FTUtils.isA9()){ - mDisplayHeight = 170; - mDisplayWidth = 170; - }else if(FTUtils.isV20()) { - mDisplayHeight = 280; - mDisplayWidth = 280; - }else { - mDisplayHeight = myDisplay.getHeight(); - mDisplayWidth = myDisplay.getWidth(); - } - - mDisplayHeight = mDisplayHeight; - - - absY = mDisplayHeight / numY; - - // mDisplayWidth = 859; - -// if(myDisplay.getWidth()==730){ -// mDisplayWidth = 855; -// }else{ -// mDisplayWidth = 1280; -// } - - - absX = mDisplayWidth / numX; - rectList = new ArrayList(numX * numY); - for (int i = 0; i < numX; i++) { - for (int j = 0; j < numY; j += (numY - 1) / 2) { - Rect r = new Rect(i * absX, j * absY, absX, absY); - - rectList.add(r); - } - } - - for (int i = 0; i < numX; i += (numX - 1) / 2) { - for (int j = 1; j < numY - 1; j++) { - if (j == (numY - 1) / 2) - continue; - - Rect r = new Rect(i * absX, j * absY, absX, absY); - - rectList.add(r); - } - } - - -// for (int i = 0; i < 2; i++) { -// for (int j = 0; j < 2; j++) { -// Rect r = new Rect(absX + i * absX * (numX - 1) / 2, absY + j * absY * (numY - 1) / 2, -// (numX - 3) / 2 * absX, (numY - 3) / 2 * absY); -// -// rectList.add(r); -// -// } -// } - } - - private void doAfterTest() { - // Bundle b = new Bundle(); - // Intent intent = new Intent(); - // b.putInt("test_result", 1); - // - // intent.putExtras(b); - // setResult(RESULT_OK, intent); - -// // 发送广播给systemUI显示bar -// Intent systemuiIntent = new Intent(); -// systemuiIntent.setAction("mobile.miki.touchscreen.TouchTest"); -// systemuiIntent.putExtra("open", true); -// sendBroadcast(systemuiIntent); - - Intent intent2 = Config.getNextTestIntent(this,this.getClass());//new Intent(this, LcdActivity.class); - intent2.putExtra("running", true); - Intent intent1 = new Intent(this, TestMainActivity.class); - - if (!running) { - startActivity(intent1); - } else { - startActivity(intent2); - } - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("touch", "true") - .commit(); - - finish(); - - } - - private class Rect { - int x; - int y; - int dx; - int dy; - - Rect(int x, int y, int dx, int dy) { - this.x = x; - this.y = y; - this.dx = dx; - this.dy = dy; - } - - public boolean isInRect(int x, int y) { - if (x >= this.x && x <= this.x + this.dx && y >= this.y && y <= this.y + this.dy) { - return true; - } else { - return false; - } - } - } - - private class TPTestView extends View { - private Bitmap bitmap; - private Canvas canvas; - private Paint paint; - private Rect tempRect; - - public TPTestView(Context context) { - super(context); - paint = new Paint(Paint.DITHER_FLAG); - bitmap = Bitmap.createBitmap(mDisplayWidth, mDisplayHeight, Bitmap.Config.ARGB_8888); - canvas = new Canvas(); - canvas.setBitmap(bitmap); - - paint.setStyle(Style.FILL); - paint.setStrokeWidth(5); - paint.setColor(Color.WHITE); - paint.setAntiAlias(true); - - Iterator iterator = rectList.iterator(); - while (iterator.hasNext()) { - Rect rect = iterator.next(); - canvas.drawRect(rect.x, rect.y, rect.x + rect.dx - 1, rect.y + rect.dy - 1, paint); - } - invalidate(); - - paint.setColor(Color.GREEN); - - } - - protected void onDraw(Canvas canvas) { - canvas.drawBitmap(bitmap, 0, 0, null); - } - - public boolean onTouchEvent(MotionEvent event) { - int action = event.getAction(); - float x = event.getX(); - float y = event.getY(); - if (mDebug) - Log.v(TAG, "onTouchEvent" + " x=" + x + " y=" + y); - - if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) { - if (rectList.size() == 0) { - doAfterTest(); - } - boolean bNeedFindRect = false; - if (tempRect == null) { - bNeedFindRect = true; - } else { - if (!tempRect.isInRect((int) x, (int) y)) { - bNeedFindRect = true; - } else { - bNeedFindRect = false; - } - - } - if (mDebug) - Log.v(TAG, "onTouchEvent" + " bNeedFindRect=" + bNeedFindRect); - if (bNeedFindRect) { - Iterator iterator = rectList.iterator(); - while (iterator.hasNext()) { - Rect rect = iterator.next(); - if (rect.isInRect((int) x, (int) y)) { - tempRect = rect; - canvas.drawRect(rect.x, rect.y, rect.x + rect.dx, rect.y + rect.dy, paint); - invalidate(); - rectList.remove(rect); - break; - } - } - } - } - return true; - } - } - - @Override - public void onBackPressed() { - // super.onBackPressed(); - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("touch", "false") - .commit(); - if (running) { - Intent intent = new Intent(this, TestMainList.class); - startActivity(intent); - finish(); - // doAfterTest(); - } else { - finish(); - } - - } - -} +package mobile.miki; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Paint.Style; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.util.Log; +import android.view.Display; +import android.view.MotionEvent; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Toast; + +import java.util.ArrayList; +import java.util.Iterator; + +import mobile.miki.lcd.LcdActivity; +import mobile.miki.mainui.TestMainActivity; +import mobile.miki.mainui.TestMainList; +import mobile.miki.util.Config; +import mobile.miki.util.FTUtils; + +//import sim.android.mtkcit.TestActivity; +//import sim.android.mtkcit.cittools.CITTools; + + +public class TouchTest extends BaseActivity { + private static final String TAG = "TouchpanelTest"; + private static final boolean mDebug = false; + private TPTestView tpView; + private ArrayList rectList; + private static int numX = 4; + private static int numY = 7; + private int mDisplayWidth = 320; + private int mDisplayHeight = 320; + private int absX; + private int absY; + boolean running; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + MyApplication.getInstance().addActivity(this); + if (mDebug) + Log.v(TAG, "start TouchpanelTest"); + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + requestWindowFeature(Window.FEATURE_NO_TITLE); + // 发送广播给systemUI全屏显示 + Intent systemuiIntent = new Intent(); + systemuiIntent.setAction("mobile.miki.touchscreen.TouchScreen_Activity"); + systemuiIntent.putExtra("close", true); + sendBroadcast(systemuiIntent); + // end + initRec(); + Toast.makeText(this, /*"请进行触摸屏测试"*/this.getResources().getString(R.string.touchtest_toast), Toast.LENGTH_LONG).show(); + tpView = new TPTestView(this); + setContentView(tpView); + Intent intent = getIntent(); + running = false; + if (intent != null) { + running = intent.getBooleanExtra("running", false); + } + + } + + private void initRec() { + + Display myDisplay = getWindowManager().getDefaultDisplay(); + + + if (FTUtils.isA9()){ + mDisplayHeight = 170; + mDisplayWidth = 170; + }else if(FTUtils.isV20()|| FTUtils.isGT09()) { + mDisplayHeight = 280; + mDisplayWidth = 280; + }else { + mDisplayHeight = myDisplay.getHeight(); + mDisplayWidth = myDisplay.getWidth(); + } + + mDisplayHeight = mDisplayHeight; + + + absY = mDisplayHeight / numY; + + // mDisplayWidth = 859; + +// if(myDisplay.getWidth()==730){ +// mDisplayWidth = 855; +// }else{ +// mDisplayWidth = 1280; +// } + + + absX = mDisplayWidth / numX; + rectList = new ArrayList(numX * numY); + for (int i = 0; i < numX; i++) { + for (int j = 0; j < numY; j += (numY - 1) / 2) { + Rect r = new Rect(i * absX, j * absY, absX, absY); + + rectList.add(r); + } + } + + for (int i = 0; i < numX; i += (numX - 1) / 2) { + for (int j = 1; j < numY - 1; j++) { + if (j == (numY - 1) / 2) + continue; + + Rect r = new Rect(i * absX, j * absY, absX, absY); + + rectList.add(r); + } + } + + +// for (int i = 0; i < 2; i++) { +// for (int j = 0; j < 2; j++) { +// Rect r = new Rect(absX + i * absX * (numX - 1) / 2, absY + j * absY * (numY - 1) / 2, +// (numX - 3) / 2 * absX, (numY - 3) / 2 * absY); +// +// rectList.add(r); +// +// } +// } + } + + private void doAfterTest() { + // Bundle b = new Bundle(); + // Intent intent = new Intent(); + // b.putInt("test_result", 1); + // + // intent.putExtras(b); + // setResult(RESULT_OK, intent); + +// // 发送广播给systemUI显示bar +// Intent systemuiIntent = new Intent(); +// systemuiIntent.setAction("mobile.miki.touchscreen.TouchTest"); +// systemuiIntent.putExtra("open", true); +// sendBroadcast(systemuiIntent); + + Intent intent2 = Config.getNextTestIntent(this,this.getClass());//new Intent(this, LcdActivity.class); + intent2.putExtra("running", true); + Intent intent1 = new Intent(this, TestMainActivity.class); + + if (!running) { + startActivity(intent1); + } else { + startActivity(intent2); + } + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("touch", "true") + .commit(); + + finish(); + + } + + private class Rect { + int x; + int y; + int dx; + int dy; + + Rect(int x, int y, int dx, int dy) { + this.x = x; + this.y = y; + this.dx = dx; + this.dy = dy; + } + + public boolean isInRect(int x, int y) { + if (x >= this.x && x <= this.x + this.dx && y >= this.y && y <= this.y + this.dy) { + return true; + } else { + return false; + } + } + } + + private class TPTestView extends View { + private Bitmap bitmap; + private Canvas canvas; + private Paint paint; + private Rect tempRect; + + public TPTestView(Context context) { + super(context); + paint = new Paint(Paint.DITHER_FLAG); + bitmap = Bitmap.createBitmap(mDisplayWidth, mDisplayHeight, Bitmap.Config.ARGB_8888); + canvas = new Canvas(); + canvas.setBitmap(bitmap); + + paint.setStyle(Style.FILL); + paint.setStrokeWidth(5); + paint.setColor(Color.WHITE); + paint.setAntiAlias(true); + + Iterator iterator = rectList.iterator(); + while (iterator.hasNext()) { + Rect rect = iterator.next(); + canvas.drawRect(rect.x, rect.y, rect.x + rect.dx - 1, rect.y + rect.dy - 1, paint); + } + invalidate(); + + paint.setColor(Color.GREEN); + + } + + protected void onDraw(Canvas canvas) { + canvas.drawBitmap(bitmap, 0, 0, null); + } + + public boolean onTouchEvent(MotionEvent event) { + int action = event.getAction(); + float x = event.getX(); + float y = event.getY(); + if (mDebug) + Log.v(TAG, "onTouchEvent" + " x=" + x + " y=" + y); + + if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) { + if (rectList.size() == 0) { + doAfterTest(); + } + boolean bNeedFindRect = false; + if (tempRect == null) { + bNeedFindRect = true; + } else { + if (!tempRect.isInRect((int) x, (int) y)) { + bNeedFindRect = true; + } else { + bNeedFindRect = false; + } + + } + if (mDebug) + Log.v(TAG, "onTouchEvent" + " bNeedFindRect=" + bNeedFindRect); + if (bNeedFindRect) { + Iterator iterator = rectList.iterator(); + while (iterator.hasNext()) { + Rect rect = iterator.next(); + if (rect.isInRect((int) x, (int) y)) { + tempRect = rect; + canvas.drawRect(rect.x, rect.y, rect.x + rect.dx, rect.y + rect.dy, paint); + invalidate(); + rectList.remove(rect); + break; + } + } + } + } + return true; + } + } + + @Override + public void onBackPressed() { + // super.onBackPressed(); + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("touch", "false") + .commit(); + if (running) { + Intent intent = new Intent(this, TestMainList.class); + startActivity(intent); + finish(); + // doAfterTest(); + } else { + finish(); + } + + } + +} diff --git a/app/src/main/java/mobile/miki/VersionActivity.java b/app/src/main/java/mobile/miki/VersionActivity.java index a08cd8d..f4d3bba 100644 --- a/app/src/main/java/mobile/miki/VersionActivity.java +++ b/app/src/main/java/mobile/miki/VersionActivity.java @@ -1,318 +1,323 @@ -/** - * Generated by smali2java 1.0.0.558 - * Copyright (C) 2013 Hensence.com - */ - -package mobile.miki; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Build; -import android.os.Bundle; -import android.os.SystemProperties; -import android.preference.PreferenceManager; -import android.telephony.TelephonyManager; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.View; -import android.widget.LinearLayout; -import android.widget.TextView; - -import mobile.miki.mainui.ButtonViewTwo; -import mobile.miki.mainui.TestMainActivity; -import mobile.miki.mainui.TestMainList; -import mobile.miki.util.Config; -import mobile.miki.util.FTUtils; -import mobile.miki.util.IATUtils; - -public class VersionActivity extends BaseActivity implements android.view.View.OnClickListener { - private static final String TAG = "VersionActivity"; - private ButtonViewTwo buttonView; - boolean running; - boolean pcbatest; - TextView rfParametersValue; //校准状态 - String imeiValue = ""; - String barCode = ""; - LinearLayout ll_imei2; - private TextView simidParametersValue, cidParameters, cidParametersValue; - - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - MyApplication.getInstance().addActivity(this); - setContentView(R.layout.version_layout); - Intent intent = getIntent(); - running = false; - pcbatest = false; - if (intent != null) { - running = intent.getBooleanExtra("running", false); - pcbatest = intent.getBooleanExtra("pcbatest",false); - } - - rfParametersValue = (TextView) findViewById(R.id.rfParametersValue); - ll_imei2 = ((LinearLayout) findViewById(R.id.ll_imei2)); - ll_imei2.setVisibility(View.GONE); - //版本号 - ((TextView) findViewById(R.id.tvBuildNumberValue)).setText(Build.DISPLAY); - //SIM卡 ICCID - simidParametersValue = (TextView) findViewById(R.id.SimidParametersValue); - setICCID(); - setImei(); - - cidParameters = (TextView)findViewById(R.id.cidParameters); - cidParametersValue = (TextView) findViewById(R.id.cidParametersValue); - barCode = SystemProperties.get("gsm.serial", ""); - Log.i(TAG, "barCode " + barCode); - //写入cid号 - String cidValue = ""; - Log.i(TAG, "ro.product.brand" + SystemProperties.get("ro.product.brand","")); - if("sprd".equalsIgnoreCase(SystemProperties.get("ro.product.brand",""))){ - cidValue = FTUtils.GetCidFromSystem(); - }else{ - cidValue = getSerialNumber(barCode); - } - cidParameters.setText(getResources().getString(R.string.cid)); - // 校准 - setRF(); - - // 糖果cid地址指向serialno位置 - if (FTUtils.isSugar()) { - ((TextView) findViewById(R.id.barcode)).setText(barCode); - cidParametersValue.setText(Build.SERIAL); - ((TextView) findViewById(R.id.wifi_mac_address)).setText(FTUtils.getWifiMacAddress()); - ((TextView) findViewById(R.id.bluethooth_mac_address)).setText(FTUtils.getBtAddressViaReflection()); - } else { - cidParametersValue.setText(cidValue); - ((LinearLayout) findViewById(R.id.ll_wifi_mac_address)).setVisibility(View.GONE); - ((LinearLayout) findViewById(R.id.ll_bluethooth_mac_address)).setVisibility(View.GONE); - ((LinearLayout) findViewById(R.id.ll_barcode)).setVisibility(View.GONE); - } - - // 展讯获取校准标准 - if (FTUtils.isLieBao() || SystemProperties.get("ro.product.brand", "").equalsIgnoreCase("SPRD")) { - getZhanXunRf(); - String zhanxunCid = FTUtils.GetCidFromSystem(); - cidParameters.setVisibility(View.GONE); - cidParametersValue.setText(zhanxunCid); - } - // end - getDisplayMetrics(); - - buttonView = (ButtonViewTwo) findViewById(R.id.btn_set); - buttonView.btn_left.setOnClickListener(this); - buttonView.btn_right.setOnClickListener(this); - buttonView.btn_left.setClickable(false); - - registerBroadCast(); - } - - private void setImei() { - // imei - TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); - if (Build.VERSION.SDK_INT < 26) { - imeiValue = telephonyManager.getDeviceId(); - } else { - imeiValue = FTUtils.getImei(this); - } - ((TextView) findViewById(R.id.tv_imei)).setText(imeiValue + ""); - - // imei2 - String imei2 = SystemProperties.get("gsm.mtk.imei2", ""); - //酷达需要imei2 - String android_model = Build.MODEL; - if (android_model.contains("CMCC-CW1A")) { - if (imei2 != null) { - ll_imei2.setVisibility(View.VISIBLE); - ((TextView) findViewById(R.id.imeiParametersValue)).setText(imei2); - } - } - } - - - private void setRF() { - if (barCode.length() == 0 || barCode == null) {//值为空,未校准 - rfParametersValue.setText(R.string.no); - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("rf", "false") - .commit(); -// } else if (strVal.length()>=62 && "10".equals(strVal.substring(60, 62))) {//值不为空且后面等于10,校准 - } else if (barCode.length() >= 62 && barCode.substring(barCode.length() - 10, barCode.length()).contains("10")) { - rfParametersValue.setText(getResources().getString(R.string.yes)); - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("rf", "true") - .commit(); - } else {//值不为空,后面不等于10,未校准 - rfParametersValue.setText(getResources().getString(R.string._fail)); - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("rf", "false") - .commit(); - } - } - - private void setICCID() { - if ("".equals(getSimId()) || getSimId() == null) { - simidParametersValue.setText("null"); - } else { - simidParametersValue.setText(getSimId()); - } - } - - //获取屏幕分辨率 - private void getDisplayMetrics() { - DisplayMetrics dm = new DisplayMetrics(); - this.getWindowManager().getDefaultDisplay().getMetrics(dm); - int screenWidth = dm.widthPixels; - int screenHeight = dm.heightPixels; - ((TextView) findViewById(R.id.screenResolutionParametersValue)).setText(screenWidth + "*" + screenHeight); - } - - public static String getSerialNumber(String serial) { - try { - if (serial != null) { - serial = serial.replaceAll("\\s*", "");//去掉空白字符 - if (serial.length() >= 16) { - serial = serial.substring(0, 16); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return serial; - } - - - public String getSimId() { - TelephonyManager telephonyManager = (TelephonyManager) this - .getSystemService(Context.TELEPHONY_SERVICE); - - String simSerialNumber = telephonyManager.getSimSerialNumber(); - - return simSerialNumber; - } - - @Override - public void onClick(View arg0) { - Intent intent ; -// if (pcbatest) { -// intent = new Intent(this, CameraPreview.class); -// intent.putExtra("running", true); -// intent.putExtra("pcbatest", true); -// }else{ - intent = Config.getNextTestIntent(this,this.getClass());//new Intent(this, TouchTest.class); - intent.putExtra("running", true); - intent.putExtra("pcbatest",false); -// } - - Intent intent1 = new Intent(this, TestMainActivity.class); - // TestResult testResult = (TestResult) getApplicationContext(); - switch (arg0.getId()) { - - case R.id.btn_two_left: - if (!running) { - startActivity(intent1); - } else { - startActivity(intent); - } - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("version", "true") - .commit(); - finish(); - break; - case R.id.btn_two_right: - if (!running) { - startActivity(intent1); - } else { - startActivity(intent); - } - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("version", "false") - .commit(); - finish(); - break; - } - } - - @Override - protected void onResume() { - buttonView.setSuccessColor(); - buttonView.btn_left.setClickable(true); - super.onResume(); - } - - @Override - public void onBackPressed() { - // super.onBackPressed(); - if (running) { - Intent intent = new Intent(this, TestMainList.class); - startActivity(intent); - finish(); - } else { - finish(); - } - } - - private void registerBroadCast() { - IntentFilter filter1 = new IntentFilter(); - filter1.addAction("android.intent.action.SIM_STATE_CHANGED"); - registerReceiver(getSimState, filter1); - } - - // 广播 - private BroadcastReceiver getSimState = new BroadcastReceiver() { - @Override - public void onReceive(Context arg0, Intent arg1) { - String action = arg1.getAction(); - if (action.equals("android.intent.action.SIM_STATE_CHANGED")) { - if ("".equals(getSimId()) || getSimId() == null) { - simidParametersValue.setText("null"); - } else { - simidParametersValue.setText(getSimId()); - } - } - - } - }; - - @Override - protected void onDestroy() { - super.onDestroy(); - unregisterReceiver(getSimState); - } - - private String str = "loading..."; - - private void getZhanXunRf() { - str = "GSM "; - str += IATUtils.sendATCmd("AT+SGMR=0,0,3,0", "atchannel0"); - sleep(100); - str += "WCDMA "; - str += IATUtils.sendATCmd("AT+SGMR=0,0,3,1", "atchannel0"); - sleep(100); - str += "LTE "; - str += IATUtils.sendATCmd("AT+SGMR=1,0,3,3", "atchannel0"); - sleep(100); - Log.i(TAG, "str " + str); - boolean rfSuccess = isRfSuccess(str); - if (rfSuccess) { - rfParametersValue.setText(getResources().getString(R.string.yes)); - } else { - rfParametersValue.setText(getResources().getString(R.string._fail)); - } - Log.i(TAG, "rfSuccess " + rfSuccess); - } - - private void sleep(long time) { - try { - Thread.sleep(time); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - private boolean isRfSuccess(String str) { - if (str.contains("BIT2:DCS AGC calibrated Pass") && str.contains("BIT3:DCS APC calibrated Pass") - && str.contains("BIT4:EGSM AGC calibrated Pass") && str.contains("BIT5:EGSM APC calibrated Pass") - && str.contains("BIT8:GSM AFC calibrated Pass") && str.contains("BIT20:EDGE Calibration Pass") - && str.contains("BIT1:TDD LTE AGC Pass") && str.contains("BIT2:TDD LTE APC Pass")) { - return true; - } - return false; - } - +/** + * Generated by smali2java 1.0.0.558 + * Copyright (C) 2013 Hensence.com + */ + +package mobile.miki; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Build; +import android.os.Bundle; +import android.os.SystemProperties; +import android.preference.PreferenceManager; +import android.telephony.TelephonyManager; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; + +import mobile.miki.mainui.ButtonViewTwo; +import mobile.miki.mainui.TestMainActivity; +import mobile.miki.mainui.TestMainList; +import mobile.miki.util.Config; +import mobile.miki.util.FTUtils; +import mobile.miki.util.IATUtils; + +public class VersionActivity extends BaseActivity implements android.view.View.OnClickListener { + private static final String TAG = "VersionActivity"; + private ButtonViewTwo buttonView; + boolean running; + boolean pcbatest; + TextView rfParametersValue; //校准状态 + String imeiValue = ""; + String barCode = ""; + LinearLayout ll_imei2; + private TextView simidParametersValue, cidParameters, cidParametersValue; + + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + MyApplication.getInstance().addActivity(this); + if(FTUtils.isGT09()){ + setContentView(R.layout.version_layout_280); + }else { + setContentView(R.layout.version_layout); + } + Intent intent = getIntent(); + running = false; + pcbatest = false; + if (intent != null) { + running = intent.getBooleanExtra("running", false); + pcbatest = intent.getBooleanExtra("pcbatest",false); + } + + rfParametersValue = (TextView) findViewById(R.id.rfParametersValue); + ll_imei2 = ((LinearLayout) findViewById(R.id.ll_imei2)); + ll_imei2.setVisibility(View.GONE); + //版本号 + ((TextView) findViewById(R.id.tvBuildNumberValue)).setText(Build.DISPLAY); + //SIM卡 ICCID + simidParametersValue = (TextView) findViewById(R.id.SimidParametersValue); + setICCID(); + setImei(); + + cidParameters = (TextView)findViewById(R.id.cidParameters); + cidParametersValue = (TextView) findViewById(R.id.cidParametersValue); + barCode = SystemProperties.get("gsm.serial", ""); + Log.i(TAG, "barCode " + barCode); + //写入cid号 + String cidValue = ""; + Log.i(TAG, "ro.product.brand" + SystemProperties.get("ro.product.brand","")); + if("sprd".equalsIgnoreCase(SystemProperties.get("ro.product.brand",""))){ + cidValue = FTUtils.GetCidFromSystem(); + }else{ + cidValue = getSerialNumber(barCode); + } + cidParameters.setText(getResources().getString(R.string.cid)); + // 校准 + setRF(); + + // 糖果cid地址指向serialno位置 + if (FTUtils.isSugar()) { + ((TextView) findViewById(R.id.barcode)).setText(barCode); + cidParametersValue.setText(Build.SERIAL); + ((TextView) findViewById(R.id.wifi_mac_address)).setText(FTUtils.getWifiMacAddress()); + ((TextView) findViewById(R.id.bluethooth_mac_address)).setText(FTUtils.getBtAddressViaReflection()); + } else { + cidParametersValue.setText(cidValue); + ((LinearLayout) findViewById(R.id.ll_wifi_mac_address)).setVisibility(View.GONE); + ((LinearLayout) findViewById(R.id.ll_bluethooth_mac_address)).setVisibility(View.GONE); + ((LinearLayout) findViewById(R.id.ll_barcode)).setVisibility(View.GONE); + } + + // 展讯获取校准标准 + if (FTUtils.isLieBao() || SystemProperties.get("ro.product.brand", "").equalsIgnoreCase("SPRD")) { + getZhanXunRf(); + String zhanxunCid = FTUtils.GetCidFromSystem(); + cidParameters.setVisibility(View.GONE); + cidParametersValue.setText(zhanxunCid); + } + // end + getDisplayMetrics(); + + buttonView = (ButtonViewTwo) findViewById(R.id.btn_set); + buttonView.btn_left.setOnClickListener(this); + buttonView.btn_right.setOnClickListener(this); + buttonView.btn_left.setClickable(false); + + registerBroadCast(); + } + + private void setImei() { + // imei + TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); + if (Build.VERSION.SDK_INT < 26) { + imeiValue = telephonyManager.getDeviceId(); + } else { + imeiValue = FTUtils.getImei(this); + } + ((TextView) findViewById(R.id.tv_imei)).setText(imeiValue + ""); + + // imei2 + String imei2 = SystemProperties.get("gsm.mtk.imei2", ""); + //酷达需要imei2 + String android_model = Build.MODEL; + if (android_model.contains("CMCC-CW1A")) { + if (imei2 != null) { + ll_imei2.setVisibility(View.VISIBLE); + ((TextView) findViewById(R.id.imeiParametersValue)).setText(imei2); + } + } + } + + + private void setRF() { + if (barCode.length() == 0 || barCode == null) {//值为空,未校准 + rfParametersValue.setText(R.string.no); + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("rf", "false") + .commit(); +// } else if (strVal.length()>=62 && "10".equals(strVal.substring(60, 62))) {//值不为空且后面等于10,校准 + } else if (barCode.length() >= 62 && barCode.substring(barCode.length() - 10, barCode.length()).contains("10")) { + rfParametersValue.setText(getResources().getString(R.string.yes)); + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("rf", "true") + .commit(); + } else {//值不为空,后面不等于10,未校准 + rfParametersValue.setText(getResources().getString(R.string._fail)); + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("rf", "false") + .commit(); + } + } + + private void setICCID() { + if ("".equals(getSimId()) || getSimId() == null) { + simidParametersValue.setText("null"); + } else { + simidParametersValue.setText(getSimId()); + } + } + + //获取屏幕分辨率 + private void getDisplayMetrics() { + DisplayMetrics dm = new DisplayMetrics(); + this.getWindowManager().getDefaultDisplay().getMetrics(dm); + int screenWidth = dm.widthPixels; + int screenHeight = dm.heightPixels; + ((TextView) findViewById(R.id.screenResolutionParametersValue)).setText(screenWidth + "*" + screenHeight); + } + + + public static String getSerialNumber(String serial) { + try { + if (serial != null) { + serial = serial.replaceAll("\\s*", "");//去掉空白字符 + if (serial.length() >= 16) { + serial = serial.substring(0, 16); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return serial; + } + + + public String getSimId() { + TelephonyManager telephonyManager = (TelephonyManager) this + .getSystemService(Context.TELEPHONY_SERVICE); + + String simSerialNumber = telephonyManager.getSimSerialNumber(); + + return simSerialNumber; + } + + @Override + public void onClick(View arg0) { + Intent intent ; +// if (pcbatest) { +// intent = new Intent(this, CameraPreview.class); +// intent.putExtra("running", true); +// intent.putExtra("pcbatest", true); +// }else{ + intent = Config.getNextTestIntent(this,this.getClass());//new Intent(this, TouchTest.class); + intent.putExtra("running", true); + intent.putExtra("pcbatest",false); +// } + + Intent intent1 = new Intent(this, TestMainActivity.class); + // TestResult testResult = (TestResult) getApplicationContext(); + switch (arg0.getId()) { + + case R.id.btn_two_left: + if (!running) { + startActivity(intent1); + } else { + startActivity(intent); + } + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("version", "true") + .commit(); + finish(); + break; + case R.id.btn_two_right: + if (!running) { + startActivity(intent1); + } else { + startActivity(intent); + } + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("version", "false") + .commit(); + finish(); + break; + } + } + + @Override + protected void onResume() { + buttonView.setSuccessColor(); + buttonView.btn_left.setClickable(true); + super.onResume(); + } + + @Override + public void onBackPressed() { + // super.onBackPressed(); + if (running) { + Intent intent = new Intent(this, TestMainList.class); + startActivity(intent); + finish(); + } else { + finish(); + } + } + + private void registerBroadCast() { + IntentFilter filter1 = new IntentFilter(); + filter1.addAction("android.intent.action.SIM_STATE_CHANGED"); + registerReceiver(getSimState, filter1); + } + + // 广播 + private BroadcastReceiver getSimState = new BroadcastReceiver() { + @Override + public void onReceive(Context arg0, Intent arg1) { + String action = arg1.getAction(); + if (action.equals("android.intent.action.SIM_STATE_CHANGED")) { + if ("".equals(getSimId()) || getSimId() == null) { + simidParametersValue.setText("null"); + } else { + simidParametersValue.setText(getSimId()); + } + } + + } + }; + + @Override + protected void onDestroy() { + super.onDestroy(); + unregisterReceiver(getSimState); + } + + private String str = "loading..."; + + private void getZhanXunRf() { + str = "GSM "; + str += IATUtils.sendATCmd("AT+SGMR=0,0,3,0", "atchannel0"); + sleep(100); + str += "WCDMA "; + str += IATUtils.sendATCmd("AT+SGMR=0,0,3,1", "atchannel0"); + sleep(100); + str += "LTE "; + str += IATUtils.sendATCmd("AT+SGMR=1,0,3,3", "atchannel0"); + sleep(100); + Log.i(TAG, "str " + str); + boolean rfSuccess = isRfSuccess(str); + if (rfSuccess) { + rfParametersValue.setText(getResources().getString(R.string.yes)); + } else { + rfParametersValue.setText(getResources().getString(R.string._fail)); + } + Log.i(TAG, "rfSuccess " + rfSuccess); + } + + private void sleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private boolean isRfSuccess(String str) { + if (str.contains("BIT2:DCS AGC calibrated Pass") && str.contains("BIT3:DCS APC calibrated Pass") + && str.contains("BIT4:EGSM AGC calibrated Pass") && str.contains("BIT5:EGSM APC calibrated Pass") + && str.contains("BIT8:GSM AFC calibrated Pass") && str.contains("BIT20:EDGE Calibration Pass") + && str.contains("BIT1:TDD LTE AGC Pass") && str.contains("BIT2:TDD LTE APC Pass")) { + return true; + } + return false; + } + } \ No newline at end of file diff --git a/app/src/main/java/mobile/miki/adapter/TestMainListAdapter.java b/app/src/main/java/mobile/miki/adapter/TestMainListAdapter.java index 7a4379a..366d69d 100644 --- a/app/src/main/java/mobile/miki/adapter/TestMainListAdapter.java +++ b/app/src/main/java/mobile/miki/adapter/TestMainListAdapter.java @@ -1,57 +1,61 @@ -package mobile.miki.adapter; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.TextView; - -import java.util.List; - -import mobile.miki.R; - -public class TestMainListAdapter extends BaseAdapter { - private Context mContext; - private List list; - private String[] stateArr; - - public TestMainListAdapter(Context context, List list, String[] stateArr) { - mContext = context; - this.list = list; - this.stateArr = stateArr; - } - - @Override - public int getCount() { - return list.size(); - } - - @Override - public Object getItem(int i) { - return list.get(i); - } - - @Override - public long getItemId(int i) { - return 0; - } - @Override - public View getView(int position, View convertView, ViewGroup parent) { - LayoutInflater mInflater = LayoutInflater.from(mContext); - convertView = mInflater.inflate(R.layout.testmain_adapter, null); - TextView text = (TextView) convertView.findViewById(R.id.text_item); - text.setText(list.get(position)); - if (stateArr[position].equals("true")) { - convertView.setBackgroundResource(R.drawable.button_common_green_bg); - } else if (stateArr[position].equals("false")) { - convertView.setBackgroundResource(R.drawable.button_common_red_bg); - } - return convertView; - } - - private String getString(int stringId) { - return mContext.getResources().getString(stringId); - } - -} +package mobile.miki.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import java.util.List; + +import mobile.miki.R; +import mobile.miki.util.FTUtils; + +public class TestMainListAdapter extends BaseAdapter { + private Context mContext; + private List list; + private String[] stateArr; + + public TestMainListAdapter(Context context, List list, String[] stateArr) { + mContext = context; + this.list = list; + this.stateArr = stateArr; + } + + @Override + public int getCount() { + return list.size(); + } + + @Override + public Object getItem(int i) { + return list.get(i); + } + + @Override + public long getItemId(int i) { + return 0; + } + @Override + public View getView(int position, View convertView, ViewGroup parent) { + LayoutInflater mInflater = LayoutInflater.from(mContext); + if(FTUtils.isGT09()) + convertView = mInflater.inflate(R.layout.testmain_adapter_280, null); + else + convertView = mInflater.inflate(R.layout.testmain_adapter, null); + TextView text = (TextView) convertView.findViewById(R.id.text_item); + text.setText(list.get(position)); + if (stateArr[position].equals("true")) { + convertView.setBackgroundResource(R.drawable.button_common_green_bg); + } else if (stateArr[position].equals("false")) { + convertView.setBackgroundResource(R.drawable.button_common_red_bg); + } + return convertView; + } + + private String getString(int stringId) { + return mContext.getResources().getString(stringId); + } + +} diff --git a/app/src/main/java/mobile/miki/mainui/TestMainActivity.java b/app/src/main/java/mobile/miki/mainui/TestMainActivity.java index e6deeb2..6bd1202 100644 --- a/app/src/main/java/mobile/miki/mainui/TestMainActivity.java +++ b/app/src/main/java/mobile/miki/mainui/TestMainActivity.java @@ -79,7 +79,10 @@ public class TestMainActivity extends BaseActivity implements OnClickListener, A protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyApplication.getInstance().addActivity(this); - setContentView(R.layout.urovo_layout_table); + if(FTUtils.isGT09()) + setContentView(R.layout.urovo_layout_table_280); + else + setContentView(R.layout.urovo_layout_table); initView(); } diff --git a/app/src/main/java/mobile/miki/mainui/TestMainList.java b/app/src/main/java/mobile/miki/mainui/TestMainList.java index df0ed4b..2babe78 100644 --- a/app/src/main/java/mobile/miki/mainui/TestMainList.java +++ b/app/src/main/java/mobile/miki/mainui/TestMainList.java @@ -57,6 +57,9 @@ public class TestMainList extends BaseActivity implements OnClickListener { // TODO Auto-generated method stub super.onCreate(savedInstanceState); MyApplication.getInstance().addActivity(this); + if(FTUtils.isGT09()){ + setContentView(R.layout.dig_layout_testlist_280); + }else setContentView(R.layout.dig_layout_testlist); pcbatest = (LinearLayout) findViewById(R.id.pcba_test); diff --git a/app/src/main/java/mobile/miki/util/Config.java b/app/src/main/java/mobile/miki/util/Config.java index 030b810..186dada 100644 --- a/app/src/main/java/mobile/miki/util/Config.java +++ b/app/src/main/java/mobile/miki/util/Config.java @@ -1,320 +1,329 @@ -package mobile.miki.util; - -import android.app.Application; -import android.content.Context; -import android.content.Intent; - -import java.util.ArrayList; -import java.util.List; - -import mobile.miki.AntiMonitorActivity; -import mobile.miki.BatteryTestActivity; -import mobile.miki.BlooToothActivity; -import mobile.miki.BrightnessTest; -import mobile.miki.CameraPreview; -import mobile.miki.DSPActivity; -import mobile.miki.DialerTestActivity; -import mobile.miki.GpsTest; -import mobile.miki.GravitySensorActivity; -import mobile.miki.HeartRate; -import mobile.miki.KeysTestActivity; -import mobile.miki.MikeTest; -import mobile.miki.MotorTestActivity; -import mobile.miki.MyApplication; -import mobile.miki.R; -import mobile.miki.RingtoneActivity; -import mobile.miki.SimDetectActivity; -import mobile.miki.SystemMemory; -import mobile.miki.TemperatureActivity; -import mobile.miki.TouchTest; -import mobile.miki.UltravioletMonitorActivity; -import mobile.miki.VersionActivity; -import mobile.miki.WifiTestActiviy; -import mobile.miki.lcd.LcdActivity; -import mobile.miki.mainui.TestMainActivity; - -public class Config { - - private static List TestItems=null; - private static List TestResult=null; - public static void setTestItems(List items){ - - if(items==null){ - Logger.d("setTestItems items is null"); - return ; - } - if (TestItems==null){ - TestItems=new ArrayList(); - TestResult=new ArrayList(); - } - TestItems.clear(); - TestResult.clear(); - - for (int i=0;i< items.size();i++ ) { - TestItems.add(i,items.get(i)); - TestResult.add(i,"false"); - } - - } - - public static int getIndexByTestItemName(String name){ - Logger.d("name "+name+" item "+TestItems); - -// if (TestItems==null) initConfig(MyApplication.getInstance().getApplicationContext()); - if(name!=null && TestItems!=null) { - for (int i = 0; i < TestItems.size(); i++) { - Logger.d("name "+name+" item "+TestItems.get(i)+" "+i); - if (name.equals(TestItems.get(i))) { - return i; - } - } - } - return -1; - } - public static String getNextTestItemName(String testItemmName){ - - int index=-1; - index=getIndexByTestItemName(testItemmName); - Logger.d("find "+testItemmName+", index "+index); - if (TestItems!=null && index >=0&& index+1< TestItems.size()){ - String itemname= TestItems.get(index+1); - return itemname; - }else{ - return null; - } - } - public static String getNextTestItemName(int index){ - if (TestItems!=null && index >=0&& index+1< TestItems.size()){ - return TestItems.get(index+1); - }else{ - return null; - } - } - - public static Intent getNextTestIntent(Context context,Class cls){ - String currentTestItemName=getTestNameByClass(context,cls.getSimpleName()); - Logger.d("currentTestItemName="+currentTestItemName); - String nextTestItemName=getNextTestItemName(currentTestItemName); - Logger.d("nextTestItemName="+nextTestItemName); - return getIntent(context,nextTestItemName); - } - public static String getTestNameByClass(Context context,String ClassName){ - - if (context==null || ClassName==null) return null; - if (ClassName.equals(VersionActivity.class.getSimpleName())) { - return context.getResources().getString(R.string.version_new); - }else if (ClassName.equals(TouchTest.class.getSimpleName())){ - return context.getResources().getString(R.string.touch); - }else if (ClassName.equals(LcdActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.light_new); - }else if (ClassName.equals(CameraPreview.class.getSimpleName())){ - return context.getResources().getString(R.string.camera); - }else if (ClassName.equals(WifiTestActiviy.class.getSimpleName())){ - return context.getResources().getString(R.string.wifi); - }else if (ClassName.equals(GpsTest.class.getSimpleName())){ - return context.getResources().getString(R.string.gps); - }else if (ClassName.equals(RingtoneActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.speak); - }else if (ClassName.equals(MikeTest.class.getSimpleName())){ - return context.getResources().getString(R.string.mic_title); - }else if (ClassName.equals(SimDetectActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.sim_title); - }else if (ClassName.equals(DialerTestActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.dual_new); - }else if (ClassName.equals(SystemMemory.class.getSimpleName())){ - return context.getResources().getString(R.string.ramromTest); - }else if (ClassName.equals(BrightnessTest.class.getSimpleName())){ - return context.getResources().getString(R.string.beiguang_new); - }else if (ClassName.equals(GravitySensorActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.test_sensor); - }else if (ClassName.equals(BatteryTestActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.test_battery); - }else if (ClassName.equals(KeysTestActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.test_keypad); - }else if (ClassName.equals(BlooToothActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.bt); - }else if (ClassName.equals(MotorTestActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.shakeTest); - }else if (ClassName.equals(UltravioletMonitorActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.ultraviolet); - }else if (ClassName.equals(DSPActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.dsp); - }else if (ClassName.equals(HeartRate.class.getSimpleName())) { - return context.getResources().getString(R.string.heartrate); - }else if (ClassName.equals(AntiMonitorActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.anti_check); - }else if (ClassName.equals(TemperatureActivity.class.getSimpleName())){ - return context.getResources().getString(R.string.temperature); - }else { - - return null; - } - - } - public static Intent getIntent(Context context, String testItemName) { - - if (context==null || testItemName==null) - return (new Intent(context, TestMainActivity.class));; - Intent intent = null; - if (testItemName.equals(context.getResources().getString(R.string.version_new))) { - intent = new Intent(context, VersionActivity.class); - } else if (testItemName.equals(context.getResources().getString(R.string.touch))) { - intent = new Intent(context, TouchTest.class); - } else if (testItemName.equals(context.getResources().getString(R.string.light_new))) { - intent = new Intent(context, LcdActivity.class); - } else if (testItemName.equals(context.getResources().getString(R.string.camera))) { - intent = new Intent(context, CameraPreview.class); - } else if (testItemName.equals(context.getResources().getString(R.string.wifi))) { - intent = new Intent(context, WifiTestActiviy.class); - }else if (testItemName.equals(context.getResources().getString(R.string.gps))) { - intent = new Intent(context, GpsTest.class); - }else if (testItemName.equals(context.getResources().getString(R.string.speak))) { - intent = new Intent(context, RingtoneActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.mic_title))) { - intent = new Intent(context, MikeTest.class); - }else if (testItemName.equals(context.getResources().getString(R.string.sim_title))) { - intent = new Intent(context, SimDetectActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.dual_new))) { - intent = new Intent(context, DialerTestActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.ramromTest))) { - intent = new Intent(context, SystemMemory.class); - }else if (testItemName.equals(context.getResources().getString(R.string.beiguang_new))) { - intent = new Intent(context, BrightnessTest.class); - }else if (testItemName.equals(context.getResources().getString(R.string.test_sensor))) { - intent = new Intent(context, GravitySensorActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.test_battery))) { - intent = new Intent(context, BatteryTestActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.test_keypad))) { - intent = new Intent(context, KeysTestActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.bt))) { - intent = new Intent(context, BlooToothActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.shakeTest))) { - intent = new Intent(context, MotorTestActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.ultraviolet))) { - intent = new Intent(context, UltravioletMonitorActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.dsp))) { - intent = new Intent(context, DSPActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.heartrate))) { - intent = new Intent(context, HeartRate.class); - }else if (testItemName.equals(context.getResources().getString(R.string.anti_check))) { - intent = new Intent(context, AntiMonitorActivity.class); - }else if (testItemName.equals(context.getResources().getString(R.string.temperature))) { - intent = new Intent(context, TemperatureActivity.class); - } - - if (intent != null) { - intent.putExtra("running", false); - }else{ - intent = new Intent(context, TestMainActivity.class); - } - return intent; - } - public static String getItemAt(int i){ - if (TestItems!=null && i >=0&& i< TestItems.size()){ - return TestItems.get(i); - }else{ - return null; - } - } - public static String getItemResultAt(int i){ - if (TestResult!=null && i >=0&& i< TestResult.size()){ - return TestResult.get(i); - }else{ - return null; - } - } - - public static boolean setTestResult(int i, boolean pass){ - if (TestResult!=null && i >=0&& i< TestResult.size()){ - TestResult.set(i,String.valueOf(pass)); - return true; - } - return false; - } - - public static void initConfig(Context context){ - setTestItems(getArray(context)); - - } - - public static String[] getList(Context context) { - String[] listTem = {context.getString(R.string.version_new), context.getString(R.string.touch), context.getString(R.string.light_new), context.getString(R.string.camera), - context.getString(R.string.wifi), context.getString(R.string.gps), context.getString(R.string.speak), context.getString(R.string.mic_title), - context.getString(R.string.sim_title), context.getString(R.string.dual_new), context.getString(R.string.ramromTest), context.getString(R.string.beiguang_new), - context.getString(R.string.test_sensor), context.getString(R.string.test_battery)}; - return listTem; - } - public static String[] stateArr; - public static List testResultList; - public static List getArray(Context context) { - List list = new ArrayList(); - testResultList = new ArrayList(); - for (int i = 0; i < getList(context).length; i++) { - list.add(getList(context)[i]); - testResultList.add(sharedPreferencesArr[i]); - } - if (FTUtils.isLieBao()) { - list.add(context.getString(R.string.test_keypad)); - testResultList.add("keys"); - } else if (FTUtils.isSugar()) { - list.add(context.getString(R.string.test_keypad)); - list.add(context.getString(R.string.bt)); - list.add(context.getString(R.string.shakeTest)); - list.add(context.getString(R.string.ultraviolet)); - - testResultList.add("keys"); - testResultList.add("bt"); - testResultList.add("vibrator"); - testResultList.add("Ultraviolet"); - } else if (FTUtils.isS06()) { - // s06 添加dsp测试 - list.add(context.getString(R.string.hall)); - list.add(context.getString(R.string.bt)); - list.add(context.getString(R.string.dsp)); - list.add(context.getString(R.string.heartrate)); - - testResultList.add("keys"); - testResultList.add("bt"); - testResultList.add("dsp"); - testResultList.add("heartrate"); - - } else if (FTUtils.hasHRS_TEMP()){ - - //list.add(context.getString(R.string.test_keypad)); - list.add(context.getString(R.string.heartrate)); - list.add(context.getString(R.string.temperature)); - list.remove(context.getString(R.string.camera)); - list.add(context.getString(R.string.anti_check)); - //testResultList.add("keys"); - testResultList.add("heartrate"); - testResultList.add("temperature"); - testResultList.remove("camera"); - testResultList.add("anti"); - } else if (FTUtils.isQ3FT()){ - list.add(context.getString(R.string.test_keypad)); - list.add(context.getString(R.string.heartrate)); - list.add(context.getString(R.string.temperature)); - list.remove(context.getString(R.string.camera)); - list.add(context.getString(R.string.anti_check)); - testResultList.add("keys"); - testResultList.add("heartrate"); - testResultList.add("temperature"); - testResultList.remove("camera"); - testResultList.add("anti"); - } else if (FTUtils.isQ3F()){ - - list.add(context.getString(R.string.test_keypad)); - list.add(context.getString(R.string.shakeTest)); - list.add(context.getString(R.string.heartrate)); - testResultList.add("keys"); - testResultList.add("vibrator"); - testResultList.add("heartrate"); - } - stateArr = new String[testResultList.size()]; - return list; - } - - - static String[] sharedPreferencesArr = {"version", "touch", "lcd", "camera", "wifi", "gps", "speak", "mic", "sim", "dialer", - "watchmemory", "light", "Gsensor", "watchbattery"/*, "keys", "bt", "vibrator", "Ultraviolet", "dsp"*/}; -} +package mobile.miki.util; + +import android.app.Application; +import android.content.Context; +import android.content.Intent; + +import java.util.ArrayList; +import java.util.List; + +import mobile.miki.AntiMonitorActivity; +import mobile.miki.BatteryTestActivity; +import mobile.miki.BlooToothActivity; +import mobile.miki.BrightnessTest; +import mobile.miki.CameraPreview; +import mobile.miki.DSPActivity; +import mobile.miki.DialerTestActivity; +import mobile.miki.GpsTest; +import mobile.miki.GravitySensorActivity; +import mobile.miki.HeartRate; +import mobile.miki.KeysTestActivity; +import mobile.miki.MikeTest; +import mobile.miki.MotorTestActivity; +import mobile.miki.MyApplication; +import mobile.miki.R; +import mobile.miki.RingtoneActivity; +import mobile.miki.SimDetectActivity; +import mobile.miki.SystemMemory; +import mobile.miki.TemperatureActivity; +import mobile.miki.TouchTest; +import mobile.miki.UltravioletMonitorActivity; +import mobile.miki.VersionActivity; +import mobile.miki.WifiTestActiviy; +import mobile.miki.lcd.LcdActivity; +import mobile.miki.mainui.TestMainActivity; + +public class Config { + + private static List TestItems=null; + private static List TestResult=null; + public static void setTestItems(List items){ + + if(items==null){ + Logger.d("setTestItems items is null"); + return ; + } + if (TestItems==null){ + TestItems=new ArrayList(); + TestResult=new ArrayList(); + } + TestItems.clear(); + TestResult.clear(); + + for (int i=0;i< items.size();i++ ) { + TestItems.add(i,items.get(i)); + TestResult.add(i,"false"); + } + + } + + public static int getIndexByTestItemName(String name){ + Logger.d("name "+name+" item "+TestItems); + +// if (TestItems==null) initConfig(MyApplication.getInstance().getApplicationContext()); + if(name!=null && TestItems!=null) { + for (int i = 0; i < TestItems.size(); i++) { + Logger.d("name "+name+" item "+TestItems.get(i)+" "+i); + if (name.equals(TestItems.get(i))) { + return i; + } + } + } + return -1; + } + public static String getNextTestItemName(String testItemmName){ + + int index=-1; + index=getIndexByTestItemName(testItemmName); + Logger.d("find "+testItemmName+", index "+index); + if (TestItems!=null && index >=0&& index+1< TestItems.size()){ + String itemname= TestItems.get(index+1); + return itemname; + }else{ + return null; + } + } + public static String getNextTestItemName(int index){ + if (TestItems!=null && index >=0&& index+1< TestItems.size()){ + return TestItems.get(index+1); + }else{ + return null; + } + } + + public static Intent getNextTestIntent(Context context,Class cls){ + String currentTestItemName=getTestNameByClass(context,cls.getSimpleName()); + Logger.d("currentTestItemName="+currentTestItemName); + String nextTestItemName=getNextTestItemName(currentTestItemName); + Logger.d("nextTestItemName="+nextTestItemName); + return getIntent(context,nextTestItemName); + } + public static String getTestNameByClass(Context context,String ClassName){ + + if (context==null || ClassName==null) return null; + if (ClassName.equals(VersionActivity.class.getSimpleName())) { + return context.getResources().getString(R.string.version_new); + }else if (ClassName.equals(TouchTest.class.getSimpleName())){ + return context.getResources().getString(R.string.touch); + }else if (ClassName.equals(LcdActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.light_new); + }else if (ClassName.equals(CameraPreview.class.getSimpleName())){ + return context.getResources().getString(R.string.camera); + }else if (ClassName.equals(WifiTestActiviy.class.getSimpleName())){ + return context.getResources().getString(R.string.wifi); + }else if (ClassName.equals(GpsTest.class.getSimpleName())){ + return context.getResources().getString(R.string.gps); + }else if (ClassName.equals(RingtoneActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.speak); + }else if (ClassName.equals(MikeTest.class.getSimpleName())){ + return context.getResources().getString(R.string.mic_title); + }else if (ClassName.equals(SimDetectActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.sim_title); + }else if (ClassName.equals(DialerTestActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.dual_new); + }else if (ClassName.equals(SystemMemory.class.getSimpleName())){ + return context.getResources().getString(R.string.ramromTest); + }else if (ClassName.equals(BrightnessTest.class.getSimpleName())){ + return context.getResources().getString(R.string.beiguang_new); + }else if (ClassName.equals(GravitySensorActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.test_sensor); + }else if (ClassName.equals(BatteryTestActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.test_battery); + }else if (ClassName.equals(KeysTestActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.test_keypad); + }else if (ClassName.equals(BlooToothActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.bt); + }else if (ClassName.equals(MotorTestActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.shakeTest); + }else if (ClassName.equals(UltravioletMonitorActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.ultraviolet); + }else if (ClassName.equals(DSPActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.dsp); + }else if (ClassName.equals(HeartRate.class.getSimpleName())) { + return context.getResources().getString(R.string.heartrate); + }else if (ClassName.equals(AntiMonitorActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.anti_check); + }else if (ClassName.equals(TemperatureActivity.class.getSimpleName())){ + return context.getResources().getString(R.string.temperature); + }else { + + return null; + } + + } + public static Intent getIntent(Context context, String testItemName) { + + if (context==null || testItemName==null) + return (new Intent(context, TestMainActivity.class));; + Intent intent = null; + if (testItemName.equals(context.getResources().getString(R.string.version_new))) { + intent = new Intent(context, VersionActivity.class); + } else if (testItemName.equals(context.getResources().getString(R.string.touch))) { + intent = new Intent(context, TouchTest.class); + } else if (testItemName.equals(context.getResources().getString(R.string.light_new))) { + intent = new Intent(context, LcdActivity.class); + } else if (testItemName.equals(context.getResources().getString(R.string.camera))) { + intent = new Intent(context, CameraPreview.class); + } else if (testItemName.equals(context.getResources().getString(R.string.wifi))) { + intent = new Intent(context, WifiTestActiviy.class); + }else if (testItemName.equals(context.getResources().getString(R.string.gps))) { + intent = new Intent(context, GpsTest.class); + }else if (testItemName.equals(context.getResources().getString(R.string.speak))) { + intent = new Intent(context, RingtoneActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.mic_title))) { + intent = new Intent(context, MikeTest.class); + }else if (testItemName.equals(context.getResources().getString(R.string.sim_title))) { + intent = new Intent(context, SimDetectActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.dual_new))) { + intent = new Intent(context, DialerTestActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.ramromTest))) { + intent = new Intent(context, SystemMemory.class); + }else if (testItemName.equals(context.getResources().getString(R.string.beiguang_new))) { + intent = new Intent(context, BrightnessTest.class); + }else if (testItemName.equals(context.getResources().getString(R.string.test_sensor))) { + intent = new Intent(context, GravitySensorActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.test_battery))) { + intent = new Intent(context, BatteryTestActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.test_keypad))) { + intent = new Intent(context, KeysTestActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.bt))) { + intent = new Intent(context, BlooToothActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.shakeTest))) { + intent = new Intent(context, MotorTestActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.ultraviolet))) { + intent = new Intent(context, UltravioletMonitorActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.dsp))) { + intent = new Intent(context, DSPActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.heartrate))) { + intent = new Intent(context, HeartRate.class); + }else if (testItemName.equals(context.getResources().getString(R.string.anti_check))) { + intent = new Intent(context, AntiMonitorActivity.class); + }else if (testItemName.equals(context.getResources().getString(R.string.temperature))) { + intent = new Intent(context, TemperatureActivity.class); + } + + if (intent != null) { + intent.putExtra("running", false); + }else{ + intent = new Intent(context, TestMainActivity.class); + } + return intent; + } + public static String getItemAt(int i){ + if (TestItems!=null && i >=0&& i< TestItems.size()){ + return TestItems.get(i); + }else{ + return null; + } + } + public static String getItemResultAt(int i){ + if (TestResult!=null && i >=0&& i< TestResult.size()){ + return TestResult.get(i); + }else{ + return null; + } + } + + public static boolean setTestResult(int i, boolean pass){ + if (TestResult!=null && i >=0&& i< TestResult.size()){ + TestResult.set(i,String.valueOf(pass)); + return true; + } + return false; + } + + public static void initConfig(Context context){ + setTestItems(getArray(context)); + + } + + public static String[] getList(Context context) { + String[] listTem = {context.getString(R.string.version_new), context.getString(R.string.touch), context.getString(R.string.light_new), context.getString(R.string.camera), + context.getString(R.string.wifi), context.getString(R.string.gps), context.getString(R.string.speak), context.getString(R.string.mic_title), + context.getString(R.string.sim_title), context.getString(R.string.dual_new), context.getString(R.string.ramromTest), context.getString(R.string.beiguang_new), + context.getString(R.string.test_sensor), context.getString(R.string.test_battery)}; + return listTem; + } + public static String[] stateArr; + public static List testResultList; + public static List getArray(Context context) { + List list = new ArrayList(); + testResultList = new ArrayList(); + for (int i = 0; i < getList(context).length; i++) { + list.add(getList(context)[i]); + testResultList.add(sharedPreferencesArr[i]); + } + if (FTUtils.isLieBao()) { + list.add(context.getString(R.string.test_keypad)); + testResultList.add("keys"); + } else if (FTUtils.isSugar()) { + list.add(context.getString(R.string.test_keypad)); + list.add(context.getString(R.string.bt)); + list.add(context.getString(R.string.shakeTest)); + list.add(context.getString(R.string.ultraviolet)); + + testResultList.add("keys"); + testResultList.add("bt"); + testResultList.add("vibrator"); + testResultList.add("Ultraviolet"); + } else if (FTUtils.isS06()) { + // s06 添加dsp测试 + list.add(context.getString(R.string.hall)); + list.add(context.getString(R.string.bt)); + list.add(context.getString(R.string.dsp)); + list.add(context.getString(R.string.heartrate)); + + testResultList.add("keys"); + testResultList.add("bt"); + testResultList.add("dsp"); + testResultList.add("heartrate"); + + + } else if (FTUtils.isQ3FT()){ + list.add(context.getString(R.string.test_keypad)); + list.add(context.getString(R.string.heartrate)); + list.add(context.getString(R.string.temperature)); + list.add(context.getString(R.string.shakeTest)); + list.add(context.getString(R.string.anti_check)); + testResultList.add("keys"); + testResultList.add("heartrate"); + testResultList.add("temperature"); + testResultList.add("vibrator"); + testResultList.add("anti"); + } else if (FTUtils.isQ3F()){ + + list.add(context.getString(R.string.test_keypad)); + list.add(context.getString(R.string.shakeTest)); + list.add(context.getString(R.string.heartrate)); + testResultList.add("keys"); + testResultList.add("vibrator"); + testResultList.add("heartrate"); + }else if (FTUtils.isGT09()) { + list.add(context.getString(R.string.shakeTest)); + testResultList.add("vibrator"); + + list.remove(context.getString(R.string.sim_title)); + list.remove(context.getString(R.string.dual_new)); + testResultList.remove("sim"); + testResultList.remove("dialer"); + } else if (FTUtils.hasHRS_TEMP()){ + + //list.add(context.getString(R.string.test_keypad)); + list.remove(context.getString(R.string.camera)); + list.add(context.getString(R.string.heartrate)); + list.add(context.getString(R.string.temperature)); + list.add(context.getString(R.string.anti_check)); + //testResultList.add("keys"); + testResultList.remove("camera"); + testResultList.add("heartrate"); + testResultList.add("temperature"); + testResultList.add("anti"); + } + stateArr = new String[testResultList.size()]; + return list; + } + + + static String[] sharedPreferencesArr = {"version", "touch", "lcd", "camera", "wifi", "gps", "speak", "mic", "sim", "dialer", + "watchmemory", "light", "Gsensor", "watchbattery"/*, "keys", "bt", "vibrator", "Ultraviolet", "dsp"*/}; +} diff --git a/app/src/main/java/mobile/miki/util/FTUtils.java b/app/src/main/java/mobile/miki/util/FTUtils.java index 21f7cee..052fa2a 100644 --- a/app/src/main/java/mobile/miki/util/FTUtils.java +++ b/app/src/main/java/mobile/miki/util/FTUtils.java @@ -1,242 +1,254 @@ -package mobile.miki.util; - -import android.bluetooth.BluetoothAdapter; -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Build; -import android.os.SystemProperties; -import android.telephony.TelephonyManager; -import android.util.Log; - -import java.io.FileInputStream; -import java.lang.reflect.Method; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.util.Enumeration; - -public class FTUtils { - public static String getDISPLAY() { - return Build.DISPLAY.toUpperCase(); - } - - public static String getMODEL() { - return Build.MODEL.toUpperCase(); - } - - /** - * 展讯猎豹项目 - * @return - */ - public static boolean isLieBao() { - return getMODEL().contains("C02A") || getMODEL().contains("S09") || getMODEL().contains("C02"); - } - - /** - * sugar - * @return - */ - public static boolean isSugar() { - return getDISPLAY().contains("W501CS") || getMODEL().contains("SUGAR"); - } - - public static boolean doPCBATest(){ - return false; - } - public static void SetPreferences(Context paramContext, int paramInt, - Long time) { - SharedPreferences sharedPreferences = paramContext.getSharedPreferences("AgingTest", 0); - String str = paramContext.getResources().getString(paramInt); - SharedPreferences.Editor localEditor = sharedPreferences.edit(); - localEditor.putLong(str, time); - localEditor.commit(); - } - - public static long GetPreferences(Context paramContext, int paramInt) { - SharedPreferences sharedPreferences = paramContext.getSharedPreferences("AgingTest", 0); - String str = paramContext.getResources().getString(paramInt); - long time = sharedPreferences.getLong(str, 0); - return time; - } - - public static void SetAgeingWorktimePreferences(Context paramContext, int paramInt, - int time) { - SharedPreferences sharedPreferences = paramContext.getSharedPreferences("AgingTest_workTime", 0); - String str = paramContext.getResources().getString(paramInt); - SharedPreferences.Editor localEditor = sharedPreferences.edit(); - localEditor.putInt(str, time); - localEditor.commit(); - } - - public static int GetAgeingWorktimePreferences(Context paramContext, int paramInt) { - SharedPreferences sharedPreferences = paramContext.getSharedPreferences("AgingTest_workTime", 0); - String str = paramContext.getResources().getString(paramInt); - int time = sharedPreferences.getInt(str, 0); - return time; - } - - - /** - * android 7.0及以上 (2)扫描各个网络接口获取mac地址 - * - */ - /** - * 获取设备HardwareAddress地址 - * - * @return - */ - public static String getWifiMacAddress() { - Enumeration interfaces = null; - try { - interfaces = NetworkInterface.getNetworkInterfaces(); - } catch (SocketException e) { - e.printStackTrace(); - } - String hardWareAddress = null; - NetworkInterface iF = null; - if (interfaces == null) { - return null; - } - while (interfaces.hasMoreElements()) { - iF = interfaces.nextElement(); - try { - hardWareAddress = bytesToString(iF.getHardwareAddress()); - if (hardWareAddress != null) - break; - } catch (SocketException e) { - e.printStackTrace(); - } - } - return hardWareAddress; - } - - /*** - * byte转为String - * - * @param bytes - * @return - */ - private static String bytesToString(byte[] bytes) { - if (bytes == null || bytes.length == 0) { - return null; - } - StringBuilder buf = new StringBuilder(); - for (byte b : bytes) { - buf.append(String.format("%02X:", b)); - } - if (buf.length() > 0) { - buf.deleteCharAt(buf.length() - 1); - } - return buf.toString(); - } - - - - // 展讯获取cid - public static String GetCidFromSystem() { - String cid_file = SystemProperties.get("ro.product.partitionpath", "") + "miscdata"; - byte[] resCid = new byte[16]; - try { - byte[] buf = new byte[50]; - FileInputStream inputStream = new FileInputStream(cid_file); - int len = inputStream.read(buf); - if (len < 50) return null; - for (int i = 0; i < 16; i++) { - resCid[i] = buf[i + 28]; - } -// for (int i = 0; i < 16; i++) { -// if ((resCid[i] >= 0x30 && resCid[i] <= 0x39) || (resCid[i] >= 0x61 && resCid[i] <= 0x7A) || (resCid[i] >= 0x41 && resCid[i] <= 0x5A)) { -// // valid -// } else { -// // invalid -// for (int j = 28; j < 28 + 16; j++) { -// resCid[j] = 0x30; -// } -// break; -// } -// } - } catch (Exception e) { - e.printStackTrace(); - } - String cid = new String(resCid); - Log.d("FTUtils", "get cid=" + cid); - return cid; - } - - public static String getImei(Context context) { - TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); - String imei = ""; - - Class clazz = null; - if (manager != null) { - clazz = manager.getClass(); - } - - try { - Method getImei = null; - if (clazz != null) { - getImei = clazz.getDeclaredMethod("getImei"); - } - if (getImei != null) { - getImei.setAccessible(true); - imei = (String) getImei.invoke(manager); - } - } catch (Exception e) { - e.printStackTrace(); - } - return imei; - } - - public static String getBtAddressViaReflection() { - return BluetoothAdapter.getDefaultAdapter().getAddress(); - } - - public static boolean isS06() { - if (SystemProperties.get("ro.product.brand", "").equalsIgnoreCase("SPRD") && SystemProperties.get("ro.build.version.release", "").equalsIgnoreCase("8.1.0")) { - return true; - } - return false; - } - - public static boolean isA9(){ - if(SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("A9") - || SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("YQ")) { - - return true; - } - return false; - } - public static boolean isV20(){ - if(SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("V20") - || SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("C46")) { - - return true; - } - return false; - } - public static boolean isQ3FT(){ - - if ( SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("VitracK")) { - return true; - } - return false; - } - public static boolean isQ3F(){ - - if (getMODEL().contains("C41-QL02")||getMODEL().contains("C41S-QL02")|| SystemProperties.get("ro.product.isQ3F","").equalsIgnoreCase("true") || SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("q3f")) { - return true; - } - return false; - } - public static boolean hasHRS_TEMP(){ - - if (getMODEL().contains("H88") - ||SystemProperties.get("ro.product.isH88","").equalsIgnoreCase("true") - || SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("H88") - || SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("A9") - || SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("YQ") - ) { - return true; - } - return false; - } -} +package mobile.miki.util; + +import android.bluetooth.BluetoothAdapter; +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Build; +import android.os.SystemProperties; +import android.telephony.TelephonyManager; +import android.util.Log; + +import java.io.FileInputStream; +import java.lang.reflect.Method; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.Enumeration; + +public class FTUtils { + public static String getDISPLAY() { + return Build.DISPLAY.toUpperCase(); + } + + public static String getMODEL() { + return Build.MODEL.toUpperCase(); + } + + /** + * 展讯猎豹项目 + * @return + */ + public static boolean isLieBao() { +// return getMODEL().contains("C02A") || getMODEL().contains("S09") || getMODEL().contains("C02"); + return false; + } + + /** + * sugar + * @return + */ + public static boolean isSugar() { +// return getDISPLAY().contains("W501CS") || getMODEL().contains("SUGAR"); + return false; + } + + public static boolean doPCBATest(){ + return false; + } + public static void SetPreferences(Context paramContext, int paramInt, + Long time) { + SharedPreferences sharedPreferences = paramContext.getSharedPreferences("AgingTest", 0); + String str = paramContext.getResources().getString(paramInt); + SharedPreferences.Editor localEditor = sharedPreferences.edit(); + localEditor.putLong(str, time); + localEditor.commit(); + } + + public static long GetPreferences(Context paramContext, int paramInt) { + SharedPreferences sharedPreferences = paramContext.getSharedPreferences("AgingTest", 0); + String str = paramContext.getResources().getString(paramInt); + long time = sharedPreferences.getLong(str, 0); + return time; + } + + public static void SetAgeingWorktimePreferences(Context paramContext, int paramInt, + int time) { + SharedPreferences sharedPreferences = paramContext.getSharedPreferences("AgingTest_workTime", 0); + String str = paramContext.getResources().getString(paramInt); + SharedPreferences.Editor localEditor = sharedPreferences.edit(); + localEditor.putInt(str, time); + localEditor.commit(); + } + + public static int GetAgeingWorktimePreferences(Context paramContext, int paramInt) { + SharedPreferences sharedPreferences = paramContext.getSharedPreferences("AgingTest_workTime", 0); + String str = paramContext.getResources().getString(paramInt); + int time = sharedPreferences.getInt(str, 0); + return time; + } + + + /** + * android 7.0及以上 (2)扫描各个网络接口获取mac地址 + * + */ + /** + * 获取设备HardwareAddress地址 + * + * @return + */ + public static String getWifiMacAddress() { + Enumeration interfaces = null; + try { + interfaces = NetworkInterface.getNetworkInterfaces(); + } catch (SocketException e) { + e.printStackTrace(); + } + String hardWareAddress = null; + NetworkInterface iF = null; + if (interfaces == null) { + return null; + } + while (interfaces.hasMoreElements()) { + iF = interfaces.nextElement(); + try { + hardWareAddress = bytesToString(iF.getHardwareAddress()); + if (hardWareAddress != null) + break; + } catch (SocketException e) { + e.printStackTrace(); + } + } + return hardWareAddress; + } + + /*** + * byte转为String + * + * @param bytes + * @return + */ + private static String bytesToString(byte[] bytes) { + if (bytes == null || bytes.length == 0) { + return null; + } + StringBuilder buf = new StringBuilder(); + for (byte b : bytes) { + buf.append(String.format("%02X:", b)); + } + if (buf.length() > 0) { + buf.deleteCharAt(buf.length() - 1); + } + return buf.toString(); + } + + + + // 展讯获取cid + public static String GetCidFromSystem() { + String cid_file = SystemProperties.get("ro.product.partitionpath", "") + "miscdata"; + byte[] resCid = new byte[16]; + try { + byte[] buf = new byte[50]; + FileInputStream inputStream = new FileInputStream(cid_file); + int len = inputStream.read(buf); + if (len < 50) return null; + for (int i = 0; i < 16; i++) { + resCid[i] = buf[i + 28]; + } +// for (int i = 0; i < 16; i++) { +// if ((resCid[i] >= 0x30 && resCid[i] <= 0x39) || (resCid[i] >= 0x61 && resCid[i] <= 0x7A) || (resCid[i] >= 0x41 && resCid[i] <= 0x5A)) { +// // valid +// } else { +// // invalid +// for (int j = 28; j < 28 + 16; j++) { +// resCid[j] = 0x30; +// } +// break; +// } +// } + } catch (Exception e) { + e.printStackTrace(); + } + String cid = new String(resCid); + Log.d("FTUtils", "get cid=" + cid); + return cid; + } + + public static String getImei(Context context) { + TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + String imei = ""; + + Class clazz = null; + if (manager != null) { + clazz = manager.getClass(); + } + + try { + Method getImei = null; + if (clazz != null) { + getImei = clazz.getDeclaredMethod("getImei"); + } + if (getImei != null) { + getImei.setAccessible(true); + imei = (String) getImei.invoke(manager); + } + } catch (Exception e) { + e.printStackTrace(); + } + return imei; + } + + public static String getBtAddressViaReflection() { + return BluetoothAdapter.getDefaultAdapter().getAddress(); + } + + public static boolean isS06() { +// if (SystemProperties.get("ro.product.brand", "").equalsIgnoreCase("SPRD") && SystemProperties.get("ro.build.version.release", "").equalsIgnoreCase("8.1.0")) { +// return true; +// } + return false; + } + + public static boolean isA9(){ + if(SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("A9") + || SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("YQ")) { + + return true; + } + return false; + } + public static boolean isV20(){ + if(SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("V20") + || SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("C46")) { + + return true; + } + return false; + } + + public static boolean isGT09(){ + if(SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("GT09") + || SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("GT09")) { + + return true; + } + return false; + } + + public static boolean isQ3FT(){ + + if ( SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("VitracK")) { + return true; + } + return false; + } + public static boolean isQ3F(){ + + if (getMODEL().contains("C41-QL02")||getMODEL().contains("C41S-QL02")|| SystemProperties.get("ro.product.isQ3F","").equalsIgnoreCase("true") || SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("q3f")) { + return true; + } + return false; + } + public static boolean hasHRS_TEMP(){ + + if (getMODEL().contains("H88") + ||SystemProperties.get("ro.product.isH88","").equalsIgnoreCase("true") + || SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("H88") + || SystemProperties.get("persist.sys.id_num","").equalsIgnoreCase("A9") + || SystemProperties.get("persist.sys.customname","").equalsIgnoreCase("YQ") + ) { + return true; + } + return false; + } +} diff --git a/app/src/main/libs/armeabi-v7a/ag333m_tool b/app/src/main/libs/armeabi-v7a/ag333m_tool new file mode 100644 index 0000000..001b677 Binary files /dev/null and b/app/src/main/libs/armeabi-v7a/ag333m_tool differ diff --git a/app/src/main/libs/armeabi-v7a/libag3335m_jni.so b/app/src/main/libs/armeabi-v7a/libag3335m_jni.so new file mode 100644 index 0000000..ac58cc6 Binary files /dev/null and b/app/src/main/libs/armeabi-v7a/libag3335m_jni.so differ diff --git a/app/src/main/res/layout/dig_layout_testlist_280.xml b/app/src/main/res/layout/dig_layout_testlist_280.xml new file mode 100644 index 0000000..9234bd1 --- /dev/null +++ b/app/src/main/res/layout/dig_layout_testlist_280.xml @@ -0,0 +1,363 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/gps_full_test_activity_280.xml b/app/src/main/res/layout/gps_full_test_activity_280.xml new file mode 100644 index 0000000..599083a --- /dev/null +++ b/app/src/main/res/layout/gps_full_test_activity_280.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/testmain_adapter_280.xml b/app/src/main/res/layout/testmain_adapter_280.xml new file mode 100644 index 0000000..e457e87 --- /dev/null +++ b/app/src/main/res/layout/testmain_adapter_280.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/urovo_layout_table_280.xml b/app/src/main/res/layout/urovo_layout_table_280.xml new file mode 100644 index 0000000..1eaf6e7 --- /dev/null +++ b/app/src/main/res/layout/urovo_layout_table_280.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + +