• 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, uint64_t tokenIdEx, 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 
GetTokenIdEx()59     inline uint64_t GetTokenIdEx() const
60     {
61         return tokenIdEx_;
62     }
63 
SetTokenIdEx(uint64_t tokenIdEx)64     inline void SetTokenIdEx(uint64_t tokenIdEx)
65     {
66         tokenIdEx_ = tokenIdEx;
67     }
68 
GetFirstTokenId()69     inline uint32_t GetFirstTokenId() const
70     {
71         return firstTokenId_;
72     }
73 
SetFirstTokenId(uint32_t firstTokenId)74     inline void SetFirstTokenId(uint32_t firstTokenId)
75     {
76         firstTokenId_ = firstTokenId;
77     }
78 
GetBundleName()79     inline std::string GetBundleName() const
80     {
81         return bundleName_;
82     }
83 
SetBundleName(std::string bundleName)84     inline void SetBundleName(std::string bundleName)
85     {
86         bundleName_ = bundleName;
87     }
88 
89     std::string ToString() const;
90 private:
91     pid_t uid_;
92     pid_t pid_;
93     uint32_t tokenId_;
94     uint64_t tokenIdEx_;
95     uint32_t firstTokenId_;
96     std::string bundleName_;
97 };
98 } // namespace Location
99 } // namespace OHOS
100 #endif // APP_IDENTITY_H