android接收到蓝牙配对请求时如何点亮屏幕具体实现
程序员文章站
2023-10-19 13:50:19
file: bluetootheventloop.java gb/gb2/gb3: 1. import android.os.powermanager; 2. 变量申明:p...
file: bluetootheventloop.java
gb/gb2/gb3:
1. import android.os.powermanager;
2. 变量申明:private powermanager.wakelock mwakelock;
3. bluetootheventloop(){} 构造函数里面添加定义:
powermanager pm = (powermanager)context.getsystemservice(context.power_service);
mwakelock = pm.newwakelock(powermanager.full_wake_lock | powermanager.acquire_causes_wakeup
| powermanager.on_after_release, tag);
mwakelock.setreferencecounted(false);
4. onrequestpairingconsent(){
...
mwakelock.acquire(5000); // xintong , 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
5. onrequestpasskeyconfirmation(){
...
mwakelock.acquire(5000); // xintong , 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
6. onrequestpasskey(){
...
mwakelock.acquire(5000); // xintong , 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
7. onrequestpincode(){
...
mwakelock.acquire(5000); // xintong 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
8. ondisplaypasskey(){
...
mwakelock.acquire(5000); // xintong , 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
ics/ics2/jb/jb2/jb3:
省略掉gb中修改的第1、2、3步;
对4、5、6、7、8中修改的function中:将原生的mwakelock.acquire(); 改为mwakelock.acquire(5000), 删掉对应function中的mwakelock.release();
修改完后,模块会被编译进framework.jar
gb/gb2/gb3:
1. import android.os.powermanager;
2. 变量申明:private powermanager.wakelock mwakelock;
3. bluetootheventloop(){} 构造函数里面添加定义:
powermanager pm = (powermanager)context.getsystemservice(context.power_service);
mwakelock = pm.newwakelock(powermanager.full_wake_lock | powermanager.acquire_causes_wakeup
| powermanager.on_after_release, tag);
mwakelock.setreferencecounted(false);
4. onrequestpairingconsent(){
...
mwakelock.acquire(5000); // xintong , 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
5. onrequestpasskeyconfirmation(){
...
mwakelock.acquire(5000); // xintong , 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
6. onrequestpasskey(){
...
mwakelock.acquire(5000); // xintong , 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
7. onrequestpincode(){
...
mwakelock.acquire(5000); // xintong 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
8. ondisplaypasskey(){
...
mwakelock.acquire(5000); // xintong , 亮屏5s
intent intent = new intent(bluetoothdevice.action_pairing_request);
...
}
ics/ics2/jb/jb2/jb3:
省略掉gb中修改的第1、2、3步;
对4、5、6、7、8中修改的function中:将原生的mwakelock.acquire(); 改为mwakelock.acquire(5000), 删掉对应function中的mwakelock.release();
修改完后,模块会被编译进framework.jar