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

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

Issue 2841943003: bluetooth: Use BuildInfo to retrieve the Android version (Closed)
Patch Set: bluetooth: Use BuildInfo to retrieve the Android version Created 3 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 | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_factory.h" 5 #include "device/bluetooth/bluetooth_adapter_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "device/bluetooth/bluetooth_adapter.h" 14 #include "device/bluetooth/bluetooth_adapter.h"
15 15
16 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
17 #include "base/mac/mac_util.h" 17 #include "base/mac/mac_util.h"
18 #endif 18 #endif
19 #if defined(OS_WIN) 19 #if defined(OS_WIN)
20 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
21 #endif 21 #endif
22 #if defined(ANDROID)
23 #include "base/android/build_info.h"
24 #endif
22 25
23 namespace device { 26 namespace device {
24 27
25 namespace { 28 namespace {
26 29
27 // Shared default adapter instance. We don't want to keep this class around 30 // Shared default adapter instance. We don't want to keep this class around
28 // if nobody is using it, so use a WeakPtr and create the object when needed. 31 // if nobody is using it, so use a WeakPtr and create the object when needed.
29 // Since Google C++ Style (and clang's static analyzer) forbids us having 32 // Since Google C++ Style (and clang's static analyzer) forbids us having
30 // exit-time destructors, we use a leaky lazy instance for it. 33 // exit-time destructors, we use a leaky lazy instance for it.
31 base::LazyInstance<base::WeakPtr<BluetoothAdapter>>::Leaky default_adapter = 34 base::LazyInstance<base::WeakPtr<BluetoothAdapter>>::Leaky default_adapter =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #endif 73 #endif
71 } 74 }
72 75
73 // static 76 // static
74 bool BluetoothAdapterFactory::IsLowEnergySupported() { 77 bool BluetoothAdapterFactory::IsLowEnergySupported() {
75 // SetAdapterForTesting() may be used to provide a test or mock adapter 78 // SetAdapterForTesting() may be used to provide a test or mock adapter
76 // instance even on platforms that would otherwise not support it. 79 // instance even on platforms that would otherwise not support it.
77 if (default_adapter.Get()) 80 if (default_adapter.Get())
78 return true; 81 return true;
79 82
80 #if defined(OS_ANDROID) && __ANDROID_API__ >= 23 83 #if defined(OS_ANDROID)
81 return true; 84 return base::android::BuildInfo::GetInstance()->sdk_int() >=
85 base::android::SDK_VERSION_MARSHMALLOW;
82 #elif defined(OS_WIN) 86 #elif defined(OS_WIN)
83 // Windows 8 supports Low Energy GATT operations but it does not support 87 // Windows 8 supports Low Energy GATT operations but it does not support
84 // scanning, initiating connections and GATT Server. To keep the API 88 // scanning, initiating connections and GATT Server. To keep the API
85 // consistent we consider Windows 8 as lacking Low Energy support. 89 // consistent we consider Windows 8 as lacking Low Energy support.
86 return base::win::GetVersion() >= base::win::VERSION_WIN10; 90 return base::win::GetVersion() >= base::win::VERSION_WIN10;
87 #elif defined(OS_MACOSX) 91 #elif defined(OS_MACOSX)
88 return base::mac::IsAtLeastOS10_10(); 92 return base::mac::IsAtLeastOS10_10();
89 #elif defined(OS_LINUX) || defined(OS_CHROMEOS) 93 #elif defined(OS_LINUX) || defined(OS_CHROMEOS)
90 return true; 94 return true;
91 #else 95 #else
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 scoped_refptr<BluetoothAdapter> adapter) { 136 scoped_refptr<BluetoothAdapter> adapter) {
133 default_adapter.Get() = adapter->GetWeakPtrForTesting(); 137 default_adapter.Get() = adapter->GetWeakPtrForTesting();
134 } 138 }
135 139
136 // static 140 // static
137 bool BluetoothAdapterFactory::HasSharedInstanceForTesting() { 141 bool BluetoothAdapterFactory::HasSharedInstanceForTesting() {
138 return default_adapter.Get() != nullptr; 142 return default_adapter.Get() != nullptr;
139 } 143 }
140 144
141 } // namespace device 145 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698