"common/bluetooth/avrcp_int_value.cc",
"common/bluetooth/avrcp_media_attr.cc",
"common/bluetooth/avrcp_register_notification_response.cc",
- "common/bluetooth/avrcp_string_value.cc",
"common/bluetooth/characteristic.cc",
"common/bluetooth/descriptor.cc",
"common/bluetooth/remote_device_props.cc",
#include "service/low_energy_client.h"
#include "service/low_energy_scanner.h"
-using android::String16;
using std::lock_guard;
using std::mutex;
RemoteDeviceProps ParseRemoteDeviceProps(int num_properties,
bt_property_t* properties) {
- android::String16 name;
- android::String16 address;
+ std::string name;
+ std::string address;
std::vector<Uuid> service_uuids;
int32_t device_class = 0;
int32_t device_type = 0;
break;
}
bt_bdname_t* hal_name = reinterpret_cast<bt_bdname_t*>(property->val);
- name = String16(reinterpret_cast<char*>(hal_name->name));
+ name = reinterpret_cast<char*>(hal_name->name);
break;
}
case BT_PROPERTY_BDADDR: {
NOTREACHED() << "Invalid length for BT_PROPERTY_BDADDR";
break;
}
- std::string remote_bdaddr_str =
- BtAddrString(reinterpret_cast<RawAddress*>(property->val));
- address = String16(remote_bdaddr_str.c_str(), remote_bdaddr_str.size());
+ address = BtAddrString(reinterpret_cast<RawAddress*>(property->val));
break;
}
case BT_PROPERTY_UUIDS: {
RemoteDeviceProps props =
ParseRemoteDeviceProps(num_properties, properties);
- std::string remote_bdaddr_str = BtAddrString(remote_bdaddr);
- android::String16 address =
- String16(remote_bdaddr_str.c_str(), remote_bdaddr_str.size());
+ std::string address = BtAddrString(remote_bdaddr);
props.set_address(address);
lock_guard<mutex> lock(observers_lock_);
#include "stack/include/avrc_defs.h"
-using android::String16;
namespace bluetooth {
btrc_element_attr_val_t* p_attrs) {
std::string device_address = BtAddrString(&bd_addr);
- String16 title;
- String16 artist;
- String16 album;
- String16 genre;
+ std::string title;
+ std::string artist;
+ std::string album;
+ std::string genre;
int track_num = -1;
int num_tracks = -1;
int play_time = -1;
auto attr_text = reinterpret_cast<char*>(p_attrs[i].text);
switch (p_attrs[i].attr_id) {
case BTRC_MEDIA_ATTR_ID_TITLE:
- title = String16(attr_text);
+ title = attr_text;
break;
case BTRC_MEDIA_ATTR_ID_ARTIST:
- artist = String16(attr_text);
+ artist = attr_text;
break;
case BTRC_MEDIA_ATTR_ID_ALBUM:
- album = String16(attr_text);
+ album = attr_text;
break;
case BTRC_MEDIA_ATTR_ID_TRACK_NUM:
if (!base::StringToInt(attr_text, &track_num)) {
}
break;
case BTRC_MEDIA_ATTR_ID_GENRE:
- genre = String16(attr_text);
+ genre = attr_text;
break;
case BTRC_MEDIA_ATTR_ID_PLAYING_TIME:
if (!base::StringToInt(attr_text, &play_time)) {
#define TRY_RET_FUNC(expr) TRY_RET(expr, __func__ << " failed")
-using android::String8;
using LockGuard = std::lock_guard<std::mutex>;
namespace bluetooth {
std::vector<btrc_player_setting_text_t> btrc_attrs(attrs.size());
for (size_t i = 0; i < attrs.size(); ++i) {
btrc_attrs[i].id = attrs[i].id();
- String8 str(attrs[i].value());
- size_t to_copy = std::min(sizeof(btrc_attrs[i].text) - 1, str.bytes());
- if (to_copy < str.bytes()) {
+ std::string str(attrs[i].value());
+ size_t to_copy = std::min(sizeof(btrc_attrs[i].text) - 1, str.size());
+ if (to_copy < str.size()) {
LOG(WARNING) << "Value truncated";
}
- memcpy(btrc_attrs[i].text, str.string(), to_copy);
+ memcpy(btrc_attrs[i].text, str.data(), to_copy);
btrc_attrs[i].text[to_copy] = '\0';
}
std::vector<btrc_element_attr_val_t> btrc_attrs(attrs.size());
for (size_t i = 0; i < attrs.size(); ++i) {
btrc_attrs[i].attr_id = attrs[i].id();
- String8 str(attrs[i].value());
- size_t to_copy = std::min(sizeof(btrc_attrs[i].text) - 1, str.bytes());
- if (to_copy < str.bytes()) {
+ std::string str(attrs[i].value());
+ size_t to_copy = std::min(sizeof(btrc_attrs[i].text) - 1, str.size());
+ if (to_copy < str.size()) {
LOG(WARNING) << "Value truncated";
}
- memcpy(btrc_attrs[i].text, str.string(), to_copy);
+ memcpy(btrc_attrs[i].text, str.data(), to_copy);
btrc_attrs[i].text[to_copy] = '\0';
}
"bluetooth/avrcp_int_value.cc",
"bluetooth/avrcp_media_attr.cc",
"bluetooth/avrcp_register_notification_response.cc",
- "bluetooth/avrcp_string_value.cc",
"bluetooth/characteristic.cc",
"bluetooth/descriptor.cc",
"bluetooth/remote_device_props.cc",
namespace bluetooth {
status_t BluetoothAvrcpMediaAttr::writeToParcel(Parcel* parcel) const {
- status_t status = parcel->writeString16(title_);
+ status_t status =
+ parcel->writeString16(String16(title_.c_str(), title_.size()));
if (status != OK) return status;
- status = parcel->writeString16(artist_);
+ status = parcel->writeString16(String16(artist_.c_str(), artist_.size()));
if (status != OK) return status;
- status = parcel->writeString16(album_);
+ status = parcel->writeString16(String16(album_.c_str(), album_.size()));
if (status != OK) return status;
- status = parcel->writeString16(genre_);
+ status = parcel->writeString16(String16(genre_.c_str(), genre_.size()));
if (status != OK) return status;
status = parcel->writeInt32(track_num_);
}
status_t BluetoothAvrcpMediaAttr::readFromParcel(const Parcel* parcel) {
- status_t status = parcel->readString16(&title_);
+ String16 title;
+ status_t status = parcel->readString16(&title);
if (status != OK) return status;
+ title_ = String8(title).string();
- status = parcel->readString16(&artist_);
+ String16 artist;
+ status = parcel->readString16(&artist);
if (status != OK) return status;
+ artist_ = String8(artist).string();
- status = parcel->readString16(&album_);
+ String16 album;
+ status = parcel->readString16(&album);
if (status != OK) return status;
+ album_ = String8(album).string();
- status = parcel->readString16(&genre_);
+ String16 genre;
+ status = parcel->readString16(&genre);
if (status != OK) return status;
+ genre_ = String8(genre).string();
int32_t tmp;
status = parcel->readInt32(&tmp);
status_t status = parcel->writeInt32(id_);
if (status != OK) return status;
- status = parcel->writeString16(value_);
+ status = parcel->writeString16(String16(value_.c_str(), value_.size()));
if (status != OK) return status;
return status;
if (status != OK) return status;
id_ = tmp;
- status = parcel->readString16(&value_);
+ String16 value;
+ status = parcel->readString16(&value);
if (status != OK) return status;
+ value_ = String8(value).string();
return status;
}
namespace bluetooth {
status_t BluetoothRemoteDeviceProps::writeToParcel(Parcel* parcel) const {
- status_t status = parcel->writeString16(name_);
+ status_t status =
+ parcel->writeString16(String16(name_.c_str(), name_.size()));
if (status != OK) return status;
- status = parcel->writeString16(address_);
+ status = parcel->writeString16(String16(address_.c_str(), address_.size()));
if (status != OK) return status;
std::vector<UUID> uuids;
}
status_t BluetoothRemoteDeviceProps::readFromParcel(const Parcel* parcel) {
- status_t status = parcel->readString16(&name_);
+ String16 name;
+ status_t status = parcel->readString16(&name);
if (status != OK) return status;
+ name_ = String8(name).string();
- status = parcel->readString16(&address_);
+ String16 address;
+ status = parcel->readString16(&address);
if (status != OK) return status;
+ address_ = String8(address).string();
std::vector<UUID> uuids;
status = parcel->readParcelableVector(&uuids);
#include "bluetooth/avrcp_media_attr.h"
-using android::String16;
-
namespace bluetooth {
AvrcpMediaAttr::AvrcpMediaAttr() = default;
AvrcpMediaAttr::AvrcpMediaAttr(const AvrcpMediaAttr& other) = default;
-AvrcpMediaAttr::AvrcpMediaAttr(const String16& title, const String16& artist,
- const String16& album, const String16& genre,
- int track_num, int num_tracks, int play_time)
+AvrcpMediaAttr::AvrcpMediaAttr(const std::string& title,
+ const std::string& artist,
+ const std::string& album,
+ const std::string& genre, int track_num,
+ int num_tracks, int play_time)
: title_(title),
artist_(artist),
album_(album),
#pragma once
-#include <utils/String16.h>
+#include <string>
namespace bluetooth {
public:
AvrcpMediaAttr();
AvrcpMediaAttr(const AvrcpMediaAttr& other);
- AvrcpMediaAttr(const android::String16& title,
- const android::String16& artist,
- const android::String16& album, const android::String16& genre,
+ AvrcpMediaAttr(const std::string& title, const std::string& artist,
+ const std::string& album, const std::string& genre,
int track_num, int num_tracks, int play_time);
~AvrcpMediaAttr();
- const android::String16& title() const { return title_; }
- const android::String16& artist() const { return artist_; }
- const android::String16& album() const { return album_; }
- const android::String16& genre() const { return genre_; }
+ const std::string& title() const { return title_; }
+ const std::string& artist() const { return artist_; }
+ const std::string& album() const { return album_; }
+ const std::string& genre() const { return genre_; }
int track_num() const { return track_num_; }
int num_tracks() const { return num_tracks_; }
int play_time() const { return play_time_; }
protected:
- android::String16 title_;
- android::String16 artist_;
- android::String16 album_;
- android::String16 genre_;
+ std::string title_;
+ std::string artist_;
+ std::string album_;
+ std::string genre_;
int track_num_ = -1;
int num_tracks_ = -1;
int play_time_ = -1;
+++ /dev/null
-//
-// Copyright (C) 2017 Google, Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at:
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#include "bluetooth/avrcp_string_value.h"
-
-using android::String16;
-
-namespace bluetooth {
-
-AvrcpStringValue::AvrcpStringValue() = default;
-AvrcpStringValue::AvrcpStringValue(const AvrcpStringValue& other) = default;
-AvrcpStringValue::AvrcpStringValue(int id, const String16& value)
- : id_(id), value_(value) {}
-AvrcpStringValue::~AvrcpStringValue() = default;
-
-} // namespace bluetooth
#pragma once
-#include <utils/String16.h>
+#include <string>
namespace bluetooth {
class AvrcpStringValue {
public:
- AvrcpStringValue();
- AvrcpStringValue(const AvrcpStringValue& other);
- AvrcpStringValue(int id, const android::String16& value);
- ~AvrcpStringValue();
+ AvrcpStringValue() = default;
+ AvrcpStringValue(const AvrcpStringValue& other) = default;
+ AvrcpStringValue(int id, const std::string& value) : id_(id), value_(value){};
+ ~AvrcpStringValue() = default;
int id() const { return id_; }
- const android::String16& value() const { return value_; }
+ const std::string& value() const { return value_; }
protected:
int id_ = 0;
- android::String16 value_;
+ std::string value_;
};
} // namespace bluetooth
#include "bluetooth/remote_device_props.h"
-using android::String16;
+using std::string;
namespace bluetooth {
RemoteDeviceProps::RemoteDeviceProps() = default;
RemoteDeviceProps::RemoteDeviceProps(const RemoteDeviceProps& other) = default;
-RemoteDeviceProps::RemoteDeviceProps(const android::String16& name,
- const android::String16& address,
+RemoteDeviceProps::RemoteDeviceProps(const std::string& name,
+ const std::string& address,
const std::vector<Uuid>& service_uuids,
int32_t device_class, int32_t device_type,
int32_t rssi)
#pragma once
+#include <string>
#include <vector>
-#include <utils/String16.h>
-
#include "bluetooth/uuid.h"
namespace bluetooth {
public:
RemoteDeviceProps();
RemoteDeviceProps(const RemoteDeviceProps& other);
- RemoteDeviceProps(const android::String16& name,
- const android::String16& address,
+ RemoteDeviceProps(const std::string& name, const std::string& address,
const std::vector<Uuid>& service_uuids,
int32_t device_class, int32_t device_type, int32_t rssi);
~RemoteDeviceProps();
- void set_address(const android::String16& address) { address_ = address; }
+ void set_address(const std::string& address) { address_ = address; }
- const android::String16& name() const { return name_; }
- const android::String16& address() const { return address_; }
+ const std::string& name() const { return name_; }
+ const std::string& address() const { return address_; }
const std::vector<Uuid>& service_uuids() const { return service_uuids_; }
int32_t device_class() const { return device_class_; }
int32_t device_type() const { return device_type_; }
int32_t rssi() const { return rssi_; }
protected:
- android::String16 name_;
- android::String16 address_;
+ std::string name_;
+ std::string address_;
std::vector<Uuid> service_uuids_;
int32_t device_class_ = -1;
int32_t device_type_ = -1;