EXTRA_PREVIOUS_SCAN_MODE始终为Android蓝牙返回错误

Leo*_*ang 19 android bluetooth cordova

当设备的蓝牙扫描模式发生变化(即可发现/不可发现)时,我正在使用以下代码将对象返回到Cordova.

cordova.getActivity().getApplicationContext().registerReceiver(new BroadcastReceiver(){
    @Override
    public void onReceive(Context c,Intent intent){
        JSONObject json=new JSONObject();
        try{
            json.put("current",intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE,BluetoothAdapter.ERROR));
            json.put("previous",intent.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_SCAN_MODE,BluetoothAdapter.ERROR));
        }catch(JSONException e){
        }
        PluginResult result=new PluginResult(PluginResult.Status.OK,json);
        result.setKeepCallback(true);
        discoverableCallback.sendPluginResult(result); // discoverableCallback is a callbackContext
    }
},new IntentFilter(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED));
Run Code Online (Sandbox Code Playgroud)

但是,intent.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_SCAN_MODE,BluetoothAdapter.ERROR)总是如此BluetoothAdapter.ERROR.我尝试连续多次开启和关闭可发现性,并且始终如此BluetoothAdapter.ERROR.如何让它返回先前的扫描模式?

nan*_*esh 2

从我在AOSP源代码中看到的来看,EXTRA_PREVIOUS_SCAN_MODE从未被使用过。所以我猜谷歌的文档在这种情况下是错误的。如果您在此处搜索,则整个源代码中没有任何引用