1 /*
2  * Copyright (C) 2018 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 IDMAP2_IDMAP2D_IDMAP2SERVICE_H_
18 #define IDMAP2_IDMAP2D_IDMAP2SERVICE_H_
19 
20 #include <android-base/unique_fd.h>
21 #include <binder/BinderService.h>
22 #include <binder/Nullable.h>
23 
24 #include "android/os/BnIdmap2.h"
25 
26 namespace android::os {
27 
28 class Idmap2Service : public BinderService<Idmap2Service>, public BnIdmap2 {
29  public:
getServiceName()30   static char const* getServiceName() {
31     return "idmap";
32   }
33 
34   binder::Status getIdmapPath(const std::string& overlay_apk_path, int32_t user_id,
35                               std::string* _aidl_return) override;
36 
37   binder::Status removeIdmap(const std::string& overlay_apk_path, int32_t user_id,
38                              bool* _aidl_return) override;
39 
40   binder::Status verifyIdmap(const std::string& target_apk_path,
41                              const std::string& overlay_apk_path, int32_t fulfilled_policies,
42                              bool enforce_overlayable, int32_t user_id,
43                              bool* _aidl_return) override;
44 
45   binder::Status createIdmap(const std::string& target_apk_path,
46                              const std::string& overlay_apk_path, int32_t fulfilled_policies,
47                              bool enforce_overlayable, int32_t user_id,
48                              aidl::nullable<std::string>* _aidl_return) override;
49 
50  private:
51   // Cache the crc of the android framework package since the crc cannot change without a reboot.
52   std::optional<uint32_t> android_crc_;
53 };
54 
55 }  // namespace android::os
56 
57 #endif  // IDMAP2_IDMAP2D_IDMAP2SERVICE_H_
58