• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_ANDROID_RADIO_UTILS_H_
6 #define BASE_ANDROID_RADIO_UTILS_H_
7 
8 #include "base/android/jni_android.h"
9 #include "third_party/abseil-cpp/absl/types/optional.h"
10 
11 namespace base {
12 namespace android {
13 
14 // These values are persisted to logs. Entries should not be renumbered and
15 // numeric values should never be reused. Keep in sync with RadioSignalLevel
16 // in //tools/metrics/histograms/enums.xml.
17 enum class RadioSignalLevel {
18   kNoneOrUnknown = 0,
19   kPoor = 1,
20   kModerate = 2,
21   kGood = 3,
22   kGreat = 4,
23   kMaxValue = kGreat,
24 };
25 
26 enum class RadioDataActivity {
27   kNone = 0,
28   kIn = 1,
29   kOut = 2,
30   kInOut = 3,
31   kDormant = 4,
32 };
33 
34 enum class RadioConnectionType {
35   kUnknown = 0,
36   kWifi = 1,
37   kCell = 2,
38 };
39 
40 class BASE_EXPORT RadioUtils {
41  public:
42   class OverrideForTesting {
43    public:
44     OverrideForTesting();
45     ~OverrideForTesting();
46 
SetConnectionTypeForTesting(RadioConnectionType connection_type)47     void SetConnectionTypeForTesting(RadioConnectionType connection_type) {
48       connection_type_ = connection_type;
49     }
50 
GetConnectionType()51     RadioConnectionType GetConnectionType() { return connection_type_; }
52 
53    private:
54     RadioConnectionType connection_type_;
55   };
56   static bool IsSupported();
57   static RadioConnectionType GetConnectionType();
58   static absl::optional<RadioSignalLevel> GetCellSignalLevel();
59   static absl::optional<RadioDataActivity> GetCellDataActivity();
60 };
61 
62 }  // namespace android
63 }  // namespace base
64 
65 #endif  // BASE_ANDROID_RADIO_UTILS_H_
66