1 /*
2  * Copyright (C) 2019 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 #pragma once
17 
18 #include "linkerconfig/namespace.h"
19 
20 using namespace android::linkerconfig::modules;
21 
CreateNamespaceWithPaths(std::string name,bool is_isolated,bool is_visible)22 inline Namespace CreateNamespaceWithPaths(std::string name, bool is_isolated,
23                                           bool is_visible) {
24   Namespace ns(name, is_isolated, is_visible);
25   ns.AddSearchPath("/search_path1");
26   ns.AddSearchPath("/apex/search_path2");
27   ns.AddPermittedPath("/permitted_path1");
28   ns.AddPermittedPath("/apex/permitted_path2");
29 
30   return ns;
31 }
32 
CreateNamespaceWithLinks(std::string name,bool is_isolated,bool is_visible,std::string target_1,std::string target_2)33 inline Namespace CreateNamespaceWithLinks(std::string name, bool is_isolated,
34                                           bool is_visible, std::string target_1,
35                                           std::string target_2) {
36   Namespace ns = CreateNamespaceWithPaths(name, is_isolated, is_visible);
37   auto& link = ns.GetLink(target_1);
38   link.AddSharedLib("lib1.so", "lib2.so", "lib3.so");
39 
40   ns.GetLink(target_2).AllowAllSharedLibs();
41   return ns;
42 }
43