开始修改光大pda兼容性问题
This commit is contained in:
@ -11,7 +11,7 @@ android {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 15
|
||||
versionCode 1
|
||||
versionName "V1.078"
|
||||
versionName "V1.079"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@ -23,8 +23,6 @@
|
||||
<permission android:name="android.permission.BAIDU_LOCATION_SERVICE" >
|
||||
</permission>
|
||||
|
||||
<uses-permission android:name="android.permission.BAIDU_LOCATION_SERVICE" >
|
||||
</uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" >
|
||||
</uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
|
||||
@ -125,11 +123,6 @@
|
||||
<intent-filter>
|
||||
<action android:name="com.baidu.location.service_v2.9"></action>
|
||||
</intent-filter>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-->
|
||||
</service>
|
||||
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
package android_serialport_api;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
import com.util.DialogUtil;
|
||||
import com.util.GlobalApplication;
|
||||
import map.baidu.com.BMapManagerUtil;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -22,10 +26,12 @@ public class SerialPort {
|
||||
su.getOutputStream().write(cmd.getBytes());
|
||||
|
||||
if ((su.waitFor() != 0) || !device.canRead() || !device.canWrite()) {
|
||||
DialogUtil.builder(BMapManagerUtil.getGlobalApplicationContext(),"获取su命令权限失败","系统或许未root",15);
|
||||
throw new SecurityException();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DialogUtil.builder(BMapManagerUtil.getGlobalApplicationContext(),"获取root权限失败",e.toString(),15);
|
||||
throw new SecurityException();
|
||||
}
|
||||
}
|
||||
@ -33,6 +39,7 @@ public class SerialPort {
|
||||
Log.i("info", "open device!!");
|
||||
if (mFd == null) {
|
||||
Log.e(TAG, "native open returns null");
|
||||
DialogUtil.builder(BMapManagerUtil.getGlobalApplicationContext(),"获取文件描述符失败","native open returns null",15);
|
||||
throw new IOException();
|
||||
}
|
||||
mFileInputStream = new FileInputStream(mFd);
|
||||
|
||||
@ -13,7 +13,7 @@ public class ZKR322AControl {
|
||||
private SerialPort mSerialPort = null;
|
||||
private OutputStream mOutputStream = null;
|
||||
private InputStream mInputStream = null;
|
||||
//private boolean readVal = false;
|
||||
private boolean readVal = false;
|
||||
|
||||
public ZKR322AControl() throws SecurityException, IOException {
|
||||
mSerialPort = new SerialPort(new File("/dev/ttyS4"), 115200, 8, 'N', 1,0);
|
||||
@ -37,18 +37,18 @@ public class ZKR322AControl {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
//readVal = true;
|
||||
// GpioJNI.gpio_switch_scan_trig(1);
|
||||
readVal = true;
|
||||
GpioJNI.gpio_switch_scan_trig(1);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
//readVal = false;
|
||||
// GpioJNI.gpio_switch_scan_trig(0);
|
||||
readVal = false;
|
||||
GpioJNI.gpio_switch_scan_trig(0);
|
||||
}
|
||||
|
||||
//public boolean isRead() {
|
||||
// return readVal;
|
||||
//}
|
||||
public boolean isRead() {
|
||||
return readVal;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (mSerialPort != null) {
|
||||
@ -58,7 +58,7 @@ public class ZKR322AControl {
|
||||
|
||||
|
||||
public void initScan() {
|
||||
// GpioJNI.gpio_switch_scan_rf_ired(0);
|
||||
// GpioJNI.gpio_switch_scan_power(1);
|
||||
GpioJNI.gpio_switch_scan_rf_ired(0);
|
||||
GpioJNI.gpio_switch_scan_power(1);
|
||||
}
|
||||
}
|
||||
|
||||
31
app/src/main/java/com/util/GlobalApplication.java
Normal file
31
app/src/main/java/com/util/GlobalApplication.java
Normal file
@ -0,0 +1,31 @@
|
||||
package com.util;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2021-01-15 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* 全局上下文,可以用来弹出无依赖的对话框等
|
||||
*/
|
||||
public class GlobalApplication extends Application {
|
||||
|
||||
private static Context context;//全局上下文
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
context = getApplicationContext();
|
||||
}
|
||||
|
||||
//获取全局的上下文
|
||||
public static Context getContext() {
|
||||
return context;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package map.baidu.com;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
import com.baidu.mapapi.BMapManager;
|
||||
import com.baidu.mapapi.MKEvent;
|
||||
@ -57,5 +58,9 @@ public class BMapManagerUtil extends Application {
|
||||
}
|
||||
super.onTerminate();
|
||||
}
|
||||
|
||||
public static Context getGlobalApplicationContext(){
|
||||
return bMapManagerUtil.getApplicationContext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user