1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHRE_CORE_SETTINGS_H_
18 #define CHRE_CORE_SETTINGS_H_
19 
20 #include <cinttypes>
21 
22 #include "chre/util/system/debug_dump.h"
23 
24 namespace chre {
25 
26 enum class Setting : uint8_t {
27   LOCATION = 0,
28   WIFI_AVAILABLE,
29   AIRPLANE_MODE,
30   MICROPHONE,
31   SETTING_MAX,
32 };
33 
34 enum class SettingState : int8_t { UNKNOWN = -1, ENABLED = 0, DISABLED };
35 
36 /**
37  * Updates the state of a given setting.
38  *
39  * @param setting The setting to update.
40  * @param state The state of the setting.
41  */
42 void postSettingChange(Setting setting, SettingState state);
43 
44 /**
45  * Gets the current state of a given setting. Must be called from the context of
46  * the main CHRE thread.
47  *
48  * @param setting The setting to check the current state of.
49  *
50  * @return The current state of the setting, SETTING_STATE_UNKNOWN if the
51  * provided setting is invalid.
52  */
53 SettingState getSettingState(Setting setting);
54 
55 /**
56  * Gets the current state of a given setting, but returns the state as an
57  * int8_t. The state is guaranteed to be a member of enum chreUserSettingState.
58  *
59  * @param setting The setting to check the current state of (see
60  * CHRE_USER_SETTINGS).
61  *
62  * @return The current state of the setting (see enum chreUserSettingState)
63  */
64 int8_t getSettingStateAsInt8(uint8_t setting);
65 
66 /**
67  * Logs the settings related stats in the debug dump. Must be called from the
68  * context of the main CHRE thread.
69  *
70  * @param debugDump The object that is printed into for debug dump logs.
71  */
72 void logSettingStateToBuffer(DebugDumpWrapper &debugDump);
73 
74 }  // namespace chre
75 
76 #endif  // CHRE_CORE_SETTINGS_H_
77