• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef APP_IDENTITY_H
17 #define APP_IDENTITY_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace Location {
23 class AppIdentity {
24 public:
25     AppIdentity();
26     explicit AppIdentity(pid_t uid, pid_t pid, uint32_t tokenId, uint32_t firstTokenId);
27     virtual ~AppIdentity() = default;
28 
GetPid()29     inline pid_t GetPid() const
30     {
31         return pid_;
32     }
33 
SetPid(pid_t pid)34     inline void SetPid(pid_t pid)
35     {
36         pid_ = pid;
37     }
38 
GetUid()39     inline pid_t GetUid() const
40     {
41         return uid_;
42     }
43 
SetUid(pid_t uid)44     inline void SetUid(pid_t uid)
45     {
46         uid_ = uid;
47     }
48 
GetTokenId()49     inline uint32_t GetTokenId() const
50     {
51         return tokenId_;
52     }
53 
SetTokenId(uint32_t tokenId)54     inline void SetTokenId(uint32_t tokenId)
55     {
56         tokenId_ = tokenId;
57     }
58 
GetFirstTokenId()59     inline uint32_t GetFirstTokenId() const
60     {
61         return firstTokenId_;
62     }
63 
SetFirstTokenId(uint32_t firstTokenId)64     inline void SetFirstTokenId(uint32_t firstTokenId)
65     {
66         firstTokenId_ = firstTokenId;
67     }
68 
GetBundleName()69     inline std::string GetBundleName() const
70     {
71         return bundleName_;
72     }
73 
SetBundleName(std::string bundleName)74     inline void SetBundleName(std::string bundleName)
75     {
76         bundleName_ = bundleName;
77     }
78 
79     std::string ToString() const;
80 private:
81     pid_t uid_;
82     pid_t pid_;
83     uint32_t tokenId_;
84     uint32_t firstTokenId_;
85     std::string bundleName_;
86 };
87 } // namespace Location
88 } // namespace OHOS
89 #endif // APP_IDENTITY_H