import com.enqualcomm.support.bean.ICLocation;\r
import com.enqualcomm.support.utils.DeviceInfoUtil;\r
import com.enqualcomm.support.utils.ServiceUtil;\r
+import com.enqualcomm.support.utils.StorageUtils;\r
import com.ic.jni.ICJniUtils;\r
import com.enqualcomm.support.Constants;\r
import com.enqualcomm.support.GSensorListener;\r
import com.enqualcomm.support.utils.SimSignalUtil;\r
import com.enqualcomm.support.utils.TimeUtil;\r
import com.enqualcomm.support.utils.Util;\r
+import com.sina.util.dnscache.log.FileUtil;\r
\r
import java.lang.ref.WeakReference;\r
import chestnut.ui.Toastc;\r
\r
private void getDBFile() {\r
StringBuilder stringBuilder = new StringBuilder();\r
- stringBuilder.append(getExternalCacheDir());\r
+ stringBuilder.append(StorageUtils.getExternalStorageLogDir());\r
stringBuilder.append("/contacts.db");\r
FileOutputUtil.copyFolder("/data/data/com.enqualcomm.support/databases", stringBuilder.toString());\r
}\r
import android.widget.Toast;\r
\r
import com.enqualcomm.support.R;\r
+import com.enqualcomm.support.utils.StorageUtils;\r
\r
import java.io.File;\r
import java.io.FileOutputStream;\r
// if (Environment.getExternalStorageState().equals(\r
// Environment.MEDIA_MOUNTED)) {\r
// File dir = new File(mContext.getExternalCacheDir(), "crash");\r
- File dir=mContext.getExternalCacheDir();\r
+ File dir= new File(StorageUtils.getExternalStorageLogDir());\r
String path = dir.getPath();\r
if (!dir.exists()) {\r
dir.mkdirs();\r
// timer.schedule(tmt,0,2000);\r
// showmessage=true;\r
NMEAListener.set_callback(this);\r
- screenOnWakelock = WakeLockUtil.getScreenOnWakeLock(this,GPSActivity.class.getSimpleName());\r
+ if (screenOnWakelock==null)\r
+ screenOnWakelock = WakeLockUtil.getScreenOnWakeLock(this,GPSActivity.class.getSimpleName());\r
}\r
\r
@Override\r
// timer = null;\r
// }\r
showmessage=false;\r
- screenOnWakelock.release();\r
+ if(screenOnWakelock!=null) {\r
+ if (screenOnWakelock.isHeld()) {\r
+ screenOnWakelock.release();\r
+ }\r
+ screenOnWakelock=null;\r
+ }\r
\r
}\r
}\r
}\r
// public void EqcAlgorithmInterfaceMethod2() {\r
public void startGpsLocate() {\r
- ICLogger.i("开启GPS扫描");\r
-\r
- if(!nmeaListener.isListening()) {\r
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态\r
-\r
- //防止与工厂测试冲突\r
- if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) {\r
-\r
- Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true);\r
+ //防止与工厂测试冲突\r
+ if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) {\r
+ ICLogger.i("开启GPS扫描!");\r
+ if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","开启GPS扫描!");\r
+ if (!nmeaListener.isListening()) {\r
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态\r
Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {\r
public void call(Object param1Object) {\r
nmeaListener.startListen();\r
}\r
});\r
+\r
+ } else {\r
+ ICLogger.i("GPS is still listening, skip open it!");\r
+ if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "GPS is still listening, skip open it!");\r
}\r
}else{\r
- ICLogger.i("GPS is still listening, skip open it!");\r
+ ICLogger.i("工厂模式,skip 开启GPS扫描!");\r
+ if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","工厂模式,skip 开启GPS扫描!");\r
}\r
}\r
\r
// Deliver.is_active_location = false;\r
// getLocationWakeLock();\r
// }\r
- ICLogger.i("stopGpsLocate");\r
-\r
//防止与工厂测试冲突\r
if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) {\r
-\r
- Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, false);\r
+ ICLogger.i("stopGpsLocate");\r
+ if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","stopGpsLocate");\r
Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {\r
public void call(Object param1Object) {\r
nmeaListener.stopListen();\r
}\r
});\r
+ }else{\r
+ ICLogger.i("工厂模式 skip stopGpsLocate");\r
+ if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","工厂模式 skip stopGpsLocate");\r
}\r
}\r
\r
import android.os.Bundle;\r
import android.os.Handler;\r
import android.os.Message;\r
+import android.provider.Settings;\r
+\r
import com.enqualcomm.support.bean.ICLocation;\r
import com.enqualcomm.support.bean.Runtime;\r
import com.enqualcomm.support.utils.FileOutputUtil;\r
import java.util.Iterator;\r
import java.util.List;\r
\r
+import rx.Single;\r
+import rx.android.schedulers.AndroidSchedulers;\r
+import rx.functions.Action1;\r
+\r
+import static android.location.LocationManager.GPS_PROVIDER;\r
+\r
public class NMEAListener implements NmeaListener, LocationListener {\r
- private boolean listening=false;\r
+ private static boolean listening=false;\r
\r
public boolean isListening(){\r
return listening;\r
public boolean startListen() {\r
\r
if (this.listening == false) {\r
+ Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true);\r
+\r
+\r
Criteria criteria = new Criteria();\r
criteria.setAccuracy(Criteria.ACCURACY_FINE);// 设置为最大精度\r
criteria.setAltitudeRequired(false);//不要求海拔信息\r
\r
String provider = locationManager.getBestProvider(criteria, true);\r
\r
+\r
ICLogger.i("GPS StartListen with Provider " + provider);\r
+\r
+ if( Config.LOG_TOFILE) ICLogger.logToFile("GPS","GPS StartListen with Provider " + provider);\r
+\r
this.locationManager.requestLocationUpdates(provider, 0L, 0.0F, this);\r
+\r
this.listening = true;\r
noSignalCount = 0;\r
longitude = 0;\r
return true;//gpsHotStart();\r
}else{\r
ICLogger.i(" location listening, skip !");\r
+ if( Config.LOG_TOFILE)ICLogger.logToFile("GPS"," location listening, skip !");\r
\r
return true;\r
}\r
this.locationManager.removeUpdates(this);\r
this.listening = false;\r
ICLogger.i("stopListen 定位 ");\r
+ if( Config.LOG_TOFILE)ICLogger.logToFile("GPS","stopListen 定位 ");\r
+ Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, false);\r
+\r
}\r
\r
public enum GPS_CURRENT_STATUS {\r
public class WakeLockUtil {\r
public static PowerManager.WakeLock getScreenOnWakeLock(Context context, String tag) {\r
PowerManager.WakeLock wakeLock = ((PowerManager)(context.getSystemService(Context.POWER_SERVICE))).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, tag);\r
- wakeLock.acquire(900000L);\r
+// wakeLock.acquire(900000L);\r
+ wakeLock.acquire();\r
return wakeLock;\r
}\r
}\r
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="重启服务" />
+ android:text="重启服务"
+ android:textSize="18sp" />
<Button
android:id="@+id/btn_tools"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="工具" />
+ android:text="工具"
+ android:textSize="18sp" />
</LinearLayout>
<HorizontalScrollView
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_weight="1"\r
- android:text="上传日志" />\r
+ android:text="上传日志"\r
+ android:textSize="18sp" />\r
\r
<Button\r
android:id="@+id/btn_simReset"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_weight="1"\r
- android:text="重置SIM" />\r
+ android:text="重置SIM"\r
+ android:textSize="18sp" />\r
\r
<Button\r
android:id="@+id/btn_sim2"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_weight="1"\r
- android:text="GPS状态" />\r
+ android:text="GPS状态"\r
+ android:textSize="18sp" />\r
</LinearLayout>\r
\r
<LinearLayout\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_weight="1"\r
- android:text="模式3" />\r
+ android:text="模式3"\r
+ android:textSize="18sp" />\r
\r
<Button\r
android:id="@+id/btn_location530"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_weight="1"\r
- android:text="模式5.30" />\r
+ android:text="模式5.30"\r
+ android:textSize="18sp" />\r
\r
<Button\r
android:id="@+id/btn_location1"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_weight="1"\r
- android:text="模式1" />\r
+ android:text="模式1"\r
+ android:textSize="18sp" />\r
</LinearLayout>\r
\r
</LinearLayout>
\ No newline at end of file
# Location of the SDK. This is only used by Gradle.\r
# For customization when using a Version Control System, please read the\r
# header note.\r
-#Sun Mar 15 23:29:11 CST 2020\r
-sdk.dir=E\:\\Android\\sdk\r
+#Mon Mar 16 11:44:29 CST 2020\r
+sdk.dir=C\:\\Users\\incar\\AppData\\Local\\Android\\Sdk\r