.. | .. |
---|
24 | 24 | import android.net.ConnectivityManager; |
---|
25 | 25 | import android.net.NetworkInfo; |
---|
26 | 26 | import android.net.NetworkInfo.DetailedState; |
---|
| 27 | +import android.os.Build; |
---|
27 | 28 | import android.os.PowerManager; |
---|
28 | 29 | import android.os.RemoteException; |
---|
29 | 30 | import android.text.format.DateFormat; |
---|
30 | 31 | 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; |
---|
31 | 36 | |
---|
32 | 37 | |
---|
33 | 38 | public class Utils { |
---|
.. | .. |
---|
67 | 72 | Thread thread_set_time_reboot = null; |
---|
68 | 73 | Thread thread_STOP_WATCH_DOG = null; |
---|
69 | 74 | Thread thread_AlarmPower_Repeat_Poweroff = null; |
---|
70 | | - |
---|
71 | | - |
---|
| 75 | + |
---|
72 | 76 | |
---|
73 | 77 | |
---|
74 | 78 | public Utils(Context context) { |
---|
.. | .. |
---|
80 | 84 | sharedPreferences = context.getSharedPreferences(shapre, context.MODE_PRIVATE); |
---|
81 | 85 | editor = sharedPreferences.edit(); |
---|
82 | 86 | } |
---|
83 | | - |
---|
84 | 87 | |
---|
85 | 88 | public void shut_Down() |
---|
86 | 89 | { |
---|
.. | .. |
---|
250 | 253 | return; |
---|
251 | 254 | } |
---|
252 | 255 | |
---|
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 | + |
---|
258 | 264 | editor.putString(repeat_alarm_poweron_time, ""); |
---|
259 | 265 | editor.putString(repeat_alarm_poweroff_time, ""); |
---|
260 | 266 | editor.commit(); |
---|
261 | | - |
---|
262 | | - setFileState("0", "/sys/class/minix-rtc/MCURTCDATA"); |
---|
263 | | - |
---|
| 267 | + |
---|
264 | 268 | if(active) |
---|
265 | 269 | { |
---|
266 | 270 | if(repeat.equals("true")) |
---|
267 | 271 | { |
---|
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 | + |
---|
273 | 280 | editor.putString(repeat_alarm_poweron_time, hms_on[0]+":"+hms_on[1]+":"+0); |
---|
274 | 281 | editor.putString(repeat_alarm_poweroff_time, hms_off[0]+":"+hms_off[1]+":"+0); |
---|
275 | 282 | editor.commit(); |
---|
.. | .. |
---|
284 | 291 | editor.commit(); |
---|
285 | 292 | |
---|
286 | 293 | 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 | + } |
---|
303 | 325 | } |
---|
304 | 326 | } |
---|
305 | 327 | } |
---|
.. | .. |
---|
667 | 689 | return re; |
---|
668 | 690 | } |
---|
669 | 691 | |
---|
670 | | - |
---|
671 | | - |
---|
672 | | - |
---|
| 692 | + public boolean isSpiritVersion() { |
---|
| 693 | + return Build.VERSION.SDK_INT <= 25; |
---|
| 694 | + } |
---|
| 695 | + |
---|
| 696 | + |
---|
673 | 697 | } |
---|