import android.content.IClipboard;
import android.content.Intent;
import android.media.AudioManager;
+import android.media.MediaRouter;
import android.os.Handler;
import android.os.IBinder;
Runtime runtime;
private BroadcastReceiver screenOnReceiver = new BroadcastReceiver() {
- public void onReceive(Context param1Context, Intent param1Intent) {
+ public void onReceive(Context context, Intent intent) {
- if ("android.intent.action.SCREEN_ON".equals(param1Intent.getAction())) {
+ if ("android.intent.action.SCREEN_ON".equals(intent.getAction())) {
StringBuilder var3 = new StringBuilder();
var3.append("screen on wake is_wifi_network_ok=");
var3.append(CoreService.is_wifi_network_ok);
ICLogger.i(var3.toString());
//检测电池电量 并上报低电报警
- batteryUtil.getBatteryLevel(param1Context);
+ batteryUtil.getBatteryLevel(context);
if (CoreService.is_in_sleep_mode) {
/*屏幕亮起时,如果在sleep模式(夜晚的那个睡眠模式,非系统休眠,暂时没实现,还不会跑到这里),则唤醒各个进程*/
// if (!Util.isWifiIsOpen(runtime.getContextProxy().context,runtime))
// Util.turnOnWifiForConnect(runtime.getContextProxy().context, runtime);
}
- } else if ("android.intent.action.SCREEN_OFF".equals(param1Intent.getAction()) && Util.isWifiIsOpen(runtime.getContextProxy().context,runtime)) {
+ } else if ("android.intent.action.SCREEN_OFF".equals(intent.getAction()) && Util.isWifiIsOpen(runtime.getContextProxy().context,runtime)) {
// CoreService.is_wifi_network_ok = true;
if (!runtime.isNoTurnOffWifiOnScreenOff()) {
//不关闭wifi when ScreenOff
// if (Util.isWifiIsOpen(runtime.getContextProxy().context,runtime))
// Util.turnOffWifiForSleep(runtime.getContextProxy().context, runtime);
}
+ }else if (intent.getAction().equals("android.media.VOLUME_CHANGED_ACTION")) {
+ int streamType = intent.getIntExtra("android.media.EXTRA_VOLUME_STREAM_TYPE", -1);
+ ICLogger.i("Volume changed stream type "+streamType);
+
+ int newVolume = intent.getIntExtra("android.media.EXTRA_VOLUME_STREAM_VALUE", 0);
+ int oldVolume = intent.getIntExtra("android.media.EXTRA_PREV_VOLUME_STREAM_VALUE", 0);
+ if (newVolume != oldVolume) {
+ ICLogger.i("Volume changed old "+oldVolume+" new "+newVolume);
+ Config.setMasterVolume(context,newVolume);
+ }
}
}
};
intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.SCREEN_ON");
intentFilter.addAction("android.intent.action.SCREEN_OFF");
+ intentFilter.addAction("android.media.VOLUME_CHANGED_ACTION");
(this.runtime.getContextProxy()).context.registerReceiver(this.screenOnReceiver, intentFilter);
//注册接收 AT指令结果返回消息
runtime.bleInfo.bleScanCycle=Config.getBleScanCycle(this);
if(Config.BLEScanProtocol==1 && runtime.bleInfo.bleScanCycle>0)
{
+
setBleScanAlarm(runtime.bleInfo.bleScanCycle);
}
}
public void setBleScanAlarm(int cycle){
+ //只有蓝牙扫描协议1才需要设置周期,蓝牙扫描协议0 为心跳及定位时才进行扫描
if (Config.BLEScanProtocol!=1) {
ICLogger.i("BLEScanProtocol!=1 skip setPolingCheckAntiAlarm");
return;
}
StringBuilder sb=new StringBuilder();
- if (cycle>1) {
- AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context, cycle, ACTION_ALARM_BLE_SCAN);
+ if (cycle>=15) {
+ //由于蓝牙扫描一次15秒,所以周期要大于等于15秒
+ AlarmHelper.setRealTimeAlarmInMicorSeconds(runtime.getContextProxy().context, cycle*1000, ACTION_ALARM_BLE_SCAN);
}
- sb.append("setBleScanAlarm " + cycle);
+ sb.append("setBleScanAlarm " + cycle+" seconds");
locationClient.triggerBLEProcess();
ICLogger.i(sb.toString());
if (Config.LOG_TOFILE)ICLogger.logToFile("alarmCycle",sb.toString());