Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: device/bluetooth/bluetooth_adapter_bluez.cc

Issue 1810993002: Don't improve Bluetooth Adapter name on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluetooth_adapter_bluez.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluetooth_adapter_bluez.h" 5 #include "device/bluetooth/bluetooth_adapter_bluez.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 VLOG(1) << "Registering pairing agent"; 817 VLOG(1) << "Registering pairing agent";
818 bluez::BluezDBusManager::Get() 818 bluez::BluezDBusManager::Get()
819 ->GetBluetoothAgentManagerClient() 819 ->GetBluetoothAgentManagerClient()
820 ->RegisterAgent(dbus::ObjectPath(kAgentPath), 820 ->RegisterAgent(dbus::ObjectPath(kAgentPath),
821 bluetooth_agent_manager::kKeyboardDisplayCapability, 821 bluetooth_agent_manager::kKeyboardDisplayCapability,
822 base::Bind(&BluetoothAdapterBlueZ::OnRegisterAgent, 822 base::Bind(&BluetoothAdapterBlueZ::OnRegisterAgent,
823 weak_ptr_factory_.GetWeakPtr()), 823 weak_ptr_factory_.GetWeakPtr()),
824 base::Bind(&BluetoothAdapterBlueZ::OnRegisterAgentError, 824 base::Bind(&BluetoothAdapterBlueZ::OnRegisterAgentError,
825 weak_ptr_factory_.GetWeakPtr())); 825 weak_ptr_factory_.GetWeakPtr()));
826 826
827 SetDefaultAdapterName(); 827 #if defined(OS_CHROMEOS)
828 SetStandardChromeOSAdapterName();
829 #endif
828 830
829 bluez::BluetoothAdapterClient::Properties* properties = 831 bluez::BluetoothAdapterClient::Properties* properties =
830 bluez::BluezDBusManager::Get() 832 bluez::BluezDBusManager::Get()
831 ->GetBluetoothAdapterClient() 833 ->GetBluetoothAdapterClient()
832 ->GetProperties(object_path_); 834 ->GetProperties(object_path_);
833 835
834 PresentChanged(true); 836 PresentChanged(true);
835 837
836 if (properties->powered.value()) 838 if (properties->powered.value())
837 PoweredChanged(true); 839 PoweredChanged(true);
838 if (properties->discoverable.value()) 840 if (properties->discoverable.value())
839 DiscoverableChanged(true); 841 DiscoverableChanged(true);
840 if (properties->discovering.value()) 842 if (properties->discovering.value())
841 DiscoveringChanged(true); 843 DiscoveringChanged(true);
842 844
843 std::vector<dbus::ObjectPath> device_paths = 845 std::vector<dbus::ObjectPath> device_paths =
844 bluez::BluezDBusManager::Get() 846 bluez::BluezDBusManager::Get()
845 ->GetBluetoothDeviceClient() 847 ->GetBluetoothDeviceClient()
846 ->GetDevicesForAdapter(object_path_); 848 ->GetDevicesForAdapter(object_path_);
847 849
848 for (std::vector<dbus::ObjectPath>::iterator iter = device_paths.begin(); 850 for (std::vector<dbus::ObjectPath>::iterator iter = device_paths.begin();
849 iter != device_paths.end(); ++iter) { 851 iter != device_paths.end(); ++iter) {
850 DeviceAdded(*iter); 852 DeviceAdded(*iter);
851 } 853 }
852 } 854 }
853 855
854 void BluetoothAdapterBlueZ::SetDefaultAdapterName() { 856 #if defined(OS_CHROMEOS)
857 void BluetoothAdapterBlueZ::SetStandardChromeOSAdapterName() {
855 DCHECK(IsPresent()); 858 DCHECK(IsPresent());
856 859
857 std::string alias; 860 std::string alias;
858 #if defined(OS_CHROMEOS)
859 switch (chromeos::GetDeviceType()) { 861 switch (chromeos::GetDeviceType()) {
860 case chromeos::DeviceType::kChromebase: 862 case chromeos::DeviceType::kChromebase:
861 alias = "Chromebase"; 863 alias = "Chromebase";
862 break; 864 break;
863 case chromeos::DeviceType::kChromebit: 865 case chromeos::DeviceType::kChromebit:
864 alias = "Chromebit"; 866 alias = "Chromebit";
865 break; 867 break;
866 case chromeos::DeviceType::kChromebook: 868 case chromeos::DeviceType::kChromebook:
867 alias = "Chromebook"; 869 alias = "Chromebook";
868 break; 870 break;
869 case chromeos::DeviceType::kChromebox: 871 case chromeos::DeviceType::kChromebox:
870 alias = "Chromebox"; 872 alias = "Chromebox";
871 break; 873 break;
872 case chromeos::DeviceType::kUnknown: 874 case chromeos::DeviceType::kUnknown:
873 alias = "Chromebook"; 875 alias = "Chromebook";
874 break; 876 break;
875 } 877 }
876 #elif defined(OS_LINUX)
877 alias = "ChromeLinux";
878 #endif
879
880 // Take the lower 2 bytes of hashed Bluetooth address and combine it with the 878 // Take the lower 2 bytes of hashed Bluetooth address and combine it with the
881 // device type to create a more identifiable device name. 879 // device type to create a more identifiable device name.
882 const std::string address = GetAddress(); 880 const std::string address = GetAddress();
883 alias = base::StringPrintf( 881 alias = base::StringPrintf(
884 "%s_%04X", alias.c_str(), 882 "%s_%04X", alias.c_str(),
885 base::SuperFastHash(address.data(), address.size()) & 0xFFFF); 883 base::SuperFastHash(address.data(), address.size()) & 0xFFFF);
886 SetName(alias, base::Bind(&base::DoNothing), base::Bind(&base::DoNothing)); 884 SetName(alias, base::Bind(&base::DoNothing), base::Bind(&base::DoNothing));
887 } 885 }
886 #endif
888 887
889 void BluetoothAdapterBlueZ::RemoveAdapter() { 888 void BluetoothAdapterBlueZ::RemoveAdapter() {
890 DCHECK(IsPresent()); 889 DCHECK(IsPresent());
891 VLOG(1) << object_path_.value() << ": adapter removed."; 890 VLOG(1) << object_path_.value() << ": adapter removed.";
892 891
893 bluez::BluetoothAdapterClient::Properties* properties = 892 bluez::BluetoothAdapterClient::Properties* properties =
894 bluez::BluezDBusManager::Get() 893 bluez::BluezDBusManager::Get()
895 ->GetBluetoothAdapterClient() 894 ->GetBluetoothAdapterClient()
896 ->GetProperties(object_path_); 895 ->GetProperties(object_path_);
897 896
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 1448
1450 // If the queued request resulted in a pending call, then let it 1449 // If the queued request resulted in a pending call, then let it
1451 // asynchonously process the remaining queued requests once the pending 1450 // asynchonously process the remaining queued requests once the pending
1452 // call returns. 1451 // call returns.
1453 if (discovery_request_pending_) 1452 if (discovery_request_pending_)
1454 return; 1453 return;
1455 } 1454 }
1456 } 1455 }
1457 1456
1458 } // namespace bluez 1457 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_bluez.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698