Fel*_*han 1 android bluetooth headset
我想模拟进入throgh设置 - >无线 - >蓝牙的动作,并以编程方式连接配对的蓝牙耳机.我已经做了在#1和谷歌一些搜索,都表明存在API级别之前没有可用的解决方案11.不过,我感兴趣的是通过蓝牙实现Android系统的源代码偷看工作吧.问题是我不知道应该检查哪些具体的源代码.有什么建议?非常感谢.
在您的代码中添加此私有方法:
private IBluetoothA2dp getIBluetoothA2dp() {
IBluetoothA2dp ibta = null;
try {
Class c2 = Class.forName("android.os.ServiceManager");
Method m2 = c2.getDeclaredMethod("getService", String.class);
IBinder b = (IBinder) m2.invoke(null, "bluetooth_a2dp");
Log.d("Felix", "Test2: " + b.getInterfaceDescriptor());
Class c3 = Class.forName("android.bluetooth.IBluetoothA2dp");
Class[] s2 = c3.getDeclaredClasses();
Class c = s2[0];
// printMethods(c);
Method m = c.getDeclaredMethod("asInterface", IBinder.class);
m.setAccessible(true);
ibta = (IBluetoothA2dp) m.invoke(null, b);
} catch (Exception e) {
Log.e("flowlab", "Erroraco!!! " + e.getMessage());
}
Run Code Online (Sandbox Code Playgroud)用这个测试:
private void testBluetoothA2dp(BluetoothDevice device) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
IBluetoothA2dp ibta = getIBluetoothA2dp();
try {
Log.d("Felix", "Here: " + ibta.getSinkPriority(device));
ibta.connectSink(device);
} catch (RemoteException e) {
// * TODO Auto-generated catch block
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
}
我无法提供这些代码的引用,因为我花了很多时间谷歌搜索,检查stackoverflow,并审查Android源代码,但未能跟踪来源.非常感谢Stackoverflow中的你们:)
| 归档时间: |
|
| 查看次数: |
8549 次 |
| 最近记录: |