blob: d3da90039da07269f7de469cc3d06e97fdf8cb3d [file] [log] [blame]
Todd Poynor539d2562017-05-24 17:19:18 -07001/*
2 * Copyright (C) 2017 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 ANDROID_THERMALSERVICE_THERMALSERVICE_H
18#define ANDROID_THERMALSERVICE_THERMALSERVICE_H
19
20#include <android/os/BnThermalService.h>
21#include <android/os/IThermalEventListener.h>
22#include <android/os/Temperature.h>
23#include <utils/Mutex.h>
24#include <utils/String16.h>
25#include <utils/Vector.h>
26
27namespace android {
28namespace os {
29
30class ThermalService : public BnThermalService,
31 public IBinder::DeathRecipient {
32public:
33 ThermalService() : mThrottled(false) {};
34 void publish(const sp<ThermalService>& service);
35 binder::Status notifyThrottling(
36 const bool isThrottling, const Temperature& temperature);
Wei Wang52150002018-10-24 19:33:10 -070037 status_t dump(int fd, const Vector<String16>& args) override;
Todd Poynor539d2562017-05-24 17:19:18 -070038
39private:
40 Mutex mListenersLock;
41 Vector<sp<IThermalEventListener> > mListeners;
42 bool mThrottled;
43 Temperature mThrottleTemperature;
44
45 binder::Status registerThermalEventListener(
46 const sp<IThermalEventListener>& listener);
47 binder::Status unregisterThermalEventListener(
48 const sp<IThermalEventListener>& listener);
49 binder::Status isThrottling(bool* _aidl_return);
50 void binderDied(const wp<IBinder>& who);
51};
52
53}; // namespace os
54}; // namespace android
55
56#endif // ANDROID_THERMALSERVICE_THERMALSERVICE_H