}
BluetoothAdapter::BluetoothAdapter(BluetoothInstance& instance)
- : is_visible_(false),
+ : is_callback_set_(false),
+ is_visible_(false),
is_powered_(false),
is_initialized_(false),
user_request_list_(),
ReportSuccess(picojson::value(iter->second.second), out);
}
+void BluetoothAdapter::SetChangeListenerCallback(bool val) {
+ ScopeLogger();
+ is_callback_set_ = val;
+}
+
} // namespace bluetooth
} // namespace extension
void UnregisterUUID(const std::string& uuid, int callback_handle);
+ void SetChangeListenerCallback(bool val);
+
private:
BluetoothAdapter(const BluetoothAdapter&) = delete;
BluetoothAdapter& operator=(const BluetoothAdapter&) = delete;
void InvokeSocketOnMessageEvent(int id);
void InvokeSocketOnCloseEvent(int id);
+ bool is_callback_set_;
bool is_visible_;
bool is_powered_;
bool is_initialized_;
'BluetoothAdapterChangeCallback',
_BluetoothAdapterChangeCallback
);
+ native.callSync('BluetoothAdapterSetChangeListener', {});
}
_listener = args.changeCallback;
};
'BluetoothAdapterChangeCallback',
_BluetoothAdapterChangeCallback
);
+ native.callSync('BluetoothAdapterUnsetChangeListener', {});
_listener = undefined;
}
};
REGISTER_METHOD(BluetoothAdapterGetPowered);
REGISTER_METHOD(BluetoothAdapterGetVisible);
REGISTER_METHOD(BluetoothAdapterIsServiceConnected);
+ REGISTER_METHOD(BluetoothAdapterSetChangeListener);
+ REGISTER_METHOD(BluetoothAdapterUnsetChangeListener);
REGISTER_METHOD(BluetoothDeviceConnectToServiceByUUID);
REGISTER_METHOD(BluetoothDeviceGetBoolValue);
bluetooth_adapter_.IsServiceConnected(args, out);
}
+void BluetoothInstance::BluetoothAdapterSetChangeListener(const picojson::value& args,
+ picojson::object& out) {
+ ScopeLogger();
+ bluetooth_adapter_.SetChangeListenerCallback(true);
+}
+
+void BluetoothInstance::BluetoothAdapterUnsetChangeListener(const picojson::value& args,
+ picojson::object& out) {
+ ScopeLogger();
+ bluetooth_adapter_.SetChangeListenerCallback(false);
+}
+
void BluetoothInstance::BluetoothDeviceConnectToServiceByUUID(const picojson::value& args,
picojson::object& out) {
ScopeLogger();
void BluetoothAdapterGetPowered(const picojson::value& args, picojson::object& out);
void BluetoothAdapterGetVisible(const picojson::value& args, picojson::object& out);
void BluetoothAdapterIsServiceConnected(const picojson::value& args, picojson::object& out);
+ void BluetoothAdapterSetChangeListener(const picojson::value& args, picojson::object& out);
+ void BluetoothAdapterUnsetChangeListener(const picojson::value& args, picojson::object& out);
void BluetoothDeviceConnectToServiceByUUID(const picojson::value& args, picojson::object& out);
void BluetoothDeviceGetBoolValue(const picojson::value& args, picojson::object& out);