hjw
2023-04-20 b2dd8ca6ea52926382dabd0914efcc6b552267d1
app/src/main/java/com/jwipc/nodka_reboot_under/utils/Utils.java
....@@ -24,10 +24,15 @@
2424 import android.net.ConnectivityManager;
2525 import android.net.NetworkInfo;
2626 import android.net.NetworkInfo.DetailedState;
27
+import android.os.Build;
2728 import android.os.PowerManager;
2829 import android.os.RemoteException;
2930 import android.text.format.DateFormat;
3031 import android.util.Log;
32
+
33
+import com.jwipc.nodka_reboot_under.MyApplication;
34
+import com.nodka.api.NodkaAPI;
35
+import com.nodka.api.NodkaNative;
3136
3237
3338 public class Utils {
....@@ -67,8 +72,7 @@
6772 Thread thread_set_time_reboot = null;
6873 Thread thread_STOP_WATCH_DOG = null;
6974 Thread thread_AlarmPower_Repeat_Poweroff = null;
70
-
71
-
75
+
7276
7377
7478 public Utils(Context context) {
....@@ -80,7 +84,6 @@
8084 sharedPreferences = context.getSharedPreferences(shapre, context.MODE_PRIVATE);
8185 editor = sharedPreferences.edit();
8286 }
83
-
8487
8588 public void shut_Down()
8689 {
....@@ -250,26 +253,30 @@
250253 return;
251254 }
252255
253
-
254
- AlarmPowerManager mAlarmPowerManager = new AlarmPowerManager();
255
-
256
- mAlarmPowerManager.removeAllalarmPower();
257
-
256
+ if (isSpiritVersion()) {
257
+ new AlarmPowerManager().removeAllalarmPower();
258
+ setFileState("0", "/sys/class/minix-rtc/MCURTCDATA");
259
+ } else {
260
+ MyApplication.getApplication().getNodkaAPI().alarm_removeAllalarmPower();
261
+ setFileState("0", "/sys/class/minix-rtc/minix_RTC_DATA");
262
+ }
263
+
258264 editor.putString(repeat_alarm_poweron_time, "");
259265 editor.putString(repeat_alarm_poweroff_time, "");
260266 editor.commit();
261
-
262
- setFileState("0", "/sys/class/minix-rtc/MCURTCDATA");
263
-
267
+
264268 if(active)
265269 {
266270 if(repeat.equals("true"))
267271 {
268
- SpiritAlarmManager mSpiritAlarmManager = new SpiritAlarmManager();
269
- mSpiritAlarmManager.setSpiritAlarmWithDay(1, hms_on[0], hms_on[1]);
270
-
271
- setFileState("1", "/sys/class/minix-rtc/MCURTCDATA");
272
-
272
+ if (isSpiritVersion()) {
273
+ new SpiritAlarmManager().setSpiritAlarmWithDay(1, hms_on[0], hms_on[1]);
274
+ setFileState("1", "/sys/class/minix-rtc/MCURTCDATA");
275
+ } else {
276
+ MyApplication.getApplication().getNodkaAPI().alarm_setSpiritAlarmWithDay(1, hms_on[0], hms_on[1]);
277
+ setFileState("1", "/sys/class/minix-rtc/minix_RTC_DATA");
278
+ }
279
+
273280 editor.putString(repeat_alarm_poweron_time, hms_on[0]+":"+hms_on[1]+":"+0);
274281 editor.putString(repeat_alarm_poweroff_time, hms_off[0]+":"+hms_off[1]+":"+0);
275282 editor.commit();
....@@ -284,22 +291,37 @@
284291 editor.commit();
285292
286293 Calendar calendar = Calendar.getInstance();
287
-
288
- // 改接口 setSpiritAlarmWithDay()
289
- mAlarmPowerManager.CreatOneAlarmPower(calendar.get(Calendar.YEAR)+"",
290
- calendar.get(Calendar.MONTH)+1+"",
291
- calendar.get(Calendar.DAY_OF_MONTH)+"",
292
- hms_on[0]+"",
293
- hms_on[1]+"",
294
- hms_on[2]+"",
295
- hms_off[0]+"",
296
- hms_off[1]+"",
297
- hms_off[2]+"",
298
- hms_on[0]>12? "0":"1",
299
- hms_off[0]>12? "0":"1");
300
-
301
- mAlarmPowerManager.updateAlarmPowerActive(0, active+"");
302
-
294
+
295
+ if (isSpiritVersion()) {
296
+ // 改接口 setSpiritAlarmWithDay()
297
+ new AlarmPowerManager().CreatOneAlarmPower(calendar.get(Calendar.YEAR)+"",
298
+ calendar.get(Calendar.MONTH)+1+"",
299
+ calendar.get(Calendar.DAY_OF_MONTH)+"",
300
+ hms_on[0]+"",
301
+ hms_on[1]+"",
302
+ hms_on[2]+"",
303
+ hms_off[0]+"",
304
+ hms_off[1]+"",
305
+ hms_off[2]+"",
306
+ hms_on[0]>12? "0":"1",
307
+ hms_off[0]>12? "0":"1");
308
+
309
+ new AlarmPowerManager().updateAlarmPowerActive(0, active+"");
310
+ } else {
311
+ MyApplication.getApplication().getNodkaAPI().alarm_creatOneAlarmPower(calendar.get(Calendar.YEAR)+"",
312
+ calendar.get(Calendar.MONTH)+1+"",
313
+ calendar.get(Calendar.DAY_OF_MONTH)+"",
314
+ hms_on[0]+"",
315
+ hms_on[1]+"",
316
+ hms_on[2]+"",
317
+ hms_off[0]+"",
318
+ hms_off[1]+"",
319
+ hms_off[2]+"",
320
+ hms_on[0]>12? "0":"1",
321
+ hms_off[0]>12? "0":"1");
322
+
323
+ MyApplication.getApplication().getNodkaAPI().alarm_updateAlarmPowerActive(0, active+"");
324
+ }
303325 }
304326 }
305327 }
....@@ -667,7 +689,9 @@
667689 return re;
668690 }
669691
670
-
671
-
672
-
692
+ public boolean isSpiritVersion() {
693
+ return Build.VERSION.SDK_INT <= 25;
694
+ }
695
+
696
+
673697 }