summaryrefslogtreecommitdiff
path: root/services/powermanager/include/android/BatterySaverPolicyConfig.h
blob: 3a0c9d0dddaec82ea92580e589dd7a2c286c0fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_OS_BATTERY_SAVER_POLICY_CONFIG_H
#define ANDROID_OS_BATTERY_SAVER_POLICY_CONFIG_H

#include <math.h>
#include <binder/Parcelable.h>
#include <utils/RefBase.h>

namespace android::os {

enum class LocationMode : int32_t;
enum class SoundTriggerMode : int32_t;
/**
 * BatterySaverPolicyConfig is a structure of configs to set Battery Saver policy flags.
 * This file needs to be kept in sync with
 * frameworks/base/core/java/android/os/BatterySaverPolicyConfig.java
 */
struct BatterySaverPolicyConfig : public android::Parcelable {

    BatterySaverPolicyConfig(float adjustBrightnessFactor = 1.0f,
                             bool advertiseIsEnabled = false,
                             bool deferFullBackup = false,
                             bool deferKeyValueBackup = false,
                             std::vector<std::pair<String16, String16>> deviceSpecificSettings = {},
                             bool disableAnimation = false,
                             bool disableAod = false,
                             bool disableLaunchBoost = false,
                             bool disableOptionalSensors = false,
                             bool disableVibration = false,
                             bool enableAdjustBrightness = false,
                             bool enableDataSaver = false,
                             bool enableFirewall = false,
                             bool enableNightMode = false,
                             bool enableQuickDoze = false,
                             bool forceAllAppsStandby = false,
                             bool forceBackgroundCheck = false,
                             LocationMode locationMode = static_cast<LocationMode>(0),
                             SoundTriggerMode soundTriggerMode = static_cast<SoundTriggerMode>(0))
        : mAdjustBrightnessFactor(adjustBrightnessFactor),
          mAdvertiseIsEnabled(advertiseIsEnabled),
          mDeferFullBackup(deferFullBackup),
          mDeferKeyValueBackup(deferKeyValueBackup),
          mDeviceSpecificSettings(deviceSpecificSettings),
          mDisableAnimation(disableAnimation),
          mDisableAod(disableAod),
          mDisableLaunchBoost(disableLaunchBoost),
          mDisableOptionalSensors(disableOptionalSensors),
          mDisableVibration(disableVibration),
          mEnableAdjustBrightness(enableAdjustBrightness),
          mEnableDataSaver(enableDataSaver),
          mEnableFirewall(enableFirewall),
          mEnableNightMode(enableNightMode),
          mEnableQuickDoze(enableQuickDoze),
          mForceAllAppsStandby(forceAllAppsStandby),
          mForceBackgroundCheck(forceBackgroundCheck),
          mLocationMode(locationMode),
          mSoundTriggerMode(soundTriggerMode) {
    }

    status_t readFromParcel(const android::Parcel* parcel) override;
    status_t writeToParcel(android::Parcel* parcel) const override;
    bool operator == (const BatterySaverPolicyConfig &bsp) const {
        return fabs(mAdjustBrightnessFactor - bsp.mAdjustBrightnessFactor) == 0.0f &&
               mAdvertiseIsEnabled == bsp.mAdvertiseIsEnabled &&
               mDeferFullBackup == bsp.mDeferFullBackup &&
               mDeferKeyValueBackup == bsp.mDeferKeyValueBackup &&
               mDeviceSpecificSettings == bsp.mDeviceSpecificSettings &&
               mDisableAnimation == bsp.mDisableAnimation &&
               mDisableAod == bsp.mDisableAod &&
               mDisableLaunchBoost == bsp.mDisableLaunchBoost &&
               mDisableOptionalSensors == bsp.mDisableOptionalSensors &&
               mDisableVibration == bsp.mDisableVibration &&
               mEnableAdjustBrightness == bsp.mEnableAdjustBrightness &&
               mEnableDataSaver == bsp.mEnableDataSaver &&
               mEnableFirewall == bsp.mEnableFirewall &&
               mEnableNightMode == bsp.mEnableNightMode &&
               mEnableQuickDoze == bsp.mEnableQuickDoze &&
               mForceAllAppsStandby == bsp.mForceAllAppsStandby &&
               mForceBackgroundCheck == bsp.mForceBackgroundCheck &&
               mLocationMode == bsp.mLocationMode &&
               mSoundTriggerMode == bsp.mSoundTriggerMode;
    }

private:
    status_t readDeviceSpecificSettings(const android::Parcel *parcel);
    status_t writeDeviceSpecificSettings(android::Parcel *parcel) const;
    /** Adjust screen brightness factor */
    float mAdjustBrightnessFactor;
    /** Is advertise enabled */
    bool mAdvertiseIsEnabled;
    /** Defer full backup */
    bool mDeferFullBackup;
    /** Defer key value backup */
    bool mDeferKeyValueBackup;
    /** Device specific settings */
    std::vector<std::pair<String16, String16>> mDeviceSpecificSettings;
    /** Disable animation */
    bool mDisableAnimation;
    /** Disable Aod */
    bool mDisableAod;
    /** Disable launch boost */
    bool mDisableLaunchBoost;
    /** Disable optional sensors */
    bool mDisableOptionalSensors;
    /** Disable vibration */
    bool mDisableVibration;
    /** Enable adjust brightness */
    bool mEnableAdjustBrightness;
    /** Enable data saver */
    bool mEnableDataSaver;
    /** Enable firewall */
    bool mEnableFirewall;
    /** Enable night mode */
    bool mEnableNightMode;
    /** Enable quick doze */
    bool mEnableQuickDoze;
    /** Force all Apps standby */
    bool mForceAllAppsStandby;
    /** Force Background check */
    bool mForceBackgroundCheck;
    /** Location mode */
    LocationMode mLocationMode;
    /** SoundTrigger mode */
    SoundTriggerMode mSoundTriggerMode;
};

} // namespace android::os

#endif /* ANDROID_OS_BATTERY_SAVER_POLICY_CONFIG_H */