• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 SERVICES_INCLUDE_IDENTITY_CHECKER_H
17 #define SERVICES_INCLUDE_IDENTITY_CHECKER_H
18 
19 #include "access_token.h"
20 #include "iremote_object.h"
21 namespace OHOS {
22 namespace MiscServices {
23 class IdentityChecker {
24 public:
25     static constexpr uint64_t DEFAULT_DISPLAY_ID = 0;
26     static constexpr int64_t INVALID_PID = -1;
27     virtual ~IdentityChecker() = default;
28     virtual bool IsFocused(int64_t callingPid, uint32_t callingTokenId, int64_t focusedPid = INVALID_PID,
29         bool isAttach = false, sptr<IRemoteObject> abilityToken = nullptr) = 0;
30     virtual bool IsSystemApp(uint64_t fullTokenId) = 0;
31     virtual bool IsBundleNameValid(uint32_t tokenId, const std::string &validBundleName) = 0;
32     virtual bool HasPermission(uint32_t tokenId, const std::string &permission) = 0;
33     virtual bool IsBroker(Security::AccessToken::AccessTokenID tokenId) = 0;
34     virtual bool IsNativeSa(Security::AccessToken::AccessTokenID tokenId) = 0;
35     virtual bool IsFormShell(Security::AccessToken::AccessTokenID tokenId) = 0;
36     virtual std::string GetBundleNameByToken(uint32_t tokenId);
37     virtual bool IsFocusedUIExtension(uint32_t callingTokenId, sptr<IRemoteObject> abilityToken = nullptr)
38     {
39         return false;
40     };
GetDisplayIdByWindowId(int32_t callingWindowId)41     virtual uint64_t GetDisplayIdByWindowId(int32_t callingWindowId)
42     {
43         return DEFAULT_DISPLAY_ID;
44     };
45     virtual uint64_t GetDisplayIdByPid(int64_t callingPid, sptr<IRemoteObject> abilityToken = nullptr)
46     {
47         return DEFAULT_DISPLAY_ID;
48     };
IsValidVirtualIme(int32_t callingUid)49     virtual bool IsValidVirtualIme(int32_t callingUid)
50     {
51         return false;
52     };
53     virtual bool IsSpecialSaUid() = 0;
54 };
55 } // namespace MiscServices
56 } // namespace OHOS
57 
58 #endif // SERVICES_INCLUDE_IDENTITY_CHECKER_H
59