• 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 #include "permission_record.h"
17 #include "privacy_field_const.h"
18 
19 namespace OHOS {
20 namespace Security {
21 namespace AccessToken {
TranslationIntoGenericValues(const PermissionRecord & record,GenericValues & values)22 void PermissionRecord::TranslationIntoGenericValues(const PermissionRecord& record, GenericValues& values)
23 {
24     values.Put(PrivacyFiledConst::FIELD_TOKEN_ID, static_cast<int32_t>(record.tokenId));
25     values.Put(PrivacyFiledConst::FIELD_OP_CODE, record.opCode);
26     values.Put(PrivacyFiledConst::FIELD_STATUS, record.status);
27     values.Put(PrivacyFiledConst::FIELD_TIMESTAMP, record.timestamp);
28     values.Put(PrivacyFiledConst::FIELD_ACCESS_DURATION, record.accessDuration);
29     values.Put(PrivacyFiledConst::FIELD_ACCESS_COUNT, record.accessCount);
30     values.Put(PrivacyFiledConst::FIELD_REJECT_COUNT, record.rejectCount);
31 }
32 
TranslationIntoPermissionRecord(const GenericValues & values,PermissionRecord & record)33 void PermissionRecord::TranslationIntoPermissionRecord(const GenericValues& values, PermissionRecord& record)
34 {
35     record.tokenId = values.GetInt(PrivacyFiledConst::FIELD_TOKEN_ID);
36     record.opCode = values.GetInt(PrivacyFiledConst::FIELD_OP_CODE);
37     record.status = values.GetInt(PrivacyFiledConst::FIELD_STATUS);
38     record.timestamp = values.GetInt64(PrivacyFiledConst::FIELD_TIMESTAMP);
39     record.accessDuration = values.GetInt64(PrivacyFiledConst::FIELD_ACCESS_DURATION);
40     record.accessCount = values.GetInt(PrivacyFiledConst::FIELD_ACCESS_COUNT);
41     record.rejectCount = values.GetInt(PrivacyFiledConst::FIELD_REJECT_COUNT);
42 }
43 } // namespace AccessToken
44 } // namespace Security
45 } // namespace OHOS