refactor codes.
authorTrillGates <williamtrillgates@gmail.com>
Wed, 18 Aug 2021 13:03:19 +0000 (21:03 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Wed, 18 Aug 2021 13:03:19 +0000 (21:03 +0800)
app/src/main/java/com/enqualcomm/support/Config.java
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/service/SilentManager.java
app/src/main/java/com/enqualcomm/support/utils/DBHelper.java
app/src/main/java/com/enqualcomm/support/utils/ICAudioManager.java
app/src/main/java/com/enqualcomm/support/utils/ProfileManager.java
app/src/main/java/com/ic/protocols/protocol_gator.java
app/src/main/java/com/ic/protocols/protocol_ic.java
app/src/main/java/com/ic/protocols/protocol_s123.java
build.gradle

index c3a761d..5c4667f 100644 (file)
@@ -348,7 +348,7 @@ public class Config {
         ICLogger.i("current Cycles PPG " + runtime.getPpgTestCycleInMinutes() + " , LocationCycle " + runtime.getLocationInstance().getLocation_cycle() + " LocationMode " + runtime.getLocationInstance().getWorkingMod());
 
         int mastervolume = getMasterVolume(context);
-        ICAudioManager.setMasterVolumn(context, mastervolume);
+        ICAudioManager.setMasterVolume(context, mastervolume);
 
         int duration = getDurationOfVibration(context);
         VibrateUtil.setVibPattern(duration * 1000);
index 10598b9..e382133 100644 (file)
@@ -21,7 +21,6 @@ import android.os.Message;
 import android.os.Messenger;
 import android.os.PowerManager;
 import android.os.RemoteException;
-import android.os.SystemClock;
 import android.support.annotation.Nullable;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -227,7 +226,7 @@ public class CoreService extends Service {
                 AlarmWakeUp.isNeedWakeUpAlarm(runtime);
         }
     };
-    private BroadcastReceiver broadcastSOSReceiver = new BroadcastReceiver() {
+    private final BroadcastReceiver broadcastSOSReceiver = new BroadcastReceiver() {
         public void onReceive(Context param1Context, Intent param1Intent) {
 
             StringBuilder stringBuilder2 = new StringBuilder();
@@ -472,20 +471,14 @@ public class CoreService extends Service {
 
     AbstractInvokeHandlerService invokeHandlerServiceChain;
 
-    private AntiMonitorService antiservice;
+    private AntiMonitorService antiService;
     LocationClient locationClient;
 
     private Deliver mDeliver;
 
-    private boolean mHaveSetWeatherAlarm;
-
     private KeepAlive mKeepAlive;
 
-
-    private SimSignalUtil mSignalUtil;
-
     private BatteryUtil batteryUtil;
-    private long mWeatherTime;
 
     Runtime runtime;
 
@@ -577,11 +570,11 @@ public class CoreService extends Service {
         SendChatMessage sendChatMessage = new SendChatMessage();
         HeartRateManager heartRateManager = HeartRateManager.getInstance();
         heartRateManager.init(this.runtime);
-        antiservice = new AntiMonitorService();
+        antiService = new AntiMonitorService();
         silentManager = SilentManager.getInstance();// new SilentManager();
         sendChatMessage.setNext(heartRateManager);
         heartRateManager.setNext(silentManager);
-        silentManager.setNext(antiservice);
+        silentManager.setNext(antiService);
         return sendChatMessage;
     }
 
@@ -705,10 +698,6 @@ public class CoreService extends Service {
         this.locationClient.onAlarm(getWakeLock(Config.HeartBeatAlarmCycle));
         this.connectionServiceChain.processAlarmClock(this.connection, this.runtime);
         this.invokeHandlerServiceChain.processAlarmClock(this.connection, this.runtime);
-        if (SystemClock.elapsedRealtime() - this.mWeatherTime > 60000L && this.mHaveSetWeatherAlarm) {
-            setWeatherAlarm();
-            this.mHaveSetWeatherAlarm = false;
-        }
         Toast.makeText((this.runtime.getContextProxy()).context, "从深度睡眠中切换模式,联网中", Toast.LENGTH_SHORT).show();
     }
 
@@ -918,8 +907,6 @@ public class CoreService extends Service {
         intentFilter.addAction(Constants.ACTION_START_PRACTISE);
         registerReceiver(broadcastPracticeCMDReceiver, intentFilter);
 
-        //初始化Sim信号
-        this.mSignalUtil = SimSignalUtil.getInstance(this);
 
         //初始化 电池电量监控工具(内部注册接收电池变化)
         batteryUtil = new BatteryUtil(this.runtime, connection);
@@ -1196,7 +1183,7 @@ public class CoreService extends Service {
 
             if (Config.A9_noBroadCastActionStrip) {
                 if (Config.needBroadcastCutoffAlarm) {
-                    antiservice.send_cutoff_event_broadcast(1);
+                    antiService.send_cutoff_event_broadcast(1);
                 }
 
             }
@@ -1491,9 +1478,9 @@ public class CoreService extends Service {
 
             } else if (ACTION_CHECK_ANTIOFF_EVENT.equals(paramIntent.getAction())) {
                 //只在中断式检测过程中延时用
-                antiservice.check_ant_event();
+                antiService.check_ant_event();
             } else if (ACTION_CHECK_CUTOFF_EVENT.equals(paramIntent.getAction())) {
-                antiservice.check_cut_event();
+                antiService.check_cut_event();
             } else if (ALARM_POWER_OFF.equals(paramIntent.getAction())) {
                 //收到定时关机闹钟指令
                 //先设置下一次的,然后再去关机
@@ -1892,7 +1879,7 @@ public class CoreService extends Service {
 
     public void getFZDWeatherInfo() {
         protocolAPIHelper.doWeatherGet(connection, runtime);
-        //TODO:定时,3个小时获取一次天气
+        //定时,3个小时获取一次天气
     }
 
 
index 36a4e4f..529f500 100644 (file)
@@ -366,11 +366,11 @@ public class SilentManager extends AbstractInvokeHandlerService {
 
         if (silent) {
             VibrateUtil.setVibPattern(0);
-            ICAudioManager.setMasterVolumn(context, 0);
+            ICAudioManager.setMasterVolume(context, 0);
             Util.SetRingMode(context, AudioManager.RINGER_MODE_SILENT, false);
         } else {
             int mastervolume = Config.getMasterVolume(context);
-            ICAudioManager.setMasterVolumn(context, mastervolume);
+            ICAudioManager.setMasterVolume(context, mastervolume);
             int duration = Config.getDurationOfVibration(context);
             VibrateUtil.setVibPattern(duration * 1000);
             Util.SetRingMode(context, AudioManager.MODE_NORMAL, true);
index 70d8ac7..75cbc30 100644 (file)
@@ -817,12 +817,11 @@ public class DBHelper {
         this.cr.delete(ICContentProvider.SILENT_URI, (String) null, (String[]) null);
         int count = sList.size();
         if (count != 0) {
-            ContentValues[] contentValueslist = new ContentValues[count];
-
+            ContentValues[] contentValuesList = new ContentValues[count];
             for (int row = 0; row < count; ++row) {
                 Silent silent = (Silent) sList.get(row);
                 ContentValues contentValues = new ContentValues();
-                contentValueslist[row] = contentValues;
+                contentValuesList[row] = contentValues;
                 contentValues.put("START_TIME", silent.start);
                 contentValues.put("END_TIME", silent.end);
                 contentValues.put("WEEK", silent.week);
@@ -833,7 +832,7 @@ public class DBHelper {
                         + silent.status + " " + current_sys_status);
             }
 
-            this.cr.bulkInsert(ICContentProvider.SILENT_URI, contentValueslist);
+            this.cr.bulkInsert(ICContentProvider.SILENT_URI, contentValuesList);
         }
 
     }
index fd1a9c2..d141e37 100644 (file)
@@ -1,19 +1,18 @@
 package com.enqualcomm.support.utils;
 
 import android.content.Context;
-import android.content.Intent;
 import android.media.AudioManager;
 import android.os.Build;
 
 public class ICAudioManager {
 
-    private static int saved_volumn = 0;
+    private static int saved_volume = 0;
     public static boolean needMute = false;
 
-    public static void setMasterVolumn(Context context, int volume) {
+    public static void setMasterVolume(Context context, int volume) {
         AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
         int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
-        ICLogger.i("======setVolumn " + volume + " maxvolmun " + maxVolume);
+        ICLogger.i("======setVolume " + volume + " maxVolume " + maxVolume);
         if (volume > maxVolume) {
             volume = maxVolume;
         }
@@ -37,7 +36,7 @@ public class ICAudioManager {
     }
 
     public static void restoreVolume(Context context) {
-        ICLogger.i("======restoreVolume " + saved_volumn);
+        ICLogger.i("======restoreVolume " + saved_volume);
         AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
         if (audioManager != null) {
             audioManager.setMasterMute(false);
@@ -107,7 +106,7 @@ public class ICAudioManager {
             if (audioManager != null) {
                 if (audioManager.isSpeakerphoneOn()) {
                     audioManager.setSpeakerphoneOn(false);
-                    audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, saved_volumn,
+                    audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, saved_volume,
                             AudioManager.STREAM_VOICE_CALL);
                 }
             }
@@ -125,7 +124,7 @@ public class ICAudioManager {
             AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
             //audioManager.setMode(AudioManager.ROUTE_SPEAKER);
             audioManager.setMode(AudioManager.MODE_IN_CALL);
-            saved_volumn = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
+            saved_volume = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
 
             if (!audioManager.isSpeakerphoneOn()) {
                 audioManager.setSpeakerphoneOn(true);
index a8efe17..89310b4 100644 (file)
@@ -63,11 +63,21 @@ public class ProfileManager {
         int musicVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
         int notificationVolume = audio.getStreamVolume(AudioManager.STREAM_NOTIFICATION);
         int alarmVolume = audio.getStreamVolume(AudioManager.STREAM_ALARM);
-        SharePreferenceUtil.setPrefInt(context, "audio_systemVolume", systemVolume);
-        SharePreferenceUtil.setPrefInt(context, "audio_ringVolume", ringVolume);
-        SharePreferenceUtil.setPrefInt(context, "audio_musicVolume", musicVolume);
-        SharePreferenceUtil.setPrefInt(context, "audio_notificationVolume", notificationVolume);
-        SharePreferenceUtil.setPrefInt(context, "audio_alarmVolume", alarmVolume);
+        if (systemVolume != 0) {
+            SharePreferenceUtil.setPrefInt(context, "audio_systemVolume", systemVolume);
+        }
+        if (ringVolume != 0) {
+            SharePreferenceUtil.setPrefInt(context, "audio_ringVolume", ringVolume);
+        }
+        if (musicVolume != 0) {
+            SharePreferenceUtil.setPrefInt(context, "audio_musicVolume", musicVolume);
+        }
+        if (notificationVolume != 0) {
+            SharePreferenceUtil.setPrefInt(context, "audio_notificationVolume", notificationVolume);
+        }
+        if (alarmVolume != 0) {
+            SharePreferenceUtil.setPrefInt(context, "audio_alarmVolume", alarmVolume);
+        }
         audio.setStreamVolume(AudioManager.STREAM_SYSTEM, 0, 0);
         audio.setStreamVolume(AudioManager.STREAM_RING, 0, 0);
         audio.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
@@ -86,11 +96,21 @@ public class ProfileManager {
         int musicVolume = SharePreferenceUtil.getPrefInt(context, "audio_musicVolume", 5);
         int notificationVolume = SharePreferenceUtil.getPrefInt(context, "audio_notificationVolume", 5);
         int alarmVolume = SharePreferenceUtil.getPrefInt(context, "audio_alarmVolume", 5);
-        audio.setStreamVolume(AudioManager.STREAM_SYSTEM, systemVolume, 0);
-        audio.setStreamVolume(AudioManager.STREAM_RING, ringVolume, 0);
-        audio.setStreamVolume(AudioManager.STREAM_MUSIC, musicVolume, 0);
-        audio.setStreamVolume(AudioManager.STREAM_NOTIFICATION, notificationVolume, 0);
-        audio.setStreamVolume(AudioManager.STREAM_ALARM, alarmVolume, 0);
+        if (systemVolume != 0) {
+            audio.setStreamVolume(AudioManager.STREAM_SYSTEM, systemVolume, 0);
+        }
+        if (ringVolume != 0) {
+            audio.setStreamVolume(AudioManager.STREAM_RING, ringVolume, 0);
+        }
+        if (musicVolume != 0) {
+            audio.setStreamVolume(AudioManager.STREAM_MUSIC, musicVolume, 0);
+        }
+        if (notificationVolume != 0) {
+            audio.setStreamVolume(AudioManager.STREAM_NOTIFICATION, notificationVolume, 0);
+        }
+        if (alarmVolume != 0) {
+            audio.setStreamVolume(AudioManager.STREAM_ALARM, alarmVolume, 0);
+        }
         ICLogger.d("restoreSilent...");
     }
 }
index 30dd663..4a7c163 100644 (file)
@@ -1261,7 +1261,7 @@ SOS报警上行WIFI、LBS混合定位数据,步数为255步,电量等级5,数
                 if (volume < 0) volume = 0;
                 if (volume >= 14) volume = 15;
                 Config.setMasterVolume(runtime.getContextProxy().context, mastervolume * 2);
-                ICAudioManager.setMasterVolumn(runtime.getContextProxy().context, mastervolume * 2);
+                ICAudioManager.setMasterVolume(runtime.getContextProxy().context, mastervolume * 2);
                 connection.send(BPXX_REPLY(runtime, CMD_TYPE.BP21, index, true));
             } catch (Exception e) {
                 ICLogger.e(e.getMessage(), e);
index 56d54d7..56c0464 100644 (file)
@@ -2939,7 +2939,7 @@ public class protocol_ic {
                 if (volume < 0) volume = 0;
                 if (volume >= 14) volume = 15;
                 Config.setMasterVolume(runtime.getContextProxy().context, mastervolume * 2);
-                ICAudioManager.setMasterVolumn(runtime.getContextProxy().context, mastervolume * 2);
+                ICAudioManager.setMasterVolume(runtime.getContextProxy().context, mastervolume * 2);
 
             } else {
                 ICLogger.i(" BP65 Format error!");
index 050b170..98d84d8 100644 (file)
@@ -3307,7 +3307,7 @@ public class protocol_s123 {
                 if (volume < 0) volume = 0;
                 if (volume >= 14) volume = 15;
                 Config.setMasterVolume(runtime.getContextProxy().context, mastervolume * 2);
-                ICAudioManager.setMasterVolumn(runtime.getContextProxy().context, mastervolume * 2);
+                ICAudioManager.setMasterVolume(runtime.getContextProxy().context, mastervolume * 2);
 
             } else {
                 ICLogger.i(" BP65 Format error!");
index e9f3aa3..9c1b7ee 100644 (file)
@@ -35,8 +35,6 @@ allprojects {
 
     gradle.projectsEvaluated {
         tasks.withType(JavaCompile) {
-//            options.compilerArgs.add('-Xbootclasspath/p:app\\libs\\telephony-common-full-debug.jar')
-//            options.compilerArgs.add('-Xbootclasspath/p:app\\libs\\frameworks-full-debug.jar')
             options.compilerArgs << '-Xbootclasspath/p:app\\libs\\frameworks-full-debug.jar;app\\libs\\telephony-common-full-debug.jar'
         }
     }