• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H
17 #define OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H
18 
19 #include "ios_account.h"
20 #include "account_permission_manager.h"
21 #include "iremote_stub.h"
22 
23 namespace OHOS {
24 namespace AccountSA {
25 class OsAccountStub : public IRemoteStub<IOsAccount> {
26 public:
27     using MessageProcFunction = ErrCode (OsAccountStub::*)(MessageParcel &data, MessageParcel &reply);
28     typedef struct OsAccountMessageProc {
29         MessageProcFunction messageProcFunction;
30         bool isSyetemApi = false;
31     } OsAccountMessageProc;
32     OsAccountStub();
33     ~OsAccountStub() override;
34     int OnRemoteRequest(
35         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
36 
37 public:
38     ErrCode ProcCreateOsAccount(MessageParcel &data, MessageParcel &reply);
39     ErrCode ProcCreateOsAccountForDomain(MessageParcel &data, MessageParcel &reply);
40     ErrCode ProcRemoveOsAccount(MessageParcel &data, MessageParcel &reply);
41     ErrCode ProcSetOsAccountName(MessageParcel &data, MessageParcel &reply);
42     ErrCode ProcSetOsAccountConstraints(MessageParcel &data, MessageParcel &reply);
43     ErrCode ProcSetOsAccountProfilePhoto(MessageParcel &data, MessageParcel &reply);
44     ErrCode ProcQueryOsAccountById(MessageParcel &data, MessageParcel &reply);
45     ErrCode ProcQueryCurrentOsAccount(MessageParcel &data, MessageParcel &reply);
46     ErrCode ProcQueryAllCreatedOsAccounts(MessageParcel &data, MessageParcel &reply);
47     ErrCode ProcQueryMaxOsAccountNumber(MessageParcel &data, MessageParcel &reply);
48     ErrCode ProcGetCreatedOsAccountsCount(MessageParcel &data, MessageParcel &reply);
49     ErrCode ProcGetOsAccountAllConstraints(MessageParcel &data, MessageParcel &reply);
50     ErrCode ProcGetOsAccountLocalIdFromProcess(MessageParcel &data, MessageParcel &reply);
51     ErrCode ProcIsMainOsAccount(MessageParcel &data, MessageParcel &reply);
52     ErrCode ProcGetOsAccountProfilePhoto(MessageParcel &data, MessageParcel &reply);
53     ErrCode ProcGetOsAccountLocalIdFromDomain(MessageParcel &data, MessageParcel &reply);
54     ErrCode ProcGetOsAccountTypeFromProcess(MessageParcel &data, MessageParcel &reply);
55     ErrCode ProcGetApplicationConstraints(MessageParcel &data, MessageParcel &reply);
56     ErrCode ProcGetApplicationConstraintsByNumber(MessageParcel &data, MessageParcel &reply);
57     ErrCode ProcGetOsAccountLocalIdBySerialNumber(MessageParcel &data, MessageParcel &reply);
58     ErrCode ProcGetSerialNumberByOsAccountLocalId(MessageParcel &data, MessageParcel &reply);
59     ErrCode ProcIsOsAccountActived(MessageParcel &data, MessageParcel &reply);
60     ErrCode ProcIsOsAccountConstraintEnable(MessageParcel &data, MessageParcel &reply);
61     ErrCode ProcCheckOsAccountConstraintEnabled(MessageParcel &data, MessageParcel &reply);
62     ErrCode ProcIsMultiOsAccountEnable(MessageParcel &data, MessageParcel &reply);
63     ErrCode ProcIsOsAccountVerified(MessageParcel &data, MessageParcel &reply);
64     ErrCode ProcIsOsAccountExists(MessageParcel &data, MessageParcel &reply);
65     ErrCode ProcSubscribeOsAccount(MessageParcel &data, MessageParcel &reply);
66     ErrCode ProcUnsubscribeOsAccount(MessageParcel &data, MessageParcel &reply);
67     ErrCode ProcActivateOsAccount(MessageParcel &data, MessageParcel &reply);
68     ErrCode ProcStartOsAccount(MessageParcel &data, MessageParcel &reply);
69     ErrCode ProcStopOsAccount(MessageParcel &data, MessageParcel &reply);
70     ErrCode ProcGetOsAccountSwitchMod(MessageParcel &data, MessageParcel &reply);
71     ErrCode ProcIsCurrentOsAccountVerified(MessageParcel &data, MessageParcel &reply);
72     ErrCode ProcIsOsAccountCompleted(MessageParcel &data, MessageParcel &reply);
73     ErrCode ProcSetCurrentOsAccountIsVerified(MessageParcel &data, MessageParcel &reply);
74     ErrCode ProcSetOsAccountIsVerified(MessageParcel &data, MessageParcel &reply);
75     ErrCode ProcDumpState(MessageParcel &data, MessageParcel &reply);
76     ErrCode ProcGetCreatedOsAccountNumFromDatabase(MessageParcel &data, MessageParcel &reply);
77     ErrCode ProcGetSerialNumberFromDatabase(MessageParcel &data, MessageParcel &reply);
78     ErrCode ProcGetMaxAllowCreateIdFromDatabase(MessageParcel &data, MessageParcel &reply);
79     ErrCode ProcGetOsAccountFromDatabase(MessageParcel &data, MessageParcel &reply);
80     ErrCode ProcGetOsAccountListFromDatabase(MessageParcel &data, MessageParcel &reply);
81     ErrCode ProcQueryActiveOsAccountIds(MessageParcel &data, MessageParcel &reply);
82     ErrCode ProcQueryOsAccountConstraintSourceTypes(MessageParcel &data, MessageParcel &reply);
83     ErrCode ProcSetGlobalOsAccountConstraints(MessageParcel &data, MessageParcel &reply);
84     ErrCode ProcSetSpecificOsAccountConstraints(MessageParcel &data, MessageParcel &reply);
85     ErrCode ProcSetDefaultActivatedOsAccount(MessageParcel &data, MessageParcel &reply);
86     ErrCode ProcGetDefaultActivatedOsAccount(MessageParcel &data, MessageParcel &reply);
87 
88 private:
89     template<typename T>
90     bool WriteParcelableVector(const std::vector<T> &parcelableVector, MessageParcel &data);
91     template<typename T>
92     bool ReadParcelableVector(std::vector<T> &parcelableInfos, MessageParcel &data);
93     std::map<uint32_t, OsAccountMessageProc> messageProcMap_;
94     DISALLOW_COPY_AND_MOVE(OsAccountStub);
95     ErrCode ProcCheckOsAccountConstraintEnabled(uint32_t code, MessageParcel &data, MessageParcel &reply);
96 };
97 }  // namespace AccountSA
98 }  // namespace OHOS
99 
100 #endif  // OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H
101