Browse Source

fix: init

sibichiAi
高志龙 10 months ago
parent
commit
0725b14725
  1. 3
      app/build.gradle
  2. BIN
      app/libs/sdkapi.jar
  3. 135
      app/src/main/java/qianmu/container/activity/BaseActivity.java
  4. 7
      app/src/main/java/qianmu/container/app/Constant.java
  5. 12
      app/src/main/java/qianmu/container/app/MyApplication.java
  6. 22
      app/src/main/java/qianmu/container/data/PowerData.java

3
app/build.gradle

@ -97,7 +97,8 @@ dependencies {
implementation files('libs\\jna-min.jar')
implementation files('libs\\toolbox_kit.jar')//
implementation files('libs\\shockman.jar')//
implementation files('libs/signway.jar')//
implementation files('libs/signway.jar') //
implementation files('libs\\sdkapi.jar') //Bv-3588
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

BIN
app/libs/sdkapi.jar

Binary file not shown.

135
app/src/main/java/qianmu/container/activity/BaseActivity.java

@ -61,10 +61,10 @@ public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//隐藏标题栏
// 隐藏标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
//隐藏状态栏
// 隐藏状态栏
Window window = getWindow();
int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
window.setFlags(flag, flag);
@ -101,10 +101,7 @@ public abstract class BaseActivity extends AppCompatActivity {
EventBus.getDefault().register(this);
sendPackageName();
Constant.whoActivity = currRoute;
Log.e("TAG","哪个activty:"+Constant.whoActivity);
if(Constant.androidBoardType.equals("huamo") && Constant.ROUTE_SCREEN_SAVER==currRoute){
}
Log.e("TAG", "哪个activty:" + Constant.whoActivity);
}
@Override
@ -130,27 +127,32 @@ public abstract class BaseActivity extends AppCompatActivity {
if (Constant.ACTION_CAPTURE_SCREEN.equals(message.getCode())) {
uploadScreenCapture();
} else if (Constant.ACTION_SHOW_SPLASH.equals(message.getCode())) {
if (currRoute == Constant.ROUTE_SCREEN_SAVER) return;
if (currRoute == Constant.ROUTE_SCREEN_SAVER)
return;
ScreenSaverActivity.startAction(this);
// ARouter.getInstance().build(Constant.ROUTE_SCREEN_SAVER).navigation();
// ARouter.getInstance().build(Constant.ROUTE_SCREEN_SAVER).navigation();
} else if (Constant.UPDATE_DEVICE_IP.equals(message.getCode())) {
//ip变更
// ip变更
DeviceUtil.updateDeviceIP(this);
} else if(Constant.ACTION_UPDATE_WEBVIEW.equals(message.getCode())){
//显示主页,并更新webview
LoggerUtil.e("BaseActivity","ACTION_UPDATE_WEBVIEW");
if(DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE).equals("信发") || DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE).equals("双面屏")) return;
if (currRoute == Constant.ROUTE_WEB_VIEW || currRoute == Constant.ROUTE_UPDATE_FILE) return;
ARouter.getInstance().build(Constant.ROUTE_WEB_VIEW).withBoolean(Constant.KEY_LOAD_H5_URL, true).navigation();
}else if(Constant.ACTION_RESTART_APP.equals(message.getCode())){
//重启app
} else if (Constant.ACTION_UPDATE_WEBVIEW.equals(message.getCode())) {
// 显示主页,并更新webview
LoggerUtil.e("BaseActivity", "ACTION_UPDATE_WEBVIEW");
if (DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE).equals("信发")
|| DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE).equals("双面屏"))
return;
if (currRoute == Constant.ROUTE_WEB_VIEW || currRoute == Constant.ROUTE_UPDATE_FILE)
return;
ARouter.getInstance().build(Constant.ROUTE_WEB_VIEW).withBoolean(Constant.KEY_LOAD_H5_URL, true)
.navigation();
} else if (Constant.ACTION_RESTART_APP.equals(message.getCode())) {
// 重启app
restartApp();
}else if(Constant.ACTION_RESTART_MQTT.equals(message.getCode())){
//重启mqtt服务
LoggerUtil.e("BaseActivity","通知关闭mqtt服务");
stopService(new Intent(this, MQTTService.class));//关闭Mqtt服务
} else if (Constant.ACTION_RESTART_MQTT.equals(message.getCode())) {
// 重启mqtt服务
LoggerUtil.e("BaseActivity", "通知关闭mqtt服务");
stopService(new Intent(this, MQTTService.class));// 关闭Mqtt服务
Constant.mqttState = "off";
}
@ -164,21 +166,22 @@ public abstract class BaseActivity extends AppCompatActivity {
return super.dispatchTouchEvent(ev);
}
//当前activity截图
// 当前activity截图
public Bitmap captureScreen() {
getWindow().getDecorView().setDrawingCacheEnabled(true);
getWindow().getDecorView().destroyDrawingCache();
return getWindow().getDecorView().getDrawingCache();
}
//上传界面截图
// 上传界面截图
private void uploadScreenCapture() {
String dataStr = StringUtil.strSplice("{\"code\":\"", DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_CODE), "\",\"filename\":\"screenshot.jpg\"}");
final byte[] bytes1 = StringUtil.strSplice(String.format("%06d", dataStr.length()), dataStr).getBytes(); //ip和文件名转成字节数组
//图片转成字节数组
String dataStr = StringUtil.strSplice("{\"code\":\"", DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_CODE),
"\",\"filename\":\"screenshot.jpg\"}");
final byte[] bytes1 = StringUtil.strSplice(String.format("%06d", dataStr.length()), dataStr).getBytes(); // ip和文件名转成字节数组
// 图片转成字节数组
String filePath = BitmapUtil.saveBitmapToSDCard(captureScreen());
final byte[] bytes2 = BitmapUtil.file2byte(filePath);
//开启线程池 上传文件
// 开启线程池 上传文件
final String requestURL = StringUtil.strSplice(Constant.getBaseAddress(), "/API/Dev/UploadScreenshot");
Executors.newSingleThreadExecutor().execute(() -> FileUtil.uploadFile(bytes1, bytes2, requestURL));
}
@ -187,47 +190,47 @@ public abstract class BaseActivity extends AppCompatActivity {
*
* */
Long onkey = 0l;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.e("TAG","按键:"+keyCode);
Log.e("TAG", "按键:" + keyCode);
if ((keyCode == KeyEvent.KEYCODE_F1)) {
if(System.currentTimeMillis()- onkey<1000) {
if (System.currentTimeMillis() - onkey < 1000) {
LoggerUtil.e("遥控按键", "退出应用");
sendExitPackageName();
exitApp();
}else {
} else {
onkey = System.currentTimeMillis();
}
}else if ((keyCode == KeyEvent.KEYCODE_F4)) {
} else if ((keyCode == KeyEvent.KEYCODE_F4)) {
if(System.currentTimeMillis()- onkey<1000){
LoggerUtil.e("遥控按键","重启设备");
if (System.currentTimeMillis() - onkey < 1000) {
LoggerUtil.e("遥控按键", "重启设备");
SignWayUtil.reboot();
}else {
} else {
onkey = System.currentTimeMillis();
}
}else if(keyCode == KeyEvent.KEYCODE_F3){
} else if (keyCode == KeyEvent.KEYCODE_F3) {
}else if ((keyCode == KeyEvent.KEYCODE_F2)) {
if(System.currentTimeMillis()- onkey<1000) {
} else if ((keyCode == KeyEvent.KEYCODE_F2)) {
if (System.currentTimeMillis() - onkey < 1000) {
LoggerUtil.e("遥控按键", "退到设置");
ARouter.getInstance().build(Constant.ROUTE_DEVICE_INFO).navigation();
}else {
} else {
onkey = System.currentTimeMillis();
}
}else if ((keyCode == KeyEvent.KEYCODE_F10)) {
} else if ((keyCode == KeyEvent.KEYCODE_F10)) {
}
return super.onKeyDown(keyCode, event);
}
/**
* 发送广播给奔溃自启app告诉包名
* */
public void sendPackageName(){
*/
public void sendPackageName() {
Intent intent = new Intent(Constant.APP_SEND_PACKAGE_NAME);
intent.putExtra(Constant.PACKAGE_NAME, DeviceUtil.getPackageName());
sendStickyBroadcast(intent);
@ -235,8 +238,8 @@ public abstract class BaseActivity extends AppCompatActivity {
/**
* 发送广播给奔溃自启app告诉包名
* */
public void sendExitPackageName(){
*/
public void sendExitPackageName() {
Intent intent = new Intent(Constant.APP_SEND_PACKAGE_NAME);
intent.putExtra(Constant.PACKAGE_NAME, "packageName");
this.sendStickyBroadcast(intent);
@ -244,8 +247,8 @@ public abstract class BaseActivity extends AppCompatActivity {
/**
* 退出软件
* */
public void exitApp(){
*/
public void exitApp() {
LoggerUtil.e("BaseActivity", "退出软件");
sendExitPackageName();
SignWayUtil.hideStatusBar(true);
@ -255,17 +258,17 @@ public abstract class BaseActivity extends AppCompatActivity {
stopService(new Intent(this, CoreService.class));
stopService(new Intent(this, MQTTService.class));
//欣威视通看门狗
if(Constant.androidBoardType.equals("xwst2")){
boolean ret= SdkApi.getInstance().Watchdog().getWatchdogOnoff();
if(ret){
// 欣威视通看门狗
if (Constant.androidBoardType.equals("xwst2")) {
boolean ret = SdkApi.getInstance().Watchdog().getWatchdogOnoff();
if (ret) {
SdkApi.getInstance().Watchdog().setWatchdogOnoff(false);
}
}
if("指路机".equals(DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE))){
//开启背景音乐
stopService(new Intent(this, MusicService.class));//背景音乐
if ("指路机".equals(DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE))) {
// 开启背景音乐
stopService(new Intent(this, MusicService.class));// 背景音乐
}
try {
@ -273,12 +276,12 @@ public abstract class BaseActivity extends AppCompatActivity {
} catch (InterruptedException e) {
e.printStackTrace();
}
if(Constant.androidBoardType.equals("xwst")){
if (Constant.androidBoardType.equals("xwst")) {
SignWayUtil.killbackgroundapk(DeviceUtil.getPackageName());
}else {
} else {
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//栈内复用模式
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);// 栈内复用模式
startActivity(startMain);
System.exit(0);
}
@ -286,25 +289,25 @@ public abstract class BaseActivity extends AppCompatActivity {
/**
* 重启软件
* */
public void restartApp(){
*/
public void restartApp() {
LoggerUtil.e("BaseActivity", "重启软件");
stopService(new Intent(this, ContainerService.class));
stopService(new Intent(this, MessengerService.class));
stopService(new Intent(this, CoreService.class));
stopService(new Intent(this, MQTTService.class));
//欣威视通看门狗
if(Constant.androidBoardType.equals("xwst2")){
boolean ret= SdkApi.getInstance().Watchdog().getWatchdogOnoff();
if(ret){
// 欣威视通看门狗
if (Constant.androidBoardType.equals("xwst2")) {
boolean ret = SdkApi.getInstance().Watchdog().getWatchdogOnoff();
if (ret) {
SdkApi.getInstance().Watchdog().setWatchdogOnoff(false);
}
}
if("指路机".equals(DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE))){
//开启背景音乐
stopService(new Intent(this, MusicService.class));//背景音乐
if ("指路机".equals(DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE))) {
// 开启背景音乐
stopService(new Intent(this, MusicService.class));// 背景音乐
}
try {
Thread.sleep(1000);

7
app/src/main/java/qianmu/container/app/Constant.java

@ -23,14 +23,15 @@ public class Constant {
public static boolean newGuide = false; // 指路机类型,true:新版指路机 false:老板指路机(流花)
public static String mqttState = ""; // 屏幕连接方式
// public static String androidBoardType = ""; //设备板子型号 无固定版
public static String androidBoardType = "ys"; // 设备板子型号 ys(亿晟) 北京颐堤港定制touch
// public static String androidBoardType = "ys"; // 设备板子型号 ys(亿晟) 北京颐堤港定制touch
// public static String androidBoardType = "xwst"; //设备板子型号 xwst(欣威视通3399)
// public static String androidBoardType = "xwst2"; //设备板子型号
// xwst2(欣威视通3588、T982、3576)
// public static String androidBoardType = "xwst2"; //设备板子型号 xwst2(欣威视通3588、T982、3576)
// public static String androidBoardType = "zc"; //设备板子型号 zc(卓策主板——王府井喜悦、杨浦中心医院)
// public static String androidBoardType = "sx"; //设备板子型号 sx(视想)
// public static String androidBoardType = "nova"; //设备板子型号 诺瓦盒子 华贸LED
// public static String androidBoardType = "huidu"; //设备板子型号 huidu(灰度主板) 罗湖寻车机
public static String androidBoardType = "bv"; // Bv-3588M
public static String whoActivity = ""; // 哪个activity页面
// 本地缓存地址
public static final String CACHE_PATH = StringUtil.strSplice(Environment.getExternalStorageDirectory().getPath(),

12
app/src/main/java/qianmu/container/app/MyApplication.java

@ -10,6 +10,7 @@ import android.os.PowerManager;
import com.alibaba.android.arouter.BuildConfig;
import com.alibaba.android.arouter.launcher.ARouter;
import com.jakewharton.processphoenix.ProcessPhoenix;
import com.lztek.toolkit.Lztek;
import com.lzy.okgo.OkGo;
import com.sdkapi.api.SdkApi;
import com.squareup.leakcanary.LeakCanary;
@ -47,6 +48,7 @@ public class MyApplication extends Application {
public static long lastClick = 0;//最后点击时间
public static long lastClickTime = 0;//最后点击时间
public static int clickTimes = 0;//累计点击次数
private Lztek lztek=null;
public SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
@ -65,9 +67,19 @@ public class MyApplication extends Application {
initOkGo();
SocketServerManager.startSocketServer();
initDefaultUncaughtExceptionHandler();
if(Constant.androidBoardType.equals("ys")){
lztek = Lztek.create(this.getBaseContext());
}
// refWatcher = LeakCanary.install(this);
}
public Lztek getLztek() {
if(lztek == null){
lztek = Lztek.create(this.getBaseContext());
}
return lztek;
}
//初始化页面路由框架
private void initARouter() {
try {

22
app/src/main/java/qianmu/container/data/PowerData.java

@ -75,11 +75,31 @@ public class PowerData extends BaseData {
long currentLong = System.currentTimeMillis();//当前时间
String s = TimeUtil.stampToDate(currentLong);
long bootLong = TimeUtil.pareTLong2(s + " " + bootTime);//开机时间
if(Math.abs(currentLong-bootLong)<30000){
if(Math.abs(currentLong-bootLong)<60000){
LoggerUtil.e("PowerData","避免设备定时失效,进行重新设置定时开关机");
newTimeInfo="";
}
}
//BV-3588 定时开关机
if(Constant.androidBoardType.equals("bv") && !bootTime.isEmpty()){
long currentLong = System.currentTimeMillis();//当前时间
String s = TimeUtil.stampToDate(currentLong);
long parameterLong = TimeUtil.pareTLong2(s + " " + parameter);//关机时间
long bootLong = TimeUtil.pareTLong2(s + " " + bootTime);//开机时间
long bootLong2 = bootLong+24*60*60*1000;//第二天开机时间
if(Math.abs(currentLong-parameterLong)<65000){
//并且设定的开机与关机时间必须超过当前时间,否则,会清除掉已设定的开机时间或关机时间,导致不能达到预想的要求。
if(parameterLong > bootLong) {
//关机时间大于开机时间,第二天开机
int second =(int)(bootLong2-currentLong)/1000;
MyApplication.getInstance().getLztek().alarmPoweron(second);
}else {
//关机时间小于开机时间,当天关机,当天开机
int second =(int)(bootLong-currentLong)/1000;
MyApplication.getInstance().getLztek().alarmPoweron(second);
}
}
}
//华贸设备设置开关屏
if(Constant.androidBoardType.equals("nova") && !bootTime.isEmpty()){

Loading…
Cancel
Save