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 <optional> 9 10 #include "base/android/jni_android.h" 11 12 namespace base { 13 namespace android { 14 15 // These values are persisted to logs. Entries should not be renumbered and 16 // numeric values should never be reused. Keep in sync with RadioSignalLevel 17 // in //tools/metrics/histograms/enums.xml. 18 enum class RadioSignalLevel { 19 kNoneOrUnknown = 0, 20 kPoor = 1, 21 kModerate = 2, 22 kGood = 3, 23 kGreat = 4, 24 kMaxValue = kGreat, 25 }; 26 27 enum class RadioDataActivity { 28 kNone = 0, 29 kIn = 1, 30 kOut = 2, 31 kInOut = 3, 32 kDormant = 4, 33 }; 34 35 enum class RadioConnectionType { 36 kUnknown = 0, 37 kWifi = 1, 38 kCell = 2, 39 }; 40 41 class BASE_EXPORT RadioUtils { 42 public: 43 class OverrideForTesting { 44 public: 45 OverrideForTesting(); 46 ~OverrideForTesting(); 47 SetConnectionTypeForTesting(RadioConnectionType connection_type)48 void SetConnectionTypeForTesting(RadioConnectionType connection_type) { 49 connection_type_ = connection_type; 50 } 51 GetConnectionType()52 RadioConnectionType GetConnectionType() { return connection_type_; } 53 54 private: 55 RadioConnectionType connection_type_; 56 }; 57 static bool IsSupported(); 58 static RadioConnectionType GetConnectionType(); 59 static std::optional<RadioSignalLevel> GetCellSignalLevel(); 60 static std::optional<RadioDataActivity> GetCellDataActivity(); 61 }; 62 63 } // namespace android 64 } // namespace base 65 66 #endif // BASE_ANDROID_RADIO_UTILS_H_ 67