• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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_VEHICLE_MONITOR_H
18 #define ANDROID_VEHICLE_MONITOR_H
19 
20 #include <binder/IInterface.h>
21 
22 #include <utils/Mutex.h>
23 
24 #include "IVehicleMonitor.h"
25 
26 namespace android {
27 
28 // ----------------------------------------------------------------------------
29 
30 /**
31  * Vehicle monitor API for low level components like HALs to access
32  * monitoring service.
33  * This is reference counted. So use with sp<>.
34  */
35 class VehicleMonitor : public IBinder::DeathRecipient {
36 public:
37     /**
38      * Factory method for VehicleMonitor. Client should use this method
39      * to create a new instance.
40      */
41     static sp<VehicleMonitor> createVehicleMonitor();
42 
43     virtual ~VehicleMonitor();
44 
45     status_t setAppPriority(
46             uint32_t pid, uint32_t uid, vehicle_app_priority priority);
47 
48     //IBinder::DeathRecipient, not for client
49     void binderDied(const wp<IBinder>& who);
50 
51 private:
52     VehicleMonitor(sp<IVehicleMonitor>& vehicleMonitor);
53     // RefBase
54     virtual void onFirstRef();
55     sp<IVehicleMonitor> getService();
56 
57 private:
58     sp<IVehicleMonitor> mService;
59     Mutex mLock;
60 };
61 
62 // ----------------------------------------------------------------------------
63 
64 }; // namespace android
65 
66 #endif /* ANDROID_VEHICLE_MONITOR_H */
67