diff --git a/frameworks/accesstoken/BUILD.gn b/frameworks/accesstoken/BUILD.gn index bdc63b3da30b7ead14e4ff3c6d81c18a9102c78c..d43f760308c46a0d5c093d95d389dac037641e62 100644 --- a/frameworks/accesstoken/BUILD.gn +++ b/frameworks/accesstoken/BUILD.gn @@ -1,55 +1,55 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -config("accesstoken_communication_adapter_cxx_public_config") { - visibility = [ ":*" ] - include_dirs = [ - "include", - "//base/security/access_token/frameworks/common/include", - "//base/security/access_token/interfaces/innerkits/accesstoken/include", - ] -} - -ohos_shared_library("accesstoken_communication_adapter_cxx") { - subsystem_name = "security" - part_name = "access_token" - - public_configs = [ ":accesstoken_communication_adapter_cxx_public_config" ] - - include_dirs = [ - "include", - "//base/security/access_token/interfaces/innerkits/accesstoken/include", - "//commonlibrary/c_utils/base/include", - ] - - sources = [ - "src/hap_info_parcel.cpp", - "src/hap_policy_parcel.cpp", - "src/hap_token_info_for_sync_parcel.cpp", - "src/hap_token_info_parcel.cpp", - "src/native_token_info_for_sync_parcel.cpp", - "src/native_token_info_parcel.cpp", - "src/permission_def_parcel.cpp", - "src/permission_list_state_parcel.cpp", - "src/permission_state_change_info_parcel.cpp", - "src/permission_state_change_scope_parcel.cpp", - "src/permission_state_full_parcel.cpp", - ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_single", - ] -} +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +config("accesstoken_communication_adapter_cxx_public_config") { + visibility = [ ":*" ] + include_dirs = [ + "include", + "//base/security/access_token/frameworks/common/include", + "//base/security/access_token/interfaces/innerkits/accesstoken/include", + ] +} + +ohos_shared_library("accesstoken_communication_adapter_cxx") { + subsystem_name = "security" + part_name = "access_token" + + public_configs = [ ":accesstoken_communication_adapter_cxx_public_config" ] + + include_dirs = [ + "include", + "//base/security/access_token/interfaces/innerkits/accesstoken/include", + "//commonlibrary/c_utils/base/include", + ] + + sources = [ + "src/hap_info_parcel.cpp", + "src/hap_policy_parcel.cpp", + "src/hap_token_info_for_sync_parcel.cpp", + "src/hap_token_info_parcel.cpp", + "src/native_token_info_for_sync_parcel.cpp", + "src/native_token_info_parcel.cpp", + "src/permission_def_parcel.cpp", + "src/permission_list_state_parcel.cpp", + "src/permission_state_change_info_parcel.cpp", + "src/permission_state_change_scope_parcel.cpp", + "src/permission_state_full_parcel.cpp", + ] + + external_deps = [ + "c_utils:utils", + "ipc:ipc_single", + ] +} diff --git a/frameworks/accesstoken/include/hap_token_info_for_sync_parcel.h b/frameworks/accesstoken/include/hap_token_info_for_sync_parcel.h index b0c838402a24fb0c18e96943fc6d451a023cb802..33d01bad803b9671aefda7f7a1468ca07a90d75a 100644 --- a/frameworks/accesstoken/include/hap_token_info_for_sync_parcel.h +++ b/frameworks/accesstoken/include/hap_token_info_for_sync_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HAP_TOKEN_INFO_FOR_SYNC_PARCEL_H -#define HAP_TOKEN_INFO_FOR_SYNC_PARCEL_H - -#include "hap_token_info.h" -#include "parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct HapTokenInfoForSyncParcel final : public Parcelable { - HapTokenInfoForSyncParcel() = default; - - ~HapTokenInfoForSyncParcel() override = default; - - bool Marshalling(Parcel &out) const override; - - static HapTokenInfoForSyncParcel *Unmarshalling(Parcel &in); - - HapTokenInfoForSync hapTokenInfoForSyncParams; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // HAP_TOKEN_INFO_FOR_SYNC_PARCEL_H - +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HAP_TOKEN_INFO_FOR_SYNC_PARCEL_H +#define HAP_TOKEN_INFO_FOR_SYNC_PARCEL_H + +#include "hap_token_info.h" +#include "parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct HapTokenInfoForSyncParcel final : public Parcelable { + HapTokenInfoForSyncParcel() = default; + + ~HapTokenInfoForSyncParcel() override = default; + + bool Marshalling(Parcel &out) const override; + + static HapTokenInfoForSyncParcel *Unmarshalling(Parcel &in); + + HapTokenInfoForSync hapTokenInfoForSyncParams; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // HAP_TOKEN_INFO_FOR_SYNC_PARCEL_H + diff --git a/frameworks/accesstoken/include/i_accesstoken_manager.h b/frameworks/accesstoken/include/i_accesstoken_manager.h index d5216bf647b3a3e34ed332314c8ad51d14ca6067..323adb37dd36c274287a3b93aaf66b792077c7c8 100644 --- a/frameworks/accesstoken/include/i_accesstoken_manager.h +++ b/frameworks/accesstoken/include/i_accesstoken_manager.h @@ -1,124 +1,124 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef I_ACCESSTOKEN_MANAGER_H -#define I_ACCESSTOKEN_MANAGER_H - -#include - -#include "access_token.h" -#include "errors.h" -#include "hap_info_parcel.h" -#include "hap_policy_parcel.h" -#include "hap_token_info_for_sync_parcel.h" -#include "hap_token_info_parcel.h" -#include "iremote_broker.h" -#include "i_permission_state_callback.h" -#include "native_token_info_for_sync_parcel.h" -#include "native_token_info_parcel.h" -#include "permission_def_parcel.h" -#include "permission_list_state_parcel.h" -#include "permission_state_full_parcel.h" -#include "permission_state_change_scope_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class IAccessTokenManager : public IRemoteBroker { -public: - static const int SA_ID_ACCESSTOKEN_MANAGER_SERVICE = 3503; - - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.IAccessTokenManager"); - - virtual int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName) = 0; - virtual int VerifyNativeToken(AccessTokenID tokenID, const std::string& permissionName) = 0; - virtual int GetDefPermission(const std::string& permissionName, PermissionDefParcel& permissionDefResult) = 0; - virtual int GetDefPermissions(AccessTokenID tokenID, std::vector& permList) = 0; - virtual int GetReqPermissions( - AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant) = 0; - virtual int GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName) = 0; - virtual PermissionOper GetSelfPermissionsState( - std::vector& permListParcel) = 0; - virtual int GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag) = 0; - virtual int RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag) = 0; - virtual int ClearUserGrantedPermissionState(AccessTokenID tokenID) = 0; - virtual AccessTokenIDEx AllocHapToken(const HapInfoParcel& hapInfo, const HapPolicyParcel& policyParcel) = 0; - virtual int DeleteToken(AccessTokenID tokenID) = 0; - virtual int GetTokenType(AccessTokenID tokenID) = 0; - virtual int CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap) = 0; - virtual AccessTokenID GetHapTokenID(int userID, const std::string& bundleName, int instIndex) = 0; - virtual AccessTokenID AllocLocalTokenID(const std::string& remoteDeviceID, AccessTokenID remoteTokenID) = 0; - virtual int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfoParcel& nativeTokenInfoRes) = 0; - virtual int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfoParcel& hapTokenInfoRes) = 0; - virtual int UpdateHapToken(AccessTokenID tokenID, const std::string& appIDDesc, int32_t apiVersion, - const HapPolicyParcel& policyParcel) = 0; - virtual int32_t RegisterPermStateChangeCallback( - const PermStateChangeScopeParcel& scope, const sptr& callback) = 0; - virtual int32_t UnRegisterPermStateChangeCallback(const sptr& callback) = 0; - -#ifdef TOKEN_SYNC_ENABLE - virtual int GetHapTokenInfoFromRemote(AccessTokenID tokenID, - HapTokenInfoForSyncParcel& hapSyncParcel) = 0; - virtual int GetAllNativeTokenInfo(std::vector& nativeTokenInfoRes) = 0; - virtual int SetRemoteHapTokenInfo(const std::string& deviceID, - HapTokenInfoForSyncParcel& hapSyncParcel) = 0; - virtual int SetRemoteNativeTokenInfo(const std::string& deviceID, - std::vector& nativeTokenInfoForSyncParcel) = 0; - virtual int DeleteRemoteToken(const std::string& deviceID, AccessTokenID tokenID) = 0; - virtual AccessTokenID GetRemoteNativeTokenID(const std::string& deviceID, AccessTokenID tokenID) = 0; - virtual int DeleteRemoteDeviceTokens(const std::string& deviceID) = 0; -#endif - - virtual void DumpTokenInfo(AccessTokenID tokenID, std::string& tokenInfo) = 0; - - enum class InterfaceCode { - VERIFY_ACCESSTOKEN = 0xff10, - GET_DEF_PERMISSION = 0xff11, - GET_DEF_PERMISSIONS = 0xff12, - GET_REQ_PERMISSIONS = 0xff13, - GET_PERMISSION_FLAG = 0xff14, - GRANT_PERMISSION = 0xff15, - REVOKE_PERMISSION = 0xff16, - CLEAR_USER_GRANT_PERMISSION = 0xff17, - ALLOC_TOKEN_HAP = 0xff18, - TOKEN_DELETE = 0xff19, - GET_TOKEN_TYPE = 0xff20, - CHECK_NATIVE_DCAP = 0xff21, - GET_HAP_TOKEN_ID = 0xff22, - ALLOC_LOCAL_TOKEN_ID = 0xff23, - GET_NATIVE_TOKENINFO = 0xff24, - GET_HAP_TOKENINFO = 0xff25, - UPDATE_HAP_TOKEN = 0xff26, - - GET_HAP_TOKEN_FROM_REMOTE = 0xff27, - GET_ALL_NATIVE_TOKEN_FROM_REMOTE = 0xff28, - SET_REMOTE_HAP_TOKEN_INFO = 0xff29, - SET_REMOTE_NATIVE_TOKEN_INFO = 0xff2a, - DELETE_REMOTE_TOKEN_INFO = 0xff2b, - DELETE_REMOTE_DEVICE_TOKEN = 0xff2c, - VERIFY_NATIVETOKEN = 0xff2d, - GET_NATIVE_REMOTE_TOKEN = 0xff2f, - - DUMP_TOKENINFO = 0xff30, - GET_PERMISSION_OPER_STATE = 0xff31, - REGISTER_PERM_STATE_CHANGE_CALLBACK = 0xff32, - UNREGISTER_PERM_STATE_CHANGE_CALLBACK = 0xff33, - }; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // I_ACCESSTOKEN_MANAGER_H +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef I_ACCESSTOKEN_MANAGER_H +#define I_ACCESSTOKEN_MANAGER_H + +#include + +#include "access_token.h" +#include "errors.h" +#include "hap_info_parcel.h" +#include "hap_policy_parcel.h" +#include "hap_token_info_for_sync_parcel.h" +#include "hap_token_info_parcel.h" +#include "iremote_broker.h" +#include "i_permission_state_callback.h" +#include "native_token_info_for_sync_parcel.h" +#include "native_token_info_parcel.h" +#include "permission_def_parcel.h" +#include "permission_list_state_parcel.h" +#include "permission_state_full_parcel.h" +#include "permission_state_change_scope_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class IAccessTokenManager : public IRemoteBroker { +public: + static const int SA_ID_ACCESSTOKEN_MANAGER_SERVICE = 3503; + + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.IAccessTokenManager"); + + virtual int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName) = 0; + virtual int VerifyNativeToken(AccessTokenID tokenID, const std::string& permissionName) = 0; + virtual int GetDefPermission(const std::string& permissionName, PermissionDefParcel& permissionDefResult) = 0; + virtual int GetDefPermissions(AccessTokenID tokenID, std::vector& permList) = 0; + virtual int GetReqPermissions( + AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant) = 0; + virtual int GetPermissionFlag(AccessTokenID tokenID, const std::string& permissionName) = 0; + virtual PermissionOper GetSelfPermissionsState( + std::vector& permListParcel) = 0; + virtual int GrantPermission(AccessTokenID tokenID, const std::string& permissionName, int flag) = 0; + virtual int RevokePermission(AccessTokenID tokenID, const std::string& permissionName, int flag) = 0; + virtual int ClearUserGrantedPermissionState(AccessTokenID tokenID) = 0; + virtual AccessTokenIDEx AllocHapToken(const HapInfoParcel& hapInfo, const HapPolicyParcel& policyParcel) = 0; + virtual int DeleteToken(AccessTokenID tokenID) = 0; + virtual int GetTokenType(AccessTokenID tokenID) = 0; + virtual int CheckNativeDCap(AccessTokenID tokenID, const std::string& dcap) = 0; + virtual AccessTokenID GetHapTokenID(int userID, const std::string& bundleName, int instIndex) = 0; + virtual AccessTokenID AllocLocalTokenID(const std::string& remoteDeviceID, AccessTokenID remoteTokenID) = 0; + virtual int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfoParcel& nativeTokenInfoRes) = 0; + virtual int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfoParcel& hapTokenInfoRes) = 0; + virtual int UpdateHapToken(AccessTokenID tokenID, const std::string& appIDDesc, int32_t apiVersion, + const HapPolicyParcel& policyParcel) = 0; + virtual int32_t RegisterPermStateChangeCallback( + const PermStateChangeScopeParcel& scope, const sptr& callback) = 0; + virtual int32_t UnRegisterPermStateChangeCallback(const sptr& callback) = 0; + +#ifdef TOKEN_SYNC_ENABLE + virtual int GetHapTokenInfoFromRemote(AccessTokenID tokenID, + HapTokenInfoForSyncParcel& hapSyncParcel) = 0; + virtual int GetAllNativeTokenInfo(std::vector& nativeTokenInfoRes) = 0; + virtual int SetRemoteHapTokenInfo(const std::string& deviceID, + HapTokenInfoForSyncParcel& hapSyncParcel) = 0; + virtual int SetRemoteNativeTokenInfo(const std::string& deviceID, + std::vector& nativeTokenInfoForSyncParcel) = 0; + virtual int DeleteRemoteToken(const std::string& deviceID, AccessTokenID tokenID) = 0; + virtual AccessTokenID GetRemoteNativeTokenID(const std::string& deviceID, AccessTokenID tokenID) = 0; + virtual int DeleteRemoteDeviceTokens(const std::string& deviceID) = 0; +#endif + + virtual void DumpTokenInfo(AccessTokenID tokenID, std::string& tokenInfo) = 0; + + enum class InterfaceCode { + VERIFY_ACCESSTOKEN = 0xff10, + GET_DEF_PERMISSION = 0xff11, + GET_DEF_PERMISSIONS = 0xff12, + GET_REQ_PERMISSIONS = 0xff13, + GET_PERMISSION_FLAG = 0xff14, + GRANT_PERMISSION = 0xff15, + REVOKE_PERMISSION = 0xff16, + CLEAR_USER_GRANT_PERMISSION = 0xff17, + ALLOC_TOKEN_HAP = 0xff18, + TOKEN_DELETE = 0xff19, + GET_TOKEN_TYPE = 0xff20, + CHECK_NATIVE_DCAP = 0xff21, + GET_HAP_TOKEN_ID = 0xff22, + ALLOC_LOCAL_TOKEN_ID = 0xff23, + GET_NATIVE_TOKENINFO = 0xff24, + GET_HAP_TOKENINFO = 0xff25, + UPDATE_HAP_TOKEN = 0xff26, + + GET_HAP_TOKEN_FROM_REMOTE = 0xff27, + GET_ALL_NATIVE_TOKEN_FROM_REMOTE = 0xff28, + SET_REMOTE_HAP_TOKEN_INFO = 0xff29, + SET_REMOTE_NATIVE_TOKEN_INFO = 0xff2a, + DELETE_REMOTE_TOKEN_INFO = 0xff2b, + DELETE_REMOTE_DEVICE_TOKEN = 0xff2c, + VERIFY_NATIVETOKEN = 0xff2d, + GET_NATIVE_REMOTE_TOKEN = 0xff2f, + + DUMP_TOKENINFO = 0xff30, + GET_PERMISSION_OPER_STATE = 0xff31, + REGISTER_PERM_STATE_CHANGE_CALLBACK = 0xff32, + UNREGISTER_PERM_STATE_CHANGE_CALLBACK = 0xff33, + }; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // I_ACCESSTOKEN_MANAGER_H diff --git a/frameworks/accesstoken/include/i_permission_state_callback.h b/frameworks/accesstoken/include/i_permission_state_callback.h index 508f28c1e0835b77563c49633fcb4cd25590f13c..9ec9b13dc86af14cdd66f2aaa73990b585e47e78 100644 --- a/frameworks/accesstoken/include/i_permission_state_callback.h +++ b/frameworks/accesstoken/include/i_permission_state_callback.h @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef I_PERMISSION_STATE_CALLBACK_H -#define I_PERMISSION_STATE_CALLBACK_H - -#include - -#include "access_token.h" -#include "errors.h" -#include "iremote_broker.h" -#include "permission_state_change_info.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class IPermissionStateCallback : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.IPermissionStateCallback"); - - virtual void PermStateChangeCallback(PermStateChangeInfo& result) = 0; - - enum { - PERMISSION_STATE_CHANGE = 0, - }; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // I_PERMISSION_STATE_CALLBACK_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef I_PERMISSION_STATE_CALLBACK_H +#define I_PERMISSION_STATE_CALLBACK_H + +#include + +#include "access_token.h" +#include "errors.h" +#include "iremote_broker.h" +#include "permission_state_change_info.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class IPermissionStateCallback : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.IPermissionStateCallback"); + + virtual void PermStateChangeCallback(PermStateChangeInfo& result) = 0; + + enum { + PERMISSION_STATE_CHANGE = 0, + }; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // I_PERMISSION_STATE_CALLBACK_H diff --git a/frameworks/accesstoken/include/native_token_info_for_sync_parcel.h b/frameworks/accesstoken/include/native_token_info_for_sync_parcel.h index a4b6b397cf9d2f4c83d8291ae38f71b7829ad79d..fe7b5bd46ccde88fdd14a9db6b00cadaeb800656 100644 --- a/frameworks/accesstoken/include/native_token_info_for_sync_parcel.h +++ b/frameworks/accesstoken/include/native_token_info_for_sync_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NATIVE_TOKEN_INFO_FOR_SYNC_PARCEL_H -#define NATIVE_TOKEN_INFO_FOR_SYNC_PARCEL_H - -#include "native_token_info.h" -#include "parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct NativeTokenInfoForSyncParcel final : public Parcelable { - NativeTokenInfoForSyncParcel() = default; - - ~NativeTokenInfoForSyncParcel() override = default; - - bool Marshalling(Parcel &out) const override; - - static NativeTokenInfoForSyncParcel *Unmarshalling(Parcel &in); - - NativeTokenInfoForSync nativeTokenInfoForSyncParams; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // NATIVE_TOKEN_INFO_FOR_SYNC_PARCEL_H - +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_TOKEN_INFO_FOR_SYNC_PARCEL_H +#define NATIVE_TOKEN_INFO_FOR_SYNC_PARCEL_H + +#include "native_token_info.h" +#include "parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct NativeTokenInfoForSyncParcel final : public Parcelable { + NativeTokenInfoForSyncParcel() = default; + + ~NativeTokenInfoForSyncParcel() override = default; + + bool Marshalling(Parcel &out) const override; + + static NativeTokenInfoForSyncParcel *Unmarshalling(Parcel &in); + + NativeTokenInfoForSync nativeTokenInfoForSyncParams; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // NATIVE_TOKEN_INFO_FOR_SYNC_PARCEL_H + diff --git a/frameworks/accesstoken/include/permission_def_parcel.h b/frameworks/accesstoken/include/permission_def_parcel.h index c509deb9167cc207010e5d44fd18c53477f889ec..fe4fb536636cddc33ab087c25dcfcb3fb3431c8f 100644 --- a/frameworks/accesstoken/include/permission_def_parcel.h +++ b/frameworks/accesstoken/include/permission_def_parcel.h @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_DEF_PARCEL_H -#define PERMISSION_DEF_PARCEL_H - -#include "permission_def.h" -#include "parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionDefParcel final : public Parcelable { - PermissionDefParcel() = default; - - ~PermissionDefParcel() override = default; - - bool Marshalling(Parcel &out) const override; - - static PermissionDefParcel *Unmarshalling(Parcel &in); - - PermissionDef permissionDef; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_DEF_PARCEL_H +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_DEF_PARCEL_H +#define PERMISSION_DEF_PARCEL_H + +#include "permission_def.h" +#include "parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionDefParcel final : public Parcelable { + PermissionDefParcel() = default; + + ~PermissionDefParcel() override = default; + + bool Marshalling(Parcel &out) const override; + + static PermissionDefParcel *Unmarshalling(Parcel &in); + + PermissionDef permissionDef; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERMISSION_DEF_PARCEL_H diff --git a/frameworks/accesstoken/include/permission_list_state_parcel.h b/frameworks/accesstoken/include/permission_list_state_parcel.h index c2c180fae5598dfacde63c1ba8601c6f2879651e..bb7c7c36d7aa37d736b315ab84cc0e61c046a6b6 100644 --- a/frameworks/accesstoken/include/permission_list_state_parcel.h +++ b/frameworks/accesstoken/include/permission_list_state_parcel.h @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INTERFACES_INNER_KITS_PERMISSION_PERMISSION_LIST_STATE_PARCEL_H -#define INTERFACES_INNER_KITS_PERMISSION_PERMISSION_LIST_STATE_PARCEL_H - -#include "permission_list_state.h" -#include "parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionListStateParcel final : public Parcelable { - PermissionListStateParcel() = default; - - ~PermissionListStateParcel() override = default; - - bool Marshalling(Parcel &out) const override; - - static PermissionListStateParcel *Unmarshalling(Parcel &in); - - PermissionListState permsState; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // INTERFACES_INNER_KITS_PERMISSION_PERMISSION_LIST_STATE_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INTERFACES_INNER_KITS_PERMISSION_PERMISSION_LIST_STATE_PARCEL_H +#define INTERFACES_INNER_KITS_PERMISSION_PERMISSION_LIST_STATE_PARCEL_H + +#include "permission_list_state.h" +#include "parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionListStateParcel final : public Parcelable { + PermissionListStateParcel() = default; + + ~PermissionListStateParcel() override = default; + + bool Marshalling(Parcel &out) const override; + + static PermissionListStateParcel *Unmarshalling(Parcel &in); + + PermissionListState permsState; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // INTERFACES_INNER_KITS_PERMISSION_PERMISSION_LIST_STATE_PARCEL_H diff --git a/frameworks/accesstoken/include/permission_state_change_info_parcel.h b/frameworks/accesstoken/include/permission_state_change_info_parcel.h index eb95593c328e9f76b399913d3b169ae559a18983..635822d2e2fc6627f0cc739d98ea8e7051d757cf 100644 --- a/frameworks/accesstoken/include/permission_state_change_info_parcel.h +++ b/frameworks/accesstoken/include/permission_state_change_info_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_STATE_CHANGE_INFO_PARCEL_H -#define PERMISSION_STATE_CHANGE_INFO_PARCEL_H - -#include "parcel.h" -#include "permission_state_change_info.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionStateChangeInfoParcel final : public Parcelable { - PermissionStateChangeInfoParcel() = default; - - ~PermissionStateChangeInfoParcel() override = default; - - bool Marshalling(Parcel& out) const override; - - static PermissionStateChangeInfoParcel* Unmarshalling(Parcel& in); - - PermStateChangeInfo changeInfo; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // PERMISSION_STATE_CHANGE_INFO_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_STATE_CHANGE_INFO_PARCEL_H +#define PERMISSION_STATE_CHANGE_INFO_PARCEL_H + +#include "parcel.h" +#include "permission_state_change_info.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionStateChangeInfoParcel final : public Parcelable { + PermissionStateChangeInfoParcel() = default; + + ~PermissionStateChangeInfoParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static PermissionStateChangeInfoParcel* Unmarshalling(Parcel& in); + + PermStateChangeInfo changeInfo; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERMISSION_STATE_CHANGE_INFO_PARCEL_H diff --git a/frameworks/accesstoken/include/permission_state_change_scope_parcel.h b/frameworks/accesstoken/include/permission_state_change_scope_parcel.h index e1988a8f27bcc112fa80722991116954c28122eb..1256356fa7752a5128103e85c408ea6520e5cf5b 100644 --- a/frameworks/accesstoken/include/permission_state_change_scope_parcel.h +++ b/frameworks/accesstoken/include/permission_state_change_scope_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_STATE_CHANGE_SCOPE_PARCEL_H -#define PERMISSION_STATE_CHANGE_SCOPE_PARCEL_H - -#include "parcel.h" -#include "permission_state_change_info.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermStateChangeScopeParcel final : public Parcelable { - PermStateChangeScopeParcel() = default; - - ~PermStateChangeScopeParcel() override = default; - - bool Marshalling(Parcel& out) const override; - - static PermStateChangeScopeParcel* Unmarshalling(Parcel& in); - - PermStateChangeScope scope; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // PERMISSION_STATE_CHANGE_SCOPE_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_STATE_CHANGE_SCOPE_PARCEL_H +#define PERMISSION_STATE_CHANGE_SCOPE_PARCEL_H + +#include "parcel.h" +#include "permission_state_change_info.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermStateChangeScopeParcel final : public Parcelable { + PermStateChangeScopeParcel() = default; + + ~PermStateChangeScopeParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static PermStateChangeScopeParcel* Unmarshalling(Parcel& in); + + PermStateChangeScope scope; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERMISSION_STATE_CHANGE_SCOPE_PARCEL_H diff --git a/frameworks/accesstoken/include/permission_state_full_parcel.h b/frameworks/accesstoken/include/permission_state_full_parcel.h index 71e869ed1ef93fd7b1d968ee6e2dcc00bb30eb13..af7177b109dcc5191af6c36f168c125d212e6405 100644 --- a/frameworks/accesstoken/include/permission_state_full_parcel.h +++ b/frameworks/accesstoken/include/permission_state_full_parcel.h @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H -#define INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H - -#include "permission_state_full.h" -#include "parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionStateFullParcel final : public Parcelable { - PermissionStateFullParcel() = default; - - ~PermissionStateFullParcel() override = default; - - bool Marshalling(Parcel &out) const override; - - static PermissionStateFullParcel *Unmarshalling(Parcel &in); - - PermissionStateFull permStatFull; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H +#define INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H + +#include "permission_state_full.h" +#include "parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionStateFullParcel final : public Parcelable { + PermissionStateFullParcel() = default; + + ~PermissionStateFullParcel() override = default; + + bool Marshalling(Parcel &out) const override; + + static PermissionStateFullParcel *Unmarshalling(Parcel &in); + + PermissionStateFull permStatFull; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // INTERFACES_INNER_KITS_PERMISSION_PERMISSION_STATE_FULL_PARCEL_H diff --git a/frameworks/accesstoken/src/hap_policy_parcel.cpp b/frameworks/accesstoken/src/hap_policy_parcel.cpp index 6bbccf7de8c1db04c83497277681c1fb2e2b48f3..c37e589b5aa18983044c4fa54feceab7f740828a 100644 --- a/frameworks/accesstoken/src/hap_policy_parcel.cpp +++ b/frameworks/accesstoken/src/hap_policy_parcel.cpp @@ -1,87 +1,87 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hap_policy_parcel.h" -#include "refbase.h" -#include "access_token.h" -#include "parcel_utils.h" -#include "permission_def.h" -#include "permission_def_parcel.h" -#include "permission_state_full.h" -#include "permission_state_full_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool HapPolicyParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteInt32(this->hapPolicyParameter.apl)); - RETURN_IF_FALSE(out.WriteString(this->hapPolicyParameter.domain)); - - const std::vector& permList = this->hapPolicyParameter.permList; - int32_t permListSize = static_cast(permList.size()); - RETURN_IF_FALSE(out.WriteInt32(permListSize)); - - for (int i = 0; i < permListSize; i++) { - PermissionDefParcel permDefParcel; - permDefParcel.permissionDef = permList[i]; - out.WriteParcelable(&permDefParcel); - } - - const std::vector& permStateList = this->hapPolicyParameter.permStateList; - int32_t permStateListSize = static_cast(permStateList.size()); - RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); - - for (int i = 0; i < permStateListSize; i++) { - PermissionStateFullParcel permStateParcel; - permStateParcel.permStatFull = permStateList[i]; - out.WriteParcelable(&permStateParcel); - } - - return true; -} - -HapPolicyParcel* HapPolicyParcel::Unmarshalling(Parcel& in) -{ - auto* hapPolicyParcel = new (std::nothrow) HapPolicyParcel(); - RELEASE_IF_FALSE(hapPolicyParcel != nullptr, hapPolicyParcel); - - int32_t apl; - RELEASE_IF_FALSE(in.ReadInt32(apl), hapPolicyParcel); - hapPolicyParcel->hapPolicyParameter.apl = ATokenAplEnum(apl); - - hapPolicyParcel->hapPolicyParameter.domain = in.ReadString(); - - int permListSize; - RELEASE_IF_FALSE(in.ReadInt32(permListSize), hapPolicyParcel); - - for (int i = 0; i < permListSize; i++) { - sptr permDefParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(permDefParcel != nullptr, hapPolicyParcel); - hapPolicyParcel->hapPolicyParameter.permList.emplace_back(permDefParcel->permissionDef); - } - - int permStateListSize; - RELEASE_IF_FALSE(in.ReadInt32(permStateListSize), hapPolicyParcel); - for (int i = 0; i < permStateListSize; i++) { - sptr permissionStateParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(permissionStateParcel != nullptr, hapPolicyParcel); - hapPolicyParcel->hapPolicyParameter.permStateList.emplace_back(permissionStateParcel->permStatFull); - } - return hapPolicyParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hap_policy_parcel.h" +#include "refbase.h" +#include "access_token.h" +#include "parcel_utils.h" +#include "permission_def.h" +#include "permission_def_parcel.h" +#include "permission_state_full.h" +#include "permission_state_full_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool HapPolicyParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteInt32(this->hapPolicyParameter.apl)); + RETURN_IF_FALSE(out.WriteString(this->hapPolicyParameter.domain)); + + const std::vector& permList = this->hapPolicyParameter.permList; + int32_t permListSize = static_cast(permList.size()); + RETURN_IF_FALSE(out.WriteInt32(permListSize)); + + for (int i = 0; i < permListSize; i++) { + PermissionDefParcel permDefParcel; + permDefParcel.permissionDef = permList[i]; + out.WriteParcelable(&permDefParcel); + } + + const std::vector& permStateList = this->hapPolicyParameter.permStateList; + int32_t permStateListSize = static_cast(permStateList.size()); + RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); + + for (int i = 0; i < permStateListSize; i++) { + PermissionStateFullParcel permStateParcel; + permStateParcel.permStatFull = permStateList[i]; + out.WriteParcelable(&permStateParcel); + } + + return true; +} + +HapPolicyParcel* HapPolicyParcel::Unmarshalling(Parcel& in) +{ + auto* hapPolicyParcel = new (std::nothrow) HapPolicyParcel(); + RELEASE_IF_FALSE(hapPolicyParcel != nullptr, hapPolicyParcel); + + int32_t apl; + RELEASE_IF_FALSE(in.ReadInt32(apl), hapPolicyParcel); + hapPolicyParcel->hapPolicyParameter.apl = ATokenAplEnum(apl); + + hapPolicyParcel->hapPolicyParameter.domain = in.ReadString(); + + int permListSize; + RELEASE_IF_FALSE(in.ReadInt32(permListSize), hapPolicyParcel); + + for (int i = 0; i < permListSize; i++) { + sptr permDefParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(permDefParcel != nullptr, hapPolicyParcel); + hapPolicyParcel->hapPolicyParameter.permList.emplace_back(permDefParcel->permissionDef); + } + + int permStateListSize; + RELEASE_IF_FALSE(in.ReadInt32(permStateListSize), hapPolicyParcel); + for (int i = 0; i < permStateListSize; i++) { + sptr permissionStateParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(permissionStateParcel != nullptr, hapPolicyParcel); + hapPolicyParcel->hapPolicyParameter.permStateList.emplace_back(permissionStateParcel->permStatFull); + } + return hapPolicyParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp b/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp index 17b04b3a53e3154c28d2af7b6e8fb9107cec6bac..e02db64346f8b8a52287d5d5d97768eb1cb8e727 100644 --- a/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp +++ b/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hap_token_info_for_sync_parcel.h" -#include "refbase.h" -#include "hap_token_info_parcel.h" -#include "parcel_utils.h" -#include "permission_state_full.h" -#include "permission_state_full_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool HapTokenInfoForSyncParcel::Marshalling(Parcel& out) const -{ - HapTokenInfoParcel baseInfoParcel; - baseInfoParcel.hapTokenInfoParams = this->hapTokenInfoForSyncParams.baseInfo; - out.WriteParcelable(&baseInfoParcel); - - const std::vector& permStateList = this->hapTokenInfoForSyncParams.permStateList; - int32_t permStateListSize = static_cast(permStateList.size()); - RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); - RETURN_IF_FALSE((permStateListSize <= MAX_PERMLIST_SIZE)); - for (int i = 0; i < permStateListSize; i++) { - PermissionStateFullParcel permStateParcel; - permStateParcel.permStatFull = permStateList[i]; - out.WriteParcelable(&permStateParcel); - } - - return true; -} - -HapTokenInfoForSyncParcel* HapTokenInfoForSyncParcel::Unmarshalling(Parcel& in) -{ - auto* hapTokenInfoForSyncParcel = new (std::nothrow) HapTokenInfoForSyncParcel(); - RELEASE_IF_FALSE(hapTokenInfoForSyncParcel != nullptr, hapTokenInfoForSyncParcel); - - sptr baseInfoParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(baseInfoParcel != nullptr, hapTokenInfoForSyncParcel); - hapTokenInfoForSyncParcel->hapTokenInfoForSyncParams.baseInfo = baseInfoParcel->hapTokenInfoParams; - - int permStateListSize; - RELEASE_IF_FALSE(in.ReadInt32(permStateListSize), hapTokenInfoForSyncParcel); - for (int i = 0; i < permStateListSize; i++) { - sptr permissionStateParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(permissionStateParcel != nullptr, hapTokenInfoForSyncParcel); - hapTokenInfoForSyncParcel->hapTokenInfoForSyncParams.permStateList.emplace_back( - permissionStateParcel->permStatFull); - } - return hapTokenInfoForSyncParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hap_token_info_for_sync_parcel.h" +#include "refbase.h" +#include "hap_token_info_parcel.h" +#include "parcel_utils.h" +#include "permission_state_full.h" +#include "permission_state_full_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool HapTokenInfoForSyncParcel::Marshalling(Parcel& out) const +{ + HapTokenInfoParcel baseInfoParcel; + baseInfoParcel.hapTokenInfoParams = this->hapTokenInfoForSyncParams.baseInfo; + out.WriteParcelable(&baseInfoParcel); + + const std::vector& permStateList = this->hapTokenInfoForSyncParams.permStateList; + int32_t permStateListSize = static_cast(permStateList.size()); + RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); + RETURN_IF_FALSE((permStateListSize <= MAX_PERMLIST_SIZE)); + for (int i = 0; i < permStateListSize; i++) { + PermissionStateFullParcel permStateParcel; + permStateParcel.permStatFull = permStateList[i]; + out.WriteParcelable(&permStateParcel); + } + + return true; +} + +HapTokenInfoForSyncParcel* HapTokenInfoForSyncParcel::Unmarshalling(Parcel& in) +{ + auto* hapTokenInfoForSyncParcel = new (std::nothrow) HapTokenInfoForSyncParcel(); + RELEASE_IF_FALSE(hapTokenInfoForSyncParcel != nullptr, hapTokenInfoForSyncParcel); + + sptr baseInfoParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(baseInfoParcel != nullptr, hapTokenInfoForSyncParcel); + hapTokenInfoForSyncParcel->hapTokenInfoForSyncParams.baseInfo = baseInfoParcel->hapTokenInfoParams; + + int permStateListSize; + RELEASE_IF_FALSE(in.ReadInt32(permStateListSize), hapTokenInfoForSyncParcel); + for (int i = 0; i < permStateListSize; i++) { + sptr permissionStateParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(permissionStateParcel != nullptr, hapTokenInfoForSyncParcel); + hapTokenInfoForSyncParcel->hapTokenInfoForSyncParams.permStateList.emplace_back( + permissionStateParcel->permStatFull); + } + return hapTokenInfoForSyncParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/hap_token_info_parcel.cpp b/frameworks/accesstoken/src/hap_token_info_parcel.cpp index 6d209ca4b63e72db0208d8d55c71f838fd57d38d..afea5d570e9bca8ac11a80f7ee76e991589cf251 100644 --- a/frameworks/accesstoken/src/hap_token_info_parcel.cpp +++ b/frameworks/accesstoken/src/hap_token_info_parcel.cpp @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hap_token_info_parcel.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool HapTokenInfoParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.apl)); - RETURN_IF_FALSE(out.WriteUint8(this->hapTokenInfoParams.ver)); - RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.userID)); - RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.bundleName)); - RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.apiVersion)); - RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.instIndex)); - RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.dlpType)); - RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.appID)); - RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.deviceID)); - RETURN_IF_FALSE(out.WriteUint32(this->hapTokenInfoParams.tokenID)); - RETURN_IF_FALSE(out.WriteUint32(this->hapTokenInfoParams.tokenAttr)); - return true; -} - -HapTokenInfoParcel* HapTokenInfoParcel::Unmarshalling(Parcel& in) -{ - auto* hapTokenInfoParcel = new (std::nothrow) HapTokenInfoParcel(); - RELEASE_IF_FALSE(hapTokenInfoParcel != nullptr, hapTokenInfoParcel); - int apl; - uint8_t ver; - RELEASE_IF_FALSE(in.ReadInt32(apl), hapTokenInfoParcel); - hapTokenInfoParcel->hapTokenInfoParams.apl = ATokenAplEnum(apl); - RELEASE_IF_FALSE(in.ReadUint8(ver), hapTokenInfoParcel); - hapTokenInfoParcel->hapTokenInfoParams.ver = ver; - RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.userID), hapTokenInfoParcel); - hapTokenInfoParcel->hapTokenInfoParams.bundleName = in.ReadString(); - RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.apiVersion), hapTokenInfoParcel); - RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.instIndex), hapTokenInfoParcel); - RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.dlpType), hapTokenInfoParcel); - hapTokenInfoParcel->hapTokenInfoParams.appID = in.ReadString(); - hapTokenInfoParcel->hapTokenInfoParams.deviceID = in.ReadString(); - RELEASE_IF_FALSE(in.ReadUint32(hapTokenInfoParcel->hapTokenInfoParams.tokenID), hapTokenInfoParcel); - RELEASE_IF_FALSE(in.ReadUint32(hapTokenInfoParcel->hapTokenInfoParams.tokenAttr), hapTokenInfoParcel); - return hapTokenInfoParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hap_token_info_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool HapTokenInfoParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.apl)); + RETURN_IF_FALSE(out.WriteUint8(this->hapTokenInfoParams.ver)); + RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.userID)); + RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.bundleName)); + RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.apiVersion)); + RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.instIndex)); + RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.dlpType)); + RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.appID)); + RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.deviceID)); + RETURN_IF_FALSE(out.WriteUint32(this->hapTokenInfoParams.tokenID)); + RETURN_IF_FALSE(out.WriteUint32(this->hapTokenInfoParams.tokenAttr)); + return true; +} + +HapTokenInfoParcel* HapTokenInfoParcel::Unmarshalling(Parcel& in) +{ + auto* hapTokenInfoParcel = new (std::nothrow) HapTokenInfoParcel(); + RELEASE_IF_FALSE(hapTokenInfoParcel != nullptr, hapTokenInfoParcel); + int apl; + uint8_t ver; + RELEASE_IF_FALSE(in.ReadInt32(apl), hapTokenInfoParcel); + hapTokenInfoParcel->hapTokenInfoParams.apl = ATokenAplEnum(apl); + RELEASE_IF_FALSE(in.ReadUint8(ver), hapTokenInfoParcel); + hapTokenInfoParcel->hapTokenInfoParams.ver = ver; + RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.userID), hapTokenInfoParcel); + hapTokenInfoParcel->hapTokenInfoParams.bundleName = in.ReadString(); + RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.apiVersion), hapTokenInfoParcel); + RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.instIndex), hapTokenInfoParcel); + RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.dlpType), hapTokenInfoParcel); + hapTokenInfoParcel->hapTokenInfoParams.appID = in.ReadString(); + hapTokenInfoParcel->hapTokenInfoParams.deviceID = in.ReadString(); + RELEASE_IF_FALSE(in.ReadUint32(hapTokenInfoParcel->hapTokenInfoParams.tokenID), hapTokenInfoParcel); + RELEASE_IF_FALSE(in.ReadUint32(hapTokenInfoParcel->hapTokenInfoParams.tokenAttr), hapTokenInfoParcel); + return hapTokenInfoParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/native_token_info_for_sync_parcel.cpp b/frameworks/accesstoken/src/native_token_info_for_sync_parcel.cpp index 6b0f65ed6b380b7a1f61f755cad17755df6b87a5..311d5046f541c105854012fbfac73607fff24671 100644 --- a/frameworks/accesstoken/src/native_token_info_for_sync_parcel.cpp +++ b/frameworks/accesstoken/src/native_token_info_for_sync_parcel.cpp @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_token_info_for_sync_parcel.h" -#include "refbase.h" -#include "native_token_info_parcel.h" -#include "parcel_utils.h" -#include "permission_state_full.h" -#include "permission_state_full_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool NativeTokenInfoForSyncParcel::Marshalling(Parcel& out) const -{ - NativeTokenInfoParcel baseInfoParcel; - baseInfoParcel.nativeTokenInfoParams = this->nativeTokenInfoForSyncParams.baseInfo; - RETURN_IF_FALSE(out.WriteParcelable(&baseInfoParcel)); - - const std::vector& permStateList = this->nativeTokenInfoForSyncParams.permStateList; - int32_t permStateListSize = static_cast(permStateList.size()); - RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); - RETURN_IF_FALSE((permStateListSize <= MAX_PERMLIST_SIZE)); - for (int i = 0; i < permStateListSize; i++) { - PermissionStateFullParcel permStateParcel; - permStateParcel.permStatFull = permStateList[i]; - RETURN_IF_FALSE(out.WriteParcelable(&permStateParcel)); - } - - return true; -} - -NativeTokenInfoForSyncParcel* NativeTokenInfoForSyncParcel::Unmarshalling(Parcel& in) -{ - auto* nativeTokenInfoForSyncParcel = new (std::nothrow) NativeTokenInfoForSyncParcel(); - RELEASE_IF_FALSE(nativeTokenInfoForSyncParcel != nullptr, nativeTokenInfoForSyncParcel); - - sptr baseInfoParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(baseInfoParcel != nullptr, nativeTokenInfoForSyncParcel); - nativeTokenInfoForSyncParcel->nativeTokenInfoForSyncParams.baseInfo = baseInfoParcel->nativeTokenInfoParams; - - int permStateListSize; - RELEASE_IF_FALSE(in.ReadInt32(permStateListSize), nativeTokenInfoForSyncParcel); - for (int i = 0; i < permStateListSize; i++) { - sptr permissionStateParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(permissionStateParcel != nullptr, nativeTokenInfoForSyncParcel); - nativeTokenInfoForSyncParcel->nativeTokenInfoForSyncParams.permStateList.emplace_back( - permissionStateParcel->permStatFull); - } - return nativeTokenInfoForSyncParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_token_info_for_sync_parcel.h" +#include "refbase.h" +#include "native_token_info_parcel.h" +#include "parcel_utils.h" +#include "permission_state_full.h" +#include "permission_state_full_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool NativeTokenInfoForSyncParcel::Marshalling(Parcel& out) const +{ + NativeTokenInfoParcel baseInfoParcel; + baseInfoParcel.nativeTokenInfoParams = this->nativeTokenInfoForSyncParams.baseInfo; + RETURN_IF_FALSE(out.WriteParcelable(&baseInfoParcel)); + + const std::vector& permStateList = this->nativeTokenInfoForSyncParams.permStateList; + int32_t permStateListSize = static_cast(permStateList.size()); + RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); + RETURN_IF_FALSE((permStateListSize <= MAX_PERMLIST_SIZE)); + for (int i = 0; i < permStateListSize; i++) { + PermissionStateFullParcel permStateParcel; + permStateParcel.permStatFull = permStateList[i]; + RETURN_IF_FALSE(out.WriteParcelable(&permStateParcel)); + } + + return true; +} + +NativeTokenInfoForSyncParcel* NativeTokenInfoForSyncParcel::Unmarshalling(Parcel& in) +{ + auto* nativeTokenInfoForSyncParcel = new (std::nothrow) NativeTokenInfoForSyncParcel(); + RELEASE_IF_FALSE(nativeTokenInfoForSyncParcel != nullptr, nativeTokenInfoForSyncParcel); + + sptr baseInfoParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(baseInfoParcel != nullptr, nativeTokenInfoForSyncParcel); + nativeTokenInfoForSyncParcel->nativeTokenInfoForSyncParams.baseInfo = baseInfoParcel->nativeTokenInfoParams; + + int permStateListSize; + RELEASE_IF_FALSE(in.ReadInt32(permStateListSize), nativeTokenInfoForSyncParcel); + for (int i = 0; i < permStateListSize; i++) { + sptr permissionStateParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(permissionStateParcel != nullptr, nativeTokenInfoForSyncParcel); + nativeTokenInfoForSyncParcel->nativeTokenInfoForSyncParams.permStateList.emplace_back( + permissionStateParcel->permStatFull); + } + return nativeTokenInfoForSyncParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/native_token_info_parcel.cpp b/frameworks/accesstoken/src/native_token_info_parcel.cpp index 621ce872c591eae6ecb34184b2e9b315b691c114..38804183a32b4e685e41702d2f96f4834e4e720c 100644 --- a/frameworks/accesstoken/src/native_token_info_parcel.cpp +++ b/frameworks/accesstoken/src/native_token_info_parcel.cpp @@ -1,95 +1,95 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_token_info_parcel.h" -#include -#include -#include -#include -#include "access_token.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool NativeTokenInfoParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteInt32(this->nativeTokenInfoParams.apl)); - RETURN_IF_FALSE(out.WriteUint8(this->nativeTokenInfoParams.ver)); - RETURN_IF_FALSE(out.WriteString(this->nativeTokenInfoParams.processName)); - RETURN_IF_FALSE(out.WriteUint32(this->nativeTokenInfoParams.tokenID)); - RETURN_IF_FALSE(out.WriteUint32(this->nativeTokenInfoParams.tokenAttr)); - - if ((this->nativeTokenInfoParams.dcap).size() > INT32_MAX) { - return false; - } - int32_t dcapSize = static_cast((this->nativeTokenInfoParams.dcap).size()); - RETURN_IF_FALSE(out.WriteInt32(dcapSize)); - - for (const auto& dcapItem : this->nativeTokenInfoParams.dcap) { - RETURN_IF_FALSE(out.WriteString(dcapItem)); - } - - if ((this->nativeTokenInfoParams.nativeAcls).size() > INT32_MAX) { - return false; - } - int32_t nativeAclSize = static_cast((this->nativeTokenInfoParams.nativeAcls).size()); - RETURN_IF_FALSE(out.WriteInt32(nativeAclSize)); - - for (const auto& item : this->nativeTokenInfoParams.nativeAcls) { - RETURN_IF_FALSE(out.WriteString(item)); - } - - return true; -} - -NativeTokenInfoParcel* NativeTokenInfoParcel::Unmarshalling(Parcel& in) -{ - auto* nativeTokenInfoParcel = new (std::nothrow) NativeTokenInfoParcel(); - RELEASE_IF_FALSE(nativeTokenInfoParcel != nullptr, nativeTokenInfoParcel); - - int32_t apl; - uint8_t ver; - RELEASE_IF_FALSE(in.ReadInt32(apl), nativeTokenInfoParcel); - RELEASE_IF_FALSE(in.ReadUint8(ver), nativeTokenInfoParcel); - nativeTokenInfoParcel->nativeTokenInfoParams.apl = ATokenAplEnum(apl); - nativeTokenInfoParcel->nativeTokenInfoParams.ver = ver; - - nativeTokenInfoParcel->nativeTokenInfoParams.processName = in.ReadString(); - RELEASE_IF_FALSE(in.ReadUint32(nativeTokenInfoParcel->nativeTokenInfoParams.tokenID), nativeTokenInfoParcel); - RELEASE_IF_FALSE(in.ReadUint32(nativeTokenInfoParcel->nativeTokenInfoParams.tokenAttr), nativeTokenInfoParcel); - - int32_t dcapSize; - RELEASE_IF_FALSE(in.ReadInt32(dcapSize), nativeTokenInfoParcel); - - for (int32_t i = 0; i < dcapSize; i++) { - std::string dcapsItem; - RELEASE_IF_FALSE(in.ReadString(dcapsItem), nativeTokenInfoParcel); - nativeTokenInfoParcel->nativeTokenInfoParams.dcap.emplace_back(dcapsItem); - } - - int32_t nativeAclSize; - RELEASE_IF_FALSE(in.ReadInt32(nativeAclSize), nativeTokenInfoParcel); - - for (int32_t i = 0; i < nativeAclSize; i++) { - std::string item; - RELEASE_IF_FALSE(in.ReadString(item), nativeTokenInfoParcel); - nativeTokenInfoParcel->nativeTokenInfoParams.nativeAcls.emplace_back(item); - } - return nativeTokenInfoParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_token_info_parcel.h" +#include +#include +#include +#include +#include "access_token.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool NativeTokenInfoParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteInt32(this->nativeTokenInfoParams.apl)); + RETURN_IF_FALSE(out.WriteUint8(this->nativeTokenInfoParams.ver)); + RETURN_IF_FALSE(out.WriteString(this->nativeTokenInfoParams.processName)); + RETURN_IF_FALSE(out.WriteUint32(this->nativeTokenInfoParams.tokenID)); + RETURN_IF_FALSE(out.WriteUint32(this->nativeTokenInfoParams.tokenAttr)); + + if ((this->nativeTokenInfoParams.dcap).size() > INT32_MAX) { + return false; + } + int32_t dcapSize = static_cast((this->nativeTokenInfoParams.dcap).size()); + RETURN_IF_FALSE(out.WriteInt32(dcapSize)); + + for (const auto& dcapItem : this->nativeTokenInfoParams.dcap) { + RETURN_IF_FALSE(out.WriteString(dcapItem)); + } + + if ((this->nativeTokenInfoParams.nativeAcls).size() > INT32_MAX) { + return false; + } + int32_t nativeAclSize = static_cast((this->nativeTokenInfoParams.nativeAcls).size()); + RETURN_IF_FALSE(out.WriteInt32(nativeAclSize)); + + for (const auto& item : this->nativeTokenInfoParams.nativeAcls) { + RETURN_IF_FALSE(out.WriteString(item)); + } + + return true; +} + +NativeTokenInfoParcel* NativeTokenInfoParcel::Unmarshalling(Parcel& in) +{ + auto* nativeTokenInfoParcel = new (std::nothrow) NativeTokenInfoParcel(); + RELEASE_IF_FALSE(nativeTokenInfoParcel != nullptr, nativeTokenInfoParcel); + + int32_t apl; + uint8_t ver; + RELEASE_IF_FALSE(in.ReadInt32(apl), nativeTokenInfoParcel); + RELEASE_IF_FALSE(in.ReadUint8(ver), nativeTokenInfoParcel); + nativeTokenInfoParcel->nativeTokenInfoParams.apl = ATokenAplEnum(apl); + nativeTokenInfoParcel->nativeTokenInfoParams.ver = ver; + + nativeTokenInfoParcel->nativeTokenInfoParams.processName = in.ReadString(); + RELEASE_IF_FALSE(in.ReadUint32(nativeTokenInfoParcel->nativeTokenInfoParams.tokenID), nativeTokenInfoParcel); + RELEASE_IF_FALSE(in.ReadUint32(nativeTokenInfoParcel->nativeTokenInfoParams.tokenAttr), nativeTokenInfoParcel); + + int32_t dcapSize; + RELEASE_IF_FALSE(in.ReadInt32(dcapSize), nativeTokenInfoParcel); + + for (int32_t i = 0; i < dcapSize; i++) { + std::string dcapsItem; + RELEASE_IF_FALSE(in.ReadString(dcapsItem), nativeTokenInfoParcel); + nativeTokenInfoParcel->nativeTokenInfoParams.dcap.emplace_back(dcapsItem); + } + + int32_t nativeAclSize; + RELEASE_IF_FALSE(in.ReadInt32(nativeAclSize), nativeTokenInfoParcel); + + for (int32_t i = 0; i < nativeAclSize; i++) { + std::string item; + RELEASE_IF_FALSE(in.ReadString(item), nativeTokenInfoParcel); + nativeTokenInfoParcel->nativeTokenInfoParams.nativeAcls.emplace_back(item); + } + return nativeTokenInfoParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/permission_def_parcel.cpp b/frameworks/accesstoken/src/permission_def_parcel.cpp index 4ca7b3d2a3d553ed44a550b9515ec78a47129d68..56578ccc3f3286edce414112c4d8ccca91faceff 100644 --- a/frameworks/accesstoken/src/permission_def_parcel.cpp +++ b/frameworks/accesstoken/src/permission_def_parcel.cpp @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_def_parcel.h" - -#include "access_token.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool PermissionDefParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteString(this->permissionDef.permissionName)); - RETURN_IF_FALSE(out.WriteString(this->permissionDef.bundleName)); - RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.grantMode)); - RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.availableLevel)); - RETURN_IF_FALSE(out.WriteBool(this->permissionDef.provisionEnable)); - RETURN_IF_FALSE(out.WriteBool(this->permissionDef.distributedSceneEnable)); - RETURN_IF_FALSE(out.WriteString(this->permissionDef.label)); - RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.labelId)); - RETURN_IF_FALSE(out.WriteString(this->permissionDef.description)); - RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.descriptionId)); - return true; -} - -PermissionDefParcel* PermissionDefParcel::Unmarshalling(Parcel& in) -{ - auto* permissionDefParcel = new (std::nothrow) PermissionDefParcel(); - RELEASE_IF_FALSE(permissionDefParcel != nullptr, permissionDefParcel); - permissionDefParcel->permissionDef.permissionName = in.ReadString(); - permissionDefParcel->permissionDef.bundleName = in.ReadString(); - RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.grantMode), permissionDefParcel); - - int level; - RELEASE_IF_FALSE(in.ReadInt32(level), permissionDefParcel); - permissionDefParcel->permissionDef.availableLevel = ATokenAplEnum(level); - - RELEASE_IF_FALSE(in.ReadBool(permissionDefParcel->permissionDef.provisionEnable), permissionDefParcel); - RELEASE_IF_FALSE(in.ReadBool(permissionDefParcel->permissionDef.distributedSceneEnable), permissionDefParcel); - permissionDefParcel->permissionDef.label = in.ReadString(); - RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.labelId), permissionDefParcel); - permissionDefParcel->permissionDef.description = in.ReadString(); - RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.descriptionId), permissionDefParcel); - return permissionDefParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_def_parcel.h" + +#include "access_token.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool PermissionDefParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteString(this->permissionDef.permissionName)); + RETURN_IF_FALSE(out.WriteString(this->permissionDef.bundleName)); + RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.grantMode)); + RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.availableLevel)); + RETURN_IF_FALSE(out.WriteBool(this->permissionDef.provisionEnable)); + RETURN_IF_FALSE(out.WriteBool(this->permissionDef.distributedSceneEnable)); + RETURN_IF_FALSE(out.WriteString(this->permissionDef.label)); + RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.labelId)); + RETURN_IF_FALSE(out.WriteString(this->permissionDef.description)); + RETURN_IF_FALSE(out.WriteInt32(this->permissionDef.descriptionId)); + return true; +} + +PermissionDefParcel* PermissionDefParcel::Unmarshalling(Parcel& in) +{ + auto* permissionDefParcel = new (std::nothrow) PermissionDefParcel(); + RELEASE_IF_FALSE(permissionDefParcel != nullptr, permissionDefParcel); + permissionDefParcel->permissionDef.permissionName = in.ReadString(); + permissionDefParcel->permissionDef.bundleName = in.ReadString(); + RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.grantMode), permissionDefParcel); + + int level; + RELEASE_IF_FALSE(in.ReadInt32(level), permissionDefParcel); + permissionDefParcel->permissionDef.availableLevel = ATokenAplEnum(level); + + RELEASE_IF_FALSE(in.ReadBool(permissionDefParcel->permissionDef.provisionEnable), permissionDefParcel); + RELEASE_IF_FALSE(in.ReadBool(permissionDefParcel->permissionDef.distributedSceneEnable), permissionDefParcel); + permissionDefParcel->permissionDef.label = in.ReadString(); + RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.labelId), permissionDefParcel); + permissionDefParcel->permissionDef.description = in.ReadString(); + RELEASE_IF_FALSE(in.ReadInt32(permissionDefParcel->permissionDef.descriptionId), permissionDefParcel); + return permissionDefParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/permission_list_state_parcel.cpp b/frameworks/accesstoken/src/permission_list_state_parcel.cpp index 5fe05d917635bb6f3fce2f365712d372a6e8742f..1e85e65604b62be3b35e021e422ed5a645e988ad 100644 --- a/frameworks/accesstoken/src/permission_list_state_parcel.cpp +++ b/frameworks/accesstoken/src/permission_list_state_parcel.cpp @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_list_state_parcel.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool PermissionListStateParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteString(this->permsState.permissionName)); - RETURN_IF_FALSE(out.WriteInt32(this->permsState.state)); - return true; -} - -PermissionListStateParcel* PermissionListStateParcel::Unmarshalling(Parcel& in) -{ - auto* permissionStateParcel = new (std::nothrow) PermissionListStateParcel(); - RELEASE_IF_FALSE(permissionStateParcel != nullptr, permissionStateParcel); - - RELEASE_IF_FALSE(in.ReadString(permissionStateParcel->permsState.permissionName), permissionStateParcel); - RELEASE_IF_FALSE(in.ReadInt32(permissionStateParcel->permsState.state), permissionStateParcel); - - return permissionStateParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_list_state_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool PermissionListStateParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteString(this->permsState.permissionName)); + RETURN_IF_FALSE(out.WriteInt32(this->permsState.state)); + return true; +} + +PermissionListStateParcel* PermissionListStateParcel::Unmarshalling(Parcel& in) +{ + auto* permissionStateParcel = new (std::nothrow) PermissionListStateParcel(); + RELEASE_IF_FALSE(permissionStateParcel != nullptr, permissionStateParcel); + + RELEASE_IF_FALSE(in.ReadString(permissionStateParcel->permsState.permissionName), permissionStateParcel); + RELEASE_IF_FALSE(in.ReadInt32(permissionStateParcel->permsState.state), permissionStateParcel); + + return permissionStateParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/permission_state_change_info_parcel.cpp b/frameworks/accesstoken/src/permission_state_change_info_parcel.cpp index 173a2d25b8e3155d6dee4393818521c4d29e1f0e..1af18a4aea061f949356d8a939da69504b54b86e 100644 --- a/frameworks/accesstoken/src/permission_state_change_info_parcel.cpp +++ b/frameworks/accesstoken/src/permission_state_change_info_parcel.cpp @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_state_change_info_parcel.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool PermissionStateChangeInfoParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteInt32(this->changeInfo.PermStateChangeType)); - RETURN_IF_FALSE(out.WriteUint32(this->changeInfo.tokenID)); - RETURN_IF_FALSE(out.WriteString(this->changeInfo.permissionName)); - return true; -} - -PermissionStateChangeInfoParcel* PermissionStateChangeInfoParcel::Unmarshalling(Parcel& in) -{ - auto* permissionStateParcel = new (std::nothrow) PermissionStateChangeInfoParcel(); - if (permissionStateParcel == nullptr) { - return nullptr; - } - RELEASE_IF_FALSE(in.ReadInt32(permissionStateParcel->changeInfo.PermStateChangeType), permissionStateParcel); - RELEASE_IF_FALSE(in.ReadUint32(permissionStateParcel->changeInfo.tokenID), permissionStateParcel); - RELEASE_IF_FALSE(in.ReadString(permissionStateParcel->changeInfo.permissionName), permissionStateParcel); - - return permissionStateParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_state_change_info_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool PermissionStateChangeInfoParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteInt32(this->changeInfo.PermStateChangeType)); + RETURN_IF_FALSE(out.WriteUint32(this->changeInfo.tokenID)); + RETURN_IF_FALSE(out.WriteString(this->changeInfo.permissionName)); + return true; +} + +PermissionStateChangeInfoParcel* PermissionStateChangeInfoParcel::Unmarshalling(Parcel& in) +{ + auto* permissionStateParcel = new (std::nothrow) PermissionStateChangeInfoParcel(); + if (permissionStateParcel == nullptr) { + return nullptr; + } + RELEASE_IF_FALSE(in.ReadInt32(permissionStateParcel->changeInfo.PermStateChangeType), permissionStateParcel); + RELEASE_IF_FALSE(in.ReadUint32(permissionStateParcel->changeInfo.tokenID), permissionStateParcel); + RELEASE_IF_FALSE(in.ReadString(permissionStateParcel->changeInfo.permissionName), permissionStateParcel); + + return permissionStateParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/permission_state_change_scope_parcel.cpp b/frameworks/accesstoken/src/permission_state_change_scope_parcel.cpp index 8555df3533764777dee7971f36034edad0b48a5d..93cd2fc1b95c55d95cf0de1e3c68048f9a531793 100644 --- a/frameworks/accesstoken/src/permission_state_change_scope_parcel.cpp +++ b/frameworks/accesstoken/src/permission_state_change_scope_parcel.cpp @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_state_change_scope_parcel.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool PermStateChangeScopeParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteUint32((this->scope.tokenIDs.size()))); - for (const auto& tokenID : this->scope.tokenIDs) { - RETURN_IF_FALSE(out.WriteUint32(tokenID)); - } - - RETURN_IF_FALSE(out.WriteUint32((this->scope.permList.size()))); - for (const auto& permissionName : this->scope.permList) { - RETURN_IF_FALSE(out.WriteString(permissionName)); - } - return true; -} - -PermStateChangeScopeParcel* PermStateChangeScopeParcel::Unmarshalling(Parcel& in) -{ - auto* permStateChangeScopeParcel = new (std::nothrow) PermStateChangeScopeParcel(); - if (permStateChangeScopeParcel == nullptr) { - return nullptr; - } - uint32_t tokenIdListSize = 0; - RELEASE_IF_FALSE(in.ReadUint32(tokenIdListSize), permStateChangeScopeParcel); - RELEASE_IF_FALSE(tokenIdListSize <= TOKENIDS_LIST_SIZE_MAX, permStateChangeScopeParcel); - for (uint32_t i = 0; i < tokenIdListSize; i++) { - AccessTokenID tokenID; - RELEASE_IF_FALSE(in.ReadUint32(tokenID), permStateChangeScopeParcel); - permStateChangeScopeParcel->scope.tokenIDs.emplace_back(tokenID); - } - - uint32_t permListSize = 0; - RELEASE_IF_FALSE(in.ReadUint32(permListSize), permStateChangeScopeParcel); - RELEASE_IF_FALSE(permListSize <= PERMS_LIST_SIZE_MAX, permStateChangeScopeParcel); - for (uint32_t i = 0; i < permListSize; i++) { - std::string permName; - RELEASE_IF_FALSE(in.ReadString(permName), permStateChangeScopeParcel); - permStateChangeScopeParcel->scope.permList.emplace_back(permName); - } - return permStateChangeScopeParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_state_change_scope_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool PermStateChangeScopeParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteUint32((this->scope.tokenIDs.size()))); + for (const auto& tokenID : this->scope.tokenIDs) { + RETURN_IF_FALSE(out.WriteUint32(tokenID)); + } + + RETURN_IF_FALSE(out.WriteUint32((this->scope.permList.size()))); + for (const auto& permissionName : this->scope.permList) { + RETURN_IF_FALSE(out.WriteString(permissionName)); + } + return true; +} + +PermStateChangeScopeParcel* PermStateChangeScopeParcel::Unmarshalling(Parcel& in) +{ + auto* permStateChangeScopeParcel = new (std::nothrow) PermStateChangeScopeParcel(); + if (permStateChangeScopeParcel == nullptr) { + return nullptr; + } + uint32_t tokenIdListSize = 0; + RELEASE_IF_FALSE(in.ReadUint32(tokenIdListSize), permStateChangeScopeParcel); + RELEASE_IF_FALSE(tokenIdListSize <= TOKENIDS_LIST_SIZE_MAX, permStateChangeScopeParcel); + for (uint32_t i = 0; i < tokenIdListSize; i++) { + AccessTokenID tokenID; + RELEASE_IF_FALSE(in.ReadUint32(tokenID), permStateChangeScopeParcel); + permStateChangeScopeParcel->scope.tokenIDs.emplace_back(tokenID); + } + + uint32_t permListSize = 0; + RELEASE_IF_FALSE(in.ReadUint32(permListSize), permStateChangeScopeParcel); + RELEASE_IF_FALSE(permListSize <= PERMS_LIST_SIZE_MAX, permStateChangeScopeParcel); + for (uint32_t i = 0; i < permListSize; i++) { + std::string permName; + RELEASE_IF_FALSE(in.ReadString(permName), permStateChangeScopeParcel); + permStateChangeScopeParcel->scope.permList.emplace_back(permName); + } + return permStateChangeScopeParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/accesstoken/src/permission_state_full_parcel.cpp b/frameworks/accesstoken/src/permission_state_full_parcel.cpp index 1919f9d52de426452fca7f0ba61b5703d39d5de8..30500ae28bd7ebd70873f9fbe0faf6096c116888 100644 --- a/frameworks/accesstoken/src/permission_state_full_parcel.cpp +++ b/frameworks/accesstoken/src/permission_state_full_parcel.cpp @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_state_full_parcel.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool PermissionStateFullParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteString(this->permStatFull.permissionName)); - RETURN_IF_FALSE(out.WriteBool(this->permStatFull.isGeneral)); - - RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permStatFull.resDeviceID.size()))); - for (auto devId : this->permStatFull.resDeviceID) { - RETURN_IF_FALSE(out.WriteString(devId)); - } - - RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permStatFull.grantStatus.size()))); - for (auto grantStat : this->permStatFull.grantStatus) { - RETURN_IF_FALSE(out.WriteInt32(grantStat)); - } - - RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permStatFull.grantFlags.size()))); - for (auto grantFlag : this->permStatFull.grantFlags) { - RETURN_IF_FALSE(out.WriteInt32(grantFlag)); - } - return true; -} - -PermissionStateFullParcel* PermissionStateFullParcel::Unmarshalling(Parcel& in) -{ - auto* permissionStateParcel = new (std::nothrow) PermissionStateFullParcel(); - RELEASE_IF_FALSE(permissionStateParcel != nullptr, permissionStateParcel); - - RELEASE_IF_FALSE(in.ReadString(permissionStateParcel->permStatFull.permissionName), permissionStateParcel); - RELEASE_IF_FALSE(in.ReadBool(permissionStateParcel->permStatFull.isGeneral), permissionStateParcel); - - int resIdSize = 0; - RELEASE_IF_FALSE(in.ReadInt32(resIdSize), permissionStateParcel); - for (int i = 0; i < resIdSize; i++) { - std::string resId; - RELEASE_IF_FALSE(in.ReadString(resId), permissionStateParcel); - permissionStateParcel->permStatFull.resDeviceID.emplace_back(resId); - } - - int grantStatsSize = 0; - RELEASE_IF_FALSE(in.ReadInt32(grantStatsSize), permissionStateParcel); - for (int i = 0; i < grantStatsSize; i++) { - int grantStat; - RELEASE_IF_FALSE(in.ReadInt32(grantStat), permissionStateParcel); - permissionStateParcel->permStatFull.grantStatus.emplace_back(grantStat); - } - - int grantFlagSize = 0; - RELEASE_IF_FALSE(in.ReadInt32(grantFlagSize), permissionStateParcel); - for (int i = 0; i < grantFlagSize; i++) { - int flag; - RELEASE_IF_FALSE(in.ReadInt32(flag), permissionStateParcel); - permissionStateParcel->permStatFull.grantFlags.emplace_back(flag); - } - return permissionStateParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_state_full_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool PermissionStateFullParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteString(this->permStatFull.permissionName)); + RETURN_IF_FALSE(out.WriteBool(this->permStatFull.isGeneral)); + + RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permStatFull.resDeviceID.size()))); + for (auto devId : this->permStatFull.resDeviceID) { + RETURN_IF_FALSE(out.WriteString(devId)); + } + + RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permStatFull.grantStatus.size()))); + for (auto grantStat : this->permStatFull.grantStatus) { + RETURN_IF_FALSE(out.WriteInt32(grantStat)); + } + + RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permStatFull.grantFlags.size()))); + for (auto grantFlag : this->permStatFull.grantFlags) { + RETURN_IF_FALSE(out.WriteInt32(grantFlag)); + } + return true; +} + +PermissionStateFullParcel* PermissionStateFullParcel::Unmarshalling(Parcel& in) +{ + auto* permissionStateParcel = new (std::nothrow) PermissionStateFullParcel(); + RELEASE_IF_FALSE(permissionStateParcel != nullptr, permissionStateParcel); + + RELEASE_IF_FALSE(in.ReadString(permissionStateParcel->permStatFull.permissionName), permissionStateParcel); + RELEASE_IF_FALSE(in.ReadBool(permissionStateParcel->permStatFull.isGeneral), permissionStateParcel); + + int resIdSize = 0; + RELEASE_IF_FALSE(in.ReadInt32(resIdSize), permissionStateParcel); + for (int i = 0; i < resIdSize; i++) { + std::string resId; + RELEASE_IF_FALSE(in.ReadString(resId), permissionStateParcel); + permissionStateParcel->permStatFull.resDeviceID.emplace_back(resId); + } + + int grantStatsSize = 0; + RELEASE_IF_FALSE(in.ReadInt32(grantStatsSize), permissionStateParcel); + for (int i = 0; i < grantStatsSize; i++) { + int grantStat; + RELEASE_IF_FALSE(in.ReadInt32(grantStat), permissionStateParcel); + permissionStateParcel->permStatFull.grantStatus.emplace_back(grantStat); + } + + int grantFlagSize = 0; + RELEASE_IF_FALSE(in.ReadInt32(grantFlagSize), permissionStateParcel); + for (int i = 0; i < grantFlagSize; i++) { + int flag; + RELEASE_IF_FALSE(in.ReadInt32(flag), permissionStateParcel); + permissionStateParcel->permStatFull.grantFlags.emplace_back(flag); + } + return permissionStateParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/com.ohos.permissionmanager/.gitignore b/frameworks/com.ohos.permissionmanager/.gitignore index 39187ebed671ccfd399a7e88520b1075926c058e..2981358453339f3410b8e9f950599013a9ee0a99 100644 --- a/frameworks/com.ohos.permissionmanager/.gitignore +++ b/frameworks/com.ohos.permissionmanager/.gitignore @@ -1,4 +1,4 @@ -/node_modules -/local.properties -/.idea +/node_modules +/local.properties +/.idea **/build \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/AppScope/app.json5 b/frameworks/com.ohos.permissionmanager/AppScope/app.json5 index 22b0ce94ea5a6ec86d8ff9cfbc079c9c9c64912f..7648d225024d0180a15678ee3603a445049e631a 100644 --- a/frameworks/com.ohos.permissionmanager/AppScope/app.json5 +++ b/frameworks/com.ohos.permissionmanager/AppScope/app.json5 @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "app": { - "bundleName": "com.ohos.permissionmanager", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true - } -} +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.ohos.permissionmanager", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/frameworks/com.ohos.permissionmanager/AppScope/resources/base/element/string.json b/frameworks/com.ohos.permissionmanager/AppScope/resources/base/element/string.json index 4fe2f85945857ee885481b8b8d6750c9caa8ccf3..b3b093150cf1112130df22149084e9916e8b0d7a 100644 --- a/frameworks/com.ohos.permissionmanager/AppScope/resources/base/element/string.json +++ b/frameworks/com.ohos.permissionmanager/AppScope/resources/base/element/string.json @@ -1,8 +1,8 @@ -{ - "string": [ - { - "name": "app_name", - "value": "权限管理" - } - ] -} +{ + "string": [ + { + "name": "app_name", + "value": "权限管理" + } + ] +} diff --git a/frameworks/com.ohos.permissionmanager/build-profile.json5 b/frameworks/com.ohos.permissionmanager/build-profile.json5 index aaf5d5afbda89e79f9d6c33d198770785896aa75..d2eee0aee734373a065f02ef67a57e85dd2cfa89 100644 --- a/frameworks/com.ohos.permissionmanager/build-profile.json5 +++ b/frameworks/com.ohos.permissionmanager/build-profile.json5 @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "app": { - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, - "products": [ - { - "name": "default", - "signingConfig": "default" - } - ], - "signingConfigs": [ - { - "name": "default", - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "permissionmanager", - "srcPath": "./permissionmanager", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default" + } + ], + "signingConfigs": [ + { + "name": "default", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "permissionmanager", + "srcPath": "./permissionmanager", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/entry/.gitignore b/frameworks/com.ohos.permissionmanager/entry/.gitignore index 4f9a973815d0b5e49bc8547681a6b4bc7a178d12..16ad22851d8b327b59cf74d965ddae2598a56e11 100644 --- a/frameworks/com.ohos.permissionmanager/entry/.gitignore +++ b/frameworks/com.ohos.permissionmanager/entry/.gitignore @@ -1,3 +1,3 @@ -/node_modules -/.preview +/node_modules +/.preview /build \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/entry/build-profile.json5 b/frameworks/com.ohos.permissionmanager/entry/build-profile.json5 index 8d4191ee3893b90de4b15ff67cfce2e295b0609f..e4f8a47c03ef66b1bf9200814c5475fecbe6c25e 100644 --- a/frameworks/com.ohos.permissionmanager/entry/build-profile.json5 +++ b/frameworks/com.ohos.permissionmanager/entry/build-profile.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": 'stageMode', - "buildOption": { - }, - "targets": [ - { - "name": "default", - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/entry/hvigorfile.js b/frameworks/com.ohos.permissionmanager/entry/hvigorfile.js index d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c..fda93c709ee47976559e87a7d0c5c47ea7d5dd5c 100644 --- a/frameworks/com.ohos.permissionmanager/entry/hvigorfile.js +++ b/frameworks/com.ohos.permissionmanager/entry/hvigorfile.js @@ -1,2 +1,2 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/frameworks/com.ohos.permissionmanager/entry/package-lock.json b/frameworks/com.ohos.permissionmanager/entry/package-lock.json index 15bc7145be1490029883067847743ea7134cf545..6b5c677321c8c4acabe0282ef103e8ad3e03aab7 100644 --- a/frameworks/com.ohos.permissionmanager/entry/package-lock.json +++ b/frameworks/com.ohos.permissionmanager/entry/package-lock.json @@ -1,5 +1,5 @@ -{ - "name": "entry", - "version": "1.0.0", - "lockfileVersion": 1 -} +{ + "name": "entry", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/frameworks/com.ohos.permissionmanager/entry/package.json b/frameworks/com.ohos.permissionmanager/entry/package.json index c7685ac4e7c0d79df04c96744f0d8f22cb4a9025..6576583641cb892756f8e1b57932eb87a84841f5 100644 --- a/frameworks/com.ohos.permissionmanager/entry/package.json +++ b/frameworks/com.ohos.permissionmanager/entry/package.json @@ -1,14 +1,14 @@ -{ - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" - }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/frameworks/com.ohos.permissionmanager/entry/src/main/ets/Application/AbilityStage.ts b/frameworks/com.ohos.permissionmanager/entry/src/main/ets/Application/AbilityStage.ts index 32dfe93ccff0375201857794de902cec4d239442..8a1acf6be6bc92e41cb9001dce17015877b7b36c 100644 --- a/frameworks/com.ohos.permissionmanager/entry/src/main/ets/Application/AbilityStage.ts +++ b/frameworks/com.ohos.permissionmanager/entry/src/main/ets/Application/AbilityStage.ts @@ -1,7 +1,7 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - } +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/entry/src/main/ets/MainAbility/MainAbility.ts b/frameworks/com.ohos.permissionmanager/entry/src/main/ets/MainAbility/MainAbility.ts index edb9130731e04190fedab08e6446428203cadc28..ecf2e8cc51da82e48d5b2415e23958288a30b8ee 100644 --- a/frameworks/com.ohos.permissionmanager/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/frameworks/com.ohos.permissionmanager/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,34 +1,34 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - - windowStage.setUIContent(this.context, "pages/index", null) - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/frameworks/com.ohos.permissionmanager/entry/src/main/ets/pages/index.ets b/frameworks/com.ohos.permissionmanager/entry/src/main/ets/pages/index.ets index 54bfa30ae2852e2e97807aebd3918c646d6aad9e..c4c382cf18941ac82d25ab571ebb3879b0f82811 100644 --- a/frameworks/com.ohos.permissionmanager/entry/src/main/ets/pages/index.ets +++ b/frameworks/com.ohos.permissionmanager/entry/src/main/ets/pages/index.ets @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Entry -@Component -struct Index { - @State message: string = 'Hello World' - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') - } - .height('100%') - } +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/entry/src/main/module.json5 b/frameworks/com.ohos.permissionmanager/entry/src/main/module.json5 index 8f7a7509a61a8ec682ca9e2cf413ac90c9f3fd84..23880f02e9a2419e6e7c9a84951db7f16222ae35 100644 --- a/frameworks/com.ohos.permissionmanager/entry/src/main/module.json5 +++ b/frameworks/com.ohos.permissionmanager/entry/src/main/module.json5 @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:entry_desc", - "mainElement": "MainAbility", - "deviceTypes": [ - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:MainAbility_desc", - "icon": "$media:icon", - "label": "$string:MainAbility_label", - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ] - } +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/entry/src/main/resources/base/element/string.json b/frameworks/com.ohos.permissionmanager/entry/src/main/resources/base/element/string.json index 490210a3908f47722dc942d49dacc98b97669a5f..dddf9123aec0b6c9500eeacf289ac1bc58ff7a6a 100644 --- a/frameworks/com.ohos.permissionmanager/entry/src/main/resources/base/element/string.json +++ b/frameworks/com.ohos.permissionmanager/entry/src/main/resources/base/element/string.json @@ -1,16 +1,16 @@ -{ - "string": [ - { - "name": "entry_desc", - "value": "description" - }, - { - "name": "MainAbility_desc", - "value": "description" - }, - { - "name": "MainAbility_label", - "value": "label" - } - ] +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/entry/src/main/resources/base/profile/main_pages.json b/frameworks/com.ohos.permissionmanager/entry/src/main/resources/base/profile/main_pages.json index feec276e105eeb8d621c20aaf838f318b0a94150..50b961efe7eba3554818d73178d6c4aa735bcd16 100644 --- a/frameworks/com.ohos.permissionmanager/entry/src/main/resources/base/profile/main_pages.json +++ b/frameworks/com.ohos.permissionmanager/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,5 @@ -{ - "src": [ - "pages/index" - ] -} +{ + "src": [ + "pages/index" + ] +} diff --git a/frameworks/com.ohos.permissionmanager/hvigorfile.js b/frameworks/com.ohos.permissionmanager/hvigorfile.js index 5f2735e3deeaf655828407544bbed9365c258278..586ced98461bdcdac2b070f2e041e99c7ac678d9 100644 --- a/frameworks/com.ohos.permissionmanager/hvigorfile.js +++ b/frameworks/com.ohos.permissionmanager/hvigorfile.js @@ -1,2 +1,2 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/package-lock.json b/frameworks/com.ohos.permissionmanager/package-lock.json index 638b410244d9b7d9adc2c752d9b8741c2149fbab..1f54866aa19a152feb4570f270d2643423eeb295 100644 --- a/frameworks/com.ohos.permissionmanager/package-lock.json +++ b/frameworks/com.ohos.permissionmanager/package-lock.json @@ -1,1643 +1,1643 @@ -{ - "name": "permissionmanager", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@ohos/hvigor": { - "version": "1.0.6", - "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor/-/@ohos/hvigor-1.0.6.tgz", - "integrity": "sha512-jjp7vpvUOMW1Nf7TdyhOtonwWHoSyBJLUiZTQqIx/GJV4UJyIqsiURUOqFwncQ4L7PDdeHuWly4uEelknYeWhg==", - "requires": { - "@ohos/hvigor-base": "1.0.6", - "interpret": "1.4.0", - "liftoff": "4.0.0", - "mute-stdout": "1.0.0", - "pretty-hrtime": "1.0.0", - "v8flags": "3.2.0", - "yargs": "7.1.0" - } - }, - "@ohos/hvigor-base": { - "version": "1.0.6", - "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-base/-/@ohos/hvigor-base-1.0.6.tgz", - "integrity": "sha512-cRDnWICTxmpNiFb9clIioqP5Oik1seLCICztXVhZqultrHuxwTheCRUZrHwlpyWdkSB2Al+FFBqmSwzIgZX4IQ==", - "requires": { - "json5": "2.2.0", - "log4js": "6.4.1", - "undertaker": "1.2.1" - } - }, - "@ohos/hvigor-ohos-plugin": { - "version": "1.0.6", - "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-ohos-plugin/-/@ohos/hvigor-ohos-plugin-1.0.6.tgz", - "integrity": "sha512-MAAi8uJxMzODUoSSNfBr+fU4HQ20dfQtkje9I+X4asc7qY2kAplW/q9f5XS8IOvv8zhC8OcSgsAXOAJuLMstOQ==", - "requires": { - "@ohos/hvigor-base": "1.0.6", - "@ohos/sdkmanager-common": "1.1.3", - "ajv": "8.10.0", - "archiver": "5.3.0", - "execa": "5.1.1", - "fs-extra": "10.0.0", - "glob": "7.2.0", - "iconv-lite": "0.6.3", - "json5": "2.2.0", - "lodash": "4.17.21", - "pretty-hrtime": "1.0.3", - "resolve-package-path": "4.0.3" - }, - "dependencies": { - "fs-extra": { - "version": "10.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.0.0.tgz", - "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "pretty-hrtime": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" - } - } - }, - "@ohos/sdkmanager-common": { - "version": "1.1.3", - "resolved": "https://repo.harmonyos.com/npm/@ohos/sdkmanager-common/-/@ohos/sdkmanager-common-1.1.3.tgz", - "integrity": "sha512-d2uhVauDDJZIUvyyaWWoavG4N/jLyfF5IH5kEXKV6R8HNf3606H1zDQzA+UZtOfwwJFXhD9djRjnVFNB8xc7aw==" - }, - "ajv": { - "version": "8.10.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/ajv/-/ajv-8.10.0.tgz", - "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", - "requires": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "archiver": { - "version": "5.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/archiver/-/archiver-5.3.0.tgz", - "integrity": "sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==", - "requires": { - "archiver-utils": "^2.1.0", - "async": "^3.2.0", - "buffer-crc32": "^0.2.1", - "readable-stream": "^3.6.0", - "readdir-glob": "^1.0.0", - "tar-stream": "^2.2.0", - "zip-stream": "^4.1.0" - } - }, - "archiver-utils": { - "version": "2.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/archiver-utils/-/archiver-utils-2.1.0.tgz", - "integrity": "sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==", - "requires": { - "glob": "^7.1.4", - "graceful-fs": "^4.2.0", - "lazystream": "^1.0.0", - "lodash.defaults": "^4.2.0", - "lodash.difference": "^4.5.0", - "lodash.flatten": "^4.4.0", - "lodash.isplainobject": "^4.0.6", - "lodash.union": "^4.6.0", - "normalize-path": "^3.0.0", - "readable-stream": "^2.0.0" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - } - } - }, - "arr-filter": { - "version": "1.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/arr-filter/-/arr-filter-1.1.2.tgz", - "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", - "requires": { - "make-iterator": "^1.0.0" - } - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" - }, - "arr-map": { - "version": "2.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/arr-map/-/arr-map-2.0.2.tgz", - "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", - "requires": { - "make-iterator": "^1.0.0" - } - }, - "array-each": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/array-each/-/array-each-1.0.1.tgz", - "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=" - }, - "array-initial": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/array-initial/-/array-initial-1.1.0.tgz", - "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", - "requires": { - "array-slice": "^1.0.0", - "is-number": "^4.0.0" - } - }, - "array-last": { - "version": "1.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/array-last/-/array-last-1.3.0.tgz", - "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==", - "requires": { - "is-number": "^4.0.0" - } - }, - "array-slice": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/array-slice/-/array-slice-1.1.0.tgz", - "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==" - }, - "async": { - "version": "3.2.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/async/-/async-3.2.3.tgz", - "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==" - }, - "async-done": { - "version": "1.3.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/async-done/-/async-done-1.3.2.tgz", - "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.2", - "process-nextick-args": "^2.0.0", - "stream-exhaust": "^1.0.1" - } - }, - "async-settle": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/async-settle/-/async-settle-1.0.0.tgz", - "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", - "requires": { - "async-done": "^1.2.2" - } - }, - "bach": { - "version": "1.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/bach/-/bach-1.2.0.tgz", - "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", - "requires": { - "arr-filter": "^1.1.1", - "arr-flatten": "^1.0.1", - "arr-map": "^2.0.0", - "array-each": "^1.0.0", - "array-initial": "^1.0.0", - "array-last": "^1.1.1", - "async-done": "^1.2.2", - "async-settle": "^1.0.0", - "now-and-later": "^2.0.0" - } - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "base64-js": { - "version": "1.5.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" - }, - "bl": { - "version": "4.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "requires": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://repo.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "3.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "requires": { - "fill-range": "^7.0.1" - } - }, - "buffer": { - "version": "5.7.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "buffer-crc32": { - "version": "0.2.13", - "resolved": "https://repo.huaweicloud.com/repository/npm/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" - }, - "call-bind": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - } - }, - "camelcase": { - "version": "3.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" - }, - "cliui": { - "version": "3.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wrap-ansi": "^2.0.0" - } - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" - }, - "collection-map": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/collection-map/-/collection-map-1.0.0.tgz", - "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", - "requires": { - "arr-map": "^2.0.2", - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "compress-commons": { - "version": "4.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/compress-commons/-/compress-commons-4.1.1.tgz", - "integrity": "sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==", - "requires": { - "buffer-crc32": "^0.2.13", - "crc32-stream": "^4.0.2", - "normalize-path": "^3.0.0", - "readable-stream": "^3.6.0" - } - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "core-util-is": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" - }, - "crc-32": { - "version": "1.2.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/crc-32/-/crc-32-1.2.2.tgz", - "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" - }, - "crc32-stream": { - "version": "4.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/crc32-stream/-/crc32-stream-4.0.2.tgz", - "integrity": "sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==", - "requires": { - "crc-32": "^1.2.0", - "readable-stream": "^3.4.0" - } - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "requires": { - "isexe": "^2.0.0" - } - } - } - }, - "d": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", - "requires": { - "es5-ext": "^0.10.50", - "type": "^1.0.1" - } - }, - "date-format": { - "version": "4.0.6", - "resolved": "https://repo.huaweicloud.com/repository/npm/date-format/-/date-format-4.0.6.tgz", - "integrity": "sha512-B9vvg5rHuQ8cbUXE/RMWMyX2YA5TecT3jKF5fLtGNlzPlU7zblSPmAm2OImDbWL+LDOQ6pUm+4LOFz+ywS41Zw==" - }, - "debug": { - "version": "4.3.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" - }, - "default-resolution": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/default-resolution/-/default-resolution-2.0.0.tgz", - "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=" - }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "requires": { - "object-keys": "^1.0.12" - } - }, - "detect-file": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=" - }, - "end-of-stream": { - "version": "1.4.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "requires": { - "once": "^1.4.0" - } - }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "requires": { - "is-arrayish": "^0.2.1" - } - }, - "es5-ext": { - "version": "0.10.59", - "resolved": "https://repo.huaweicloud.com/repository/npm/es5-ext/-/es5-ext-0.10.59.tgz", - "integrity": "sha512-cOgyhW0tIJyQY1Kfw6Kr0viu9ZlUctVchRMZ7R0HiH3dxTSp5zJDLecwxUqPUrGKMsgBI1wd1FL+d9Jxfi4cLw==", - "requires": { - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.3", - "next-tick": "^1.1.0" - } - }, - "es6-iterator": { - "version": "2.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "requires": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "es6-symbol": { - "version": "3.1.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/es6-symbol/-/es6-symbol-3.1.3.tgz", - "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", - "requires": { - "d": "^1.0.1", - "ext": "^1.1.2" - } - }, - "es6-weak-map": { - "version": "2.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/es6-weak-map/-/es6-weak-map-2.0.3.tgz", - "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", - "requires": { - "d": "1", - "es5-ext": "^0.10.46", - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.1" - } - }, - "execa": { - "version": "5.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "requires": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - } - }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "ext": { - "version": "1.6.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/ext/-/ext-1.6.0.tgz", - "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", - "requires": { - "type": "^2.5.0" - }, - "dependencies": { - "type": { - "version": "2.6.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/type/-/type-2.6.0.tgz", - "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==" - } - } - }, - "extend": { - "version": "3.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "find-up": { - "version": "1.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "findup-sync": { - "version": "5.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/findup-sync/-/findup-sync-5.0.0.tgz", - "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.3", - "micromatch": "^4.0.4", - "resolve-dir": "^1.0.1" - } - }, - "fined": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/fined/-/fined-2.0.0.tgz", - "integrity": "sha512-OFRzsL6ZMHz5s0JrsEr+TpdGNCtrVtnuG3x1yzGNiQHT0yaDnXAj8V/lWcpJVrnoDpcwXcASxAZYbuXda2Y82A==", - "requires": { - "expand-tilde": "^2.0.2", - "is-plain-object": "^5.0.0", - "object.defaults": "^1.1.0", - "object.pick": "^1.3.0", - "parse-filepath": "^1.0.2" - } - }, - "flagged-respawn": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/flagged-respawn/-/flagged-respawn-2.0.0.tgz", - "integrity": "sha512-Gq/a6YCi8zexmGHMuJwahTGzXlAZAOsbCVKduWXC6TlLCjjFRlExMJc4GC2NYPYZ0r/brw9P7CpRgQmlPVeOoA==" - }, - "flatted": { - "version": "3.2.5", - "resolved": "https://repo.huaweicloud.com/repository/npm/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==" - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" - }, - "for-own": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/for-own/-/for-own-1.0.0.tgz", - "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", - "requires": { - "for-in": "^1.0.1" - } - }, - "fs-constants": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" - }, - "fs-extra": { - "version": "10.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" - }, - "get-caller-file": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" - }, - "get-intrinsic": { - "version": "1.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "requires": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1" - } - }, - "get-stream": { - "version": "6.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" - }, - "glob": { - "version": "7.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "global-modules": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, - "graceful-fs": { - "version": "4.2.9", - "resolved": "https://repo.huaweicloud.com/repository/npm/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" - }, - "has": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-symbols": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" - }, - "homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "requires": { - "parse-passwd": "^1.0.0" - } - }, - "hosted-git-info": { - "version": "2.8.9", - "resolved": "https://repo.huaweicloud.com/repository/npm/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==" - }, - "human-signals": { - "version": "2.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" - }, - "hypium": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/hypium/-/hypium-1.0.0.tgz", - "integrity": "sha512-nl+RQVv2AU/5FvFRhsXyWO5wh+2huhdqRZ3bszBWZzW+kpNI3AT4ydvVRYIfaQbYwV4UlX/rSc7BtFjLAezhow==" - }, - "iconv-lite": { - "version": "0.6.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } - }, - "ieee754": { - "version": "1.2.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://repo.huaweicloud.com/repository/npm/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "ini": { - "version": "1.3.8", - "resolved": "https://repo.huaweicloud.com/repository/npm/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" - }, - "interpret": { - "version": "1.4.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" - }, - "invert-kv": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" - }, - "is-absolute": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-absolute/-/is-absolute-1.0.0.tgz", - "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", - "requires": { - "is-relative": "^1.0.0", - "is-windows": "^1.0.1" - } - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" - }, - "is-core-module": { - "version": "2.8.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "requires": { - "has": "^1.0.3" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "4.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==" - }, - "is-plain-object": { - "version": "5.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-plain-object/-/is-plain-object-5.0.0.tgz", - "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" - }, - "is-relative": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-relative/-/is-relative-1.0.0.tgz", - "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", - "requires": { - "is-unc-path": "^1.0.0" - } - }, - "is-stream": { - "version": "2.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" - }, - "is-unc-path": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-unc-path/-/is-unc-path-1.0.0.tgz", - "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", - "requires": { - "unc-path-regex": "^0.1.2" - } - }, - "is-utf8": { - "version": "0.2.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - }, - "json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "json5": { - "version": "2.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "requires": { - "minimist": "^1.2.5" - } - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "kind-of": { - "version": "6.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" - }, - "last-run": { - "version": "1.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/last-run/-/last-run-1.1.1.tgz", - "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", - "requires": { - "default-resolution": "^2.0.0", - "es6-weak-map": "^2.0.1" - } - }, - "lazystream": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/lazystream/-/lazystream-1.0.1.tgz", - "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==", - "requires": { - "readable-stream": "^2.0.5" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - } - } - }, - "lcid": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "requires": { - "invert-kv": "^1.0.0" - } - }, - "liftoff": { - "version": "4.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/liftoff/-/liftoff-4.0.0.tgz", - "integrity": "sha512-rMGwYF8q7g2XhG2ulBmmJgWv25qBsqRbDn5gH0+wnuyeFt7QBJlHJmtg5qEdn4pN6WVAUMgXnIxytMFRX9c1aA==", - "requires": { - "extend": "^3.0.2", - "findup-sync": "^5.0.0", - "fined": "^2.0.0", - "flagged-respawn": "^2.0.0", - "is-plain-object": "^5.0.0", - "object.map": "^1.0.1", - "rechoir": "^0.8.0", - "resolve": "^1.20.0" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://repo.huaweicloud.com/repository/npm/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "lodash.defaults": { - "version": "4.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.defaults/-/lodash.defaults-4.2.0.tgz", - "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" - }, - "lodash.difference": { - "version": "4.5.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.difference/-/lodash.difference-4.5.0.tgz", - "integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=" - }, - "lodash.flatten": { - "version": "4.4.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.flatten/-/lodash.flatten-4.4.0.tgz", - "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" - }, - "lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" - }, - "lodash.union": { - "version": "4.6.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.union/-/lodash.union-4.6.0.tgz", - "integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=" - }, - "log4js": { - "version": "6.4.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/log4js/-/log4js-6.4.1.tgz", - "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==", - "requires": { - "date-format": "^4.0.3", - "debug": "^4.3.3", - "flatted": "^3.2.4", - "rfdc": "^1.3.0", - "streamroller": "^3.0.2" - } - }, - "make-iterator": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/make-iterator/-/make-iterator-1.0.1.tgz", - "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", - "requires": { - "kind-of": "^6.0.2" - } - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=" - }, - "merge-stream": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" - }, - "micromatch": { - "version": "4.0.5", - "resolved": "https://repo.huaweicloud.com/repository/npm/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "requires": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - } - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.6", - "resolved": "https://repo.huaweicloud.com/repository/npm/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" - }, - "ms": { - "version": "2.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "mute-stdout": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/mute-stdout/-/mute-stdout-1.0.0.tgz", - "integrity": "sha1-WzLqB+tDyd7WEwQ0z5JvRrKn/U0=" - }, - "next-tick": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" - }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" - }, - "now-and-later": { - "version": "2.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/now-and-later/-/now-and-later-2.0.1.tgz", - "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", - "requires": { - "once": "^1.3.2" - } - }, - "npm-run-path": { - "version": "4.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "requires": { - "path-key": "^3.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } - }, - "object.defaults": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/object.defaults/-/object.defaults-1.1.0.tgz", - "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", - "requires": { - "array-each": "^1.0.1", - "array-slice": "^1.0.0", - "for-own": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "object.map": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/object.map/-/object.map-1.0.1.tgz", - "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", - "requires": { - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "requires": { - "isobject": "^3.0.1" - } - }, - "object.reduce": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/object.reduce/-/object.reduce-1.0.1.tgz", - "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", - "requires": { - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "onetime": { - "version": "5.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "os-locale": { - "version": "1.4.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", - "requires": { - "lcid": "^1.0.0" - } - }, - "parse-filepath": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/parse-filepath/-/parse-filepath-1.0.2.tgz", - "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", - "requires": { - "is-absolute": "^1.0.0", - "map-cache": "^0.2.0", - "path-root": "^0.1.1" - } - }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "requires": { - "error-ex": "^1.2.0" - } - }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" - }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" - }, - "path-root": { - "version": "0.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-root/-/path-root-0.1.1.tgz", - "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", - "requires": { - "path-root-regex": "^0.1.0" - } - }, - "path-root-regex": { - "version": "0.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-root-regex/-/path-root-regex-0.1.2.tgz", - "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=" - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" - }, - "pify": { - "version": "2.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "requires": { - "pinkie": "^2.0.0" - } - }, - "pretty-hrtime": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.0.tgz", - "integrity": "sha1-9ualItPmBwRSK/Db5oVu0g515Nw=" - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "readdir-glob": { - "version": "1.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/readdir-glob/-/readdir-glob-1.1.1.tgz", - "integrity": "sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==", - "requires": { - "minimatch": "^3.0.4" - } - }, - "rechoir": { - "version": "0.8.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/rechoir/-/rechoir-0.8.0.tgz", - "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", - "requires": { - "resolve": "^1.20.0" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" - }, - "resolve": { - "version": "1.22.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "requires": { - "is-core-module": "^2.8.1", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", - "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" - } - }, - "resolve-package-path": { - "version": "4.0.3", - "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-package-path/-/resolve-package-path-4.0.3.tgz", - "integrity": "sha512-SRpNAPW4kewOaNUt8VPqhJ0UMxawMwzJD8V7m1cJfdSTK9ieZwS6K7Dabsm4bmLFM96Z5Y/UznrpG5kt1im8yA==", - "requires": { - "path-root": "^0.1.1" - } - }, - "rfdc": { - "version": "1.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/rfdc/-/rfdc-1.3.0.tgz", - "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "semver": { - "version": "5.7.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" - }, - "signal-exit": { - "version": "3.0.7", - "resolved": "https://repo.huaweicloud.com/repository/npm/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" - }, - "spdx-correct": { - "version": "3.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-correct/-/spdx-correct-3.1.1.tgz", - "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-exceptions": { - "version": "2.3.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==" - }, - "spdx-expression-parse": { - "version": "3.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", - "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-license-ids": { - "version": "3.0.11", - "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", - "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==" - }, - "stream-exhaust": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/stream-exhaust/-/stream-exhaust-1.0.2.tgz", - "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==" - }, - "streamroller": { - "version": "3.0.6", - "resolved": "https://repo.huaweicloud.com/repository/npm/streamroller/-/streamroller-3.0.6.tgz", - "integrity": "sha512-Qz32plKq/MZywYyhEatxyYc8vs994Gz0Hu2MSYXXLD233UyPeIeRBZARIIGwFer4Mdb8r3Y2UqKkgyDghM6QCg==", - "requires": { - "date-format": "^4.0.6", - "debug": "^4.3.4", - "fs-extra": "^10.0.1" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "requires": { - "is-utf8": "^0.2.0" - } - }, - "strip-final-newline": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" - }, - "supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" - }, - "tar-stream": { - "version": "2.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "requires": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "requires": { - "is-number": "^7.0.0" - }, - "dependencies": { - "is-number": { - "version": "7.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" - } - } - }, - "type": { - "version": "1.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" - }, - "unc-path-regex": { - "version": "0.1.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" - }, - "undertaker": { - "version": "1.2.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/undertaker/-/undertaker-1.2.1.tgz", - "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", - "requires": { - "arr-flatten": "^1.0.1", - "arr-map": "^2.0.0", - "bach": "^1.0.0", - "collection-map": "^1.0.0", - "es6-weak-map": "^2.0.1", - "last-run": "^1.1.0", - "object.defaults": "^1.0.0", - "object.reduce": "^1.0.0", - "undertaker-registry": "^1.0.0" - } - }, - "undertaker-registry": { - "version": "1.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/undertaker-registry/-/undertaker-registry-1.0.1.tgz", - "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=" - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "requires": { - "punycode": "^2.1.0" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "v8flags": { - "version": "3.2.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/v8flags/-/v8flags-3.2.0.tgz", - "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "validate-npm-package-license": { - "version": "3.0.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "which": { - "version": "1.3.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "1.0.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/which-module/-/which-module-1.0.0.tgz", - "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=" - }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "y18n": { - "version": "3.2.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/y18n/-/y18n-3.2.2.tgz", - "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==" - }, - "yargs": { - "version": "7.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/yargs/-/yargs-7.1.0.tgz", - "integrity": "sha1-a6MY6xaWFyf10oT46gA+jWFU0Mg=", - "requires": { - "camelcase": "^3.0.0", - "cliui": "^3.2.0", - "decamelize": "^1.1.1", - "get-caller-file": "^1.0.1", - "os-locale": "^1.4.0", - "read-pkg-up": "^1.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^1.0.2", - "which-module": "^1.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^5.0.0" - } - }, - "yargs-parser": { - "version": "5.0.1", - "resolved": "https://repo.huaweicloud.com/repository/npm/yargs-parser/-/yargs-parser-5.0.1.tgz", - "integrity": "sha512-wpav5XYiddjXxirPoCTUPbqM0PXvJ9hiBMvuJgInvo4/lAOTZzUprArw17q2O1P2+GHhbBr18/iQwjL5Z9BqfA==", - "requires": { - "camelcase": "^3.0.0", - "object.assign": "^4.1.0" - } - }, - "zip-stream": { - "version": "4.1.0", - "resolved": "https://repo.huaweicloud.com/repository/npm/zip-stream/-/zip-stream-4.1.0.tgz", - "integrity": "sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==", - "requires": { - "archiver-utils": "^2.1.0", - "compress-commons": "^4.1.0", - "readable-stream": "^3.6.0" - } - } - } -} +{ + "name": "permissionmanager", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@ohos/hvigor": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor/-/@ohos/hvigor-1.0.6.tgz", + "integrity": "sha512-jjp7vpvUOMW1Nf7TdyhOtonwWHoSyBJLUiZTQqIx/GJV4UJyIqsiURUOqFwncQ4L7PDdeHuWly4uEelknYeWhg==", + "requires": { + "@ohos/hvigor-base": "1.0.6", + "interpret": "1.4.0", + "liftoff": "4.0.0", + "mute-stdout": "1.0.0", + "pretty-hrtime": "1.0.0", + "v8flags": "3.2.0", + "yargs": "7.1.0" + } + }, + "@ohos/hvigor-base": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-base/-/@ohos/hvigor-base-1.0.6.tgz", + "integrity": "sha512-cRDnWICTxmpNiFb9clIioqP5Oik1seLCICztXVhZqultrHuxwTheCRUZrHwlpyWdkSB2Al+FFBqmSwzIgZX4IQ==", + "requires": { + "json5": "2.2.0", + "log4js": "6.4.1", + "undertaker": "1.2.1" + } + }, + "@ohos/hvigor-ohos-plugin": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-ohos-plugin/-/@ohos/hvigor-ohos-plugin-1.0.6.tgz", + "integrity": "sha512-MAAi8uJxMzODUoSSNfBr+fU4HQ20dfQtkje9I+X4asc7qY2kAplW/q9f5XS8IOvv8zhC8OcSgsAXOAJuLMstOQ==", + "requires": { + "@ohos/hvigor-base": "1.0.6", + "@ohos/sdkmanager-common": "1.1.3", + "ajv": "8.10.0", + "archiver": "5.3.0", + "execa": "5.1.1", + "fs-extra": "10.0.0", + "glob": "7.2.0", + "iconv-lite": "0.6.3", + "json5": "2.2.0", + "lodash": "4.17.21", + "pretty-hrtime": "1.0.3", + "resolve-package-path": "4.0.3" + }, + "dependencies": { + "fs-extra": { + "version": "10.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "pretty-hrtime": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" + } + } + }, + "@ohos/sdkmanager-common": { + "version": "1.1.3", + "resolved": "https://repo.harmonyos.com/npm/@ohos/sdkmanager-common/-/@ohos/sdkmanager-common-1.1.3.tgz", + "integrity": "sha512-d2uhVauDDJZIUvyyaWWoavG4N/jLyfF5IH5kEXKV6R8HNf3606H1zDQzA+UZtOfwwJFXhD9djRjnVFNB8xc7aw==" + }, + "ajv": { + "version": "8.10.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ajv/-/ajv-8.10.0.tgz", + "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "archiver": { + "version": "5.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/archiver/-/archiver-5.3.0.tgz", + "integrity": "sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==", + "requires": { + "archiver-utils": "^2.1.0", + "async": "^3.2.0", + "buffer-crc32": "^0.2.1", + "readable-stream": "^3.6.0", + "readdir-glob": "^1.0.0", + "tar-stream": "^2.2.0", + "zip-stream": "^4.1.0" + } + }, + "archiver-utils": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/archiver-utils/-/archiver-utils-2.1.0.tgz", + "integrity": "sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==", + "requires": { + "glob": "^7.1.4", + "graceful-fs": "^4.2.0", + "lazystream": "^1.0.0", + "lodash.defaults": "^4.2.0", + "lodash.difference": "^4.5.0", + "lodash.flatten": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.union": "^4.6.0", + "normalize-path": "^3.0.0", + "readable-stream": "^2.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + } + } + }, + "arr-filter": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-filter/-/arr-filter-1.1.2.tgz", + "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", + "requires": { + "make-iterator": "^1.0.0" + } + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" + }, + "arr-map": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-map/-/arr-map-2.0.2.tgz", + "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", + "requires": { + "make-iterator": "^1.0.0" + } + }, + "array-each": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-each/-/array-each-1.0.1.tgz", + "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=" + }, + "array-initial": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-initial/-/array-initial-1.1.0.tgz", + "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", + "requires": { + "array-slice": "^1.0.0", + "is-number": "^4.0.0" + } + }, + "array-last": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-last/-/array-last-1.3.0.tgz", + "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==", + "requires": { + "is-number": "^4.0.0" + } + }, + "array-slice": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-slice/-/array-slice-1.1.0.tgz", + "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==" + }, + "async": { + "version": "3.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==" + }, + "async-done": { + "version": "1.3.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/async-done/-/async-done-1.3.2.tgz", + "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.2", + "process-nextick-args": "^2.0.0", + "stream-exhaust": "^1.0.1" + } + }, + "async-settle": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/async-settle/-/async-settle-1.0.0.tgz", + "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", + "requires": { + "async-done": "^1.2.2" + } + }, + "bach": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/bach/-/bach-1.2.0.tgz", + "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", + "requires": { + "arr-filter": "^1.1.1", + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "array-each": "^1.0.0", + "array-initial": "^1.0.0", + "array-last": "^1.1.1", + "async-done": "^1.2.2", + "async-settle": "^1.0.0", + "now-and-later": "^2.0.0" + } + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, + "bl": { + "version": "4.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://repo.huaweicloud.com/repository/npm/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "camelcase": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "collection-map": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/collection-map/-/collection-map-1.0.0.tgz", + "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", + "requires": { + "arr-map": "^2.0.2", + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "compress-commons": { + "version": "4.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/compress-commons/-/compress-commons-4.1.1.tgz", + "integrity": "sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==", + "requires": { + "buffer-crc32": "^0.2.13", + "crc32-stream": "^4.0.2", + "normalize-path": "^3.0.0", + "readable-stream": "^3.6.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, + "crc-32": { + "version": "1.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" + }, + "crc32-stream": { + "version": "4.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/crc32-stream/-/crc32-stream-4.0.2.tgz", + "integrity": "sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==", + "requires": { + "crc-32": "^1.2.0", + "readable-stream": "^3.4.0" + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "dependencies": { + "which": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "d": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "date-format": { + "version": "4.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/date-format/-/date-format-4.0.6.tgz", + "integrity": "sha512-B9vvg5rHuQ8cbUXE/RMWMyX2YA5TecT3jKF5fLtGNlzPlU7zblSPmAm2OImDbWL+LDOQ6pUm+4LOFz+ywS41Zw==" + }, + "debug": { + "version": "4.3.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, + "default-resolution": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/default-resolution/-/default-resolution-2.0.0.tgz", + "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=" + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "requires": { + "object-keys": "^1.0.12" + } + }, + "detect-file": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es5-ext": { + "version": "0.10.59", + "resolved": "https://repo.huaweicloud.com/repository/npm/es5-ext/-/es5-ext-0.10.59.tgz", + "integrity": "sha512-cOgyhW0tIJyQY1Kfw6Kr0viu9ZlUctVchRMZ7R0HiH3dxTSp5zJDLecwxUqPUrGKMsgBI1wd1FL+d9Jxfi4cLw==", + "requires": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "es6-weak-map": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "requires": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "execa": { + "version": "5.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + } + }, + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "ext": { + "version": "1.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ext/-/ext-1.6.0.tgz", + "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", + "requires": { + "type": "^2.5.0" + }, + "dependencies": { + "type": { + "version": "2.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/type/-/type-2.6.0.tgz", + "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==" + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "requires": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "findup-sync": { + "version": "5.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/findup-sync/-/findup-sync-5.0.0.tgz", + "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.3", + "micromatch": "^4.0.4", + "resolve-dir": "^1.0.1" + } + }, + "fined": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fined/-/fined-2.0.0.tgz", + "integrity": "sha512-OFRzsL6ZMHz5s0JrsEr+TpdGNCtrVtnuG3x1yzGNiQHT0yaDnXAj8V/lWcpJVrnoDpcwXcASxAZYbuXda2Y82A==", + "requires": { + "expand-tilde": "^2.0.2", + "is-plain-object": "^5.0.0", + "object.defaults": "^1.1.0", + "object.pick": "^1.3.0", + "parse-filepath": "^1.0.2" + } + }, + "flagged-respawn": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/flagged-respawn/-/flagged-respawn-2.0.0.tgz", + "integrity": "sha512-Gq/a6YCi8zexmGHMuJwahTGzXlAZAOsbCVKduWXC6TlLCjjFRlExMJc4GC2NYPYZ0r/brw9P7CpRgQmlPVeOoA==" + }, + "flatted": { + "version": "3.2.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/flatted/-/flatted-3.2.5.tgz", + "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==" + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" + }, + "for-own": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "requires": { + "for-in": "^1.0.1" + } + }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "fs-extra": { + "version": "10.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.0.1.tgz", + "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, + "get-stream": { + "version": "6.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" + }, + "glob": { + "version": "7.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "global-modules": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + }, + "global-prefix": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "requires": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + } + }, + "graceful-fs": { + "version": "4.2.9", + "resolved": "https://repo.huaweicloud.com/repository/npm/graceful-fs/-/graceful-fs-4.2.9.tgz", + "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" + }, + "has": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-symbols": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" + }, + "homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://repo.huaweicloud.com/repository/npm/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==" + }, + "human-signals": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" + }, + "hypium": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/hypium/-/hypium-1.0.0.tgz", + "integrity": "sha512-nl+RQVv2AU/5FvFRhsXyWO5wh+2huhdqRZ3bszBWZzW+kpNI3AT4ydvVRYIfaQbYwV4UlX/rSc7BtFjLAezhow==" + }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ini": { + "version": "1.3.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, + "interpret": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + }, + "is-absolute": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "requires": { + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" + }, + "is-core-module": { + "version": "2.8.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-core-module/-/is-core-module-2.8.1.tgz", + "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==" + }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "is-relative": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "requires": { + "is-unc-path": "^1.0.0" + } + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" + }, + "is-unc-path": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "requires": { + "unc-path-regex": "^0.1.2" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "json5": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "requires": { + "minimist": "^1.2.5" + } + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" + }, + "last-run": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/last-run/-/last-run-1.1.1.tgz", + "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", + "requires": { + "default-resolution": "^2.0.0", + "es6-weak-map": "^2.0.1" + } + }, + "lazystream": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/lazystream/-/lazystream-1.0.1.tgz", + "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==", + "requires": { + "readable-stream": "^2.0.5" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + } + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "requires": { + "invert-kv": "^1.0.0" + } + }, + "liftoff": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/liftoff/-/liftoff-4.0.0.tgz", + "integrity": "sha512-rMGwYF8q7g2XhG2ulBmmJgWv25qBsqRbDn5gH0+wnuyeFt7QBJlHJmtg5qEdn4pN6WVAUMgXnIxytMFRX9c1aA==", + "requires": { + "extend": "^3.0.2", + "findup-sync": "^5.0.0", + "fined": "^2.0.0", + "flagged-respawn": "^2.0.0", + "is-plain-object": "^5.0.0", + "object.map": "^1.0.1", + "rechoir": "^0.8.0", + "resolve": "^1.20.0" + } + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lodash.defaults": { + "version": "4.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" + }, + "lodash.difference": { + "version": "4.5.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.difference/-/lodash.difference-4.5.0.tgz", + "integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=" + }, + "lodash.flatten": { + "version": "4.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.flatten/-/lodash.flatten-4.4.0.tgz", + "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "lodash.union": { + "version": "4.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.union/-/lodash.union-4.6.0.tgz", + "integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=" + }, + "log4js": { + "version": "6.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/log4js/-/log4js-6.4.1.tgz", + "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==", + "requires": { + "date-format": "^4.0.3", + "debug": "^4.3.3", + "flatted": "^3.2.4", + "rfdc": "^1.3.0", + "streamroller": "^3.0.2" + } + }, + "make-iterator": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/make-iterator/-/make-iterator-1.0.1.tgz", + "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", + "requires": { + "kind-of": "^6.0.2" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=" + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "mute-stdout": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/mute-stdout/-/mute-stdout-1.0.0.tgz", + "integrity": "sha1-WzLqB+tDyd7WEwQ0z5JvRrKn/U0=" + }, + "next-tick": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "now-and-later": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/now-and-later/-/now-and-later-2.0.1.tgz", + "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", + "requires": { + "once": "^1.3.2" + } + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "requires": { + "path-key": "^3.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" + } + }, + "object.defaults": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.defaults/-/object.defaults-1.1.0.tgz", + "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", + "requires": { + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "object.map": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.map/-/object.map-1.0.1.tgz", + "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "requires": { + "isobject": "^3.0.1" + } + }, + "object.reduce": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.reduce/-/object.reduce-1.0.1.tgz", + "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "requires": { + "lcid": "^1.0.0" + } + }, + "parse-filepath": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", + "requires": { + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "requires": { + "error-ex": "^1.2.0" + } + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "requires": { + "pinkie-promise": "^2.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "path-root": { + "version": "0.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "requires": { + "path-root-regex": "^0.1.0" + } + }, + "path-root-regex": { + "version": "0.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=" + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "requires": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + }, + "pify": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "^2.0.0" + } + }, + "pretty-hrtime": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.0.tgz", + "integrity": "sha1-9ualItPmBwRSK/Db5oVu0g515Nw=" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "requires": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "requires": { + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "readdir-glob": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/readdir-glob/-/readdir-glob-1.1.1.tgz", + "integrity": "sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==", + "requires": { + "minimatch": "^3.0.4" + } + }, + "rechoir": { + "version": "0.8.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/rechoir/-/rechoir-0.8.0.tgz", + "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", + "requires": { + "resolve": "^1.20.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" + }, + "resolve": { + "version": "1.22.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve/-/resolve-1.22.0.tgz", + "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "requires": { + "is-core-module": "^2.8.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "resolve-dir": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "requires": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + } + }, + "resolve-package-path": { + "version": "4.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-package-path/-/resolve-package-path-4.0.3.tgz", + "integrity": "sha512-SRpNAPW4kewOaNUt8VPqhJ0UMxawMwzJD8V7m1cJfdSTK9ieZwS6K7Dabsm4bmLFM96Z5Y/UznrpG5kt1im8yA==", + "requires": { + "path-root": "^0.1.1" + } + }, + "rfdc": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "signal-exit": { + "version": "3.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "spdx-correct": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==" + }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", + "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==" + }, + "stream-exhaust": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/stream-exhaust/-/stream-exhaust-1.0.2.tgz", + "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==" + }, + "streamroller": { + "version": "3.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/streamroller/-/streamroller-3.0.6.tgz", + "integrity": "sha512-Qz32plKq/MZywYyhEatxyYc8vs994Gz0Hu2MSYXXLD233UyPeIeRBZARIIGwFer4Mdb8r3Y2UqKkgyDghM6QCg==", + "requires": { + "date-format": "^4.0.6", + "debug": "^4.3.4", + "fs-extra": "^10.0.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "requires": { + "is-utf8": "^0.2.0" + } + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + }, + "dependencies": { + "is-number": { + "version": "7.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + } + } + }, + "type": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" + }, + "undertaker": { + "version": "1.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/undertaker/-/undertaker-1.2.1.tgz", + "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", + "requires": { + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "bach": "^1.0.0", + "collection-map": "^1.0.0", + "es6-weak-map": "^2.0.1", + "last-run": "^1.1.0", + "object.defaults": "^1.0.0", + "object.reduce": "^1.0.0", + "undertaker-registry": "^1.0.0" + } + }, + "undertaker-registry": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/undertaker-registry/-/undertaker-registry-1.0.1.tgz", + "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=" + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "v8flags": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/v8flags/-/v8flags-3.2.0.tgz", + "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=" + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "y18n": { + "version": "3.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/y18n/-/y18n-3.2.2.tgz", + "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==" + }, + "yargs": { + "version": "7.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/yargs/-/yargs-7.1.0.tgz", + "integrity": "sha1-a6MY6xaWFyf10oT46gA+jWFU0Mg=", + "requires": { + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^5.0.0" + } + }, + "yargs-parser": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/yargs-parser/-/yargs-parser-5.0.1.tgz", + "integrity": "sha512-wpav5XYiddjXxirPoCTUPbqM0PXvJ9hiBMvuJgInvo4/lAOTZzUprArw17q2O1P2+GHhbBr18/iQwjL5Z9BqfA==", + "requires": { + "camelcase": "^3.0.0", + "object.assign": "^4.1.0" + } + }, + "zip-stream": { + "version": "4.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/zip-stream/-/zip-stream-4.1.0.tgz", + "integrity": "sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==", + "requires": { + "archiver-utils": "^2.1.0", + "compress-commons": "^4.1.0", + "readable-stream": "^3.6.0" + } + } + } +} diff --git a/frameworks/com.ohos.permissionmanager/package.json b/frameworks/com.ohos.permissionmanager/package.json index eff7afc86f02b7523b2a155f4c5c8198841011dd..e0cb99de987961be04f5d01d0b57db79120adaa9 100644 --- a/frameworks/com.ohos.permissionmanager/package.json +++ b/frameworks/com.ohos.permissionmanager/package.json @@ -1,18 +1,18 @@ -{ - "license":"ISC", - "devDependencies":{}, - "name":"permissionmanager", - "ohos":{ - "org":"huawei", - "directoryLevel":"project", - "buildTool":"hvigor" - }, - "description":"example description", - "repository":{}, - "version":"1.0.0", - "dependencies":{ - "@ohos/hvigor-ohos-plugin":"1.0.6", - "hypium":"^1.0.0", - "@ohos/hvigor":"1.0.6" - } +{ + "license":"ISC", + "devDependencies":{}, + "name":"permissionmanager", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" + }, + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/hvigor-ohos-plugin":"1.0.6", + "hypium":"^1.0.0", + "@ohos/hvigor":"1.0.6" + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/.gitignore b/frameworks/com.ohos.permissionmanager/permissionmanager/.gitignore index 4f9a973815d0b5e49bc8547681a6b4bc7a178d12..16ad22851d8b327b59cf74d965ddae2598a56e11 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/.gitignore +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/.gitignore @@ -1,3 +1,3 @@ -/node_modules -/.preview +/node_modules +/.preview /build \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/build-profile.json5 b/frameworks/com.ohos.permissionmanager/permissionmanager/build-profile.json5 index 8d4191ee3893b90de4b15ff67cfce2e295b0609f..e4f8a47c03ef66b1bf9200814c5475fecbe6c25e 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/build-profile.json5 +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/build-profile.json5 @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "apiType": 'stageMode', - "buildOption": { - }, - "targets": [ - { - "name": "default", - }, - { - "name": "ohosTest", - } - ] +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/hvigorfile.js b/frameworks/com.ohos.permissionmanager/permissionmanager/hvigorfile.js index d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c..fda93c709ee47976559e87a7d0c5c47ea7d5dd5c 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/hvigorfile.js +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/hvigorfile.js @@ -1,2 +1,2 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/package-lock.json b/frameworks/com.ohos.permissionmanager/permissionmanager/package-lock.json index af634257bf3cf5c0ebedba056385bf0128ec7623..62d37a750fec9d2f36caa72b1a3326bd9144769f 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/package-lock.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/package-lock.json @@ -1,5 +1,5 @@ -{ - "name": "permissionmanager", - "version": "1.0.0", - "lockfileVersion": 1 -} +{ + "name": "permissionmanager", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/package.json b/frameworks/com.ohos.permissionmanager/permissionmanager/package.json index 980ccad2bde65ef3e13f50d37b9c6b8a3db99915..983c48aafa7e41fe0e586518ec78f7872abcc3fd 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/package.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/package.json @@ -1,14 +1,14 @@ -{ - "license": "ISC", - "devDependencies": {}, - "name": "permissionmanager", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" - }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} +{ + "license": "ISC", + "devDependencies": {}, + "name": "permissionmanager", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/Application/AbilityStage.ts b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/Application/AbilityStage.ts index c5840e536fb35e184dc92643ebfc9955d883353f..4219d854218edb7d81013b5fc6c14c48409b859a 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/Application/AbilityStage.ts +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/Application/AbilityStage.ts @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import AbilityStage from "@ohos.application.AbilityStage" - -var TAG = "PermissionManager_MainAbility:" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log(TAG + "MyAbilityStage onCreate.") - } +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import AbilityStage from "@ohos.application.AbilityStage" + +var TAG = "PermissionManager_MainAbility:" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log(TAG + "MyAbilityStage onCreate.") + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/MainAbility.ts b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/MainAbility.ts index fd4781d8994a80e6069ddf8f28c477aaaa50c152..b5393843d039fb36b411c0903cf4575eedfc838c 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/MainAbility.ts +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/MainAbility/MainAbility.ts @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Ability from '@ohos.application.Ability'; - -var TAG = "PermissionManager_MainAbility:"; - -export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log(TAG + "MainAbility onCreate, ability name is " + want.abilityName + "."); - globalThis.context = this.context; - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log(TAG + "MainAbility onWindowStageCreate."); - - globalThis.context = this.context; - - windowStage.setUIContent(this.context, "pages/authority-management", null); - } - - onForeground() { - // Ability has brought to foreground - console.log(TAG + "MainAbility onForeground."); - } - - onBackground() { - // Ability has back to background - console.log(TAG + "MainAbility onBackground."); - -// this.context.terminateSelf(); - } - - onDestroy() { - console.log(TAG + "MainAbility onDestroy."); - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log(TAG + "MainAbility onWindowStageDestroy."); - } -}; +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability'; + +var TAG = "PermissionManager_MainAbility:"; + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log(TAG + "MainAbility onCreate, ability name is " + want.abilityName + "."); + globalThis.context = this.context; + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log(TAG + "MainAbility onWindowStageCreate."); + + globalThis.context = this.context; + + windowStage.setUIContent(this.context, "pages/authority-management", null); + } + + onForeground() { + // Ability has brought to foreground + console.log(TAG + "MainAbility onForeground."); + } + + onBackground() { + // Ability has back to background + console.log(TAG + "MainAbility onBackground."); + +// this.context.terminateSelf(); + } + + onDestroy() { + console.log(TAG + "MainAbility onDestroy."); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log(TAG + "MainAbility onWindowStageDestroy."); + } +}; diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts index bd3544ad7f8ddd4efd8512fcdcc29ce2dc07a5c8..52b4db3c546df1c4deb1f18155f7988430957b39 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import extension from '@ohos.application.ServiceExtensionAbility'; -import window from '@ohos.window'; -import display from '@ohos.display'; - -var TAG = "PermissionManager_Log:"; -const MAX_WIDTH = 790; -const MAX_HEIGHT = 1100; - -export default class ServiceExtensionAbility extends extension { - /** - * Lifecycle function, called back when a service extension is started for initialization. - */ - onCreate(want) { - console.info(TAG + "ServiceExtensionAbility onCreate, ability name is " + want.abilityName); - - globalThis.extensionContext = this.context; - globalThis.windowNum = 0 - } - - /** - * Lifecycle function, called back when a service extension is started or recall. - */ - onRequest(want, startId) { - globalThis.abilityWant = want - console.info(TAG + "ServiceExtensionAbility onRequest. start id is " + startId); - console.info(TAG + "want: " + JSON.stringify(want)) - - display.getDefaultDisplay().then(dis => { - let navigationBarRect = { - left: (dis.width - MAX_WIDTH)/2, - top: (dis.height - MAX_HEIGHT)/2, - width: MAX_WIDTH, - height: MAX_HEIGHT - } - this.createWindow("permissionDialog" + startId, window.WindowType.TYPE_DIALOG, navigationBarRect) - }) - } - - /** - * Lifecycle function, called back before a service extension is destroyed. - */ - onDestroy() { - console.info(TAG + "ServiceExtensionAbility onDestroy."); - } - - private async createWindow(name: string, windowType: number, rect) { - console.info(TAG + "create window") - try { - const win = await window.create(globalThis.extensionContext, name, windowType) - globalThis.extensionWin = win - await win.bindDialogTarget(globalThis.abilityWant.parameters['ohos.ability.params.token'].value, () => { - win.destroy() - globalThis.windowNum -- - if(globalThis.windowNum == 0) this.context.terminateSelf() - }) - await win.moveTo(rect.left, rect.top) - await win.resetSize(rect.width, rect.height) - await win.loadContent('pages/dialogPlus') - await win.setBackgroundColor('#00000000') - await win.show() - globalThis.windowNum ++ - } catch { - console.info(TAG + "window create failed!") - } - } +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import extension from '@ohos.application.ServiceExtensionAbility'; +import window from '@ohos.window'; +import display from '@ohos.display'; + +var TAG = "PermissionManager_Log:"; +const MAX_WIDTH = 790; +const MAX_HEIGHT = 1100; + +export default class ServiceExtensionAbility extends extension { + /** + * Lifecycle function, called back when a service extension is started for initialization. + */ + onCreate(want) { + console.info(TAG + "ServiceExtensionAbility onCreate, ability name is " + want.abilityName); + + globalThis.extensionContext = this.context; + globalThis.windowNum = 0 + } + + /** + * Lifecycle function, called back when a service extension is started or recall. + */ + onRequest(want, startId) { + globalThis.abilityWant = want + console.info(TAG + "ServiceExtensionAbility onRequest. start id is " + startId); + console.info(TAG + "want: " + JSON.stringify(want)) + + display.getDefaultDisplay().then(dis => { + let navigationBarRect = { + left: (dis.width - MAX_WIDTH)/2, + top: (dis.height - MAX_HEIGHT)/2, + width: MAX_WIDTH, + height: MAX_HEIGHT + } + this.createWindow("permissionDialog" + startId, window.WindowType.TYPE_DIALOG, navigationBarRect) + }) + } + + /** + * Lifecycle function, called back before a service extension is destroyed. + */ + onDestroy() { + console.info(TAG + "ServiceExtensionAbility onDestroy."); + } + + private async createWindow(name: string, windowType: number, rect) { + console.info(TAG + "create window") + try { + const win = await window.create(globalThis.extensionContext, name, windowType) + globalThis.extensionWin = win + await win.bindDialogTarget(globalThis.abilityWant.parameters['ohos.ability.params.token'].value, () => { + win.destroy() + globalThis.windowNum -- + if(globalThis.windowNum == 0) this.context.terminateSelf() + }) + await win.moveTo(rect.left, rect.top) + await win.resetSize(rect.width, rect.height) + await win.loadContent('pages/dialogPlus') + await win.setBackgroundColor('#00000000') + await win.show() + globalThis.windowNum ++ + } catch { + console.info(TAG + "window create failed!") + } + } }; \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/alphabeticalIndex.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/alphabeticalIndex.ets index a8270d1ee12efdd89d161aa4d2e22996c56c815d..faeca72072b5cdb19cb3cc6741d3e87e9ce32be6 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/alphabeticalIndex.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/alphabeticalIndex.ets @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Constants from '../utils/constant'; - -@Component -export struct alphabetIndexerComponent { - private value: string[] = [ - '#', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'G', - 'H', - 'I', - 'J', - 'K', - 'L', - 'M', - 'N', - 'O', - 'P', - 'Q', - 'R', - 'S', - 'T', - 'U', - 'V', - 'W', - 'X', - 'Y', - 'Z' - ]; // Array of alphabetically indexed names - @Link applicationItem: any; // application info array - @Link oldApplicationItem: any; // Original application information array - @State index: number = 0; // alphabetical index - - build() { - AlphabetIndexer({ arrayValue: this.value, selected: this.index }) - .selectedColor($r('app.color.selected_Color')) // selected color - .popupColor($r('app.color.popup_Color')) // popover color - .selectedBackgroundColor($r('app.color.selected_Background_Color')) // Check background color - .popupBackground($r('app.color.popup_Background_Color')) // popover background color - .usingPopup(true) // whether to show a popup - .selectedFont({ size: Constants.ALPHABETINDEXER_SELECTEDFONT_SIZE, weight: FontWeight.Bolder }) // selected style - .popupFont({ size: Constants.ALPHABETINDEXER_POPUPFONT_SIZE, weight: FontWeight.Bolder }) // Demo of the popup - .itemSize(Constants.ALPHABETINDEXER_ITEMSIZE) // size square of each item - .alignStyle(IndexerAlign.Left) // Align left - .onSelected((index: number) => { - this.index = index; - if (this.value[index] === '#' || this.value[index] === '☆') { - this.applicationItem = this.oldApplicationItem; - } else { - this.applicationItem = this.oldApplicationItem.filter((item) => { - return item.alphabeticalIndex.toUpperCase() === this.value[index]; - }) - } - }) - .height(Constants.ALPHABETINDEXER_HEIGHT) - .width(Constants.ALPHABETINDEXER_WIDTH) - } +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Constants from '../utils/constant'; + +@Component +export struct alphabetIndexerComponent { + private value: string[] = [ + '#', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z' + ]; // Array of alphabetically indexed names + @Link applicationItem: any; // application info array + @Link oldApplicationItem: any; // Original application information array + @State index: number = 0; // alphabetical index + + build() { + AlphabetIndexer({ arrayValue: this.value, selected: this.index }) + .selectedColor($r('app.color.selected_Color')) // selected color + .popupColor($r('app.color.popup_Color')) // popover color + .selectedBackgroundColor($r('app.color.selected_Background_Color')) // Check background color + .popupBackground($r('app.color.popup_Background_Color')) // popover background color + .usingPopup(true) // whether to show a popup + .selectedFont({ size: Constants.ALPHABETINDEXER_SELECTEDFONT_SIZE, weight: FontWeight.Bolder }) // selected style + .popupFont({ size: Constants.ALPHABETINDEXER_POPUPFONT_SIZE, weight: FontWeight.Bolder }) // Demo of the popup + .itemSize(Constants.ALPHABETINDEXER_ITEMSIZE) // size square of each item + .alignStyle(IndexerAlign.Left) // Align left + .onSelected((index: number) => { + this.index = index; + if (this.value[index] === '#' || this.value[index] === '☆') { + this.applicationItem = this.oldApplicationItem; + } else { + this.applicationItem = this.oldApplicationItem.filter((item) => { + return item.alphabeticalIndex.toUpperCase() === this.value[index]; + }) + } + }) + .height(Constants.ALPHABETINDEXER_HEIGHT) + .width(Constants.ALPHABETINDEXER_WIDTH) + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/backBar.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/backBar.ets index 8145d91d70bc59cb672b42667540d3cdbb96ac11..7843f1524820e9bb8b5f1b0e4fea87e4dd0aee9b 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/backBar.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/backBar.ets @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import router from '@system.router'; -import Resmgr from '@ohos.resourceManager' -import Constants from '../utils/constant'; - -@Component -export struct backBar { - @Prop title: string; // return title name - @Prop recordable: boolean - @State record: string = '' - - build() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image($r('app.media.left')) - .objectFit(ImageFit.Contain) - .height(Constants.BACKBAR_IMAGE_HEIGHT) - .width(Constants.BACKBAR_IMAGE_WIDTH) - .margin({ - top: Constants.BACKBAR_IMAGE_MARGIN_TOP, - left: Constants.BACKBAR_IMAGE_MARGIN_LEFT, - right: Constants.BACKBAR_IMAGE_MARGIN_RIGHT - }) - .onClick(() => { - var length = router.getLength() - Number(length) == 1 ? globalThis.context.terminateSelf() : router.back() - }) - Text(JSON.parse(this.title)) - .fontColor($r('app.color.text_color')) - .fontSize(Constants.BACKBAR_TEXT_FONT_SIZE) - .flexGrow(Constants.BACKBAR_TEXT_FLEX_GROW) - .fontWeight(FontWeight.Bold) - .margin({ top: Constants.BACKBAR_TEXT_MARGIN_TOP }) - if(this.recordable) { - Image($r("app.media.gongneng_dian")) - .objectFit(ImageFit.Contain) - .height(Constants.BACKBAR_IMAGE_HEIGHT) - .width(Constants.BACKBAR_IMAGE_WIDTH) - .margin({ top: Constants.BACKBAR_TEXT_MARGIN_TOP, right: Constants.BACKBAR_IMAGE_MARGIN_RIGHT }) - .bindMenu([ - { - value: this.record, - action: () => { - router.push({ uri: 'pages/permission-access-record' }) - } - } - ]) - } - } - } - .height(Constants.BACKBAR_HEIGHT) - .constraintSize({ minHeight: Constants.BACKBAR_MINHEIGHT }) - .alignItems(HorizontalAlign.Start) - .backgroundColor($r('app.color.background_color')) - } - - aboutToAppear() { - Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { - item.getString($r("app.string.permission_access_record").id, (err, val) => { - this.record = val - }) - }) - } +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@system.router'; +import Resmgr from '@ohos.resourceManager' +import Constants from '../utils/constant'; + +@Component +export struct backBar { + @Prop title: string; // return title name + @Prop recordable: boolean + @State record: string = '' + + build() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image($r('app.media.left')) + .objectFit(ImageFit.Contain) + .height(Constants.BACKBAR_IMAGE_HEIGHT) + .width(Constants.BACKBAR_IMAGE_WIDTH) + .margin({ + top: Constants.BACKBAR_IMAGE_MARGIN_TOP, + left: Constants.BACKBAR_IMAGE_MARGIN_LEFT, + right: Constants.BACKBAR_IMAGE_MARGIN_RIGHT + }) + .onClick(() => { + var length = router.getLength() + Number(length) == 1 ? globalThis.context.terminateSelf() : router.back() + }) + Text(JSON.parse(this.title)) + .fontColor($r('app.color.text_color')) + .fontSize(Constants.BACKBAR_TEXT_FONT_SIZE) + .flexGrow(Constants.BACKBAR_TEXT_FLEX_GROW) + .fontWeight(FontWeight.Bold) + .margin({ top: Constants.BACKBAR_TEXT_MARGIN_TOP }) + if(this.recordable) { + Image($r("app.media.gongneng_dian")) + .objectFit(ImageFit.Contain) + .height(Constants.BACKBAR_IMAGE_HEIGHT) + .width(Constants.BACKBAR_IMAGE_WIDTH) + .margin({ top: Constants.BACKBAR_TEXT_MARGIN_TOP, right: Constants.BACKBAR_IMAGE_MARGIN_RIGHT }) + .bindMenu([ + { + value: this.record, + action: () => { + router.push({ uri: 'pages/permission-access-record' }) + } + } + ]) + } + } + } + .height(Constants.BACKBAR_HEIGHT) + .constraintSize({ minHeight: Constants.BACKBAR_MINHEIGHT }) + .alignItems(HorizontalAlign.Start) + .backgroundColor($r('app.color.background_color')) + } + + aboutToAppear() { + Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { + item.getString($r("app.string.permission_access_record").id, (err, val) => { + this.record = val + }) + }) + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/dialog.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/dialog.ets index 8e86dd6ab1ad56d5e7c698305ad2f8ea837d2cd5..bea633677a98a939b993e02046dbbcdb8c78e3dc 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/dialog.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/dialog.ets @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Constants from '../utils/constant'; - -@CustomDialog -export struct authorizeDialog { - controller: CustomDialogController; - cancel: () => void; - confirm: () => void; - - build() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Center }) { - Text($r("app.string.Authorization_failed")).fontSize(Constants.DIALOG_TEXT_FONT_SIZE) - .margin({ - top: Constants.DIALOG_TEXT_MARGIN_TOP - }) - } - } - } - .backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.DIALOG_BORDER_RADIUS) - .height(Constants.DIALOG_HEIGHT) - .width(Constants.DIALOG_WIDTH) - } -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Constants from '../utils/constant'; + +@CustomDialog +export struct authorizeDialog { + controller: CustomDialogController; + cancel: () => void; + confirm: () => void; + + build() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Center }) { + Text($r("app.string.Authorization_failed")).fontSize(Constants.DIALOG_TEXT_FONT_SIZE) + .margin({ + top: Constants.DIALOG_TEXT_MARGIN_TOP + }) + } + } + } + .backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.DIALOG_BORDER_RADIUS) + .height(Constants.DIALOG_HEIGHT) + .width(Constants.DIALOG_WIDTH) + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/search.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/search.ets index 72fa15f01bfa0dbac97bf193e78dcf42c5faae38..12b040e6876eab06eda6ab8a0b38bf81f7d7609a 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/search.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/components/search.ets @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Constants from '../utils/constant'; - -@Component -export struct textInput { - @Prop placeholder: string; // Prompt text when no input - @Link applicationItem: any; // application info array - @Link oldApplicationItem: any; // Original application information array - @Link searchResult: boolean; // search results - - build() { - Column() { - Flex({ alignContent: FlexAlign.Start }) { - TextInput({ placeholder: this.placeholder }) - .backgroundColor($r('app.color.default_background_color')) - .padding({ left: Constants.TEXTINPUT_PADDING_LEFT }) - .type(InputType.Normal) - .border({ width: Constants.TEXTINPUT_BORDER_WIDTH, color: $r("app.color.label_color_20"), radius: Constants.TEXTINPUT_BORDER_RADIUS }) - .placeholderColor(Color.Grey) - .placeholderFont({ size: Constants.TEXTINPUT_PLACEHOLDER_Font_SIZE, weight: FontWeight.Normal, family: "sans-serif", style: FontStyle.Normal }) - .caretColor($r('app.color.secondary_font_color')) - .height(Constants.TEXTINPUT_HEIGHT) - .onChange((value: string) => { - if (value === '' || value === null) { - this.applicationItem = this.oldApplicationItem; - } else { - this.applicationItem = this.oldApplicationItem.filter((item) => { - return item.labelId.indexOf(value) > -1; - }) - } - if (this.applicationItem.length) { - this.searchResult = true; - } else { - this.searchResult = false; - } - }) - .onSubmit((enterKey) => { - }) - .onEditChanged((isEditing) => { - }) - Image($r('app.media.search')) - .objectFit(ImageFit.Contain) - .width(Constants.TEXTINPUT_IMAGE_WIDTH) - .height(Constants.TEXTINPUT_IMAGE_HEIGHT) - .position({ x: Constants.TEXTINPUT_IMAGE_MARGIN_LEFT, y: Constants.TEXTINPUT_IMAGE_MARGIN_TOP }) - } - } - } +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Constants from '../utils/constant'; + +@Component +export struct textInput { + @Prop placeholder: string; // Prompt text when no input + @Link applicationItem: any; // application info array + @Link oldApplicationItem: any; // Original application information array + @Link searchResult: boolean; // search results + + build() { + Column() { + Flex({ alignContent: FlexAlign.Start }) { + TextInput({ placeholder: this.placeholder }) + .backgroundColor($r('app.color.default_background_color')) + .padding({ left: Constants.TEXTINPUT_PADDING_LEFT }) + .type(InputType.Normal) + .border({ width: Constants.TEXTINPUT_BORDER_WIDTH, color: $r("app.color.label_color_20"), radius: Constants.TEXTINPUT_BORDER_RADIUS }) + .placeholderColor(Color.Grey) + .placeholderFont({ size: Constants.TEXTINPUT_PLACEHOLDER_Font_SIZE, weight: FontWeight.Normal, family: "sans-serif", style: FontStyle.Normal }) + .caretColor($r('app.color.secondary_font_color')) + .height(Constants.TEXTINPUT_HEIGHT) + .onChange((value: string) => { + if (value === '' || value === null) { + this.applicationItem = this.oldApplicationItem; + } else { + this.applicationItem = this.oldApplicationItem.filter((item) => { + return item.labelId.indexOf(value) > -1; + }) + } + if (this.applicationItem.length) { + this.searchResult = true; + } else { + this.searchResult = false; + } + }) + .onSubmit((enterKey) => { + }) + .onEditChanged((isEditing) => { + }) + Image($r('app.media.search')) + .objectFit(ImageFit.Contain) + .width(Constants.TEXTINPUT_IMAGE_WIDTH) + .height(Constants.TEXTINPUT_IMAGE_HEIGHT) + .position({ x: Constants.TEXTINPUT_IMAGE_MARGIN_LEFT, y: Constants.TEXTINPUT_IMAGE_MARGIN_TOP }) + } + } + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/model/bundle.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/model/bundle.ets index d5f38e35e9918ee78175da6496c42bc6731bfd81..048e97f51ce1ccadc37656c5e60aa23be24127e3 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/model/bundle.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/model/bundle.ets @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const BundleFlag = { - GET_BUNDLE_DEFAULT : 0x00000000, - GET_BUNDLE_WITH_ABILITIES : 0x00000001, - GET_ABILITY_INFO_WITH_PERMISSION : 0x00000002, - GET_ABILITY_INFO_WITH_APPLICATION : 0x00000004, - GET_APPLICATION_INFO_WITH_PERMISSION : 0x00000008, - GET_BUNDLE_WITH_REQUESTED_PERMISSION : 0x00000010, - GET_ALL_APPLICATION_INFO : 0xFFFF0000, - /** - * @since 8 - */ - GET_ABILITY_INFO_WITH_METADATA : 0x00000020, - /** - * @since 8 - */ - GET_APPLICATION_INFO_WITH_METADATA : 0x00000040, - /** - * @since 8 - */ - GET_ABILITY_INFO_SYSTEMAPP_ONLY : 0x00000080 -} - +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const BundleFlag = { + GET_BUNDLE_DEFAULT : 0x00000000, + GET_BUNDLE_WITH_ABILITIES : 0x00000001, + GET_ABILITY_INFO_WITH_PERMISSION : 0x00000002, + GET_ABILITY_INFO_WITH_APPLICATION : 0x00000004, + GET_APPLICATION_INFO_WITH_PERMISSION : 0x00000008, + GET_BUNDLE_WITH_REQUESTED_PERMISSION : 0x00000010, + GET_ALL_APPLICATION_INFO : 0xFFFF0000, + /** + * @since 8 + */ + GET_ABILITY_INFO_WITH_METADATA : 0x00000020, + /** + * @since 8 + */ + GET_APPLICATION_INFO_WITH_METADATA : 0x00000040, + /** + * @since 8 + */ + GET_ABILITY_INFO_SYSTEMAPP_ONLY : 0x00000080 +} + export const USER_ID: number = 100 \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/model/permissionGroup.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/model/permissionGroup.ets index d389c6b59f9cc339205b910b8fc957995fc4ae3f..a7175818a3d2bc690120268536997d6df0136a3a 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/model/permissionGroup.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/model/permissionGroup.ets @@ -1,512 +1,512 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const permissionGroups: any[] = [ - { - "permissionName": "ohos.permission.LOCATION_IN_BACKGROUND", - "groupName": "LOCATION", - "label": "后台定位权限", - "description": "允许应用在后台运行时获取位置信息。", - "groupId": 0 - }, - { - "permissionName": "ohos.permission.LOCATION", - "groupName": "LOCATION", - "label": "前台定位权限", - "description": "允许应用在前台运行时获取位置信息。", - "groupId": 0 - }, - { - "permissionName": "ohos.permission.CAMERA", - "groupName": "CAMERA", - "label": "拍摄照片和录制视频", - "description": "允许应用拍摄照片和视频。", - "groupId": 1 - }, - { - "permissionName": "ohos.permission.MICROPHONE", - "groupName": "MICROPHONE", - "label": "录制音频", - "description": "允许应用打开或关闭录音通路。", - "groupId": 2 - }, - { - "permissionName": "ohos.permission.ANSWER_CALL", - "groupName": "PHONE", - "label": "接听电话", - "description": "允许应用接听电话。", - "groupId": 3 - }, - { - "permissionName": "ohos.permission.MANAGE_VOICEMAIL", - "groupName": "PHONE", - "label": "语音信箱", - "description": "允许应用管理语音信箱。", - "groupId": 3 - }, - { - "permissionName": "ohos.permission.READ_CELL_MESSAGES", - "groupName": "SMS", - "label": "读取小区广播", - "description": "允许应用读取设备接收的小区广播信息。", - "groupId": 4 - }, - { - "permissionName": "ohos.permission.READ_MESSAGES", - "groupName": "SMS", - "label": "读取短彩信", - "description": "允许应用读取设备接收的短彩信信息。", - "groupId": 4 - }, - { - "permissionName": "ohos.permission.RECEIVE_MMS", - "groupName": "SMS", - "label": "接收彩信", - "description": "允许应用接收彩信。", - "groupId": 4 - }, - { - "permissionName": "ohos.permission.RECEIVE_SMS", - "groupName": "SMS", - "label": "接收短信", - "description": "允许应用接收短信。", - "groupId": 4 - }, - { - "permissionName": "ohos.permission.RECEIVE_WAP_MESSAGES", - "groupName": "SMS", - "label": "接收WAP消息", - "description": "允许应用接收和处理WAP消息。", - "groupId": 4 - }, - { - "permissionName": "ohos.permission.SEND_MESSAGES", - "groupName": "SMS", - "label": "发送短彩信", - "description": "允许应用发送短彩信", - "groupId": 4 - }, - { - "permissionName": "ohos.permission.READ_CONTACTS", - "groupName": "CONTACTS", - "label": "读取通讯录", - "description": "允许应用读取设备上存储的联系人信息。", - "groupId": 5 - }, - { - "permissionName": "ohos.permission.WRITE_CONTACTS", - "groupName": "CONTACTS", - "label": "新建/修改/删除通讯录", - "description": "允许应用新建/修改/删除设备上存储的联系人信息。", - "groupId": 5 - }, - { - "permissionName": "ohos.permission.READ_CALL_LOG", - "groupName": "CALL_LOG", - "label": "读取通话记录", - "description": "允许应用读取设备上的通话记录信息。", - "groupId": 6 - }, - { - "permissionName": "ohos.permission.WRITE_CALL_LOG", - "groupName": "CALL_LOG", - "label": "新建/修改/删除通话记录", - "description": "允许新建/修改/删除设备上的通话记录信息。", - "groupId": 6 - }, - { - "permissionName": "ohos.permission.MEDIA_LOCATION", - "groupName": "MEDIA", - "label": "允许应用访问拍摄位置", - "description": "应用访问用户媒体文件中的拍摄位置信息如经纬度信息。", - "groupId": 7 - }, - { - "permissionName": "ohos.permission.READ_MEDIA", - "groupName": "MEDIA", - "label": "允许应用读取媒体文件", - "description": "允许应用访问户媒体文件,如视频、音频、图片等。", - "groupId": 7 - }, - { - "permissionName": "ohos.permission.WRITE_MEDIA", - "groupName": "MEDIA", - "label": "允许应用读写媒体文件", - "description": "允许应用读写户媒体文件,如视频、音频、图片等。", - "groupId": 7 - }, - { - "permissionName": "ohos.permission.READ_CALENDAR", - "groupName": "CALENDAR", - "label": "读取日历", - "description": "允许应用读取日历。", - "groupId": 8 - }, - { - "permissionName": "ohos.permission.WRITE_CALENDAR", - "groupName": "CALENDAR", - "label": "新建/修改/删除日历", - "description": "允许应用新建/修改/删除日历。", - "groupId": 8 - }, - { - "permissionName": "ohos.permission.ACTIVITY_MOTION", - "groupName": "SPORT", - "label": "读取用户的运动状态", - "description": "允许应用程序读取用户的运动状态。", - "groupId": 9 - }, - { - "permissionName": "ohos.permission.READ_HEALTH_DATA", - "groupName": "HEALTH", - "label": "读取用户的健康数据", - "description": "允许应用程序读取用户的健康数据。", - "groupId": 10 - }, - { - "permissionName": "ohos.permission.DISTRIBUTED_DATASYNC", - "groupName": "OTHER", - "icon": $r("app.media.ic_multi_device_vector"), - "text": "使用多设备协同?", - "label": "多设备协同", - "description": "发现并访问其他设备。", - "groupId": 11 - } -] - -export const groups: any[] = [ - { - "name": "LOCATION", - "groupName": "位置信息", - "icon": $r('app.media.ic_public_gps'), - "description": "", - "label": "访问位置信息?", - "permissions": [ - "ohos.permission.LOCATION_IN_BACKGROUND", - "ohos.permission.LOCATION" - ], - "isShow":true - }, - { - "name": "CAMERA", - "groupName": "相机", - "icon": $r('app.media.ic_public_camera'), - "label": "使用相机?", - "description": "", - "permissions": [ - "ohos.permission.CAMERA" - ], - "isShow":true - }, - { - "name": "MICROPHONE", - "groupName": "麦克风", - "icon": $r('app.media.ic_public_voice'), - "label": "使用麦克风?", - "description": "", - "permissions": [ - "ohos.permission.MICROPHONE" - ], - "isShow":true - }, - { - "name": "PHONE", - "groupName": "电话", - "icon": $r('app.media.ic_public_phone'), - "label": "使用拨打电话?", - "description": "", - "permissions": [ - "ohos.permission.ANSWER_CALL", - "ohos.permission.MANAGE_VOICEMAIL" - ], - "isShow":false - }, - { - "name": "SMS", - "groupName": "信息", - "icon": $r('app.media.ic_public_message'), - "label": "访问信息?", - "description": "", - "permissions": [ - "ohos.permission.READ_CELL_MESSAGES", - "ohos.permission.READ_MESSAGES", - "ohos.permission.RECEIVE_MMS", - "ohos.permission.RECEIVE_SMS", - "ohos.permission.RECEIVE_WAP_MESSAGES", - "ohos.permission.SEND_MESSAGES" - ], - "isShow":false - }, - { - "name": "CONTACTS", - "groupName": "通讯录", - "icon": $r('app.media.ic_public_contacts_group'), - "label": "访问通讯录?", - "description": "", - "permissions": [ - "ohos.permission.READ_CONTACTS", - "ohos.permission.WRITE_CONTACTS" - ], - "isShow":false - }, - { - "name": "CALL_LOG", - "groupName": "通话记录", - "icon": $r('app.media.ic_call_logs'), - "label": "访问通话记录?", - "description": "", - "permissions": [ - "ohos.permission.READ_CALL_LOG", - "ohos.permission.WRITE_CALL_LOG" - ], - "isShow":false - }, - { - "name": "MEDIA", - "groupName": "媒体和文件", - "icon": $r('app.media.ic_public_folder'), - "description": "", - "label": "访问媒体和文件?", - "permissions": [ - "ohos.permission.MEDIA_LOCATION", - "ohos.permission.READ_MEDIA", - "ohos.permission.WRITE_MEDIA" - ], - "isShow":true - }, - { - "name": "CALENDAR", - "groupName": "日历", - "icon": $r('app.media.ic_public_calendar'), - "label": "访问日历?", - "description": "", - "permissions": [ - "ohos.permission.READ_CALENDAR", - "ohos.permission.WRITE_CALENDAR" - ], - "isShow":true - }, - { - "name": "SPORT", - "groupName": "健身运动", - "icon": $r('app.media.ic_sport'), - "label": "访问健身运动?", - "description": "", - "permissions": [ - "ohos.permission.ACTIVITY_MOTION" - ], - "isShow":true - }, - { - "name": "HEALTH", - "groupName": "身体传感器", - "icon": $r('app.media.ic_ssensor'), - "label": "使用身体传感器?", - "description": "", - "permissions": [ - "ohos.permission.READ_HEALTH_DATA" - ], - "isShow":true - }, - { - "name": "OTHER", - "groupName": "其他权限", - "icon": $r('app.media.ic_more'), - "description": "", - "permissions": [ - "ohos.permission.DISTRIBUTED_DATASYNC" - ], - "isShow":false - } -]; - -export const permissionGroupPermissions: object = { - "LOCATION": [ - "ohos.permission.LOCATION_IN_BACKGROUND", - "ohos.permission.LOCATION" - ], - "CAMERA": [ - "ohos.permission.CAMERA" - ], - "MICROPHONE": [ - "ohos.permission.MICROPHONE" - ], - "PHONE": [ - "ohos.permission.ANSWER_CALL", - "ohos.permission.MANAGE_VOICEMAIL" - ], - "SMS": [ - "ohos.permission.READ_CELL_MESSAGES", - "ohos.permission.READ_MESSAGES", - "ohos.permission.RECEIVE_MMS", - "ohos.permission.RECEIVE_SMS", - "ohos.permission.RECEIVE_WAP_MESSAGES", - "ohos.permission.SEND_MESSAGES" - ], - "CONTACTS": [ - "ohos.permission.READ_CONTACTS", - "ohos.permission.WRITE_CONTACTS" - ], - "CALL_LOG": [ - "ohos.permission.READ_CALL_LOG", - "ohos.permission.WRITE_CALL_LOG" - ], - "MEDIA": [ - "ohos.permission.MEDIA_LOCATION", - "ohos.permission.READ_MEDIA", - "ohos.permission.WRITE_MEDIA" - ], - "CALENDAR": [ - "ohos.permission.READ_CALENDAR", - "ohos.permission.WRITE_CALENDAR" - ], - "SPORT": [ - "ohos.permission.ACTIVITY_MOTION" - ], - "HEALTH": [ - "ohos.permission.READ_HEALTH_DATA" - ], - "OTHER": [ - "ohos.permission.DISTRIBUTED_DATASYNC" - ] -}; - - -export const userGrantPermissions: string[] = [ - "ohos.permission.LOCATION_IN_BACKGROUND", - "ohos.permission.LOCATION", - "ohos.permission.CAMERA", - "ohos.permission.MICROPHONE", - "ohos.permission.ANSWER_CALL", - "ohos.permission.MANAGE_VOICEMAIL", - "ohos.permission.READ_CELL_MESSAGES", - "ohos.permission.READ_MESSAGES", - "ohos.permission.RECEIVE_MMS", - "ohos.permission.RECEIVE_SMS", - "ohos.permission.RECEIVE_WAP_MESSAGES", - "ohos.permission.SEND_MESSAGES", - "ohos.permission.READ_CONTACTS", - "ohos.permission.WRITE_CONTACTS", - "ohos.permission.READ_CALL_LOG", - "ohos.permission.WRITE_CALL_LOG", - "ohos.permission.MEDIA_LOCATION", - "ohos.permission.READ_MEDIA", - "ohos.permission.WRITE_MEDIA", - "ohos.permission.READ_CALENDAR", - "ohos.permission.WRITE_CALENDAR", - "ohos.permission.ACTIVITY_MOTION", - "ohos.permission.READ_HEALTH_DATA", - "ohos.permission.DISTRIBUTED_DATASYNC" -]; - -export const permissionDescriptions: object = { - "位置信息": "允许应用在后台运行时获取位置信息。" , - "相机": "允许应用拍摄照片和视频。" , - "麦克风": "允许应用打开或关闭录音通路。" , - "电话": "允许应用接听电话。" , - "信息": "允许应用发送短彩信。" , - "通讯录": "允许应用新建/修改/删除设备上存储的联系人信息。" , - "通话记录": "允许新建/修改/删除设备上的通话记录信息。" , - "媒体和文件": "允许应用访问户媒体文件,如视频、音频、图片等。" , - "日历": "允许应用新建/修改/删除日历。" , - "健身运动": "允许应用程序读取用户的运动状态。" , - "身体传感器": "允许应用程序读取用户的健康数据。" , - "其他权限": "允许应用与远程设备交换用户数据(如图片、音乐、视频、及应用数据等)。" -}; - -export const permissionPermissionGroup: object = { - "ohos.permission.LOCATION_IN_BACKGROUND": "LOCATION", - "ohos.permission.LOCATION": "LOCATION", - "ohos.permission.CAMERA": "CAMERA", - "ohos.permission.MICROPHONE": "MICROPHONE", - "ohos.permission.ANSWER_CALL": "PHONE", - "ohos.permission.MANAGE_VOICEMAIL": "PHONE", - "ohos.permission.READ_CELL_MESSAGES": "SMS", - "ohos.permission.READ_MESSAGES": "SMS", - "ohos.permission.RECEIVE_MMS": "SMS", - "ohos.permission.RECEIVE_SMS": "SMS", - "ohos.permission.RECEIVE_WAP_MESSAGES": "SMS", - "ohos.permission.SEND_MESSAGES": "SMS", - "ohos.permission.READ_CONTACTS": "CONTACTS", - "ohos.permission.WRITE_CONTACTS": "CONTACTS", - "ohos.permission.READ_CALL_LOG": "CALL_LOG", - "ohos.permission.WRITE_CALL_LOG": "CALL_LOG", - "ohos.permission.MEDIA_LOCATION": "MEDIA", - "ohos.permission.READ_MEDIA": "MEDIA", - "ohos.permission.WRITE_MEDIA": "MEDIA", - "ohos.permission.READ_CALENDAR": "CALENDAR", - "ohos.permission.WRITE_CALENDAR": "CALENDAR", - "ohos.permission.ACTIVITY_MOTION": "SPORT", - "ohos.permission.READ_HEALTH_DATA": "HEALTH", - "ohos.permission.DISTRIBUTED_DATASYNC": "OTHER" -}; - -export const permissionGroupIds: object = { - "ohos.permission.LOCATION_IN_BACKGROUND": "0", - "ohos.permission.LOCATION": "0", - "ohos.permission.CAMERA": "1", - "ohos.permission.MICROPHONE": "2", - "ohos.permission.ANSWER_CALL": "3", - "ohos.permission.MANAGE_VOICEMAIL": "3", - "ohos.permission.READ_CELL_MESSAGES": "4", - "ohos.permission.READ_MESSAGES": "4", - "ohos.permission.RECEIVE_MMS": "4", - "ohos.permission.RECEIVE_SMS": "4", - "ohos.permission.RECEIVE_WAP_MESSAGES": "4", - "ohos.permission.SEND_MESSAGES": "4", - "ohos.permission.READ_CONTACTS": "5", - "ohos.permission.WRITE_CONTACTS": "5", - "ohos.permission.READ_CALL_LOG": "6", - "ohos.permission.WRITE_CALL_LOG": "6", - "ohos.permission.MEDIA_LOCATION": "7", - "ohos.permission.READ_MEDIA": "7", - "ohos.permission.WRITE_MEDIA": "7", - "ohos.permission.READ_CALENDAR": "8", - "ohos.permission.WRITE_CALENDAR": "8", - "ohos.permission.ACTIVITY_MOTION": "9", - "ohos.permission.READ_HEALTH_DATA": "10", - "ohos.permission.DISTRIBUTED_DATASYNC": "11" -}; - -export const orderGroup: string[] = [ - "位置信息", - "相机", - "麦克风", - "电话", - "信息", - "通讯录", - "通话记录", - "媒体和文件", - "日历", - "健身运动", - "身体传感器", - "其他权限" -]; - -export const otherPermissionsLabel: object = { - "ohos.permission.DISTRIBUTED_DATASYNC": "多设备协同" -}; - -export const noNeedDisplayApp: string[] = [ - "com.ohos.launcher" -] - -export const showSubpermissionsGrop: string[] = [ - "电话", - "日历", - "信息", - "通讯录", - "通话记录" +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const permissionGroups: any[] = [ + { + "permissionName": "ohos.permission.LOCATION_IN_BACKGROUND", + "groupName": "LOCATION", + "label": "后台定位权限", + "description": "允许应用在后台运行时获取位置信息。", + "groupId": 0 + }, + { + "permissionName": "ohos.permission.LOCATION", + "groupName": "LOCATION", + "label": "前台定位权限", + "description": "允许应用在前台运行时获取位置信息。", + "groupId": 0 + }, + { + "permissionName": "ohos.permission.CAMERA", + "groupName": "CAMERA", + "label": "拍摄照片和录制视频", + "description": "允许应用拍摄照片和视频。", + "groupId": 1 + }, + { + "permissionName": "ohos.permission.MICROPHONE", + "groupName": "MICROPHONE", + "label": "录制音频", + "description": "允许应用打开或关闭录音通路。", + "groupId": 2 + }, + { + "permissionName": "ohos.permission.ANSWER_CALL", + "groupName": "PHONE", + "label": "接听电话", + "description": "允许应用接听电话。", + "groupId": 3 + }, + { + "permissionName": "ohos.permission.MANAGE_VOICEMAIL", + "groupName": "PHONE", + "label": "语音信箱", + "description": "允许应用管理语音信箱。", + "groupId": 3 + }, + { + "permissionName": "ohos.permission.READ_CELL_MESSAGES", + "groupName": "SMS", + "label": "读取小区广播", + "description": "允许应用读取设备接收的小区广播信息。", + "groupId": 4 + }, + { + "permissionName": "ohos.permission.READ_MESSAGES", + "groupName": "SMS", + "label": "读取短彩信", + "description": "允许应用读取设备接收的短彩信信息。", + "groupId": 4 + }, + { + "permissionName": "ohos.permission.RECEIVE_MMS", + "groupName": "SMS", + "label": "接收彩信", + "description": "允许应用接收彩信。", + "groupId": 4 + }, + { + "permissionName": "ohos.permission.RECEIVE_SMS", + "groupName": "SMS", + "label": "接收短信", + "description": "允许应用接收短信。", + "groupId": 4 + }, + { + "permissionName": "ohos.permission.RECEIVE_WAP_MESSAGES", + "groupName": "SMS", + "label": "接收WAP消息", + "description": "允许应用接收和处理WAP消息。", + "groupId": 4 + }, + { + "permissionName": "ohos.permission.SEND_MESSAGES", + "groupName": "SMS", + "label": "发送短彩信", + "description": "允许应用发送短彩信", + "groupId": 4 + }, + { + "permissionName": "ohos.permission.READ_CONTACTS", + "groupName": "CONTACTS", + "label": "读取通讯录", + "description": "允许应用读取设备上存储的联系人信息。", + "groupId": 5 + }, + { + "permissionName": "ohos.permission.WRITE_CONTACTS", + "groupName": "CONTACTS", + "label": "新建/修改/删除通讯录", + "description": "允许应用新建/修改/删除设备上存储的联系人信息。", + "groupId": 5 + }, + { + "permissionName": "ohos.permission.READ_CALL_LOG", + "groupName": "CALL_LOG", + "label": "读取通话记录", + "description": "允许应用读取设备上的通话记录信息。", + "groupId": 6 + }, + { + "permissionName": "ohos.permission.WRITE_CALL_LOG", + "groupName": "CALL_LOG", + "label": "新建/修改/删除通话记录", + "description": "允许新建/修改/删除设备上的通话记录信息。", + "groupId": 6 + }, + { + "permissionName": "ohos.permission.MEDIA_LOCATION", + "groupName": "MEDIA", + "label": "允许应用访问拍摄位置", + "description": "应用访问用户媒体文件中的拍摄位置信息如经纬度信息。", + "groupId": 7 + }, + { + "permissionName": "ohos.permission.READ_MEDIA", + "groupName": "MEDIA", + "label": "允许应用读取媒体文件", + "description": "允许应用访问户媒体文件,如视频、音频、图片等。", + "groupId": 7 + }, + { + "permissionName": "ohos.permission.WRITE_MEDIA", + "groupName": "MEDIA", + "label": "允许应用读写媒体文件", + "description": "允许应用读写户媒体文件,如视频、音频、图片等。", + "groupId": 7 + }, + { + "permissionName": "ohos.permission.READ_CALENDAR", + "groupName": "CALENDAR", + "label": "读取日历", + "description": "允许应用读取日历。", + "groupId": 8 + }, + { + "permissionName": "ohos.permission.WRITE_CALENDAR", + "groupName": "CALENDAR", + "label": "新建/修改/删除日历", + "description": "允许应用新建/修改/删除日历。", + "groupId": 8 + }, + { + "permissionName": "ohos.permission.ACTIVITY_MOTION", + "groupName": "SPORT", + "label": "读取用户的运动状态", + "description": "允许应用程序读取用户的运动状态。", + "groupId": 9 + }, + { + "permissionName": "ohos.permission.READ_HEALTH_DATA", + "groupName": "HEALTH", + "label": "读取用户的健康数据", + "description": "允许应用程序读取用户的健康数据。", + "groupId": 10 + }, + { + "permissionName": "ohos.permission.DISTRIBUTED_DATASYNC", + "groupName": "OTHER", + "icon": $r("app.media.ic_multi_device_vector"), + "text": "使用多设备协同?", + "label": "多设备协同", + "description": "发现并访问其他设备。", + "groupId": 11 + } +] + +export const groups: any[] = [ + { + "name": "LOCATION", + "groupName": "位置信息", + "icon": $r('app.media.ic_public_gps'), + "description": "", + "label": "访问位置信息?", + "permissions": [ + "ohos.permission.LOCATION_IN_BACKGROUND", + "ohos.permission.LOCATION" + ], + "isShow":true + }, + { + "name": "CAMERA", + "groupName": "相机", + "icon": $r('app.media.ic_public_camera'), + "label": "使用相机?", + "description": "", + "permissions": [ + "ohos.permission.CAMERA" + ], + "isShow":true + }, + { + "name": "MICROPHONE", + "groupName": "麦克风", + "icon": $r('app.media.ic_public_voice'), + "label": "使用麦克风?", + "description": "", + "permissions": [ + "ohos.permission.MICROPHONE" + ], + "isShow":true + }, + { + "name": "PHONE", + "groupName": "电话", + "icon": $r('app.media.ic_public_phone'), + "label": "使用拨打电话?", + "description": "", + "permissions": [ + "ohos.permission.ANSWER_CALL", + "ohos.permission.MANAGE_VOICEMAIL" + ], + "isShow":false + }, + { + "name": "SMS", + "groupName": "信息", + "icon": $r('app.media.ic_public_message'), + "label": "访问信息?", + "description": "", + "permissions": [ + "ohos.permission.READ_CELL_MESSAGES", + "ohos.permission.READ_MESSAGES", + "ohos.permission.RECEIVE_MMS", + "ohos.permission.RECEIVE_SMS", + "ohos.permission.RECEIVE_WAP_MESSAGES", + "ohos.permission.SEND_MESSAGES" + ], + "isShow":false + }, + { + "name": "CONTACTS", + "groupName": "通讯录", + "icon": $r('app.media.ic_public_contacts_group'), + "label": "访问通讯录?", + "description": "", + "permissions": [ + "ohos.permission.READ_CONTACTS", + "ohos.permission.WRITE_CONTACTS" + ], + "isShow":false + }, + { + "name": "CALL_LOG", + "groupName": "通话记录", + "icon": $r('app.media.ic_call_logs'), + "label": "访问通话记录?", + "description": "", + "permissions": [ + "ohos.permission.READ_CALL_LOG", + "ohos.permission.WRITE_CALL_LOG" + ], + "isShow":false + }, + { + "name": "MEDIA", + "groupName": "媒体和文件", + "icon": $r('app.media.ic_public_folder'), + "description": "", + "label": "访问媒体和文件?", + "permissions": [ + "ohos.permission.MEDIA_LOCATION", + "ohos.permission.READ_MEDIA", + "ohos.permission.WRITE_MEDIA" + ], + "isShow":true + }, + { + "name": "CALENDAR", + "groupName": "日历", + "icon": $r('app.media.ic_public_calendar'), + "label": "访问日历?", + "description": "", + "permissions": [ + "ohos.permission.READ_CALENDAR", + "ohos.permission.WRITE_CALENDAR" + ], + "isShow":true + }, + { + "name": "SPORT", + "groupName": "健身运动", + "icon": $r('app.media.ic_sport'), + "label": "访问健身运动?", + "description": "", + "permissions": [ + "ohos.permission.ACTIVITY_MOTION" + ], + "isShow":true + }, + { + "name": "HEALTH", + "groupName": "身体传感器", + "icon": $r('app.media.ic_ssensor'), + "label": "使用身体传感器?", + "description": "", + "permissions": [ + "ohos.permission.READ_HEALTH_DATA" + ], + "isShow":true + }, + { + "name": "OTHER", + "groupName": "其他权限", + "icon": $r('app.media.ic_more'), + "description": "", + "permissions": [ + "ohos.permission.DISTRIBUTED_DATASYNC" + ], + "isShow":false + } +]; + +export const permissionGroupPermissions: object = { + "LOCATION": [ + "ohos.permission.LOCATION_IN_BACKGROUND", + "ohos.permission.LOCATION" + ], + "CAMERA": [ + "ohos.permission.CAMERA" + ], + "MICROPHONE": [ + "ohos.permission.MICROPHONE" + ], + "PHONE": [ + "ohos.permission.ANSWER_CALL", + "ohos.permission.MANAGE_VOICEMAIL" + ], + "SMS": [ + "ohos.permission.READ_CELL_MESSAGES", + "ohos.permission.READ_MESSAGES", + "ohos.permission.RECEIVE_MMS", + "ohos.permission.RECEIVE_SMS", + "ohos.permission.RECEIVE_WAP_MESSAGES", + "ohos.permission.SEND_MESSAGES" + ], + "CONTACTS": [ + "ohos.permission.READ_CONTACTS", + "ohos.permission.WRITE_CONTACTS" + ], + "CALL_LOG": [ + "ohos.permission.READ_CALL_LOG", + "ohos.permission.WRITE_CALL_LOG" + ], + "MEDIA": [ + "ohos.permission.MEDIA_LOCATION", + "ohos.permission.READ_MEDIA", + "ohos.permission.WRITE_MEDIA" + ], + "CALENDAR": [ + "ohos.permission.READ_CALENDAR", + "ohos.permission.WRITE_CALENDAR" + ], + "SPORT": [ + "ohos.permission.ACTIVITY_MOTION" + ], + "HEALTH": [ + "ohos.permission.READ_HEALTH_DATA" + ], + "OTHER": [ + "ohos.permission.DISTRIBUTED_DATASYNC" + ] +}; + + +export const userGrantPermissions: string[] = [ + "ohos.permission.LOCATION_IN_BACKGROUND", + "ohos.permission.LOCATION", + "ohos.permission.CAMERA", + "ohos.permission.MICROPHONE", + "ohos.permission.ANSWER_CALL", + "ohos.permission.MANAGE_VOICEMAIL", + "ohos.permission.READ_CELL_MESSAGES", + "ohos.permission.READ_MESSAGES", + "ohos.permission.RECEIVE_MMS", + "ohos.permission.RECEIVE_SMS", + "ohos.permission.RECEIVE_WAP_MESSAGES", + "ohos.permission.SEND_MESSAGES", + "ohos.permission.READ_CONTACTS", + "ohos.permission.WRITE_CONTACTS", + "ohos.permission.READ_CALL_LOG", + "ohos.permission.WRITE_CALL_LOG", + "ohos.permission.MEDIA_LOCATION", + "ohos.permission.READ_MEDIA", + "ohos.permission.WRITE_MEDIA", + "ohos.permission.READ_CALENDAR", + "ohos.permission.WRITE_CALENDAR", + "ohos.permission.ACTIVITY_MOTION", + "ohos.permission.READ_HEALTH_DATA", + "ohos.permission.DISTRIBUTED_DATASYNC" +]; + +export const permissionDescriptions: object = { + "位置信息": "允许应用在后台运行时获取位置信息。" , + "相机": "允许应用拍摄照片和视频。" , + "麦克风": "允许应用打开或关闭录音通路。" , + "电话": "允许应用接听电话。" , + "信息": "允许应用发送短彩信。" , + "通讯录": "允许应用新建/修改/删除设备上存储的联系人信息。" , + "通话记录": "允许新建/修改/删除设备上的通话记录信息。" , + "媒体和文件": "允许应用访问户媒体文件,如视频、音频、图片等。" , + "日历": "允许应用新建/修改/删除日历。" , + "健身运动": "允许应用程序读取用户的运动状态。" , + "身体传感器": "允许应用程序读取用户的健康数据。" , + "其他权限": "允许应用与远程设备交换用户数据(如图片、音乐、视频、及应用数据等)。" +}; + +export const permissionPermissionGroup: object = { + "ohos.permission.LOCATION_IN_BACKGROUND": "LOCATION", + "ohos.permission.LOCATION": "LOCATION", + "ohos.permission.CAMERA": "CAMERA", + "ohos.permission.MICROPHONE": "MICROPHONE", + "ohos.permission.ANSWER_CALL": "PHONE", + "ohos.permission.MANAGE_VOICEMAIL": "PHONE", + "ohos.permission.READ_CELL_MESSAGES": "SMS", + "ohos.permission.READ_MESSAGES": "SMS", + "ohos.permission.RECEIVE_MMS": "SMS", + "ohos.permission.RECEIVE_SMS": "SMS", + "ohos.permission.RECEIVE_WAP_MESSAGES": "SMS", + "ohos.permission.SEND_MESSAGES": "SMS", + "ohos.permission.READ_CONTACTS": "CONTACTS", + "ohos.permission.WRITE_CONTACTS": "CONTACTS", + "ohos.permission.READ_CALL_LOG": "CALL_LOG", + "ohos.permission.WRITE_CALL_LOG": "CALL_LOG", + "ohos.permission.MEDIA_LOCATION": "MEDIA", + "ohos.permission.READ_MEDIA": "MEDIA", + "ohos.permission.WRITE_MEDIA": "MEDIA", + "ohos.permission.READ_CALENDAR": "CALENDAR", + "ohos.permission.WRITE_CALENDAR": "CALENDAR", + "ohos.permission.ACTIVITY_MOTION": "SPORT", + "ohos.permission.READ_HEALTH_DATA": "HEALTH", + "ohos.permission.DISTRIBUTED_DATASYNC": "OTHER" +}; + +export const permissionGroupIds: object = { + "ohos.permission.LOCATION_IN_BACKGROUND": "0", + "ohos.permission.LOCATION": "0", + "ohos.permission.CAMERA": "1", + "ohos.permission.MICROPHONE": "2", + "ohos.permission.ANSWER_CALL": "3", + "ohos.permission.MANAGE_VOICEMAIL": "3", + "ohos.permission.READ_CELL_MESSAGES": "4", + "ohos.permission.READ_MESSAGES": "4", + "ohos.permission.RECEIVE_MMS": "4", + "ohos.permission.RECEIVE_SMS": "4", + "ohos.permission.RECEIVE_WAP_MESSAGES": "4", + "ohos.permission.SEND_MESSAGES": "4", + "ohos.permission.READ_CONTACTS": "5", + "ohos.permission.WRITE_CONTACTS": "5", + "ohos.permission.READ_CALL_LOG": "6", + "ohos.permission.WRITE_CALL_LOG": "6", + "ohos.permission.MEDIA_LOCATION": "7", + "ohos.permission.READ_MEDIA": "7", + "ohos.permission.WRITE_MEDIA": "7", + "ohos.permission.READ_CALENDAR": "8", + "ohos.permission.WRITE_CALENDAR": "8", + "ohos.permission.ACTIVITY_MOTION": "9", + "ohos.permission.READ_HEALTH_DATA": "10", + "ohos.permission.DISTRIBUTED_DATASYNC": "11" +}; + +export const orderGroup: string[] = [ + "位置信息", + "相机", + "麦克风", + "电话", + "信息", + "通讯录", + "通话记录", + "媒体和文件", + "日历", + "健身运动", + "身体传感器", + "其他权限" +]; + +export const otherPermissionsLabel: object = { + "ohos.permission.DISTRIBUTED_DATASYNC": "多设备协同" +}; + +export const noNeedDisplayApp: string[] = [ + "com.ohos.launcher" +] + +export const showSubpermissionsGrop: string[] = [ + "电话", + "日历", + "信息", + "通讯录", + "通话记录" ]; \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/utils/constant.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/utils/constant.ets index 1bfa23125625a0a3ff173eceef2f590ae786bbd1..3b964169b40d258d591524383dfe47ef2a17185e 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/utils/constant.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/utils/constant.ets @@ -1,349 +1,349 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default class Constants { - // alphabetIndexer - static ALPHABETINDEXER_SELECTEDFONT_SIZE = 12; - static ALPHABETINDEXER_POPUPFONT_SIZE = 30; - static ALPHABETINDEXER_ITEMSIZE = 16; - static ALPHABETINDEXER_HEIGHT = 448; - static ALPHABETINDEXER_WIDTH = 36; - - // backBar - static BACKBAR_HEIGHT = 56; - static BACKBAR_MINHEIGHT = 56; - - // image of backBar - static BACKBAR_IMAGE_HEIGHT = 24; - static BACKBAR_IMAGE_WIDTH = 24; - static BACKBAR_IMAGE_MARGIN_TOP = 17; - static BACKBAR_IMAGE_MARGIN_LEFT = 12; - static BACKBAR_IMAGE_MARGIN_RIGHT = 15; - - // text of backBar - static BACKBAR_TEXT_FONT_SIZE = 20; - static BACKBAR_TEXT_FLEX_GROW = 1; - static BACKBAR_TEXT_MARGIN_TOP = 17; - - // dialog - static DIALOG_BORDER_RADIUS = 24; - static DIALOG_HEIGHT = 70; - static DIALOG_WIDTH = 336; - - // text of dialog - static DIALOG_TEXT_FONT_SIZE = 20; - static DIALOG_TEXT_MARGIN_TOP = 25; - - // search textInput - static TEXTINPUT_PADDING_LEFT = 36; - static TEXTINPUT_BORDER_RADIUS = 20; - static TEXTINPUT_BORDER_WIDTH = 1.5; - static TEXTINPUT_PLACEHOLDER_Font_SIZE = 16; - static TEXTINPUT_HEIGHT = 40; - static TEXTINPUT_IMAGE_WIDTH = 16; - static TEXTINPUT_IMAGE_HEIGHT = 16; - static TEXTINPUT_IMAGE_MARGIN_LEFT = 12; - static TEXTINPUT_IMAGE_MARGIN_TOP = 12; - - // grid useSizeType - static GRID_MARGIN = '0vp'; - static GUTTER = 0; - static LEFT_XS_SPAN = 0; - static LEFT_XS_OFFSET = 0; - static LEFT_SM_SPAN = 0; - static LEFT_SM_OFFSET = 0; - static LEFT_MD_SPAN = 0; - static LEFT_MD_OFFSET = 0; - static LEFT_LG_SPAN = 2; - static LEFT_LG_OFFSET = 0; - static MIDDLE_XS_SPAN = 2; - static MIDDLE_XS_OFFSET = 0; - static MIDDLE_SM_SPAN = 4; - static MIDDLE_SM_OFFSET = 0; - static MIDDLE_MD_SPAN = 8; - static MIDDLE_MD_OFFSET = 0; - static MIDDLE_LG_SPAN = 8; - static MIDDLE_LG_OFFSET = 2; - static RIGHT_XS_SPAN = 0; - static RIGHT_XS_OFFSET = 2; - static RIGHT_SM_SPAN = 0; - static RIGHT_SM_OFFSET = 4; - static RIGHT_MD_SPAN = 0; - static RIGHT_MD_OFFSET = 8; - static RIGHT_LG_SPAN = 2; - static RIGHT_LG_OFFSET = 10; - - // 100% width,height - static FULL_WIDTH = '100%'; - static FULL_HEIGHT = '100%'; - - // public property style - static PERMISSION = 1; - static APPLICATION = 0; - static LAYOUT_WEIGHT = 1; - static FLEX_GROW = 1; - static TEXT_DECORATION_HEIGHT = 1; - static TEXT_MIDDLE_FONT_SIZE = 16; - static TEXT_SMAL_FONT_SIZE = 14; - static TEXT_SMALLER_FONT_SIZE = 12; - static TEXT_LINE_HEIGHT = 22; - static TEXT_SMALL_LINE_HEIGHT = 19; - static CONSTRAINTSIZE_MINHEIGHT = 48; - static LISTITEM_ROW_HEIGHT = 48; - static LISTITEM_PADDING_LEFT = 24; - static LIST_PADDING_LEFT = 12 - static LISTITEM_PADDING_RIGHT = 24; - static LISTITEM_PADDING_LEFT_RECORD = 32; - static LISTITEM_MARGIN_BOTTOM = 12; - static LISTITEM_MARGIN_BOTTOM_PERMISSION = 14; - static LISTITEM_MARGIN_BOTTOM_APPLICATION = 10; - static LISTITEM_HEIGHT_PERMISSION = 64; - static LISTITEM_HEIGHT_APPLICATION = 72; - static IMAGE_HEIGHT = 24; - static IMAGE_WIDTH = 12; - static IMAGE_HEIGHT_RECORD = 12; - static IMAGE_WIDTH_RECORD = 24; - static IMAGE_HEIGHT_RECORD_APPLICATION = 16; - static IMAGE_WIDTH_RECORD_APPLICATION = 16; - static BORDER_RADIUS = 24; - static TITLE_MARGIN_BOTTOM = 16; - static SUBTITLE_MIN_HEIGHT = 48; - static SUBTITLE_LINE_HEIGHT = 24; - static SUBTITLE_PADDING_TOP = 16; - static SUBTITLE_PADDING_BOTTOM = 8; - static TAB_HEIGHT = 56; - static TAB_DECORATION_HEIGHT = 2; - static TAB_DECORATION_POSITION_Y = 46; - static DEFAULT_PADDING_START = 12; - static DEFAULT_PADDING_END = 12; - - // application-secondary, authority-secondary - static FLEX_MARGIN_TOP = 8; - static FLEX_MARGIN_BOTTOM = 8; - static LIST_PADDING_TOP = 4; - static LIST_PADDING_BOTTOM = 4; - static LIST_MARGIN_BOTTOM = 12; - static ROW_MARGIN_TOP = 9; - static SECONDARY_TEXT_MARGIN_TOP = 19.5; - static SECONDARY_TEXT_MARGIN_LEFT = 24; - static SECONDARY_LIST_PADDING_LEFT = 12; - static SECONDARY_LIST_PADDING_RIGHT = 12; - - // application-tertiary - static TERTIARY_IMAGE_WIDTH = 64; - static TERTIARY_IMAGE_HEIGHT = 64; - static TERTIARY_IMAGE_MARGIN_LEFT = 12; - static TERTIARY_IMAGE_MARGIN_RIGHT = 12; - static TERTIARY_LABEL_MARGIN_BOTTOM = 2; - static TERTIARY_MARGIN_LEFT = 12; - static TERTIARY_TEXT_MARGIN_LEFT = 24; - static TERTIARY_HALF_WIDTH = '50%'; - static TERTIARY_ROW_MARGIN_TOP = 24; - static TERTIARY_PERMISSION_ROW_MARGIN_TOP = 12; - static TERTIARY_RADIO_IMAGE_WIDTH = 24; - static TERTIARY_RADIO_IMAGE_HEIGHT = 24; - static TERTIARY_RADIO_IMAGE_MARGIN_TOP = 4; - static TERTIARY_LISTITEM_PADDING_LEFT = 24; - static TERTIARY_LISTITEM_PADDING_RIGHT = 24; - static TERTIARY_LISTITEM_MARGIN_TOP = 1; - static TERTIARY_LIST_PADDING_LEFT = 12; - static TERTIARY_LIST_PADDING_RIGHT = 12; - static TERTIARY_LIST_PADDING_TOP = 4; - static TERTIARY_LIST_PADDING_BOTTOM = 4; - - // authority-tertiary - static AUTHORITY_IMAGE_WIDTH = 40; - static AUTHORITY_IMAGE_HEIGHT = 40; - static AUTHORITY_IMAGE_MARGIN_RIGHT = 16; - static AUTHORITY_TOGGLE_WIDTH = 36; - static AUTHORITY_TOGGLE_HEIGHT = 20; - static AUTHORITY_ROW_HEIGHT = 72; - static AUTHORITY_CONSTRAINTSIZE_MINHEIGHT = 72; - static AUTHORITY_LISTITEM_PADDING_LEFT = 12; - static AUTHORITY_LISTITEM_PADDING_RIGHT = 12; - static AUTHORITY_TEXTINPUT_PADDING_LEFT = 12; - static AUTHORITY_TEXTINPUT_PADDING_RIGHT = 24; - static AUTHORITY_TEXT_MARGIN_TOP = 24; - static AUTHORITY_TEXT_MARGIN_LEFT = 0; - static AUTHORITY_ROW_MARGIN_TOP = 24; - static NORECORD_IMAGE_WIDTH = 120; - static NORECORD_IMAGE_HEIGHT = 120; - static NORECORD_IMAGE_MARGIN_LEFT = 40; - static SEARCHNORESULT_IMAGE_WIDTH = 200; - static SEARCHNORESULT_IMAGE_HEIGHT = 200; - static AUTHORITY_COLUMN_HEIGHT = '95%'; - static AUTHORITY_ALPHABETINDEX_WIDTH = 24; - static AUTHORITY_ALPHABETINDEX_PADDING_TOP = 16; - static AUTHORITY_TEXT_DECORATION_WIDTH = '86%'; - static AUTHORITY_TEXT_DECORATION_MARGIN_LEFT = 53; - - // authority-management - static MANAGEMENT_IMAGE_WIDTH = 24; - static MANAGEMENT_IMAGE_HEIGHT = 24; - static MANAGEMENT_IMAGE_MARGIN_RIGHT = 16; - static MANAGEMENT_IMAGE_MARGIN_RIGHT_RECORD = 24; - static MANAGEMENT_IMAGE_MARGIN_LEFT = 8; - static MANAGEMENT_ROW_HEIGHT = 56; - static MANAGEMENT_TEXT_DECORATION_WIDTH = '95%'; - static MANAGEMENT_TEXT_DECORATION_MARGIN_LEFT = 40; - static MANAGEMENT_LODING_IMAGE_WIDTH = 48; - static MANAGEMENT_LODING_IMAGE_HEIGHT = 48; - static MANAGEMENT_LODING_ROW_HEIGHT = '90%'; - static MANAGEMENT_ROW_PADDING_LEFT = 12; - static MANAGEMENT_ROW_PADDING_RIGHT = 12; - static MANAGEMENT_ROW_PADDING_TOP = 8; - static MANAGEMENT_ROW_MARGIN_TOP = 12; - static MANAGEMENT_TRANSPARENCY = 0.8; - static APPLICATION_IMAGE_WIDTH = 40; - static APPLICATION_IMAGE_HEIGHT = 40; - static APPLICATION_IMAGE_MARGIN_RIGHT = 16; - static APPLICATION_TEXT_MARGIN_RIGHT = 4; - static APPLICATION_LIST_PADDING_LEFT = 12; - static APPLICATION_LIST_PADDING_RIGHT = 12; - static APPLICATION_LIST_MARGIN_BOTTOM = 50; - static APPLICATION_LISTITEM_PADDING_LEFT = 12; - static APPLICATION_LISTITEM_PADDING_RIGHT = 12; - static APPLICATION_TEXTINPUT_PADDING_LEFT = 12; - static APPLICATION_TEXTINPUT_PADDING_TOP = 8; - static APPLICATION_TEXTINPUT_PADDING_RIGHT = 24; - static APPLICATION_COLUMN_HEIGHT = '93%'; - static APPLICATION_ALPHABETINDEX_MARGIN_TOP = 12; - static APPLICATION_ALPHABETINDEX_WIDTH = 24; - static APPLICATION_TEXT_DECORATION_WIDTH = '90%'; - static APPLICATION_TEXT_DECORATION_MARGIN_LEFT = 56; - static LOADING_WIDTH = 100; - - // slice - static SLICE_START = 0; - static SLICE_END = -1; - static SLICE_START_INDEX = 0; - static SLICE_END_INDEX = 1; - - //group number - static FIXED_GROUP = 1; - static CHANGE_GROUP = 2; - static OTHER_GROUP = 3; - - // tabBar - static BAR_WIDTH = 285; - - // setTimeout - static DELAY_TIME = 1000; - static DELAY_TIME_MAX = 2000; - - // radio - static RADIO_ALLOW_NAME = '允许'; - static RADIO_ALLOW_INDEX = 0; - static RADIO_ALLOW_GROUP_NAME = 'radio'; - static RADIO_BAN_NAME = '禁止'; - static RADIO_BAN_INDEX = 1; - static RADIO_BAN_GROUP_NAME = 'radio'; - - //shape - static SHAPE_DIA = 24; - static SHAPE_BAN_DIA = 23; - static SHAPE_BIG_DIA = 48; - static SHAPE_OFFSET_X = -24; - static SHAPE_BAN_OFFSET = .5; - static SHAPE_ALLOW_DIA = 16; - static SHAPE_ALLOW_OFFSET = 4; - static SHAPE_ZINDEX = 10; - - // utils - static CHAR_CODE = 0; - static UNI_MAX = 40869; - static UNI_MIN = 19968; - - static PARMETER_BUNDLE_FLAG = 16; - static USERID = 100; - - static PERMISSION_INDEX = 0; - - static PERMISSION_NUM = 0; - - static PERMISSION_FLAG = 2; - static API_VERSION_SUPPORT_STAGE = 9; - - static PRE_AUTHORIZATION_NOT_MODIFIED = 4; - - static BUNDLE_NAME = 'com.ohos.permissionmanager' - - static START_SUBSCRIPT = 0 - static END_SUBSCRIPT = 500 - - static RECORD_PADDING_BOTTOM = '20%' - - - - - //////////////////////////////////////////// - // icon of dialog - static DIALOG_ICON_WIDTH = 24; - static DIALOG_ICON_HEIGHT = 24; - static DIALOG_ICON_MARGIN_TOP = 23; - - // label text of dialog - static DIALOG_LABEL_FONT_SIZE = 10; - static DIALOG_LABEL_MARGIN_TOP = 2; - static DIALOG_LABEL_LINE_HEIGHT = 14; - - // request text of dialog - static DIALOG_REQ_FONT_SIZE = 16; - static DIALOG_REQ_MARGIN_TOP = 16; - static DIALOG_REQ_MARGIN_LEFT = 24; - static DIALOG_REQ_LINE_HEIGHT = 22; - - // description text of dialog - static DIALOG_DESP_FONT_SIZE = 14; - static DIALOG_DESP_MARGIN_TOP = 2; - static DIALOG_DESP_MARGIN_LEFT = 24; - static DIALOG_DESP_MARGIN_RIGHT = 24; - static DIALOG_DESP_MARGIN_BOTTOM = 8; - static DIALOG_DESP_LINE_HEIGHT = 19; - - static BUTTON_FONT_SIZE = 16; - static BUTTON_DIVIDER_FONT_SIZE = 24; - static BUTTON_MARGIN_TOP = 8; - static BUTTON_MARGIN_BOTTOM = 16; - static BUTTON_MARGIN_LEFT = 16; - static BUTTON_MARGIN_RIGHT = 16; - static BUTTON_HEIGHT = 40; - static BUTTON_WIDTH = 177; - - static DIALOG_PRIVACY_BORDER_RADIUS = 32; - static DIALOG_PRIVACY_WIDTH = 395; - static DIALOG_PADDING_BOTTOM = 16; - - // initial check status - static INIT_NEED_TO_WAIT = 0 - static INIT_NEED_TO_VERIFY = 1 - static INIT_NEED_TO_TERMINATED = 2 - static INIT_NEED_TO_REFRESH = 3 - - static RESULT_SUCCESS = 1 - static RESULT_FAILURE = 0 - static RESULT_CODE = 0 - - // - static SETTING_OPER = -1 - static PASS_OPER = 0 - static DYNAMIC_OPER = 1 - static INVALID_OPER = 2 - - // - static INITIAL_INDEX = 10 - static ACCESS_TOKEN = 'ohos.security.accesstoken.tokencallback' - +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Constants { + // alphabetIndexer + static ALPHABETINDEXER_SELECTEDFONT_SIZE = 12; + static ALPHABETINDEXER_POPUPFONT_SIZE = 30; + static ALPHABETINDEXER_ITEMSIZE = 16; + static ALPHABETINDEXER_HEIGHT = 448; + static ALPHABETINDEXER_WIDTH = 36; + + // backBar + static BACKBAR_HEIGHT = 56; + static BACKBAR_MINHEIGHT = 56; + + // image of backBar + static BACKBAR_IMAGE_HEIGHT = 24; + static BACKBAR_IMAGE_WIDTH = 24; + static BACKBAR_IMAGE_MARGIN_TOP = 17; + static BACKBAR_IMAGE_MARGIN_LEFT = 12; + static BACKBAR_IMAGE_MARGIN_RIGHT = 15; + + // text of backBar + static BACKBAR_TEXT_FONT_SIZE = 20; + static BACKBAR_TEXT_FLEX_GROW = 1; + static BACKBAR_TEXT_MARGIN_TOP = 17; + + // dialog + static DIALOG_BORDER_RADIUS = 24; + static DIALOG_HEIGHT = 70; + static DIALOG_WIDTH = 336; + + // text of dialog + static DIALOG_TEXT_FONT_SIZE = 20; + static DIALOG_TEXT_MARGIN_TOP = 25; + + // search textInput + static TEXTINPUT_PADDING_LEFT = 36; + static TEXTINPUT_BORDER_RADIUS = 20; + static TEXTINPUT_BORDER_WIDTH = 1.5; + static TEXTINPUT_PLACEHOLDER_Font_SIZE = 16; + static TEXTINPUT_HEIGHT = 40; + static TEXTINPUT_IMAGE_WIDTH = 16; + static TEXTINPUT_IMAGE_HEIGHT = 16; + static TEXTINPUT_IMAGE_MARGIN_LEFT = 12; + static TEXTINPUT_IMAGE_MARGIN_TOP = 12; + + // grid useSizeType + static GRID_MARGIN = '0vp'; + static GUTTER = 0; + static LEFT_XS_SPAN = 0; + static LEFT_XS_OFFSET = 0; + static LEFT_SM_SPAN = 0; + static LEFT_SM_OFFSET = 0; + static LEFT_MD_SPAN = 0; + static LEFT_MD_OFFSET = 0; + static LEFT_LG_SPAN = 2; + static LEFT_LG_OFFSET = 0; + static MIDDLE_XS_SPAN = 2; + static MIDDLE_XS_OFFSET = 0; + static MIDDLE_SM_SPAN = 4; + static MIDDLE_SM_OFFSET = 0; + static MIDDLE_MD_SPAN = 8; + static MIDDLE_MD_OFFSET = 0; + static MIDDLE_LG_SPAN = 8; + static MIDDLE_LG_OFFSET = 2; + static RIGHT_XS_SPAN = 0; + static RIGHT_XS_OFFSET = 2; + static RIGHT_SM_SPAN = 0; + static RIGHT_SM_OFFSET = 4; + static RIGHT_MD_SPAN = 0; + static RIGHT_MD_OFFSET = 8; + static RIGHT_LG_SPAN = 2; + static RIGHT_LG_OFFSET = 10; + + // 100% width,height + static FULL_WIDTH = '100%'; + static FULL_HEIGHT = '100%'; + + // public property style + static PERMISSION = 1; + static APPLICATION = 0; + static LAYOUT_WEIGHT = 1; + static FLEX_GROW = 1; + static TEXT_DECORATION_HEIGHT = 1; + static TEXT_MIDDLE_FONT_SIZE = 16; + static TEXT_SMAL_FONT_SIZE = 14; + static TEXT_SMALLER_FONT_SIZE = 12; + static TEXT_LINE_HEIGHT = 22; + static TEXT_SMALL_LINE_HEIGHT = 19; + static CONSTRAINTSIZE_MINHEIGHT = 48; + static LISTITEM_ROW_HEIGHT = 48; + static LISTITEM_PADDING_LEFT = 24; + static LIST_PADDING_LEFT = 12 + static LISTITEM_PADDING_RIGHT = 24; + static LISTITEM_PADDING_LEFT_RECORD = 32; + static LISTITEM_MARGIN_BOTTOM = 12; + static LISTITEM_MARGIN_BOTTOM_PERMISSION = 14; + static LISTITEM_MARGIN_BOTTOM_APPLICATION = 10; + static LISTITEM_HEIGHT_PERMISSION = 64; + static LISTITEM_HEIGHT_APPLICATION = 72; + static IMAGE_HEIGHT = 24; + static IMAGE_WIDTH = 12; + static IMAGE_HEIGHT_RECORD = 12; + static IMAGE_WIDTH_RECORD = 24; + static IMAGE_HEIGHT_RECORD_APPLICATION = 16; + static IMAGE_WIDTH_RECORD_APPLICATION = 16; + static BORDER_RADIUS = 24; + static TITLE_MARGIN_BOTTOM = 16; + static SUBTITLE_MIN_HEIGHT = 48; + static SUBTITLE_LINE_HEIGHT = 24; + static SUBTITLE_PADDING_TOP = 16; + static SUBTITLE_PADDING_BOTTOM = 8; + static TAB_HEIGHT = 56; + static TAB_DECORATION_HEIGHT = 2; + static TAB_DECORATION_POSITION_Y = 46; + static DEFAULT_PADDING_START = 12; + static DEFAULT_PADDING_END = 12; + + // application-secondary, authority-secondary + static FLEX_MARGIN_TOP = 8; + static FLEX_MARGIN_BOTTOM = 8; + static LIST_PADDING_TOP = 4; + static LIST_PADDING_BOTTOM = 4; + static LIST_MARGIN_BOTTOM = 12; + static ROW_MARGIN_TOP = 9; + static SECONDARY_TEXT_MARGIN_TOP = 19.5; + static SECONDARY_TEXT_MARGIN_LEFT = 24; + static SECONDARY_LIST_PADDING_LEFT = 12; + static SECONDARY_LIST_PADDING_RIGHT = 12; + + // application-tertiary + static TERTIARY_IMAGE_WIDTH = 64; + static TERTIARY_IMAGE_HEIGHT = 64; + static TERTIARY_IMAGE_MARGIN_LEFT = 12; + static TERTIARY_IMAGE_MARGIN_RIGHT = 12; + static TERTIARY_LABEL_MARGIN_BOTTOM = 2; + static TERTIARY_MARGIN_LEFT = 12; + static TERTIARY_TEXT_MARGIN_LEFT = 24; + static TERTIARY_HALF_WIDTH = '50%'; + static TERTIARY_ROW_MARGIN_TOP = 24; + static TERTIARY_PERMISSION_ROW_MARGIN_TOP = 12; + static TERTIARY_RADIO_IMAGE_WIDTH = 24; + static TERTIARY_RADIO_IMAGE_HEIGHT = 24; + static TERTIARY_RADIO_IMAGE_MARGIN_TOP = 4; + static TERTIARY_LISTITEM_PADDING_LEFT = 24; + static TERTIARY_LISTITEM_PADDING_RIGHT = 24; + static TERTIARY_LISTITEM_MARGIN_TOP = 1; + static TERTIARY_LIST_PADDING_LEFT = 12; + static TERTIARY_LIST_PADDING_RIGHT = 12; + static TERTIARY_LIST_PADDING_TOP = 4; + static TERTIARY_LIST_PADDING_BOTTOM = 4; + + // authority-tertiary + static AUTHORITY_IMAGE_WIDTH = 40; + static AUTHORITY_IMAGE_HEIGHT = 40; + static AUTHORITY_IMAGE_MARGIN_RIGHT = 16; + static AUTHORITY_TOGGLE_WIDTH = 36; + static AUTHORITY_TOGGLE_HEIGHT = 20; + static AUTHORITY_ROW_HEIGHT = 72; + static AUTHORITY_CONSTRAINTSIZE_MINHEIGHT = 72; + static AUTHORITY_LISTITEM_PADDING_LEFT = 12; + static AUTHORITY_LISTITEM_PADDING_RIGHT = 12; + static AUTHORITY_TEXTINPUT_PADDING_LEFT = 12; + static AUTHORITY_TEXTINPUT_PADDING_RIGHT = 24; + static AUTHORITY_TEXT_MARGIN_TOP = 24; + static AUTHORITY_TEXT_MARGIN_LEFT = 0; + static AUTHORITY_ROW_MARGIN_TOP = 24; + static NORECORD_IMAGE_WIDTH = 120; + static NORECORD_IMAGE_HEIGHT = 120; + static NORECORD_IMAGE_MARGIN_LEFT = 40; + static SEARCHNORESULT_IMAGE_WIDTH = 200; + static SEARCHNORESULT_IMAGE_HEIGHT = 200; + static AUTHORITY_COLUMN_HEIGHT = '95%'; + static AUTHORITY_ALPHABETINDEX_WIDTH = 24; + static AUTHORITY_ALPHABETINDEX_PADDING_TOP = 16; + static AUTHORITY_TEXT_DECORATION_WIDTH = '86%'; + static AUTHORITY_TEXT_DECORATION_MARGIN_LEFT = 53; + + // authority-management + static MANAGEMENT_IMAGE_WIDTH = 24; + static MANAGEMENT_IMAGE_HEIGHT = 24; + static MANAGEMENT_IMAGE_MARGIN_RIGHT = 16; + static MANAGEMENT_IMAGE_MARGIN_RIGHT_RECORD = 24; + static MANAGEMENT_IMAGE_MARGIN_LEFT = 8; + static MANAGEMENT_ROW_HEIGHT = 56; + static MANAGEMENT_TEXT_DECORATION_WIDTH = '95%'; + static MANAGEMENT_TEXT_DECORATION_MARGIN_LEFT = 40; + static MANAGEMENT_LODING_IMAGE_WIDTH = 48; + static MANAGEMENT_LODING_IMAGE_HEIGHT = 48; + static MANAGEMENT_LODING_ROW_HEIGHT = '90%'; + static MANAGEMENT_ROW_PADDING_LEFT = 12; + static MANAGEMENT_ROW_PADDING_RIGHT = 12; + static MANAGEMENT_ROW_PADDING_TOP = 8; + static MANAGEMENT_ROW_MARGIN_TOP = 12; + static MANAGEMENT_TRANSPARENCY = 0.8; + static APPLICATION_IMAGE_WIDTH = 40; + static APPLICATION_IMAGE_HEIGHT = 40; + static APPLICATION_IMAGE_MARGIN_RIGHT = 16; + static APPLICATION_TEXT_MARGIN_RIGHT = 4; + static APPLICATION_LIST_PADDING_LEFT = 12; + static APPLICATION_LIST_PADDING_RIGHT = 12; + static APPLICATION_LIST_MARGIN_BOTTOM = 50; + static APPLICATION_LISTITEM_PADDING_LEFT = 12; + static APPLICATION_LISTITEM_PADDING_RIGHT = 12; + static APPLICATION_TEXTINPUT_PADDING_LEFT = 12; + static APPLICATION_TEXTINPUT_PADDING_TOP = 8; + static APPLICATION_TEXTINPUT_PADDING_RIGHT = 24; + static APPLICATION_COLUMN_HEIGHT = '93%'; + static APPLICATION_ALPHABETINDEX_MARGIN_TOP = 12; + static APPLICATION_ALPHABETINDEX_WIDTH = 24; + static APPLICATION_TEXT_DECORATION_WIDTH = '90%'; + static APPLICATION_TEXT_DECORATION_MARGIN_LEFT = 56; + static LOADING_WIDTH = 100; + + // slice + static SLICE_START = 0; + static SLICE_END = -1; + static SLICE_START_INDEX = 0; + static SLICE_END_INDEX = 1; + + //group number + static FIXED_GROUP = 1; + static CHANGE_GROUP = 2; + static OTHER_GROUP = 3; + + // tabBar + static BAR_WIDTH = 285; + + // setTimeout + static DELAY_TIME = 1000; + static DELAY_TIME_MAX = 2000; + + // radio + static RADIO_ALLOW_NAME = '允许'; + static RADIO_ALLOW_INDEX = 0; + static RADIO_ALLOW_GROUP_NAME = 'radio'; + static RADIO_BAN_NAME = '禁止'; + static RADIO_BAN_INDEX = 1; + static RADIO_BAN_GROUP_NAME = 'radio'; + + //shape + static SHAPE_DIA = 24; + static SHAPE_BAN_DIA = 23; + static SHAPE_BIG_DIA = 48; + static SHAPE_OFFSET_X = -24; + static SHAPE_BAN_OFFSET = .5; + static SHAPE_ALLOW_DIA = 16; + static SHAPE_ALLOW_OFFSET = 4; + static SHAPE_ZINDEX = 10; + + // utils + static CHAR_CODE = 0; + static UNI_MAX = 40869; + static UNI_MIN = 19968; + + static PARMETER_BUNDLE_FLAG = 16; + static USERID = 100; + + static PERMISSION_INDEX = 0; + + static PERMISSION_NUM = 0; + + static PERMISSION_FLAG = 2; + static API_VERSION_SUPPORT_STAGE = 9; + + static PRE_AUTHORIZATION_NOT_MODIFIED = 4; + + static BUNDLE_NAME = 'com.ohos.permissionmanager' + + static START_SUBSCRIPT = 0 + static END_SUBSCRIPT = 500 + + static RECORD_PADDING_BOTTOM = '20%' + + + + + //////////////////////////////////////////// + // icon of dialog + static DIALOG_ICON_WIDTH = 24; + static DIALOG_ICON_HEIGHT = 24; + static DIALOG_ICON_MARGIN_TOP = 23; + + // label text of dialog + static DIALOG_LABEL_FONT_SIZE = 10; + static DIALOG_LABEL_MARGIN_TOP = 2; + static DIALOG_LABEL_LINE_HEIGHT = 14; + + // request text of dialog + static DIALOG_REQ_FONT_SIZE = 16; + static DIALOG_REQ_MARGIN_TOP = 16; + static DIALOG_REQ_MARGIN_LEFT = 24; + static DIALOG_REQ_LINE_HEIGHT = 22; + + // description text of dialog + static DIALOG_DESP_FONT_SIZE = 14; + static DIALOG_DESP_MARGIN_TOP = 2; + static DIALOG_DESP_MARGIN_LEFT = 24; + static DIALOG_DESP_MARGIN_RIGHT = 24; + static DIALOG_DESP_MARGIN_BOTTOM = 8; + static DIALOG_DESP_LINE_HEIGHT = 19; + + static BUTTON_FONT_SIZE = 16; + static BUTTON_DIVIDER_FONT_SIZE = 24; + static BUTTON_MARGIN_TOP = 8; + static BUTTON_MARGIN_BOTTOM = 16; + static BUTTON_MARGIN_LEFT = 16; + static BUTTON_MARGIN_RIGHT = 16; + static BUTTON_HEIGHT = 40; + static BUTTON_WIDTH = 177; + + static DIALOG_PRIVACY_BORDER_RADIUS = 32; + static DIALOG_PRIVACY_WIDTH = 395; + static DIALOG_PADDING_BOTTOM = 16; + + // initial check status + static INIT_NEED_TO_WAIT = 0 + static INIT_NEED_TO_VERIFY = 1 + static INIT_NEED_TO_TERMINATED = 2 + static INIT_NEED_TO_REFRESH = 3 + + static RESULT_SUCCESS = 1 + static RESULT_FAILURE = 0 + static RESULT_CODE = 0 + + // + static SETTING_OPER = -1 + static PASS_OPER = 0 + static DYNAMIC_OPER = 1 + static INVALID_OPER = 2 + + // + static INITIAL_INDEX = 10 + static ACCESS_TOKEN = 'ohos.security.accesstoken.tokencallback' + } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/utils/utils.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/utils/utils.ets index 8caae47c6938b5a419bd398e9e574e9ac2cda4b0..db27a00106a40dae1a100c9a9190fff94e4d91bf 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/utils/utils.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/common/utils/utils.ets @@ -1,427 +1,427 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Resmgr from '@ohos.resourceManager'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; - -import { permissionGroups, groups } from "../model/permissionGroup"; -import Constants from '../utils/constant'; - -/** - * Get app name resource - * @param {Number} labelId app name id - * @param {String} bundleName Package names - */ -export function getAppLabel(labelId, bundleName) { - return new Promise((resolve) => { - Resmgr.getResourceManager(globalThis.context, bundleName).then(item => { - item.getString(labelId, (error, value) => { - resolve(value); - }) - }).catch(error => { - console.error('Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); - }) - }) -} - -/** - * Get app icon resources - * @param {Number} iconId app icon id - * @param {String} bundleName Package names - */ -export function getAppIcon(iconId, bundleName) { - return new Promise((resolve) => { - Resmgr.getResourceManager(globalThis.context, bundleName).then(item => { - item.getMediaBase64(iconId, (error, value) => { - resolve(value); - }) - }).catch(error => { - console.error('Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); - }) - }) -} - -/** - * verify permission - * @param {Number} accessTokenId - * @param {String} permission permission name - */ -export function verifyAccessToken(accessTokenId, permission) { - return new Promise((resolve) => { - abilityAccessCtrl.createAtManager().verifyAccessToken(accessTokenId, permission).then((res) => { - return resolve(res); - }) - .catch((error) => { - console.error('verifyAccessToken failed. Cause: ' + JSON.stringify(error)); - }) - }) -} - -/** -* Let arkui detect changes in array index assignments。 -*/ -export function changeIndexValue(stateList, changeItem){ - // copy array - let result = stateList.slice(0); - for (let i = 0 ; i < changeItem.length; i++) { - let item = changeItem[i]; - if (!Array.isArray(item)) { - throw new Error("error"); - } - let index = item[0]; - let value = item[1]; - if (index == undefined || value == undefined) { - throw new Error("error"); - } - if (index < 0 || index > stateList.length - 1) { - continue; - } - let start = result.slice(0, index); - start = start.concat([value]); - result = start.concat(result.slice(index + 1)); - } - return result; -} - -// List of Chinese Pinyin Initials -let strChineseFirstPY = "YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSC" + -"YYYNJQYXXGJHHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPCBZ" + -"JJBRCFTLECZSTZFXXZHTRQHYBDLYCZSSYMMRFMYQZPWWJJYFCRWFDFZQPYDDWYXKYJAWJFFXYPSFTZYHHYZYSWCJYXSCLCXXWZZXNBGNNXBXLZSZS" + -"BSGPYSYZDHMDZBQBZCWDZZYYTZHBTSYYBZGNTNXQYWQSKBPHHLXGYBFMJEBJHHGQTJCYSXSTKZHLYCKGLYSMZXYALMELDCCXGZYRJXSDLTYZCQKCN" + -"NJWHJTZZCQLJSTSTBNXBTYXCEQXGKWJYFLZQLYHYXSPSFXLMPBYSXXXYDJCZYLLLSJXFHJXPJBTFFYABYXBHZZBJYZLWLCZGGBTSSMDTJZXPTHYQT" + -"GLJSCQFZKJZJQNLZWLSLHDZBWJNCJZYZSQQYCQYRZCJJWYBRTWPYFTWEXCSKDZCTBZHYZZYYJXZCFFZZMJYXXSDZZOTTBZLQWFCKSZSXFYRLNYJMB" + -"DTHJXSQQCCSBXYYTSYFBXDZTGBCNSLCYZZPSAZYZZSCJCSHZQYDXLBPJLLMQXTYDZXSQJTZPXLCGLQTZWJBHCTSYJSFXYEJJTLBGXSXJMYJQQPFZA" + -"SYJNTYDJXKJCDJSZCBARTDCLYJQMWNQNCLLLKBYBZZSYHQQLTWLCCXTXLLZNTYLNEWYZYXCZXXGRKRMTCNDNJTSYYSSDQDGHSDBJGHRWRQLYBGLXH" + -"LGTGXBQJDZPYJSJYJCTMRNYMGRZJCZGJMZMGXMPRYXKJNYMSGMZJYMKMFXMLDTGFBHCJHKYLPFMDXLQJJSMTQGZSJLQDLDGJYCALCMZCSDJLLNXDJ" + -"FFFFJCZFMZFFPFKHKGDPSXKTACJDHHZDDCRRCFQYJKQCCWJDXHWJLYLLZGCFCQDSMLZPBJJPLSBCJGGDCKKDEZSQCCKJGCGKDJTJDLZYCXKLQSCGJ" + -"CLTFPCQCZGWPJDQYZJJBYJHSJDZWGFSJGZKQCCZLLPSPKJGQJHZZLJPLGJGJJTHJJYJZCZMLZLYQBGJWMLJKXZDZNJQSYZMLJLLJKYWXMKJLHSKJG" + -"BMCLYYMKXJQLBMLLKMDXXKWYXYSLMLPSJQQJQXYXFJTJDXMXXLLCXQBSYJBGWYMBGGBCYXPJYGPEPFGDJGBHBNSQJYZJKJKHXQFGQZKFHYGKHDKLL" + -"SDJQXPQYKYBNQSXQNSZSWHBSXWHXWBZZXDMNSJBSBKBBZKLYLXGWXDRWYQZMYWSJQLCJXXJXKJEQXSCYETLZHLYYYSDZPAQYZCMTLSHTZCFYZYXYL" + -"JSDCJQAGYSLCQLYYYSHMRQQKLDXZSCSSSYDYCJYSFSJBFRSSZQSBXXPXJYSDRCKGJLGDKZJZBDKTCSYQPYHSTCLDJDHMXMCGXYZHJDDTMHLTXZXYL" + -"YMOHYJCLTYFBQQXPFBDFHHTKSQHZYYWCNXXCRWHOWGYJLEGWDQCWGFJYCSNTMYTOLBYGWQWESJPWNMLRYDZSZTXYQPZGCWXHNGPYXSHMYQJXZTDPP" + -"BFYHZHTJYFDZWKGKZBLDNTSXHQEEGZZYLZMMZYJZGXZXKHKSTXNXXWYLYAPSTHXDWHZYMPXAGKYDXBHNHXKDPJNMYHYLPMGOCSLNZHKXXLPZZLBML" + -"SFBHHGYGYYGGBHSCYAQTYWLXTZQCEZYDQDQMMHTKLLSZHLSJZWFYHQSWSCWLQAZYNYTLSXTHAZNKZZSZZLAXXZWWCTGQQTDDYZTCCHYQZFLXPSLZY" + -"GPZSZNGLNDQTBDLXGTCTAJDKYWNSYZLJHHZZCWNYYZYWMHYCHHYXHJKZWSXHZYXLYSKQYSPSLYZWMYPPKBYGLKZHTYXAXQSYSHXASMCHKDSCRSWJP" + -"WXSGZJLWWSCHSJHSQNHCSEGNDAQTBAALZZMSSTDQJCJKTSCJAXPLGGXHHGXXZCXPDMMHLDGTYBYSJMXHMRCPXXJZCKZXSHMLQXXTTHXWZFKHCCZDY" + -"TCJYXQHLXDHYPJQXYLSYYDZOZJNYXQEZYSQYAYXWYPDGXDDXSPPYZNDLTWRHXYDXZZJHTCXMCZLHPYYYYMHZLLHNXMYLLLMDCPPXHMXDKYCYRDLTX" + -"JCHHZZXZLCCLYLNZSHZJZZLNNRLWHYQSNJHXYNTTTKYJPYCHHYEGKCTTWLGQRLGGTGTYGYHPYHYLQYQGCWYQKPYYYTTTTLHYHLLTYTTSPLKYZXGZW" + -"GPYDSSZZDQXSKCQNMJJZZBXYQMJRTFFBTKHZKBXLJJKDXJTLBWFZPPTKQTZTGPDGNTPJYFALQMKGXBDCLZFHZCLLLLADPMXDJHLCCLGYHDZFGYDDG" + -"CYYFGYDXKSSEBDHYKDKDKHNAXXYBPBYYHXZQGAFFQYJXDMLJCSQZLLPCHBSXGJYNDYBYQSPZWJLZKSDDTACTBXZDYZYPJZQSJNKKTKNJDJGYYPGTL" + -"FYQKASDNTCYHBLWDZHBBYDWJRYGKZYHEYYFJMSDTYFZJJHGCXPLXHLDWXXJKYTCYKSSSMTWCTTQZLPBSZDZWZXGZAGYKTYWXLHLSPBCLLOQMMZSSL" + -"CMBJCSZZKYDCZJGQQDSMCYTZQQLWZQZXSSFPTTFQMDDZDSHDTDWFHTDYZJYQJQKYPBDJYYXTLJHDRQXXXHAYDHRJLKLYTWHLLRLLRCXYLBWSRSZZS" + -"YMKZZHHKYHXKSMDSYDYCJPBZBSQLFCXXXNXKXWYWSDZYQOGGQMMYHCDZTTFJYYBGSTTTYBYKJDHKYXBELHTYPJQNFXFDYKZHQKZBYJTZBXHFDXKDA" + -"SWTAWAJLDYJSFHBLDNNTNQJTJNCHXFJSRFWHZFMDRYJYJWZPDJKZYJYMPCYZNYNXFBYTFYFWYGDBNZZZDNYTXZEMMQBSQEHXFZMBMFLZZSRXYMJGS" + -"XWZJSPRYDJSJGXHJJGLJJYNZZJXHGXKYMLPYYYCXYTWQZSWHWLYRJLPXSLSXMFSWWKLCTNXNYNPSJSZHDZEPTXMYYWXYYSYWLXJQZQXZDCLEEELMC" + -"PJPCLWBXSQHFWWTFFJTNQJHJQDXHWLBYZNFJLALKYYJLDXHHYCSTYYWNRJYXYWTRMDRQHWQCMFJDYZMHMYYXJWMYZQZXTLMRSPWWCHAQBXYGZYPXY" + -"YRRCLMPYMGKSJSZYSRMYJSNXTPLNBAPPYPYLXYYZKYNLDZYJZCZNNLMZHHARQMPGWQTZMXXMLLHGDZXYHXKYXYCJMFFYYHJFSBSSQLXXNDYCANNMT" + -"CJCYPRRNYTYQNYYMBMSXNDLYLYSLJRLXYSXQMLLYZLZJJJKYZZCSFBZXXMSTBJGNXYZHLXNMCWSCYZYFZLXBRNNNYLBNRTGZQYSATSWRYHYJZMZDH" + -"ZGZDWYBSSCSKXSYHYTXXGCQGXZZSHYXJSCRHMKKBXCZJYJYMKQHZJFNBHMQHYSNJNZYBKNQMCLGQHWLZNZSWXKHLJHYYBQLBFCDSXDLDSPFZPSKJY" + -"ZWZXZDDXJSMMEGJSCSSMGCLXXKYYYLNYPWWWGYDKZJGGGZGGSYCKNJWNJPCXBJJTQTJWDSSPJXZXNZXUMELPXFSXTLLXCLJXJJLJZXCTPSWXLYDHL" + -"YQRWHSYCSQYYBYAYWJJJQFWQCQQCJQGXALDBZZYJGKGXPLTZYFXJLTPADKYQHPMATLCPDCKBMTXYBHKLENXDLEEGQDYMSAWHZMLJTWYGXLYQZLJEE" + -"YYBQQFFNLYXRDSCTGJGXYYNKLLYQKCCTLHJLQMKKZGCYYGLLLJDZGYDHZWXPYSJBZKDZGYZZHYWYFQYTYZSZYEZZLYMHJJHTSMQWYZLKYYWZCSRKQ" + -"YTLTDXWCTYJKLWSQZWBDCQYNCJSRSZJLKCDCDTLZZZACQQZZDDXYPLXZBQJYLZLLLQDDZQJYJYJZYXNYYYNYJXKXDAZWYRDLJYYYRJLXLLDYXJCYW" + -"YWNQCCLDDNYYYNYCKCZHXXCCLGZQJGKWPPCQQJYSBZZXYJSQPXJPZBSBDSFNSFPZXHDWZTDWPPTFLZZBZDMYYPQJRSDZSQZSQXBDGCPZSWDWCSQZG" + -"MDHZXMWWFYBPDGPHTMJTHZSMMBGZMBZJCFZWFZBBZMQCFMBDMCJXLGPNJBBXGYHYYJGPTZGZMQBQTCGYXJXLWZKYDPDYMGCFTPFXYZTZXDZXTGKMT" + -"YBBCLBJASKYTSSQYYMSZXFJEWLXLLSZBQJJJAKLYLXLYCCTSXMCWFKKKBSXLLLLJYXTYLTJYYTDPJHNHNNKBYQNFQYYZBYYESSESSGDYHFHWTCJBS" + -"DZZTFDMXHCNJZYMQWSRYJDZJQPDQBBSTJGGFBKJBXTGQHNGWJXJGDLLTHZHHYYYYYYSXWTYYYCCBDBPYPZYCCZYJPZYWCBDLFWZCWJDXXHYHLHWZZ" + -"XJTCZLCDPXUJCZZZLYXJJTXPHFXWPYWXZPTDZZBDZCYHJHMLXBQXSBYLRDTGJRRCTTTHYTCZWMXFYTWWZCWJWXJYWCSKYBZSCCTZQNHXNWXXKHKFH" + -"TSWOCCJYBCMPZZYKBNNZPBZHHZDLSYDDYTYFJPXYNGFXBYQXCBHXCPSXTYZDMKYSNXSXLHKMZXLYHDHKWHXXSSKQYHHCJYXGLHZXCSNHEKDTGZXQY" + -"PKDHEXTYKCNYMYYYPKQYYYKXZLTHJQTBYQHXBMYHSQCKWWYLLHCYYLNNEQXQWMCFBDCCMLJGGXDQKTLXKGNQCDGZJWYJJLYHHQTTTNWCHMXCXWHWS" + -"ZJYDJCCDBQCDGDNYXZTHCQRXCBHZTQCBXWGQWYYBXHMBYMYQTYEXMQKYAQYRGYZSLFYKKQHYSSQYSHJGJCNXKZYCXSBXYXHYYLSTYCXQTHYSMGSCP" + -"MMGCCCCCMTZTASMGQZJHKLOSQYLSWTMXSYQKDZLJQQYPLSYCZTCQQPBBQJZCLPKHQZYYXXDTDDTSJCXFFLLCHQXMJLWCJCXTSPYCXNDTJSHJWXDQQ" + -"JSKXYAMYLSJHMLALYKXCYYDMNMDQMXMCZNNCYBZKKYFLMCHCMLHXRCJJHSYLNMTJZGZGYWJXSRXCWJGJQHQZDQJDCJJZKJKGDZQGJJYJYLXZXXCDQ" + -"HHHEYTMHLFSBDJSYYSHFYSTCZQLPBDRFRZTZYKYWHSZYQKWDQZRKMSYNBCRXQBJYFAZPZZEDZCJYWBCJWHYJBQSZYWRYSZPTDKZPFPBNZTKLQYHBB" + -"ZPNPPTYZZYBQNYDCPJMMCYCQMCYFZZDCMNLFPBPLNGQJTBTTNJZPZBBZNJKLJQYLNBZQHKSJZNGGQSZZKYXSHPZSNBCGZKDDZQANZHJKDRTLZLSWJ" + -"LJZLYWTJNDJZJHXYAYNCBGTZCSSQMNJPJYTYSWXZFKWJQTKHTZPLBHSNJZSYZBWZZZZLSYLSBJHDWWQPSLMMFBJDWAQYZTCJTBNNWZXQXCDSLQGDS" + -"DPDZHJTQQPSWLYYJZLGYXYZLCTCBJTKTYCZJTQKBSJLGMGZDMCSGPYNJZYQYYKNXRPWSZXMTNCSZZYXYBYHYZAXYWQCJTLLCKJJTJHGDXDXYQYZZB" + -"YWDLWQCGLZGJGQRQZCZSSBCRPCSKYDZNXJSQGXSSJMYDNSTZTPBDLTKZWXQWQTZEXNQCZGWEZKSSBYBRTSSSLCCGBPSZQSZLCCGLLLZXHZQTHCZMQ" + -"GYZQZNMCOCSZJMMZSQPJYGQLJYJPPLDXRGZYXCCSXHSHGTZNLZWZKJCXTCFCJXLBMQBCZZWPQDNHXLJCTHYZLGYLNLSZZPCXDSCQQHJQKSXZPBAJY" + -"EMSMJTZDXLCJYRYYNWJBNGZZTMJXLTBSLYRZPYLSSCNXPHLLHYLLQQZQLXYMRSYCXZLMMCZLTZSDWTJJLLNZGGQXPFSKYGYGHBFZPDKMWGHCXMSGD" + -"XJMCJZDYCABXJDLNBCDQYGSKYDQTXDJJYXMSZQAZDZFSLQXYJSJZYLBTXXWXQQZBJZUFBBLYLWDSLJHXJYZJWTDJCZFQZQZZDZSXZZQLZCDZFJHYS" + -"PYMPQZMLPPLFFXJJNZZYLSJEYQZFPFZKSYWJJJHRDJZZXTXXGLGHYDXCSKYSWMMZCWYBAZBJKSHFHJCXMHFQHYXXYZFTSJYZFXYXPZLCHMZMBXHZZ" + -"SXYFYMNCWDABAZLXKTCSHHXKXJJZJSTHYGXSXYYHHHJWXKZXSSBZZWHHHCWTZZZPJXSNXQQJGZYZYWLLCWXZFXXYXYHXMKYYSWSQMNLNAYCYSPMJK" + -"HWCQHYLAJJMZXHMMCNZHBHXCLXTJPLTXYJHDYYLTTXFSZHYXXSJBJYAYRSMXYPLCKDUYHLXRLNLLSTYZYYQYGYHHSCCSMZCTZQXKYQFPYYRPFFLKQ" + -"UNTSZLLZMWWTCQQYZWTLLMLMPWMBZSSTZRBPDDTLQJJBXZCSRZQQYGWCSXFWZLXCCRSZDZMCYGGDZQSGTJSWLJMYMMZYHFBJDGYXCCPSHXNZCSBSJ" + -"YJGJMPPWAFFYFNXHYZXZYLREMZGZCYZSSZDLLJCSQFNXZKPTXZGXJJGFMYYYSNBTYLBNLHPFZDCYFBMGQRRSSSZXYSGTZRNYDZZCDGPJAFJFZKNZB" + -"LCZSZPSGCYCJSZLMLRSZBZZLDLSLLYSXSQZQLYXZLSKKBRXBRBZCYCXZZZEEYFGKLZLYYHGZSGZLFJHGTGWKRAAJYZKZQTSSHJJXDCYZUYJLZYRZD" + -"QQHGJZXSSZBYKJPBFRTJXLLFQWJHYLQTYMBLPZDXTZYGBDHZZRBGXHWNJTJXLKSCFSMWLSDQYSJTXKZSCFWJLBXFTZLLJZLLQBLSQMQQCGCZFPBPH" + -"ZCZJLPYYGGDTGWDCFCZQYYYQYSSCLXZSKLZZZGFFCQNWGLHQYZJJCZLQZZYJPJZZBPDCCMHJGXDQDGDLZQMFGPSYTSDYFWWDJZJYSXYYCZCYHZWPB" + -"YKXRYLYBHKJKSFXTZJMMCKHLLTNYYMSYXYZPYJQYCSYCWMTJJKQYRHLLQXPSGTLYYCLJSCPXJYZFNMLRGJJTYZBXYZMSJYJHHFZQMSYXRSZCWTLRT" + -"QZSSTKXGQKGSPTGCZNJSJCQCXHMXGGZTQYDJKZDLBZSXJLHYQGGGTHQSZPYHJHHGYYGKGGCWJZZYLCZLXQSFTGZSLLLMLJSKCTBLLZZSZMMNYTPZS" + -"XQHJCJYQXYZXZQZCPSHKZZYSXCDFGMWQRLLQXRFZTLYSTCTMJCXJJXHJNXTNRZTZFQYHQGLLGCXSZSJDJLJCYDSJTLNYXHSZXCGJZYQPYLFHDJSBP" + -"CCZHJJJQZJQDYBSSLLCMYTTMQTBHJQNNYGKYRQYQMZGCJKPDCGMYZHQLLSLLCLMHOLZGDYYFZSLJCQZLYLZQJESHNYLLJXGJXLYSYYYXNBZLJSSZC" + -"QQCJYLLZLTJYLLZLLBNYLGQCHXYYXOXCXQKYJXXXYKLXSXXYQXCYKQXQCSGYXXYQXYGYTQOHXHXPYXXXULCYEYCHZZCBWQBBWJQZSCSZSSLZYLKDE" + -"SJZWMYMCYTSDSXXSCJPQQSQYLYYZYCMDJDZYWCBTJSYDJKCYDDJLBDJJSODZYSYXQQYXDHHGQQYQHDYXWGMMMAJDYBBBPPBCMUUPLJZSMTXERXJMH" + -"QNUTPJDCBSSMSSSTKJTSSMMTRCPLZSZMLQDSDMJMQPNQDXCFYNBFSDQXYXHYAYKQYDDLQYYYSSZBYDSLNTFQTZQPZMCHDHCZCWFDXTMYQSPHQYYXS" + -"RGJCWTJTZZQMGWJJTJHTQJBBHWZPXXHYQFXXQYWYYHYSCDYDHHQMNMTMWCPBSZPPZZGLMZFOLLCFWHMMSJZTTDHZZYFFYTZZGZYSKYJXQYJZQBHMB" + -"ZZLYGHGFMSHPZFZSNCLPBQSNJXZSLXXFPMTYJYGBXLLDLXPZJYZJYHHZCYWHJYLSJEXFSZZYWXKZJLUYDTMLYMQJPWXYHXSKTQJEZRPXXZHHMHWQP" + -"WQLYJJQJJZSZCPHJLCHHNXJLQWZJHBMZYXBDHHYPZLHLHLGFWLCHYYTLHJXCJMSCPXSTKPNHQXSRTYXXTESYJCTLSSLSTDLLLWWYHDHRJZSFGXTSY" + -"CZYNYHTDHWJSLHTZDQDJZXXQHGYLTZPHCSQFCLNJTCLZPFSTPDYNYLGMJLLYCQHYSSHCHYLHQYQTMZYPBYWRFQYKQSYSLZDQJMPXYYSSRHZJNYWTQ" + -"DFZBWWTWWRXCWHGYHXMKMYYYQMSMZHNGCEPMLQQMTCWCTMMPXJPJJHFXYYZSXZHTYBMSTSYJTTQQQYYLHYNPYQZLCYZHZWSMYLKFJXLWGXYPJYTYS" + -"YXYMZCKTTWLKSMZSYLMPWLZWXWQZSSAQSYXYRHSSNTSRAPXCPWCMGDXHXZDZYFJHGZTTSBJHGYZSZYSMYCLLLXBTYXHBBZJKSSDMALXHYCFYGMQYP" + -"JYCQXJLLLJGSLZGQLYCJCCZOTYXMTMTTLLWTGPXYMZMKLPSZZZXHKQYSXCTYJZYHXSHYXZKXLZWPSQPYHJWPJPWXQQYLXSDHMRSLZZYZWTTCYXYSZ" + -"ZSHBSCCSTPLWSSCJCHNLCGCHSSPHYLHFHHXJSXYLLNYLSZDHZXYLSXLWZYKCLDYAXZCMDDYSPJTQJZLNWQPSSSWCTSTSZLBLNXSMNYYMJQBQHRZWT" + -"YYDCHQLXKPZWBGQYBKFCMZWPZLLYYLSZYDWHXPSBCMLJBSCGBHXLQHYRLJXYSWXWXZSLDFHLSLYNJLZYFLYJYCDRJLFSYZFSLLCQYQFGJYHYXZLYL" + -"MSTDJCYHBZLLNWLXXYGYYHSMGDHXXHHLZZJZXCZZZCYQZFNGWPYLCPKPYYPMCLQKDGXZGGWQBDXZZKZFBXXLZXJTPJPTTBYTSZZDWSLCHZHSLTYXH" + -"QLHYXXXYYZYSWTXZKHLXZXZPYHGCHKCFSYHUTJRLXFJXPTZTWHPLYXFCRHXSHXKYXXYHZQDXQWULHYHMJTBFLKHTXCWHJFWJCFPQRYQXCYYYQYGRP" + -"YWSGSUNGWCHKZDXYFLXXHJJBYZWTSXXNCYJJYMSWZJQRMHXZWFQSYLZJZGBHYNSLBGTTCSYBYXXWXYHXYYXNSQYXMQYWRGYQLXBBZLJSYLPSYTJZY" + -"HYZAWLRORJMKSCZJXXXYXCHDYXRYXXJDTSQFXLYLTSFFYXLMTYJMJUYYYXLTZCSXQZQHZXLYYXZHDNBRXXXJCTYHLBRLMBRLLAXKYLLLJLYXXLYCR" + -"YLCJTGJCMTLZLLCYZZPZPCYAWHJJFYBDYYZSMPCKZDQYQPBPCJPDCYZMDPBCYYDYCNNPLMTMLRMFMMGWYZBSJGYGSMZQQQZTXMKQWGXLLPJGZBQCD" + -"JJJFPKJKCXBLJMSWMDTQJXLDLPPBXCWRCQFBFQJCZAHZGMYKPHYYHZYKNDKZMBPJYXPXYHLFPNYYGXJDBKXNXHJMZJXSTRSTLDXSKZYSYBZXJLXYS" + -"LBZYSLHXJPFXPQNBYLLJQKYGZMCYZZYMCCSLCLHZFWFWYXZMWSXTYNXJHPYYMCYSPMHYSMYDYSHQYZCHMJJMZCAAGCFJBBHPLYZYLXXSDJGXDHKXX" + -"TXXNBHRMLYJSLTXMRHNLXQJXYZLLYSWQGDLBJHDCGJYQYCMHWFMJYBMBYJYJWYMDPWHXQLDYGPDFXXBCGJSPCKRSSYZJMSLBZZJFLJJJLGXZGYXYX" + -"LSZQYXBEXYXHGCXBPLDYHWETTWWCJMBTXCHXYQXLLXFLYXLLJLSSFWDPZSMYJCLMWYTCZPCHQEKCQBWLCQYDPLQPPQZQFJQDJHYMMCXTXDRMJWRHX" + -"CJZYLQXDYYNHYYHRSLSRSYWWZJYMTLTLLGTQCJZYABTCKZCJYCCQLJZQXALMZYHYWLWDXZXQDLLQSHGPJFJLJHJABCQZDJGTKHSSTCYJLPSWZLXZX" + -"RWGLDLZRLZXTGSLLLLZLYXXWGDZYGBDPHZPBRLWSXQBPFDWOFMWHLYPCBJCCLDMBZPBZZLCYQXLDOMZBLZWPDWYYGDSTTHCSQSCCRSSSYSLFYBFNT" + -"YJSZDFNDPDHDZZMBBLSLCMYFFGTJJQWFTMTPJWFNLBZCMMJTGBDZLQLPYFHYYMJYLSDCHDZJWJCCTLJCLDTLJJCPDDSQDSSZYBNDBJLGGJZXSXNLY" + -"CYBJXQYCBYLZCFZPPGKCXZDZFZTJJFJSJXZBNZYJQTTYJYHTYCZHYMDJXTTMPXSPLZCDWSLSHXYPZGTFMLCJTYCBPMGDKWYCYZCDSZZYHFLYCTYGW" + -"HKJYYLSJCXGYWJCBLLCSNDDBTZBSCLYZCZZSSQDLLMQYYHFSLQLLXFTYHABXGWNYWYYPLLSDLDLLBJCYXJZMLHLJDXYYQYTDLLLBUGBFDFBBQJZZM" + -"DPJHGCLGMJJPGAEHHBWCQXAXHHHZCHXYPHJAXHLPHJPGPZJQCQZGJJZZUZDMQYYBZZPHYHYBWHAZYJHYKFGDPFQSDLZMLJXKXGALXZDAGLMDGXMWZ" + -"QYXXDXXPFDMMSSYMPFMDMMKXKSYZYSHDZKXSYSMMZZZMSYDNZZCZXFPLSTMZDNMXCKJMZTYYMZMZZMSXHHDCZJEMXXKLJSTLWLSQLYJZLLZJSSDPP" + -"MHNLZJCZYHMXXHGZCJMDHXTKGRMXFWMCGMWKDTKSXQMMMFZZYDKMSCLCMPCGMHSPXQPZDSSLCXKYXTWLWJYAHZJGZQMCSNXYYMMPMLKJXMHLMLQMX" + -"CTKZMJQYSZJSYSZHSYJZJCDAJZYBSDQJZGWZQQXFKDMSDJLFWEHKZQKJPEYPZYSZCDWYJFFMZZYLTTDZZEFMZLBNPPLPLPEPSZALLTYLKCKQZKGEN" + -"QLWAGYXYDPXLHSXQQWQCQXQCLHYXXMLYCCWLYMQYSKGCHLCJNSZKPYZKCQZQLJPDMDZHLASXLBYDWQLWDNBQCRYDDZTJYBKBWSZDXDTNPJDTCTQDF" + -"XQQMGNXECLTTBKPWSLCTYQLPWYZZKLPYGZCQQPLLKCCYLPQMZCZQCLJSLQZDJXLDDHPZQDLJJXZQDXYZQKZLJCYQDYJPPYPQYKJYRMPCBYMCXKLLZ" + -"LLFQPYLLLMBSGLCYSSLRSYSQTMXYXZQZFDZUYSYZTFFMZZSMZQHZSSCCMLYXWTPZGXZJGZGSJSGKDDHTQGGZLLBJDZLCBCHYXYZHZFYWXYZYMSDBZ" + -"ZYJGTSMTFXQYXQSTDGSLNXDLRYZZLRYYLXQHTXSRTZNGZXBNQQZFMYKMZJBZYMKBPNLYZPBLMCNQYZZZSJZHJCTZKHYZZJRDYZHNPXGLFZTLKGJTC" + -"TSSYLLGZRZBBQZZKLPKLCZYSSUYXBJFPNJZZXCDWXZYJXZZDJJKGGRSRJKMSMZJLSJYWQSKYHQJSXPJZZZLSNSHRNYPZTWCHKLPSRZLZXYJQXQKYS" + -"JYCZTLQZYBBYBWZPQDWWYZCYTJCJXCKCWDKKZXSGKDZXWWYYJQYYTCYTDLLXWKCZKKLCCLZCQQDZLQLCSFQCHQHSFSMQZZLNBJJZBSJHTSZDYSJQJ" + -"PDLZCDCWJKJZZLPYCGMZWDJJBSJQZSYZYHHXJPBJYDSSXDZNCGLQMBTSFSBPDZDLZNFGFJGFSMPXJQLMBLGQCYYXBQKDJJQYRFKZTJDHCZKLBSDZC" + -"FJTPLLJGXHYXZCSSZZXSTJYGKGCKGYOQXJPLZPBPGTGYJZGHZQZZLBJLSQFZGKQQJZGYCZBZQTLDXRJXBSXXPZXHYZYCLWDXJJHXMFDZPFZHQHQMQ" + -"GKSLYHTYCGFRZGNQXCLPDLBZCSCZQLLJBLHBZCYPZZPPDYMZZSGYHCKCPZJGSLJLNSCDSLDLXBMSTLDDFJMKDJDHZLZXLSZQPQPGJLLYBDSZGQLBZ" + -"LSLKYYHZTTNTJYQTZZPSZQZTLLJTYYLLQLLQYZQLBDZLSLYYZYMDFSZSNHLXZNCZQZPBWSKRFBSYZMTHBLGJPMCZZLSTLXSHTCSYZLZBLFEQHLXFL" + -"CJLYLJQCBZLZJHHSSTBRMHXZHJZCLXFNBGXGTQJCZTMSFZKJMSSNXLJKBHSJXNTNLZDNTLMSJXGZJYJCZXYJYJWRWWQNZTNFJSZPZSHZJFYRDJSFS" + -"ZJZBJFZQZZHZLXFYSBZQLZSGYFTZDCSZXZJBQMSZKJRHYJZCKMJKHCHGTXKXQGLXPXFXTRTYLXJXHDTSJXHJZJXZWZLCQSBTXWXGXTXXHXFTSDKFJ" + -"HZYJFJXRZSDLLLTQSQQZQWZXSYQTWGWBZCGZLLYZBCLMQQTZHZXZXLJFRMYZFLXYSQXXJKXRMQDZDMMYYBSQBHGZMWFWXGMXLZPYYTGZYCCDXYZXY" + -"WGSYJYZNBHPZJSQSYXSXRTFYZGRHZTXSZZTHCBFCLSYXZLZQMZLMPLMXZJXSFLBYZMYQHXJSXRXSQZZZSSLYFRCZJRCRXHHZXQYDYHXSJJHZCXZBT" + -"YNSYSXJBQLPXZQPYMLXZKYXLXCJLCYSXXZZLXDLLLJJYHZXGYJWKJRWYHCPSGNRZLFZWFZZNSXGXFLZSXZZZBFCSYJDBRJKRDHHGXJLJJTGXJXXST" + -"JTJXLYXQFCSGSWMSBCTLQZZWLZZKXJMLTMJYHSDDBXGZHDLBMYJFRZFSGCLYJBPMLYSMSXLSZJQQHJZFXGFQFQBPXZGYYQXGZTCQWYLTLGWSGWHRL" + -"FSFGZJMGMGBGTJFSYZZGZYZAFLSSPMLPFLCWBJZCLJJMZLPJJLYMQDMYYYFBGYGYZMLYZDXQYXRQQQHSYYYQXYLJTYXFSFSLLGNQCYHYCWFHCCCFX" + -"PYLYPLLZYXXXXXKQHHXSHJZCFZSCZJXCPZWHHHHHAPYLQALPQAFYHXDYLUKMZQGGGDDESRNNZLTZGCHYPPYSQJJHCLLJTOLNJPZLJLHYMHEYDYDSQ" + -"YCDDHGZUNDZCLZYZLLZNTNYZGSLHSLPJJBDGWXPCDUTJCKLKCLWKLLCASSTKZZDNQNTTLYYZSSYSSZZRYLJQKCQDHHCRXRZYDGRGCWCGZQFFFPPJF" + -"ZYNAKRGYWYQPQXXFKJTSZZXSWZDDFBBXTBGTZKZNPZZPZXZPJSZBMQHKCYXYLDKLJNYPKYGHGDZJXXEAHPNZKZTZCMXCXMMJXNKSZQNMNLWBWWXJK" + -"YHCPSTMCSQTZJYXTPCTPDTNNPGLLLZSJLSPBLPLQHDTNJNLYYRSZFFJFQWDPHZDWMRZCCLODAXNSSNYZRESTYJWJYJDBCFXNMWTTBYLWSTSZGYBLJ" + -"PXGLBOCLHPCBJLTMXZLJYLZXCLTPNCLCKXTPZJSWCYXSFYSZDKNTLBYJCYJLLSTGQCBXRYZXBXKLYLHZLQZLNZCXWJZLJZJNCJHXMNZZGJZZXTZJX" + -"YCYYCXXJYYXJJXSSSJSTSSTTPPGQTCSXWZDCSYFPTFBFHFBBLZJCLZZDBXGCXLQPXKFZFLSYLTUWBMQJHSZBMDDBCYSCCLDXYCDDQLYJJWMQLLCSG" + -"LJJSYFPYYCCYLTJANTJJPWYCMMGQYYSXDXQMZHSZXPFTWWZQSWQRFKJLZJQQYFBRXJHHFWJJZYQAZMYFRHCYYBYQWLPEXCCZSTYRLTTDMQLYKMBBG" + -"MYYJPRKZNPBSXYXBHYZDJDNGHPMFSGMWFZMFQMMBCMZZCJJLCNUXYQLMLRYGQZCYXZLWJGCJCGGMCJNFYZZJHYCPRRCMTZQZXHFQGTJXCCJEAQCRJ" + -"YHPLQLSZDJRBCQHQDYRHYLYXJSYMHZYDWLDFRYHBPYDTSSCNWBXGLPZMLZZTQSSCPJMXXYCSJYTYCGHYCJWYRXXLFEMWJNMKLLSWTXHYYYNCMMCWJ" + -"DQDJZGLLJWJRKHPZGGFLCCSCZMCBLTBHBQJXQDSPDJZZGKGLFQYWBZYZJLTSTDHQHCTCBCHFLQMPWDSHYYTQWCNZZJTLBYMBPDYYYXSQKXWYYFLXX" + -"NCWCXYPMAELYKKJMZZZBRXYYQJFLJPFHHHYTZZXSGQQMHSPGDZQWBWPJHZJDYSCQWZKTXXSQLZYYMYSDZGRXCKKUJLWPYSYSCSYZLRMLQSYLJXBCX" + -"TLWDQZPCYCYKPPPNSXFYZJJRCEMHSZMSXLXGLRWGCSTLRSXBZGBZGZTCPLUJLSLYLYMTXMTZPALZXPXJTJWTCYYZLBLXBZLQMYLXPGHDSLSSDMXMB" + -"DZZSXWHAMLCZCPJMCNHJYSNSYGCHSKQMZZQDLLKABLWJXSFMOCDXJRRLYQZKJMYBYQLYHETFJZFRFKSRYXFJTWDSXXSYSQJYSLYXWJHSNLXYYXHBH" + -"AWHHJZXWMYLJCSSLKYDZTXBZSYFDXGXZJKHSXXYBSSXDPYNZWRPTQZCZENYGCXQFJYKJBZMLJCMQQXUOXSLYXXLYLLJDZBTYMHPFSTTQQWLHOKYBL" + -"ZZALZXQLHZWRRQHLSTMYPYXJJXMQSJFNBXYXYJXXYQYLTHYLQYFMLKLJTMLLHSZWKZHLJMLHLJKLJSTLQXYLMBHHLNLZXQJHXCFXXLHYHJJGBYZZK" + -"BXSCQDJQDSUJZYYHZHHMGSXCSYMXFEBCQWWRBPYYJQTYZCYQYQQZYHMWFFHGZFRJFCDPXNTQYZPDYKHJLFRZXPPXZDBBGZQSTLGDGYLCQMLCHHMFY" + -"WLZYXKJLYPQHSYWMQQGQZMLZJNSQXJQSYJYCBEHSXFSZPXZWFLLBCYYJDYTDTHWZSFJMQQYJLMQXXLLDTTKHHYBFPWTYYSQQWNQWLGWDEBZWCMYGC" + -"ULKJXTMXMYJSXHYBRWFYMWFRXYQMXYSZTZZTFYKMLDHQDXWYYNLCRYJBLPSXCXYWLSPRRJWXHQYPHTYDNXHHMMYWYTZCSQMTSSCCDALWZTCPQPYJL" + -"LQZYJSWXMZZMMYLMXCLMXCZMXMZSQTZPPQQBLPGXQZHFLJJHYTJSRXWZXSCCDLXTYJDCQJXSLQYCLZXLZZXMXQRJMHRHZJBHMFLJLMLCLQNLDXZLL" + -"LPYPSYJYSXCQQDCMQJZZXHNPNXZMEKMXHYKYQLXSXTXJYYHWDCWDZHQYYBGYBCYSCFGPSJNZDYZZJZXRZRQJJYMCANYRJTLDPPYZBSTJKXXZYPFDW" + -"FGZZRPYMTNGXZQBYXNBUFNQKRJQZMJEGRZGYCLKXZDSKKNSXKCLJSPJYYZLQQJYBZSSQLLLKJXTBKTYLCCDDBLSPPFYLGYDTZJYQGGKQTTFZXBDKT" + -"YYHYBBFYTYYBCLPDYTGDHRYRNJSPTCSNYJQHKLLLZSLYDXXWBCJQSPXBPJZJCJDZFFXXBRMLAZHCSNDLBJDSZBLPRZTSWSBXBCLLXXLZDJZSJPYLY" + -"XXYFTFFFBHJJXGBYXJPMMMPSSJZJMTLYZJXSWXTYLEDQPJMYGQZJGDJLQJWJQLLSJGJGYGMSCLJJXDTYGJQJQJCJZCJGDZZSXQGSJGGCXHQXSNQLZ" + -"ZBXHSGZXCXYLJXYXYYDFQQJHJFXDHCTXJYRXYSQTJXYEFYYSSYYJXNCYZXFXMSYSZXYYSCHSHXZZZGZZZGFJDLTYLNPZGYJYZYYQZPBXQBDZTZCZY" + -"XXYHHSQXSHDHGQHJHGYWSZTMZMLHYXGEBTYLZKQWYTJZRCLEKYSTDBCYKQQSAYXCJXWWGSBHJYZYDHCSJKQCXSWXFLTYNYZPZCCZJQTZWJQDZZZQZ" + -"LJJXLSBHPYXXPSXSHHEZTXFPTLQYZZXHYTXNCFZYYHXGNXMYWXTZSJPTHHGYMXMXQZXTSBCZYJYXXTYYZYPCQLMMSZMJZZLLZXGXZAAJZYXJMZXWD" + -"XZSXZDZXLEYJJZQBHZWZZZQTZPSXZTDSXJJJZNYAZPHXYYSRNQDTHZHYYKYJHDZXZLSWCLYBZYECWCYCRYLCXNHZYDZYDYJDFRJJHTRSQTXYXJRJH" + -"OJYNXELXSFSFJZGHPZSXZSZDZCQZBYYKLSGSJHCZSHDGQGXYZGXCHXZJWYQWGYHKSSEQZZNDZFKWYSSTCLZSTSYMCDHJXXYWEYXCZAYDMPXMDSXYB" + -"SQMJMZJMTZQLPJYQZCGQHXJHHLXXHLHDLDJQCLDWBSXFZZYYSCHTYTYYBHECXHYKGJPXHHYZJFXHWHBDZFYZBCAPNPGNYDMSXHMMMMAMYNBYJTMPX" + -"YYMCTHJBZYFCGTYHWPHFTWZZEZSBZEGPFMTSKFTYCMHFLLHGPZJXZJGZJYXZSBBQSCZZLZCCSTPGXMJSFTCCZJZDJXCYBZLFCJSYZFGSZLYBCWZZB" + -"YZDZYPSWYJZXZBDSYUXLZZBZFYGCZXBZHZFTPBGZGEJBSTGKDMFHYZZJHZLLZZGJQZLSFDJSSCBZGPDLFZFZSZYZYZSYGCXSNXXCHCZXTZZLJFZGQ" + -"SQYXZJQDCCZTQCDXZJYQJQCHXZTDLGSCXZSYQJQTZWLQDQZTQCHQQJZYEZZZPBWKDJFCJPZTYPQYQTTYNLMBDKTJZPQZQZZFPZSBNJLGYJDXJDZZK" + -"ZGQKXDLPZJTCJDQBXDJQJSTCKNXBXZMSLYJCQMTJQWWCJQNJNLLLHJCWQTBZQYDZCZPZZDZYDDCYZZZCCJTTJFZDPRRTZTJDCQTQZDTJNPLZBCLLC" + -"TZSXKJZQZPZLBZRBTJDCXFCZDBCCJJLTQQPLDCGZDBBZJCQDCJWYNLLZYZCCDWLLXWZLXRXNTQQCZXKQLSGDFQTDDGLRLAJJTKUYMKQLLTZYTDYYC" + -"ZGJWYXDXFRSKSTQTENQMRKQZHHQKDLDAZFKYPBGGPZREBZZYKZZSPEGJXGYKQZZZSLYSYYYZWFQZYLZZLZHWCHKYPQGNPGBLPLRRJYXCCSYYHSFZF" + -"YBZYYTGZXYLXCZWXXZJZBLFFLGSKHYJZEYJHLPLLLLCZGXDRZELRHGKLZZYHZLYQSZZJZQLJZFLNBHGWLCZCFJYSPYXZLZLXGCCPZBLLCYBBBBUBB" + -"CBPCRNNZCZYRBFSRLDCGQYYQXYGMQZWTZYTYJXYFWTEHZZJYWLCCNTZYJJZDEDPZDZTSYQJHDYMBJNYJZLXTSSTPHNDJXXBYXQTZQDDTJTDYYTGWS" + -"CSZQFLSHLGLBCZPHDLYZJYCKWTYTYLBNYTSDSYCCTYSZYYEBHEXHQDTWNYGYCLXTSZYSTQMYGZAZCCSZZDSLZCLZRQXYYELJSBYMXSXZTEMBBLLYY" + -"LLYTDQYSHYMRQWKFKBFXNXSBYCHXBWJYHTQBPBSBWDZYLKGZSKYHXQZJXHXJXGNLJKZLYYCDXLFYFGHLJGJYBXQLYBXQPQGZTZPLNCYPXDJYQYDYM" + -"RBESJYYHKXXSTMXRCZZYWXYQYBMCLLYZHQYZWQXDBXBZWZMSLPDMYSKFMZKLZCYQYCZLQXFZZYDQZPZYGYJYZMZXDZFYFYTTQTZHGSPCZMLCCYTZX" + -"JCYTJMKSLPZHYSNZLLYTPZCTZZCKTXDHXXTQCYFKSMQCCYYAZHTJPCYLZLYJBJXTPNYLJYYNRXSYLMMNXJSMYBCSYSYLZYLXJJQYLDZLPQBFZZBLF" + -"NDXQKCZFYWHGQMRDSXYCYTXNQQJZYYPFZXDYZFPRXEJDGYQBXRCNFYYQPGHYJDYZXGRHTKYLNWDZNTSMPKLBTHBPYSZBZTJZSZZJTYYXZPHSSZZBZ" + -"CZPTQFZMYFLYPYBBJQXZMXXDJMTSYSKKBJZXHJCKLPSMKYJZCXTMLJYXRZZQSLXXQPYZXMKYXXXJCLJPRMYYGADYSKQLSNDHYZKQXZYZTCGHZTLML" + -"WZYBWSYCTBHJHJFCWZTXWYTKZLXQSHLYJZJXTMPLPYCGLTBZZTLZJCYJGDTCLKLPLLQPJMZPAPXYZLKKTKDZCZZBNZDYDYQZJYJGMCTXLTGXSZLML" + -"HBGLKFWNWZHDXUHLFMKYSLGXDTWWFRJEJZTZHYDXYKSHWFZCQSHKTMQQHTZHYMJDJSKHXZJZBZZXYMPAGQMSTPXLSKLZYNWRTSQLSZBPSPSGZWYHT" + -"LKSSSWHZZLYYTNXJGMJSZSUFWNLSOZTXGXLSAMMLBWLDSZYLAKQCQCTMYCFJBSLXCLZZCLXXKSBZQCLHJPSQPLSXXCKSLNHPSFQQYTXYJZLQLDXZQ" + -"JZDYYDJNZPTUZDSKJFSLJHYLZSQZLBTXYDGTQFDBYAZXDZHZJNHHQBYKNXJJQCZMLLJZKSPLDYCLBBLXKLELXJLBQYCXJXGCNLCQPLZLZYJTZLJGY" + -"ZDZPLTQCSXFDMNYCXGBTJDCZNBGBQYQJWGKFHTNPYQZQGBKPBBYZMTJDYTBLSQMPSXTBNPDXKLEMYYCJYNZCTLDYKZZXDDXHQSHDGMZSJYCCTAYRZ" + -"LPYLTLKXSLZCGGEXCLFXLKJRTLQJAQZNCMBYDKKCXGLCZJZXJHPTDJJMZQYKQSECQZDSHHADMLZFMMZBGNTJNNLGBYJBRBTMLBYJDZXLCJLPLDLPC" + -"QDHLXZLYCBLCXZZJADJLNZMMSSSMYBHBSQKBHRSXXJMXSDZNZPXLGBRHWGGFCXGMSKLLTSJYYCQLTSKYWYYHYWXBXQYWPYWYKQLSQPTNTKHQCWDQK" + -"TWPXXHCPTHTWUMSSYHBWCRWXHJMKMZNGWTMLKFGHKJYLSYYCXWHYECLQHKQHTTQKHFZLDXQWYZYYDESBPKYRZPJFYYZJCEQDZZDLATZBBFJLLCXDL" + -"MJSSXEGYGSJQXCWBXSSZPDYZCXDNYXPPZYDLYJCZPLTXLSXYZYRXCYYYDYLWWNZSAHJSYQYHGYWWAXTJZDAXYSRLTDPSSYYFNEJDXYZHLXLLLZQZS" + -"JNYQYQQXYJGHZGZCYJCHZLYCDSHWSHJZYJXCLLNXZJJYYXNFXMWFPYLCYLLABWDDHWDXJMCXZTZPMLQZHSFHZYNZTLLDYWLSLXHYMMYLMBWWKYXYA" + -"DTXYLLDJPYBPWUXJMWMLLSAFDLLYFLBHHHBQQLTZJCQJLDJTFFKMMMBYTHYGDCQRDDWRQJXNBYSNWZDBYYTBJHPYBYTTJXAAHGQDQTMYSTQXKBTZP" + -"KJLZRBEQQSSMJJBDJOTGTBXPGBKTLHQXJJJCTHXQDWJLWRFWQGWSHCKRYSWGFTGYGBXSDWDWRFHWYTJJXXXJYZYSLPYYYPAYXHYDQKXSHXYXGSKQH" + -"YWFDDDPPLCJLQQEEWXKSYYKDYPLTJTHKJLTCYYHHJTTPLTZZCDLTHQKZXQYSTEEYWYYZYXXYYSTTJKLLPZMCYHQGXYHSRMBXPLLNQYDQHXSXXWGDQ" + -"BSHYLLPJJJTHYJKYPPTHYYKTYEZYENMDSHLCRPQFDGFXZPSFTLJXXJBSWYYSKSFLXLPPLBBBLBSFXFYZBSJSSYLPBBFFFFSSCJDSTZSXZRYYSYFFS" + -"YZYZBJTBCTSBSDHRTJJBYTCXYJEYLXCBNEBJDSYXYKGSJZBXBYTFZWGENYHHTHZHHXFWGCSTBGXKLSXYWMTMBYXJSTZSCDYQRCYTWXZFHMYMCXLZN" + -"SDJTTTXRYCFYJSBSDYERXJLJXBBDEYNJGHXGCKGSCYMBLXJMSZNSKGXFBNBPTHFJAAFXYXFPXMYPQDTZCXZZPXRSYWZDLYBBKTYQPQJPZYPZJZNJP" + -"ZJLZZFYSBTTSLMPTZRTDXQSJEHBZYLZDHLJSQMLHTXTJECXSLZZSPKTLZKQQYFSYGYWPCPQFHQHYTQXZKRSGTTSQCZLPTXCDYYZXSQZSLXLZMYCPC" + -"QBZYXHBSXLZDLTCDXTYLZJYYZPZYZLTXJSJXHLPMYTXCQRBLZSSFJZZTNJYTXMYJHLHPPLCYXQJQQKZZSCPZKSWALQSBLCCZJSXGWWWYGYKTJBBZT" + -"DKHXHKGTGPBKQYSLPXPJCKBMLLXDZSTBKLGGQKQLSBKKTFXRMDKBFTPZFRTBBRFERQGXYJPZSSTLBZTPSZQZSJDHLJQLZBPMSMMSXLQQNHKNBLRDD" + -"NXXDHDDJCYYGYLXGZLXSYGMQQGKHBPMXYXLYTQWLWGCPBMQXCYZYDRJBHTDJYHQSHTMJSBYPLWHLZFFNYPMHXXHPLTBQPFBJWQDBYGPNZTPFZJGSD" + -"DTQSHZEAWZZYLLTYYBWJKXXGHLFKXDJTMSZSQYNZGGSWQSPHTLSSKMCLZXYSZQZXNCJDQGZDLFNYKLJCJLLZLMZZNHYDSSHTHZZLZZBBHQZWWYCRZ" + -"HLYQQJBEYFXXXWHSRXWQHWPSLMSSKZTTYGYQQWRSLALHMJTQJSMXQBJJZJXZYZKXBYQXBJXSHZTSFJLXMXZXFGHKZSZGGYLCLSARJYHSLLLMZXELG" + -"LXYDJYTLFBHBPNLYZFBBHPTGJKWETZHKJJXZXXGLLJLSTGSHJJYQLQZFKCGNNDJSSZFDBCTWWSEQFHQJBSAQTGYPQLBXBMMYWXGSLZHGLZGQYFLZB" + -"YFZJFRYSFMBYZHQGFWZSYFYJJPHZBYYZFFWODGRLMFTWLBZGYCQXCDJYGZYYYYTYTYDWEGAZYHXJLZYYHLRMGRXXZCLHNELJJTJTPWJYBJJBXJJTJ" + -"TEEKHWSLJPLPSFYZPQQBDLQJJTYYQLYZKDKSQJYYQZLDQTGJQYZJSUCMRYQTHTEJMFCTYHYPKMHYZWJDQFHYYXWSHCTXRLJHQXHCCYYYJLTKTTYTM" + -"XGTCJTZAYYOCZLYLBSZYWJYTSJYHBYSHFJLYGJXXTMZYYLTXXYPZLXYJZYZYYPNHMYMDYYLBLHLSYYQQLLNJJYMSOYQBZGDLYXYLCQYXTSZEGXHZG" + -"LHWBLJHEYXTWQMAKBPQCGYSHHEGQCMWYYWLJYJHYYZLLJJYLHZYHMGSLJLJXCJJYCLYCJPCPZJZJMMYLCQLNQLJQJSXYJMLSZLJQLYCMMHCFMMFPQ" + -"QMFYLQMCFFQMMMMHMZNFHHJGTTHHKHSLNCHHYQDXTMMQDCYZYXYQMYQYLTDCYYYZAZZCYMZYDLZFFFMMYCQZWZZMABTBYZTDMNZZGGDFTYPCGQYTT" + -"SSFFWFDTZQSSYSTWXJHXYTSXXYLBYQHWWKXHZXWZNNZZJZJJQJCCCHYYXBZXZCYZTLLCQXYNJYCYYCYNZZQYYYEWYCZDCJYCCHYJLBTZYYCQWMPWP" + -"YMLGKDLDLGKQQBGYCHJXY"; -// 375 polyphonic words are included here -let oMultiDiff = { "19969": "DZ", "19975": "WM", "19988": "QJ", "20048": "YL", "20056": "SC", "20060": "NM", - "20094": "QG", "20127": "QJ", "20167": "QC", "20193": "YG", "20250": "KH", "20256": "ZC", "20282": "SC", - "20285": "QJG", "20291": "TD", "20314": "YD", "20340": "NE", "20375": "TD", "20389": "YJ", "20391": "CZ", - "20415": "PB", "20446": "YS", "20447": "SQ", "20504": "TC", "20608": "KG", "20854": "QJ", "20857": "ZC", - "20911": "PF", "20985": "AW", "21032": "PB", "21048": "XQ", "21049": "SC", "21089": "YS", "21119": "JC", - "21242": "SB", "21273": "SC", "21305": "YP", "21306": "QO", "21330": "ZC", "21333": "SDC", "21345": "QK", - "21378": "CA", "21397": "SC", "21414": "XS", "21442": "SC", "21477": "JG", "21480": "TD", "21484": "ZS", - "21494": "YX", "21505": "YX", "21512": "HG", "21523": "XH", "21537": "PB", "21542": "PF", "21549": "KH", - "21571": "E", "21574": "DA", "21588": "TD", "21589": "O", "21618": "ZC", "21621": "KHA", "21632": "ZJ", - "21654": "KG", "21679": "LKG", "21683": "KH", "21710": "A", "21719": "YH", "21734": "WOE", "21769": "A", - "21780": "WN", "21804": "XH", "21834": "A", "21899": "ZD", "21903": "RN", "21908": "WO", "21939": "ZC", - "21956": "SA", "21964": "YA", "21970": "TD", "22003": "A", "22031": "JG", "22040": "XS", "22060": "ZC", - "22066": "ZC", "22079": "MH", "22129": "XJ", "22179": "XA", "22237": "NJ", "22244": "TD", "22280": "JQ", - "22300": "YH", "22313": "XW", "22331": "YQ", "22343": "YJ", "22351": "PH", "22395": "DC", "22412": "TD", - "22484": "PB", "22500": "PB", "22534": "ZD", "22549": "DH", "22561": "PB", "22612": "TD", "22771": "KQ", - "22831": "HB", "22841": "JG", "22855": "QJ", "22865": "XQ", "23013": "ML", "23081": "WM", "23487": "SX", - "23558": "QJ", "23561": "YW", "23586": "YW", "23614": "YW", "23615": "SN", "23631": "PB", "23646": "ZS", - "23663": "ZT", "23673": "YG", "23762": "TD", "23769": "ZS", "23780": "QJ", "23884": "QK", "24055": "XH", - "24113": "DC", "24162": "ZC", "24191": "GA", "24273": "QJ", "24324": "NL", "24377": "TD", "24378": "QJ", - "24439": "PF", "24554": "ZS", "24683": "TD", "24694": "WE", "24733": "LK", "24925": "TN", "25094": "ZG", - "25100": "XQ", "25103": "XH", "25153": "PB", "25170": "PB", "25179": "KG", "25203": "PB", "25240": "ZS", - "25282": "FB", "25303": "NA", "25324": "KG", "25341": "ZY", "25373": "WZ", "25375": "XJ", "25384": "A", - "25457": "A", "25528": "SD", "25530": "SC", "25552": "TD", "25774": "ZC", "25874": "ZC", "26044": "YW", - "26080": "WM", "26292": "PB", "26333": "PB", "26355": "ZY", "26366": "CZ", "26397": "ZC", "26399": "QJ", - "26415": "ZS", "26451": "SB", "26526": "ZC", "26552": "JG", "26561": "TD", "26588": "JG", "26597": "CZ", - "26629": "ZS", "26638": "YL", "26646": "XQ", "26653": "KG", "26657": "XJ", "26727": "HG", "26894": "ZC", - "26937": "ZS", "26946": "ZC", "26999": "KJ", "27099": "KJ", "27449": "YQ", "27481": "XS", "27542": "ZS", - "27663": "ZS", "27748": "TS", "27784": "SC", "27788": "ZD", "27795": "TD", "27812": "O", "27850": "PB", - "27852": "MB", "27895": "SL", "27898": "PL", "27973": "QJ", "27981": "KH", "27986": "HX", "27994": "XJ", - "28044": "YC", "28065": "WG", "28177": "SM", "28267": "QJ", "28291": "KH", "28337": "ZQ", "28463": "TL", - "28548": "DC", "28601": "TD", "28689": "PB", "28805": "JG", "28820": "QG", "28846": "PB", "28952": "TD", - "28975": "ZC", "29100": "A", "29325": "QJ", "29575": "SL", "29602": "FB", "30010": "TD", "30044": "CX", - "30058": "PF", "30091": "YSP", "30111": "YN", "30229": "XJ", "30427": "SC", "30465": "SX", "30631": "YQ", - "30655": "QJ", "30684": "QJG", "30707": "SD", "30729": "XH", "30796": "LG", "30917": "PB", "31074": "NM", - "31085": "JZ", "31109": "SC", "31181": "ZC", "31192": "MLB", "31293": "JQ", "31400": "YX", "31584": "YJ", - "31896": "ZN", "31909": "ZY", "31995": "XJ", "32321": "PF", "32327": "ZY", "32418": "HG", "32420": "XQ", - "32421": "HG", "32438": "LG", "32473": "GJ", "32488": "TD", "32521": "QJ", "32527": "PB", "32562": "ZSQ", - "32564": "JZ", "32735": "ZD", "32793": "PB", "33071": "PF", "33098": "XL", "33100": "YA", "33152": "PB", - "33261": "CX", "33324": "BP", "33333": "TD", "33406": "YA", "33426": "WM", "33432": "PB", "33445": "JG", - "33486": "ZN", "33493": "TS", "33507": "QJ", "33540": "QJ", "33544": "ZC", "33564": "XQ", "33617": "YT", - "33632": "QJ", "33636": "XH", "33637": "YX", "33694": "WG", "33705": "PF", "33728": "YW", "33882": "SR", - "34067": "WM", "34074": "YW", "34121": "QJ", "34255": "ZC", "34259": "XL", "34425": "JH", "34430": "XH", - "34485": "KH", "34503": "YS", "34532": "HG", "34552": "XS", "34558": "YE", "34593": "ZL", "34660": "YQ", - "34892": "XH", "34928": "SC", "34999": "QJ", "35048": "PB", "35059": "SC", "35098": "ZC", "35203": "TQ", - "35265": "JX", "35299": "JX", "35782": "SZ", "35828": "YS", "35830": "E", "35843": "TD", "35895": "YG", - "35977": "MH", "36158": "JG", "36228": "QJ", "36426": "XQ", "36466": "DC", "36710": "JC", "36711": "ZYG", - "36767": "PB", "36866": "SK", "36951": "YW", "37034": "YX", "37063": "XH", "37218": "ZC", "37325": "ZC", - "38063": "PB", "38079": "TD", "38085": "QY", "38107": "DC", "38116": "TD", "38123": "YD", "38224": "HG", - "38241": "XTC", "38271": "ZC", "38415": "YE", "38426": "KH", "38461": "YD", "38463": "AE", "38466": "PB", - "38477": "XJ", "38518": "YT", "38551": "WK", "38585": "ZC", "38704": "XS", "38739": "LJ", "38761": "GJ", - "38808": "SQ", "39048": "JG", "39049": "XJ", "39052": "HG", "39076": "CZ", "39271": "XT", "39534": "TD", - "39552": "TD", "39584": "PB", "39647": "SB", "39730": "LG", "39748": "TPB", "40109": "ZQ", "40479": "ND", - "40516": "HG", "40536": "HG", "40583": "QJ", "40765": "YQ", "40784": "QJ", "40840": "YK", "40863": "QJG" }; - -// Program that returns the first letter array of Chinese characters -export function makePy(str) { - if (typeof(str) != "string") - throw new Error("函数makePy需要字符串类型参数!"); - var arrResult = []; - // Convert string to array - for (var i = 0, len = str.length; i < len; i++) { - var ch = str.charAt(i); - arrResult.push(checkCh(ch)); - } - return mkRslt(arrResult); -} - -// Check processing Chinese characters -function checkCh(ch) { - var uni = ch.charCodeAt(Constants.CHAR_CODE); - // If it is not within the scope of Chinese character processing, return the original character, and you can also call your own processing function - if (uni > Constants.UNI_MAX || uni < Constants.UNI_MIN) - return ch; //dealWithOthers(ch); - // Check whether it is a polyphonic word, it is processed as a polyphonic word, if not, just find the corresponding first letter in the strChineseFirstPY string. - return (oMultiDiff[uni] ? oMultiDiff[uni] : (strChineseFirstPY.charAt(uni - Constants.UNI_MIN))); -} - -// Process the characters and return an array of letters -function mkRslt(arr) { - var arrRslt = [""]; - for (var i = 0, len = arr.length; i < len; i++) { - var str = arr[i]; - var strlen = str.length; - if (strlen == 1) { - for (var k = 0; k < arrRslt.length; k++) { - arrRslt[k] += str; - } - } else { - var tmpArr = arrRslt.slice(0); - arrRslt = []; - for (k = 0; k < strlen; k++) { - // Copy an identical arrRslt - var tmp = tmpArr.slice(0); - // Add the current character str[k] to the end of each element - for (var j = 0; j < tmp.length; j++) { - tmp[j] += str.charAt(k); - } - // Concatenate the copied and modified array to arrRslt - arrRslt = arrRslt.concat(tmp); - } - } - } - return arrRslt; -} - -/** - * Get the corresponding permission group id according to the permission - * @param {String} permission app name id - * @return {Number} groupId - */ -export function getPermissionGroup(permission: string) { - for (var i = 0; i < permissionGroups.length; i++) { - if (permissionGroups[i].permissionName == permission) { - if(permissionGroups[i].groupName == 'OTHER') { - return { - "name": permissionGroups[i].groupName, - "groupName": permissionGroups[i].label, - "label": permissionGroups[i].text, - "icon": permissionGroups[i].icon, - "description": '', - "permissions": [ - permissionGroups[i].permissionName - ] - } - }else { - return groups[permissionGroups[i].groupId] - } - } - } -} - -const TAG = 'PermissionManager_Log'; - -export class Log { - static info(log) { - console.info(`Info: ${TAG} ${log}`) - } - - static error(log) { - console.error(`Error: ${TAG} ${log}`) - } +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Resmgr from '@ohos.resourceManager'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; + +import { permissionGroups, groups } from "../model/permissionGroup"; +import Constants from '../utils/constant'; + +/** + * Get app name resource + * @param {Number} labelId app name id + * @param {String} bundleName Package names + */ +export function getAppLabel(labelId, bundleName) { + return new Promise((resolve) => { + Resmgr.getResourceManager(globalThis.context, bundleName).then(item => { + item.getString(labelId, (error, value) => { + resolve(value); + }) + }).catch(error => { + console.error('Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); + }) + }) +} + +/** + * Get app icon resources + * @param {Number} iconId app icon id + * @param {String} bundleName Package names + */ +export function getAppIcon(iconId, bundleName) { + return new Promise((resolve) => { + Resmgr.getResourceManager(globalThis.context, bundleName).then(item => { + item.getMediaBase64(iconId, (error, value) => { + resolve(value); + }) + }).catch(error => { + console.error('Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); + }) + }) +} + +/** + * verify permission + * @param {Number} accessTokenId + * @param {String} permission permission name + */ +export function verifyAccessToken(accessTokenId, permission) { + return new Promise((resolve) => { + abilityAccessCtrl.createAtManager().verifyAccessToken(accessTokenId, permission).then((res) => { + return resolve(res); + }) + .catch((error) => { + console.error('verifyAccessToken failed. Cause: ' + JSON.stringify(error)); + }) + }) +} + +/** +* Let arkui detect changes in array index assignments。 +*/ +export function changeIndexValue(stateList, changeItem){ + // copy array + let result = stateList.slice(0); + for (let i = 0 ; i < changeItem.length; i++) { + let item = changeItem[i]; + if (!Array.isArray(item)) { + throw new Error("error"); + } + let index = item[0]; + let value = item[1]; + if (index == undefined || value == undefined) { + throw new Error("error"); + } + if (index < 0 || index > stateList.length - 1) { + continue; + } + let start = result.slice(0, index); + start = start.concat([value]); + result = start.concat(result.slice(index + 1)); + } + return result; +} + +// List of Chinese Pinyin Initials +let strChineseFirstPY = "YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSC" + +"YYYNJQYXXGJHHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPCBZ" + +"JJBRCFTLECZSTZFXXZHTRQHYBDLYCZSSYMMRFMYQZPWWJJYFCRWFDFZQPYDDWYXKYJAWJFFXYPSFTZYHHYZYSWCJYXSCLCXXWZZXNBGNNXBXLZSZS" + +"BSGPYSYZDHMDZBQBZCWDZZYYTZHBTSYYBZGNTNXQYWQSKBPHHLXGYBFMJEBJHHGQTJCYSXSTKZHLYCKGLYSMZXYALMELDCCXGZYRJXSDLTYZCQKCN" + +"NJWHJTZZCQLJSTSTBNXBTYXCEQXGKWJYFLZQLYHYXSPSFXLMPBYSXXXYDJCZYLLLSJXFHJXPJBTFFYABYXBHZZBJYZLWLCZGGBTSSMDTJZXPTHYQT" + +"GLJSCQFZKJZJQNLZWLSLHDZBWJNCJZYZSQQYCQYRZCJJWYBRTWPYFTWEXCSKDZCTBZHYZZYYJXZCFFZZMJYXXSDZZOTTBZLQWFCKSZSXFYRLNYJMB" + +"DTHJXSQQCCSBXYYTSYFBXDZTGBCNSLCYZZPSAZYZZSCJCSHZQYDXLBPJLLMQXTYDZXSQJTZPXLCGLQTZWJBHCTSYJSFXYEJJTLBGXSXJMYJQQPFZA" + +"SYJNTYDJXKJCDJSZCBARTDCLYJQMWNQNCLLLKBYBZZSYHQQLTWLCCXTXLLZNTYLNEWYZYXCZXXGRKRMTCNDNJTSYYSSDQDGHSDBJGHRWRQLYBGLXH" + +"LGTGXBQJDZPYJSJYJCTMRNYMGRZJCZGJMZMGXMPRYXKJNYMSGMZJYMKMFXMLDTGFBHCJHKYLPFMDXLQJJSMTQGZSJLQDLDGJYCALCMZCSDJLLNXDJ" + +"FFFFJCZFMZFFPFKHKGDPSXKTACJDHHZDDCRRCFQYJKQCCWJDXHWJLYLLZGCFCQDSMLZPBJJPLSBCJGGDCKKDEZSQCCKJGCGKDJTJDLZYCXKLQSCGJ" + +"CLTFPCQCZGWPJDQYZJJBYJHSJDZWGFSJGZKQCCZLLPSPKJGQJHZZLJPLGJGJJTHJJYJZCZMLZLYQBGJWMLJKXZDZNJQSYZMLJLLJKYWXMKJLHSKJG" + +"BMCLYYMKXJQLBMLLKMDXXKWYXYSLMLPSJQQJQXYXFJTJDXMXXLLCXQBSYJBGWYMBGGBCYXPJYGPEPFGDJGBHBNSQJYZJKJKHXQFGQZKFHYGKHDKLL" + +"SDJQXPQYKYBNQSXQNSZSWHBSXWHXWBZZXDMNSJBSBKBBZKLYLXGWXDRWYQZMYWSJQLCJXXJXKJEQXSCYETLZHLYYYSDZPAQYZCMTLSHTZCFYZYXYL" + +"JSDCJQAGYSLCQLYYYSHMRQQKLDXZSCSSSYDYCJYSFSJBFRSSZQSBXXPXJYSDRCKGJLGDKZJZBDKTCSYQPYHSTCLDJDHMXMCGXYZHJDDTMHLTXZXYL" + +"YMOHYJCLTYFBQQXPFBDFHHTKSQHZYYWCNXXCRWHOWGYJLEGWDQCWGFJYCSNTMYTOLBYGWQWESJPWNMLRYDZSZTXYQPZGCWXHNGPYXSHMYQJXZTDPP" + +"BFYHZHTJYFDZWKGKZBLDNTSXHQEEGZZYLZMMZYJZGXZXKHKSTXNXXWYLYAPSTHXDWHZYMPXAGKYDXBHNHXKDPJNMYHYLPMGOCSLNZHKXXLPZZLBML" + +"SFBHHGYGYYGGBHSCYAQTYWLXTZQCEZYDQDQMMHTKLLSZHLSJZWFYHQSWSCWLQAZYNYTLSXTHAZNKZZSZZLAXXZWWCTGQQTDDYZTCCHYQZFLXPSLZY" + +"GPZSZNGLNDQTBDLXGTCTAJDKYWNSYZLJHHZZCWNYYZYWMHYCHHYXHJKZWSXHZYXLYSKQYSPSLYZWMYPPKBYGLKZHTYXAXQSYSHXASMCHKDSCRSWJP" + +"WXSGZJLWWSCHSJHSQNHCSEGNDAQTBAALZZMSSTDQJCJKTSCJAXPLGGXHHGXXZCXPDMMHLDGTYBYSJMXHMRCPXXJZCKZXSHMLQXXTTHXWZFKHCCZDY" + +"TCJYXQHLXDHYPJQXYLSYYDZOZJNYXQEZYSQYAYXWYPDGXDDXSPPYZNDLTWRHXYDXZZJHTCXMCZLHPYYYYMHZLLHNXMYLLLMDCPPXHMXDKYCYRDLTX" + +"JCHHZZXZLCCLYLNZSHZJZZLNNRLWHYQSNJHXYNTTTKYJPYCHHYEGKCTTWLGQRLGGTGTYGYHPYHYLQYQGCWYQKPYYYTTTTLHYHLLTYTTSPLKYZXGZW" + +"GPYDSSZZDQXSKCQNMJJZZBXYQMJRTFFBTKHZKBXLJJKDXJTLBWFZPPTKQTZTGPDGNTPJYFALQMKGXBDCLZFHZCLLLLADPMXDJHLCCLGYHDZFGYDDG" + +"CYYFGYDXKSSEBDHYKDKDKHNAXXYBPBYYHXZQGAFFQYJXDMLJCSQZLLPCHBSXGJYNDYBYQSPZWJLZKSDDTACTBXZDYZYPJZQSJNKKTKNJDJGYYPGTL" + +"FYQKASDNTCYHBLWDZHBBYDWJRYGKZYHEYYFJMSDTYFZJJHGCXPLXHLDWXXJKYTCYKSSSMTWCTTQZLPBSZDZWZXGZAGYKTYWXLHLSPBCLLOQMMZSSL" + +"CMBJCSZZKYDCZJGQQDSMCYTZQQLWZQZXSSFPTTFQMDDZDSHDTDWFHTDYZJYQJQKYPBDJYYXTLJHDRQXXXHAYDHRJLKLYTWHLLRLLRCXYLBWSRSZZS" + +"YMKZZHHKYHXKSMDSYDYCJPBZBSQLFCXXXNXKXWYWSDZYQOGGQMMYHCDZTTFJYYBGSTTTYBYKJDHKYXBELHTYPJQNFXFDYKZHQKZBYJTZBXHFDXKDA" + +"SWTAWAJLDYJSFHBLDNNTNQJTJNCHXFJSRFWHZFMDRYJYJWZPDJKZYJYMPCYZNYNXFBYTFYFWYGDBNZZZDNYTXZEMMQBSQEHXFZMBMFLZZSRXYMJGS" + +"XWZJSPRYDJSJGXHJJGLJJYNZZJXHGXKYMLPYYYCXYTWQZSWHWLYRJLPXSLSXMFSWWKLCTNXNYNPSJSZHDZEPTXMYYWXYYSYWLXJQZQXZDCLEEELMC" + +"PJPCLWBXSQHFWWTFFJTNQJHJQDXHWLBYZNFJLALKYYJLDXHHYCSTYYWNRJYXYWTRMDRQHWQCMFJDYZMHMYYXJWMYZQZXTLMRSPWWCHAQBXYGZYPXY" + +"YRRCLMPYMGKSJSZYSRMYJSNXTPLNBAPPYPYLXYYZKYNLDZYJZCZNNLMZHHARQMPGWQTZMXXMLLHGDZXYHXKYXYCJMFFYYHJFSBSSQLXXNDYCANNMT" + +"CJCYPRRNYTYQNYYMBMSXNDLYLYSLJRLXYSXQMLLYZLZJJJKYZZCSFBZXXMSTBJGNXYZHLXNMCWSCYZYFZLXBRNNNYLBNRTGZQYSATSWRYHYJZMZDH" + +"ZGZDWYBSSCSKXSYHYTXXGCQGXZZSHYXJSCRHMKKBXCZJYJYMKQHZJFNBHMQHYSNJNZYBKNQMCLGQHWLZNZSWXKHLJHYYBQLBFCDSXDLDSPFZPSKJY" + +"ZWZXZDDXJSMMEGJSCSSMGCLXXKYYYLNYPWWWGYDKZJGGGZGGSYCKNJWNJPCXBJJTQTJWDSSPJXZXNZXUMELPXFSXTLLXCLJXJJLJZXCTPSWXLYDHL" + +"YQRWHSYCSQYYBYAYWJJJQFWQCQQCJQGXALDBZZYJGKGXPLTZYFXJLTPADKYQHPMATLCPDCKBMTXYBHKLENXDLEEGQDYMSAWHZMLJTWYGXLYQZLJEE" + +"YYBQQFFNLYXRDSCTGJGXYYNKLLYQKCCTLHJLQMKKZGCYYGLLLJDZGYDHZWXPYSJBZKDZGYZZHYWYFQYTYZSZYEZZLYMHJJHTSMQWYZLKYYWZCSRKQ" + +"YTLTDXWCTYJKLWSQZWBDCQYNCJSRSZJLKCDCDTLZZZACQQZZDDXYPLXZBQJYLZLLLQDDZQJYJYJZYXNYYYNYJXKXDAZWYRDLJYYYRJLXLLDYXJCYW" + +"YWNQCCLDDNYYYNYCKCZHXXCCLGZQJGKWPPCQQJYSBZZXYJSQPXJPZBSBDSFNSFPZXHDWZTDWPPTFLZZBZDMYYPQJRSDZSQZSQXBDGCPZSWDWCSQZG" + +"MDHZXMWWFYBPDGPHTMJTHZSMMBGZMBZJCFZWFZBBZMQCFMBDMCJXLGPNJBBXGYHYYJGPTZGZMQBQTCGYXJXLWZKYDPDYMGCFTPFXYZTZXDZXTGKMT" + +"YBBCLBJASKYTSSQYYMSZXFJEWLXLLSZBQJJJAKLYLXLYCCTSXMCWFKKKBSXLLLLJYXTYLTJYYTDPJHNHNNKBYQNFQYYZBYYESSESSGDYHFHWTCJBS" + +"DZZTFDMXHCNJZYMQWSRYJDZJQPDQBBSTJGGFBKJBXTGQHNGWJXJGDLLTHZHHYYYYYYSXWTYYYCCBDBPYPZYCCZYJPZYWCBDLFWZCWJDXXHYHLHWZZ" + +"XJTCZLCDPXUJCZZZLYXJJTXPHFXWPYWXZPTDZZBDZCYHJHMLXBQXSBYLRDTGJRRCTTTHYTCZWMXFYTWWZCWJWXJYWCSKYBZSCCTZQNHXNWXXKHKFH" + +"TSWOCCJYBCMPZZYKBNNZPBZHHZDLSYDDYTYFJPXYNGFXBYQXCBHXCPSXTYZDMKYSNXSXLHKMZXLYHDHKWHXXSSKQYHHCJYXGLHZXCSNHEKDTGZXQY" + +"PKDHEXTYKCNYMYYYPKQYYYKXZLTHJQTBYQHXBMYHSQCKWWYLLHCYYLNNEQXQWMCFBDCCMLJGGXDQKTLXKGNQCDGZJWYJJLYHHQTTTNWCHMXCXWHWS" + +"ZJYDJCCDBQCDGDNYXZTHCQRXCBHZTQCBXWGQWYYBXHMBYMYQTYEXMQKYAQYRGYZSLFYKKQHYSSQYSHJGJCNXKZYCXSBXYXHYYLSTYCXQTHYSMGSCP" + +"MMGCCCCCMTZTASMGQZJHKLOSQYLSWTMXSYQKDZLJQQYPLSYCZTCQQPBBQJZCLPKHQZYYXXDTDDTSJCXFFLLCHQXMJLWCJCXTSPYCXNDTJSHJWXDQQ" + +"JSKXYAMYLSJHMLALYKXCYYDMNMDQMXMCZNNCYBZKKYFLMCHCMLHXRCJJHSYLNMTJZGZGYWJXSRXCWJGJQHQZDQJDCJJZKJKGDZQGJJYJYLXZXXCDQ" + +"HHHEYTMHLFSBDJSYYSHFYSTCZQLPBDRFRZTZYKYWHSZYQKWDQZRKMSYNBCRXQBJYFAZPZZEDZCJYWBCJWHYJBQSZYWRYSZPTDKZPFPBNZTKLQYHBB" + +"ZPNPPTYZZYBQNYDCPJMMCYCQMCYFZZDCMNLFPBPLNGQJTBTTNJZPZBBZNJKLJQYLNBZQHKSJZNGGQSZZKYXSHPZSNBCGZKDDZQANZHJKDRTLZLSWJ" + +"LJZLYWTJNDJZJHXYAYNCBGTZCSSQMNJPJYTYSWXZFKWJQTKHTZPLBHSNJZSYZBWZZZZLSYLSBJHDWWQPSLMMFBJDWAQYZTCJTBNNWZXQXCDSLQGDS" + +"DPDZHJTQQPSWLYYJZLGYXYZLCTCBJTKTYCZJTQKBSJLGMGZDMCSGPYNJZYQYYKNXRPWSZXMTNCSZZYXYBYHYZAXYWQCJTLLCKJJTJHGDXDXYQYZZB" + +"YWDLWQCGLZGJGQRQZCZSSBCRPCSKYDZNXJSQGXSSJMYDNSTZTPBDLTKZWXQWQTZEXNQCZGWEZKSSBYBRTSSSLCCGBPSZQSZLCCGLLLZXHZQTHCZMQ" + +"GYZQZNMCOCSZJMMZSQPJYGQLJYJPPLDXRGZYXCCSXHSHGTZNLZWZKJCXTCFCJXLBMQBCZZWPQDNHXLJCTHYZLGYLNLSZZPCXDSCQQHJQKSXZPBAJY" + +"EMSMJTZDXLCJYRYYNWJBNGZZTMJXLTBSLYRZPYLSSCNXPHLLHYLLQQZQLXYMRSYCXZLMMCZLTZSDWTJJLLNZGGQXPFSKYGYGHBFZPDKMWGHCXMSGD" + +"XJMCJZDYCABXJDLNBCDQYGSKYDQTXDJJYXMSZQAZDZFSLQXYJSJZYLBTXXWXQQZBJZUFBBLYLWDSLJHXJYZJWTDJCZFQZQZZDZSXZZQLZCDZFJHYS" + +"PYMPQZMLPPLFFXJJNZZYLSJEYQZFPFZKSYWJJJHRDJZZXTXXGLGHYDXCSKYSWMMZCWYBAZBJKSHFHJCXMHFQHYXXYZFTSJYZFXYXPZLCHMZMBXHZZ" + +"SXYFYMNCWDABAZLXKTCSHHXKXJJZJSTHYGXSXYYHHHJWXKZXSSBZZWHHHCWTZZZPJXSNXQQJGZYZYWLLCWXZFXXYXYHXMKYYSWSQMNLNAYCYSPMJK" + +"HWCQHYLAJJMZXHMMCNZHBHXCLXTJPLTXYJHDYYLTTXFSZHYXXSJBJYAYRSMXYPLCKDUYHLXRLNLLSTYZYYQYGYHHSCCSMZCTZQXKYQFPYYRPFFLKQ" + +"UNTSZLLZMWWTCQQYZWTLLMLMPWMBZSSTZRBPDDTLQJJBXZCSRZQQYGWCSXFWZLXCCRSZDZMCYGGDZQSGTJSWLJMYMMZYHFBJDGYXCCPSHXNZCSBSJ" + +"YJGJMPPWAFFYFNXHYZXZYLREMZGZCYZSSZDLLJCSQFNXZKPTXZGXJJGFMYYYSNBTYLBNLHPFZDCYFBMGQRRSSSZXYSGTZRNYDZZCDGPJAFJFZKNZB" + +"LCZSZPSGCYCJSZLMLRSZBZZLDLSLLYSXSQZQLYXZLSKKBRXBRBZCYCXZZZEEYFGKLZLYYHGZSGZLFJHGTGWKRAAJYZKZQTSSHJJXDCYZUYJLZYRZD" + +"QQHGJZXSSZBYKJPBFRTJXLLFQWJHYLQTYMBLPZDXTZYGBDHZZRBGXHWNJTJXLKSCFSMWLSDQYSJTXKZSCFWJLBXFTZLLJZLLQBLSQMQQCGCZFPBPH" + +"ZCZJLPYYGGDTGWDCFCZQYYYQYSSCLXZSKLZZZGFFCQNWGLHQYZJJCZLQZZYJPJZZBPDCCMHJGXDQDGDLZQMFGPSYTSDYFWWDJZJYSXYYCZCYHZWPB" + +"YKXRYLYBHKJKSFXTZJMMCKHLLTNYYMSYXYZPYJQYCSYCWMTJJKQYRHLLQXPSGTLYYCLJSCPXJYZFNMLRGJJTYZBXYZMSJYJHHFZQMSYXRSZCWTLRT" + +"QZSSTKXGQKGSPTGCZNJSJCQCXHMXGGZTQYDJKZDLBZSXJLHYQGGGTHQSZPYHJHHGYYGKGGCWJZZYLCZLXQSFTGZSLLLMLJSKCTBLLZZSZMMNYTPZS" + +"XQHJCJYQXYZXZQZCPSHKZZYSXCDFGMWQRLLQXRFZTLYSTCTMJCXJJXHJNXTNRZTZFQYHQGLLGCXSZSJDJLJCYDSJTLNYXHSZXCGJZYQPYLFHDJSBP" + +"CCZHJJJQZJQDYBSSLLCMYTTMQTBHJQNNYGKYRQYQMZGCJKPDCGMYZHQLLSLLCLMHOLZGDYYFZSLJCQZLYLZQJESHNYLLJXGJXLYSYYYXNBZLJSSZC" + +"QQCJYLLZLTJYLLZLLBNYLGQCHXYYXOXCXQKYJXXXYKLXSXXYQXCYKQXQCSGYXXYQXYGYTQOHXHXPYXXXULCYEYCHZZCBWQBBWJQZSCSZSSLZYLKDE" + +"SJZWMYMCYTSDSXXSCJPQQSQYLYYZYCMDJDZYWCBTJSYDJKCYDDJLBDJJSODZYSYXQQYXDHHGQQYQHDYXWGMMMAJDYBBBPPBCMUUPLJZSMTXERXJMH" + +"QNUTPJDCBSSMSSSTKJTSSMMTRCPLZSZMLQDSDMJMQPNQDXCFYNBFSDQXYXHYAYKQYDDLQYYYSSZBYDSLNTFQTZQPZMCHDHCZCWFDXTMYQSPHQYYXS" + +"RGJCWTJTZZQMGWJJTJHTQJBBHWZPXXHYQFXXQYWYYHYSCDYDHHQMNMTMWCPBSZPPZZGLMZFOLLCFWHMMSJZTTDHZZYFFYTZZGZYSKYJXQYJZQBHMB" + +"ZZLYGHGFMSHPZFZSNCLPBQSNJXZSLXXFPMTYJYGBXLLDLXPZJYZJYHHZCYWHJYLSJEXFSZZYWXKZJLUYDTMLYMQJPWXYHXSKTQJEZRPXXZHHMHWQP" + +"WQLYJJQJJZSZCPHJLCHHNXJLQWZJHBMZYXBDHHYPZLHLHLGFWLCHYYTLHJXCJMSCPXSTKPNHQXSRTYXXTESYJCTLSSLSTDLLLWWYHDHRJZSFGXTSY" + +"CZYNYHTDHWJSLHTZDQDJZXXQHGYLTZPHCSQFCLNJTCLZPFSTPDYNYLGMJLLYCQHYSSHCHYLHQYQTMZYPBYWRFQYKQSYSLZDQJMPXYYSSRHZJNYWTQ" + +"DFZBWWTWWRXCWHGYHXMKMYYYQMSMZHNGCEPMLQQMTCWCTMMPXJPJJHFXYYZSXZHTYBMSTSYJTTQQQYYLHYNPYQZLCYZHZWSMYLKFJXLWGXYPJYTYS" + +"YXYMZCKTTWLKSMZSYLMPWLZWXWQZSSAQSYXYRHSSNTSRAPXCPWCMGDXHXZDZYFJHGZTTSBJHGYZSZYSMYCLLLXBTYXHBBZJKSSDMALXHYCFYGMQYP" + +"JYCQXJLLLJGSLZGQLYCJCCZOTYXMTMTTLLWTGPXYMZMKLPSZZZXHKQYSXCTYJZYHXSHYXZKXLZWPSQPYHJWPJPWXQQYLXSDHMRSLZZYZWTTCYXYSZ" + +"ZSHBSCCSTPLWSSCJCHNLCGCHSSPHYLHFHHXJSXYLLNYLSZDHZXYLSXLWZYKCLDYAXZCMDDYSPJTQJZLNWQPSSSWCTSTSZLBLNXSMNYYMJQBQHRZWT" + +"YYDCHQLXKPZWBGQYBKFCMZWPZLLYYLSZYDWHXPSBCMLJBSCGBHXLQHYRLJXYSWXWXZSLDFHLSLYNJLZYFLYJYCDRJLFSYZFSLLCQYQFGJYHYXZLYL" + +"MSTDJCYHBZLLNWLXXYGYYHSMGDHXXHHLZZJZXCZZZCYQZFNGWPYLCPKPYYPMCLQKDGXZGGWQBDXZZKZFBXXLZXJTPJPTTBYTSZZDWSLCHZHSLTYXH" + +"QLHYXXXYYZYSWTXZKHLXZXZPYHGCHKCFSYHUTJRLXFJXPTZTWHPLYXFCRHXSHXKYXXYHZQDXQWULHYHMJTBFLKHTXCWHJFWJCFPQRYQXCYYYQYGRP" + +"YWSGSUNGWCHKZDXYFLXXHJJBYZWTSXXNCYJJYMSWZJQRMHXZWFQSYLZJZGBHYNSLBGTTCSYBYXXWXYHXYYXNSQYXMQYWRGYQLXBBZLJSYLPSYTJZY" + +"HYZAWLRORJMKSCZJXXXYXCHDYXRYXXJDTSQFXLYLTSFFYXLMTYJMJUYYYXLTZCSXQZQHZXLYYXZHDNBRXXXJCTYHLBRLMBRLLAXKYLLLJLYXXLYCR" + +"YLCJTGJCMTLZLLCYZZPZPCYAWHJJFYBDYYZSMPCKZDQYQPBPCJPDCYZMDPBCYYDYCNNPLMTMLRMFMMGWYZBSJGYGSMZQQQZTXMKQWGXLLPJGZBQCD" + +"JJJFPKJKCXBLJMSWMDTQJXLDLPPBXCWRCQFBFQJCZAHZGMYKPHYYHZYKNDKZMBPJYXPXYHLFPNYYGXJDBKXNXHJMZJXSTRSTLDXSKZYSYBZXJLXYS" + +"LBZYSLHXJPFXPQNBYLLJQKYGZMCYZZYMCCSLCLHZFWFWYXZMWSXTYNXJHPYYMCYSPMHYSMYDYSHQYZCHMJJMZCAAGCFJBBHPLYZYLXXSDJGXDHKXX" + +"TXXNBHRMLYJSLTXMRHNLXQJXYZLLYSWQGDLBJHDCGJYQYCMHWFMJYBMBYJYJWYMDPWHXQLDYGPDFXXBCGJSPCKRSSYZJMSLBZZJFLJJJLGXZGYXYX" + +"LSZQYXBEXYXHGCXBPLDYHWETTWWCJMBTXCHXYQXLLXFLYXLLJLSSFWDPZSMYJCLMWYTCZPCHQEKCQBWLCQYDPLQPPQZQFJQDJHYMMCXTXDRMJWRHX" + +"CJZYLQXDYYNHYYHRSLSRSYWWZJYMTLTLLGTQCJZYABTCKZCJYCCQLJZQXALMZYHYWLWDXZXQDLLQSHGPJFJLJHJABCQZDJGTKHSSTCYJLPSWZLXZX" + +"RWGLDLZRLZXTGSLLLLZLYXXWGDZYGBDPHZPBRLWSXQBPFDWOFMWHLYPCBJCCLDMBZPBZZLCYQXLDOMZBLZWPDWYYGDSTTHCSQSCCRSSSYSLFYBFNT" + +"YJSZDFNDPDHDZZMBBLSLCMYFFGTJJQWFTMTPJWFNLBZCMMJTGBDZLQLPYFHYYMJYLSDCHDZJWJCCTLJCLDTLJJCPDDSQDSSZYBNDBJLGGJZXSXNLY" + +"CYBJXQYCBYLZCFZPPGKCXZDZFZTJJFJSJXZBNZYJQTTYJYHTYCZHYMDJXTTMPXSPLZCDWSLSHXYPZGTFMLCJTYCBPMGDKWYCYZCDSZZYHFLYCTYGW" + +"HKJYYLSJCXGYWJCBLLCSNDDBTZBSCLYZCZZSSQDLLMQYYHFSLQLLXFTYHABXGWNYWYYPLLSDLDLLBJCYXJZMLHLJDXYYQYTDLLLBUGBFDFBBQJZZM" + +"DPJHGCLGMJJPGAEHHBWCQXAXHHHZCHXYPHJAXHLPHJPGPZJQCQZGJJZZUZDMQYYBZZPHYHYBWHAZYJHYKFGDPFQSDLZMLJXKXGALXZDAGLMDGXMWZ" + +"QYXXDXXPFDMMSSYMPFMDMMKXKSYZYSHDZKXSYSMMZZZMSYDNZZCZXFPLSTMZDNMXCKJMZTYYMZMZZMSXHHDCZJEMXXKLJSTLWLSQLYJZLLZJSSDPP" + +"MHNLZJCZYHMXXHGZCJMDHXTKGRMXFWMCGMWKDTKSXQMMMFZZYDKMSCLCMPCGMHSPXQPZDSSLCXKYXTWLWJYAHZJGZQMCSNXYYMMPMLKJXMHLMLQMX" + +"CTKZMJQYSZJSYSZHSYJZJCDAJZYBSDQJZGWZQQXFKDMSDJLFWEHKZQKJPEYPZYSZCDWYJFFMZZYLTTDZZEFMZLBNPPLPLPEPSZALLTYLKCKQZKGEN" + +"QLWAGYXYDPXLHSXQQWQCQXQCLHYXXMLYCCWLYMQYSKGCHLCJNSZKPYZKCQZQLJPDMDZHLASXLBYDWQLWDNBQCRYDDZTJYBKBWSZDXDTNPJDTCTQDF" + +"XQQMGNXECLTTBKPWSLCTYQLPWYZZKLPYGZCQQPLLKCCYLPQMZCZQCLJSLQZDJXLDDHPZQDLJJXZQDXYZQKZLJCYQDYJPPYPQYKJYRMPCBYMCXKLLZ" + +"LLFQPYLLLMBSGLCYSSLRSYSQTMXYXZQZFDZUYSYZTFFMZZSMZQHZSSCCMLYXWTPZGXZJGZGSJSGKDDHTQGGZLLBJDZLCBCHYXYZHZFYWXYZYMSDBZ" + +"ZYJGTSMTFXQYXQSTDGSLNXDLRYZZLRYYLXQHTXSRTZNGZXBNQQZFMYKMZJBZYMKBPNLYZPBLMCNQYZZZSJZHJCTZKHYZZJRDYZHNPXGLFZTLKGJTC" + +"TSSYLLGZRZBBQZZKLPKLCZYSSUYXBJFPNJZZXCDWXZYJXZZDJJKGGRSRJKMSMZJLSJYWQSKYHQJSXPJZZZLSNSHRNYPZTWCHKLPSRZLZXYJQXQKYS" + +"JYCZTLQZYBBYBWZPQDWWYZCYTJCJXCKCWDKKZXSGKDZXWWYYJQYYTCYTDLLXWKCZKKLCCLZCQQDZLQLCSFQCHQHSFSMQZZLNBJJZBSJHTSZDYSJQJ" + +"PDLZCDCWJKJZZLPYCGMZWDJJBSJQZSYZYHHXJPBJYDSSXDZNCGLQMBTSFSBPDZDLZNFGFJGFSMPXJQLMBLGQCYYXBQKDJJQYRFKZTJDHCZKLBSDZC" + +"FJTPLLJGXHYXZCSSZZXSTJYGKGCKGYOQXJPLZPBPGTGYJZGHZQZZLBJLSQFZGKQQJZGYCZBZQTLDXRJXBSXXPZXHYZYCLWDXJJHXMFDZPFZHQHQMQ" + +"GKSLYHTYCGFRZGNQXCLPDLBZCSCZQLLJBLHBZCYPZZPPDYMZZSGYHCKCPZJGSLJLNSCDSLDLXBMSTLDDFJMKDJDHZLZXLSZQPQPGJLLYBDSZGQLBZ" + +"LSLKYYHZTTNTJYQTZZPSZQZTLLJTYYLLQLLQYZQLBDZLSLYYZYMDFSZSNHLXZNCZQZPBWSKRFBSYZMTHBLGJPMCZZLSTLXSHTCSYZLZBLFEQHLXFL" + +"CJLYLJQCBZLZJHHSSTBRMHXZHJZCLXFNBGXGTQJCZTMSFZKJMSSNXLJKBHSJXNTNLZDNTLMSJXGZJYJCZXYJYJWRWWQNZTNFJSZPZSHZJFYRDJSFS" + +"ZJZBJFZQZZHZLXFYSBZQLZSGYFTZDCSZXZJBQMSZKJRHYJZCKMJKHCHGTXKXQGLXPXFXTRTYLXJXHDTSJXHJZJXZWZLCQSBTXWXGXTXXHXFTSDKFJ" + +"HZYJFJXRZSDLLLTQSQQZQWZXSYQTWGWBZCGZLLYZBCLMQQTZHZXZXLJFRMYZFLXYSQXXJKXRMQDZDMMYYBSQBHGZMWFWXGMXLZPYYTGZYCCDXYZXY" + +"WGSYJYZNBHPZJSQSYXSXRTFYZGRHZTXSZZTHCBFCLSYXZLZQMZLMPLMXZJXSFLBYZMYQHXJSXRXSQZZZSSLYFRCZJRCRXHHZXQYDYHXSJJHZCXZBT" + +"YNSYSXJBQLPXZQPYMLXZKYXLXCJLCYSXXZZLXDLLLJJYHZXGYJWKJRWYHCPSGNRZLFZWFZZNSXGXFLZSXZZZBFCSYJDBRJKRDHHGXJLJJTGXJXXST" + +"JTJXLYXQFCSGSWMSBCTLQZZWLZZKXJMLTMJYHSDDBXGZHDLBMYJFRZFSGCLYJBPMLYSMSXLSZJQQHJZFXGFQFQBPXZGYYQXGZTCQWYLTLGWSGWHRL" + +"FSFGZJMGMGBGTJFSYZZGZYZAFLSSPMLPFLCWBJZCLJJMZLPJJLYMQDMYYYFBGYGYZMLYZDXQYXRQQQHSYYYQXYLJTYXFSFSLLGNQCYHYCWFHCCCFX" + +"PYLYPLLZYXXXXXKQHHXSHJZCFZSCZJXCPZWHHHHHAPYLQALPQAFYHXDYLUKMZQGGGDDESRNNZLTZGCHYPPYSQJJHCLLJTOLNJPZLJLHYMHEYDYDSQ" + +"YCDDHGZUNDZCLZYZLLZNTNYZGSLHSLPJJBDGWXPCDUTJCKLKCLWKLLCASSTKZZDNQNTTLYYZSSYSSZZRYLJQKCQDHHCRXRZYDGRGCWCGZQFFFPPJF" + +"ZYNAKRGYWYQPQXXFKJTSZZXSWZDDFBBXTBGTZKZNPZZPZXZPJSZBMQHKCYXYLDKLJNYPKYGHGDZJXXEAHPNZKZTZCMXCXMMJXNKSZQNMNLWBWWXJK" + +"YHCPSTMCSQTZJYXTPCTPDTNNPGLLLZSJLSPBLPLQHDTNJNLYYRSZFFJFQWDPHZDWMRZCCLODAXNSSNYZRESTYJWJYJDBCFXNMWTTBYLWSTSZGYBLJ" + +"PXGLBOCLHPCBJLTMXZLJYLZXCLTPNCLCKXTPZJSWCYXSFYSZDKNTLBYJCYJLLSTGQCBXRYZXBXKLYLHZLQZLNZCXWJZLJZJNCJHXMNZZGJZZXTZJX" + +"YCYYCXXJYYXJJXSSSJSTSSTTPPGQTCSXWZDCSYFPTFBFHFBBLZJCLZZDBXGCXLQPXKFZFLSYLTUWBMQJHSZBMDDBCYSCCLDXYCDDQLYJJWMQLLCSG" + +"LJJSYFPYYCCYLTJANTJJPWYCMMGQYYSXDXQMZHSZXPFTWWZQSWQRFKJLZJQQYFBRXJHHFWJJZYQAZMYFRHCYYBYQWLPEXCCZSTYRLTTDMQLYKMBBG" + +"MYYJPRKZNPBSXYXBHYZDJDNGHPMFSGMWFZMFQMMBCMZZCJJLCNUXYQLMLRYGQZCYXZLWJGCJCGGMCJNFYZZJHYCPRRCMTZQZXHFQGTJXCCJEAQCRJ" + +"YHPLQLSZDJRBCQHQDYRHYLYXJSYMHZYDWLDFRYHBPYDTSSCNWBXGLPZMLZZTQSSCPJMXXYCSJYTYCGHYCJWYRXXLFEMWJNMKLLSWTXHYYYNCMMCWJ" + +"DQDJZGLLJWJRKHPZGGFLCCSCZMCBLTBHBQJXQDSPDJZZGKGLFQYWBZYZJLTSTDHQHCTCBCHFLQMPWDSHYYTQWCNZZJTLBYMBPDYYYXSQKXWYYFLXX" + +"NCWCXYPMAELYKKJMZZZBRXYYQJFLJPFHHHYTZZXSGQQMHSPGDZQWBWPJHZJDYSCQWZKTXXSQLZYYMYSDZGRXCKKUJLWPYSYSCSYZLRMLQSYLJXBCX" + +"TLWDQZPCYCYKPPPNSXFYZJJRCEMHSZMSXLXGLRWGCSTLRSXBZGBZGZTCPLUJLSLYLYMTXMTZPALZXPXJTJWTCYYZLBLXBZLQMYLXPGHDSLSSDMXMB" + +"DZZSXWHAMLCZCPJMCNHJYSNSYGCHSKQMZZQDLLKABLWJXSFMOCDXJRRLYQZKJMYBYQLYHETFJZFRFKSRYXFJTWDSXXSYSQJYSLYXWJHSNLXYYXHBH" + +"AWHHJZXWMYLJCSSLKYDZTXBZSYFDXGXZJKHSXXYBSSXDPYNZWRPTQZCZENYGCXQFJYKJBZMLJCMQQXUOXSLYXXLYLLJDZBTYMHPFSTTQQWLHOKYBL" + +"ZZALZXQLHZWRRQHLSTMYPYXJJXMQSJFNBXYXYJXXYQYLTHYLQYFMLKLJTMLLHSZWKZHLJMLHLJKLJSTLQXYLMBHHLNLZXQJHXCFXXLHYHJJGBYZZK" + +"BXSCQDJQDSUJZYYHZHHMGSXCSYMXFEBCQWWRBPYYJQTYZCYQYQQZYHMWFFHGZFRJFCDPXNTQYZPDYKHJLFRZXPPXZDBBGZQSTLGDGYLCQMLCHHMFY" + +"WLZYXKJLYPQHSYWMQQGQZMLZJNSQXJQSYJYCBEHSXFSZPXZWFLLBCYYJDYTDTHWZSFJMQQYJLMQXXLLDTTKHHYBFPWTYYSQQWNQWLGWDEBZWCMYGC" + +"ULKJXTMXMYJSXHYBRWFYMWFRXYQMXYSZTZZTFYKMLDHQDXWYYNLCRYJBLPSXCXYWLSPRRJWXHQYPHTYDNXHHMMYWYTZCSQMTSSCCDALWZTCPQPYJL" + +"LQZYJSWXMZZMMYLMXCLMXCZMXMZSQTZPPQQBLPGXQZHFLJJHYTJSRXWZXSCCDLXTYJDCQJXSLQYCLZXLZZXMXQRJMHRHZJBHMFLJLMLCLQNLDXZLL" + +"LPYPSYJYSXCQQDCMQJZZXHNPNXZMEKMXHYKYQLXSXTXJYYHWDCWDZHQYYBGYBCYSCFGPSJNZDYZZJZXRZRQJJYMCANYRJTLDPPYZBSTJKXXZYPFDW" + +"FGZZRPYMTNGXZQBYXNBUFNQKRJQZMJEGRZGYCLKXZDSKKNSXKCLJSPJYYZLQQJYBZSSQLLLKJXTBKTYLCCDDBLSPPFYLGYDTZJYQGGKQTTFZXBDKT" + +"YYHYBBFYTYYBCLPDYTGDHRYRNJSPTCSNYJQHKLLLZSLYDXXWBCJQSPXBPJZJCJDZFFXXBRMLAZHCSNDLBJDSZBLPRZTSWSBXBCLLXXLZDJZSJPYLY" + +"XXYFTFFFBHJJXGBYXJPMMMPSSJZJMTLYZJXSWXTYLEDQPJMYGQZJGDJLQJWJQLLSJGJGYGMSCLJJXDTYGJQJQJCJZCJGDZZSXQGSJGGCXHQXSNQLZ" + +"ZBXHSGZXCXYLJXYXYYDFQQJHJFXDHCTXJYRXYSQTJXYEFYYSSYYJXNCYZXFXMSYSZXYYSCHSHXZZZGZZZGFJDLTYLNPZGYJYZYYQZPBXQBDZTZCZY" + +"XXYHHSQXSHDHGQHJHGYWSZTMZMLHYXGEBTYLZKQWYTJZRCLEKYSTDBCYKQQSAYXCJXWWGSBHJYZYDHCSJKQCXSWXFLTYNYZPZCCZJQTZWJQDZZZQZ" + +"LJJXLSBHPYXXPSXSHHEZTXFPTLQYZZXHYTXNCFZYYHXGNXMYWXTZSJPTHHGYMXMXQZXTSBCZYJYXXTYYZYPCQLMMSZMJZZLLZXGXZAAJZYXJMZXWD" + +"XZSXZDZXLEYJJZQBHZWZZZQTZPSXZTDSXJJJZNYAZPHXYYSRNQDTHZHYYKYJHDZXZLSWCLYBZYECWCYCRYLCXNHZYDZYDYJDFRJJHTRSQTXYXJRJH" + +"OJYNXELXSFSFJZGHPZSXZSZDZCQZBYYKLSGSJHCZSHDGQGXYZGXCHXZJWYQWGYHKSSEQZZNDZFKWYSSTCLZSTSYMCDHJXXYWEYXCZAYDMPXMDSXYB" + +"SQMJMZJMTZQLPJYQZCGQHXJHHLXXHLHDLDJQCLDWBSXFZZYYSCHTYTYYBHECXHYKGJPXHHYZJFXHWHBDZFYZBCAPNPGNYDMSXHMMMMAMYNBYJTMPX" + +"YYMCTHJBZYFCGTYHWPHFTWZZEZSBZEGPFMTSKFTYCMHFLLHGPZJXZJGZJYXZSBBQSCZZLZCCSTPGXMJSFTCCZJZDJXCYBZLFCJSYZFGSZLYBCWZZB" + +"YZDZYPSWYJZXZBDSYUXLZZBZFYGCZXBZHZFTPBGZGEJBSTGKDMFHYZZJHZLLZZGJQZLSFDJSSCBZGPDLFZFZSZYZYZSYGCXSNXXCHCZXTZZLJFZGQ" + +"SQYXZJQDCCZTQCDXZJYQJQCHXZTDLGSCXZSYQJQTZWLQDQZTQCHQQJZYEZZZPBWKDJFCJPZTYPQYQTTYNLMBDKTJZPQZQZZFPZSBNJLGYJDXJDZZK" + +"ZGQKXDLPZJTCJDQBXDJQJSTCKNXBXZMSLYJCQMTJQWWCJQNJNLLLHJCWQTBZQYDZCZPZZDZYDDCYZZZCCJTTJFZDPRRTZTJDCQTQZDTJNPLZBCLLC" + +"TZSXKJZQZPZLBZRBTJDCXFCZDBCCJJLTQQPLDCGZDBBZJCQDCJWYNLLZYZCCDWLLXWZLXRXNTQQCZXKQLSGDFQTDDGLRLAJJTKUYMKQLLTZYTDYYC" + +"ZGJWYXDXFRSKSTQTENQMRKQZHHQKDLDAZFKYPBGGPZREBZZYKZZSPEGJXGYKQZZZSLYSYYYZWFQZYLZZLZHWCHKYPQGNPGBLPLRRJYXCCSYYHSFZF" + +"YBZYYTGZXYLXCZWXXZJZBLFFLGSKHYJZEYJHLPLLLLCZGXDRZELRHGKLZZYHZLYQSZZJZQLJZFLNBHGWLCZCFJYSPYXZLZLXGCCPZBLLCYBBBBUBB" + +"CBPCRNNZCZYRBFSRLDCGQYYQXYGMQZWTZYTYJXYFWTEHZZJYWLCCNTZYJJZDEDPZDZTSYQJHDYMBJNYJZLXTSSTPHNDJXXBYXQTZQDDTJTDYYTGWS" + +"CSZQFLSHLGLBCZPHDLYZJYCKWTYTYLBNYTSDSYCCTYSZYYEBHEXHQDTWNYGYCLXTSZYSTQMYGZAZCCSZZDSLZCLZRQXYYELJSBYMXSXZTEMBBLLYY" + +"LLYTDQYSHYMRQWKFKBFXNXSBYCHXBWJYHTQBPBSBWDZYLKGZSKYHXQZJXHXJXGNLJKZLYYCDXLFYFGHLJGJYBXQLYBXQPQGZTZPLNCYPXDJYQYDYM" + +"RBESJYYHKXXSTMXRCZZYWXYQYBMCLLYZHQYZWQXDBXBZWZMSLPDMYSKFMZKLZCYQYCZLQXFZZYDQZPZYGYJYZMZXDZFYFYTTQTZHGSPCZMLCCYTZX" + +"JCYTJMKSLPZHYSNZLLYTPZCTZZCKTXDHXXTQCYFKSMQCCYYAZHTJPCYLZLYJBJXTPNYLJYYNRXSYLMMNXJSMYBCSYSYLZYLXJJQYLDZLPQBFZZBLF" + +"NDXQKCZFYWHGQMRDSXYCYTXNQQJZYYPFZXDYZFPRXEJDGYQBXRCNFYYQPGHYJDYZXGRHTKYLNWDZNTSMPKLBTHBPYSZBZTJZSZZJTYYXZPHSSZZBZ" + +"CZPTQFZMYFLYPYBBJQXZMXXDJMTSYSKKBJZXHJCKLPSMKYJZCXTMLJYXRZZQSLXXQPYZXMKYXXXJCLJPRMYYGADYSKQLSNDHYZKQXZYZTCGHZTLML" + +"WZYBWSYCTBHJHJFCWZTXWYTKZLXQSHLYJZJXTMPLPYCGLTBZZTLZJCYJGDTCLKLPLLQPJMZPAPXYZLKKTKDZCZZBNZDYDYQZJYJGMCTXLTGXSZLML" + +"HBGLKFWNWZHDXUHLFMKYSLGXDTWWFRJEJZTZHYDXYKSHWFZCQSHKTMQQHTZHYMJDJSKHXZJZBZZXYMPAGQMSTPXLSKLZYNWRTSQLSZBPSPSGZWYHT" + +"LKSSSWHZZLYYTNXJGMJSZSUFWNLSOZTXGXLSAMMLBWLDSZYLAKQCQCTMYCFJBSLXCLZZCLXXKSBZQCLHJPSQPLSXXCKSLNHPSFQQYTXYJZLQLDXZQ" + +"JZDYYDJNZPTUZDSKJFSLJHYLZSQZLBTXYDGTQFDBYAZXDZHZJNHHQBYKNXJJQCZMLLJZKSPLDYCLBBLXKLELXJLBQYCXJXGCNLCQPLZLZYJTZLJGY" + +"ZDZPLTQCSXFDMNYCXGBTJDCZNBGBQYQJWGKFHTNPYQZQGBKPBBYZMTJDYTBLSQMPSXTBNPDXKLEMYYCJYNZCTLDYKZZXDDXHQSHDGMZSJYCCTAYRZ" + +"LPYLTLKXSLZCGGEXCLFXLKJRTLQJAQZNCMBYDKKCXGLCZJZXJHPTDJJMZQYKQSECQZDSHHADMLZFMMZBGNTJNNLGBYJBRBTMLBYJDZXLCJLPLDLPC" + +"QDHLXZLYCBLCXZZJADJLNZMMSSSMYBHBSQKBHRSXXJMXSDZNZPXLGBRHWGGFCXGMSKLLTSJYYCQLTSKYWYYHYWXBXQYWPYWYKQLSQPTNTKHQCWDQK" + +"TWPXXHCPTHTWUMSSYHBWCRWXHJMKMZNGWTMLKFGHKJYLSYYCXWHYECLQHKQHTTQKHFZLDXQWYZYYDESBPKYRZPJFYYZJCEQDZZDLATZBBFJLLCXDL" + +"MJSSXEGYGSJQXCWBXSSZPDYZCXDNYXPPZYDLYJCZPLTXLSXYZYRXCYYYDYLWWNZSAHJSYQYHGYWWAXTJZDAXYSRLTDPSSYYFNEJDXYZHLXLLLZQZS" + +"JNYQYQQXYJGHZGZCYJCHZLYCDSHWSHJZYJXCLLNXZJJYYXNFXMWFPYLCYLLABWDDHWDXJMCXZTZPMLQZHSFHZYNZTLLDYWLSLXHYMMYLMBWWKYXYA" + +"DTXYLLDJPYBPWUXJMWMLLSAFDLLYFLBHHHBQQLTZJCQJLDJTFFKMMMBYTHYGDCQRDDWRQJXNBYSNWZDBYYTBJHPYBYTTJXAAHGQDQTMYSTQXKBTZP" + +"KJLZRBEQQSSMJJBDJOTGTBXPGBKTLHQXJJJCTHXQDWJLWRFWQGWSHCKRYSWGFTGYGBXSDWDWRFHWYTJJXXXJYZYSLPYYYPAYXHYDQKXSHXYXGSKQH" + +"YWFDDDPPLCJLQQEEWXKSYYKDYPLTJTHKJLTCYYHHJTTPLTZZCDLTHQKZXQYSTEEYWYYZYXXYYSTTJKLLPZMCYHQGXYHSRMBXPLLNQYDQHXSXXWGDQ" + +"BSHYLLPJJJTHYJKYPPTHYYKTYEZYENMDSHLCRPQFDGFXZPSFTLJXXJBSWYYSKSFLXLPPLBBBLBSFXFYZBSJSSYLPBBFFFFSSCJDSTZSXZRYYSYFFS" + +"YZYZBJTBCTSBSDHRTJJBYTCXYJEYLXCBNEBJDSYXYKGSJZBXBYTFZWGENYHHTHZHHXFWGCSTBGXKLSXYWMTMBYXJSTZSCDYQRCYTWXZFHMYMCXLZN" + +"SDJTTTXRYCFYJSBSDYERXJLJXBBDEYNJGHXGCKGSCYMBLXJMSZNSKGXFBNBPTHFJAAFXYXFPXMYPQDTZCXZZPXRSYWZDLYBBKTYQPQJPZYPZJZNJP" + +"ZJLZZFYSBTTSLMPTZRTDXQSJEHBZYLZDHLJSQMLHTXTJECXSLZZSPKTLZKQQYFSYGYWPCPQFHQHYTQXZKRSGTTSQCZLPTXCDYYZXSQZSLXLZMYCPC" + +"QBZYXHBSXLZDLTCDXTYLZJYYZPZYZLTXJSJXHLPMYTXCQRBLZSSFJZZTNJYTXMYJHLHPPLCYXQJQQKZZSCPZKSWALQSBLCCZJSXGWWWYGYKTJBBZT" + +"DKHXHKGTGPBKQYSLPXPJCKBMLLXDZSTBKLGGQKQLSBKKTFXRMDKBFTPZFRTBBRFERQGXYJPZSSTLBZTPSZQZSJDHLJQLZBPMSMMSXLQQNHKNBLRDD" + +"NXXDHDDJCYYGYLXGZLXSYGMQQGKHBPMXYXLYTQWLWGCPBMQXCYZYDRJBHTDJYHQSHTMJSBYPLWHLZFFNYPMHXXHPLTBQPFBJWQDBYGPNZTPFZJGSD" + +"DTQSHZEAWZZYLLTYYBWJKXXGHLFKXDJTMSZSQYNZGGSWQSPHTLSSKMCLZXYSZQZXNCJDQGZDLFNYKLJCJLLZLMZZNHYDSSHTHZZLZZBBHQZWWYCRZ" + +"HLYQQJBEYFXXXWHSRXWQHWPSLMSSKZTTYGYQQWRSLALHMJTQJSMXQBJJZJXZYZKXBYQXBJXSHZTSFJLXMXZXFGHKZSZGGYLCLSARJYHSLLLMZXELG" + +"LXYDJYTLFBHBPNLYZFBBHPTGJKWETZHKJJXZXXGLLJLSTGSHJJYQLQZFKCGNNDJSSZFDBCTWWSEQFHQJBSAQTGYPQLBXBMMYWXGSLZHGLZGQYFLZB" + +"YFZJFRYSFMBYZHQGFWZSYFYJJPHZBYYZFFWODGRLMFTWLBZGYCQXCDJYGZYYYYTYTYDWEGAZYHXJLZYYHLRMGRXXZCLHNELJJTJTPWJYBJJBXJJTJ" + +"TEEKHWSLJPLPSFYZPQQBDLQJJTYYQLYZKDKSQJYYQZLDQTGJQYZJSUCMRYQTHTEJMFCTYHYPKMHYZWJDQFHYYXWSHCTXRLJHQXHCCYYYJLTKTTYTM" + +"XGTCJTZAYYOCZLYLBSZYWJYTSJYHBYSHFJLYGJXXTMZYYLTXXYPZLXYJZYZYYPNHMYMDYYLBLHLSYYQQLLNJJYMSOYQBZGDLYXYLCQYXTSZEGXHZG" + +"LHWBLJHEYXTWQMAKBPQCGYSHHEGQCMWYYWLJYJHYYZLLJJYLHZYHMGSLJLJXCJJYCLYCJPCPZJZJMMYLCQLNQLJQJSXYJMLSZLJQLYCMMHCFMMFPQ" + +"QMFYLQMCFFQMMMMHMZNFHHJGTTHHKHSLNCHHYQDXTMMQDCYZYXYQMYQYLTDCYYYZAZZCYMZYDLZFFFMMYCQZWZZMABTBYZTDMNZZGGDFTYPCGQYTT" + +"SSFFWFDTZQSSYSTWXJHXYTSXXYLBYQHWWKXHZXWZNNZZJZJJQJCCCHYYXBZXZCYZTLLCQXYNJYCYYCYNZZQYYYEWYCZDCJYCCHYJLBTZYYCQWMPWP" + +"YMLGKDLDLGKQQBGYCHJXY"; +// 375 polyphonic words are included here +let oMultiDiff = { "19969": "DZ", "19975": "WM", "19988": "QJ", "20048": "YL", "20056": "SC", "20060": "NM", + "20094": "QG", "20127": "QJ", "20167": "QC", "20193": "YG", "20250": "KH", "20256": "ZC", "20282": "SC", + "20285": "QJG", "20291": "TD", "20314": "YD", "20340": "NE", "20375": "TD", "20389": "YJ", "20391": "CZ", + "20415": "PB", "20446": "YS", "20447": "SQ", "20504": "TC", "20608": "KG", "20854": "QJ", "20857": "ZC", + "20911": "PF", "20985": "AW", "21032": "PB", "21048": "XQ", "21049": "SC", "21089": "YS", "21119": "JC", + "21242": "SB", "21273": "SC", "21305": "YP", "21306": "QO", "21330": "ZC", "21333": "SDC", "21345": "QK", + "21378": "CA", "21397": "SC", "21414": "XS", "21442": "SC", "21477": "JG", "21480": "TD", "21484": "ZS", + "21494": "YX", "21505": "YX", "21512": "HG", "21523": "XH", "21537": "PB", "21542": "PF", "21549": "KH", + "21571": "E", "21574": "DA", "21588": "TD", "21589": "O", "21618": "ZC", "21621": "KHA", "21632": "ZJ", + "21654": "KG", "21679": "LKG", "21683": "KH", "21710": "A", "21719": "YH", "21734": "WOE", "21769": "A", + "21780": "WN", "21804": "XH", "21834": "A", "21899": "ZD", "21903": "RN", "21908": "WO", "21939": "ZC", + "21956": "SA", "21964": "YA", "21970": "TD", "22003": "A", "22031": "JG", "22040": "XS", "22060": "ZC", + "22066": "ZC", "22079": "MH", "22129": "XJ", "22179": "XA", "22237": "NJ", "22244": "TD", "22280": "JQ", + "22300": "YH", "22313": "XW", "22331": "YQ", "22343": "YJ", "22351": "PH", "22395": "DC", "22412": "TD", + "22484": "PB", "22500": "PB", "22534": "ZD", "22549": "DH", "22561": "PB", "22612": "TD", "22771": "KQ", + "22831": "HB", "22841": "JG", "22855": "QJ", "22865": "XQ", "23013": "ML", "23081": "WM", "23487": "SX", + "23558": "QJ", "23561": "YW", "23586": "YW", "23614": "YW", "23615": "SN", "23631": "PB", "23646": "ZS", + "23663": "ZT", "23673": "YG", "23762": "TD", "23769": "ZS", "23780": "QJ", "23884": "QK", "24055": "XH", + "24113": "DC", "24162": "ZC", "24191": "GA", "24273": "QJ", "24324": "NL", "24377": "TD", "24378": "QJ", + "24439": "PF", "24554": "ZS", "24683": "TD", "24694": "WE", "24733": "LK", "24925": "TN", "25094": "ZG", + "25100": "XQ", "25103": "XH", "25153": "PB", "25170": "PB", "25179": "KG", "25203": "PB", "25240": "ZS", + "25282": "FB", "25303": "NA", "25324": "KG", "25341": "ZY", "25373": "WZ", "25375": "XJ", "25384": "A", + "25457": "A", "25528": "SD", "25530": "SC", "25552": "TD", "25774": "ZC", "25874": "ZC", "26044": "YW", + "26080": "WM", "26292": "PB", "26333": "PB", "26355": "ZY", "26366": "CZ", "26397": "ZC", "26399": "QJ", + "26415": "ZS", "26451": "SB", "26526": "ZC", "26552": "JG", "26561": "TD", "26588": "JG", "26597": "CZ", + "26629": "ZS", "26638": "YL", "26646": "XQ", "26653": "KG", "26657": "XJ", "26727": "HG", "26894": "ZC", + "26937": "ZS", "26946": "ZC", "26999": "KJ", "27099": "KJ", "27449": "YQ", "27481": "XS", "27542": "ZS", + "27663": "ZS", "27748": "TS", "27784": "SC", "27788": "ZD", "27795": "TD", "27812": "O", "27850": "PB", + "27852": "MB", "27895": "SL", "27898": "PL", "27973": "QJ", "27981": "KH", "27986": "HX", "27994": "XJ", + "28044": "YC", "28065": "WG", "28177": "SM", "28267": "QJ", "28291": "KH", "28337": "ZQ", "28463": "TL", + "28548": "DC", "28601": "TD", "28689": "PB", "28805": "JG", "28820": "QG", "28846": "PB", "28952": "TD", + "28975": "ZC", "29100": "A", "29325": "QJ", "29575": "SL", "29602": "FB", "30010": "TD", "30044": "CX", + "30058": "PF", "30091": "YSP", "30111": "YN", "30229": "XJ", "30427": "SC", "30465": "SX", "30631": "YQ", + "30655": "QJ", "30684": "QJG", "30707": "SD", "30729": "XH", "30796": "LG", "30917": "PB", "31074": "NM", + "31085": "JZ", "31109": "SC", "31181": "ZC", "31192": "MLB", "31293": "JQ", "31400": "YX", "31584": "YJ", + "31896": "ZN", "31909": "ZY", "31995": "XJ", "32321": "PF", "32327": "ZY", "32418": "HG", "32420": "XQ", + "32421": "HG", "32438": "LG", "32473": "GJ", "32488": "TD", "32521": "QJ", "32527": "PB", "32562": "ZSQ", + "32564": "JZ", "32735": "ZD", "32793": "PB", "33071": "PF", "33098": "XL", "33100": "YA", "33152": "PB", + "33261": "CX", "33324": "BP", "33333": "TD", "33406": "YA", "33426": "WM", "33432": "PB", "33445": "JG", + "33486": "ZN", "33493": "TS", "33507": "QJ", "33540": "QJ", "33544": "ZC", "33564": "XQ", "33617": "YT", + "33632": "QJ", "33636": "XH", "33637": "YX", "33694": "WG", "33705": "PF", "33728": "YW", "33882": "SR", + "34067": "WM", "34074": "YW", "34121": "QJ", "34255": "ZC", "34259": "XL", "34425": "JH", "34430": "XH", + "34485": "KH", "34503": "YS", "34532": "HG", "34552": "XS", "34558": "YE", "34593": "ZL", "34660": "YQ", + "34892": "XH", "34928": "SC", "34999": "QJ", "35048": "PB", "35059": "SC", "35098": "ZC", "35203": "TQ", + "35265": "JX", "35299": "JX", "35782": "SZ", "35828": "YS", "35830": "E", "35843": "TD", "35895": "YG", + "35977": "MH", "36158": "JG", "36228": "QJ", "36426": "XQ", "36466": "DC", "36710": "JC", "36711": "ZYG", + "36767": "PB", "36866": "SK", "36951": "YW", "37034": "YX", "37063": "XH", "37218": "ZC", "37325": "ZC", + "38063": "PB", "38079": "TD", "38085": "QY", "38107": "DC", "38116": "TD", "38123": "YD", "38224": "HG", + "38241": "XTC", "38271": "ZC", "38415": "YE", "38426": "KH", "38461": "YD", "38463": "AE", "38466": "PB", + "38477": "XJ", "38518": "YT", "38551": "WK", "38585": "ZC", "38704": "XS", "38739": "LJ", "38761": "GJ", + "38808": "SQ", "39048": "JG", "39049": "XJ", "39052": "HG", "39076": "CZ", "39271": "XT", "39534": "TD", + "39552": "TD", "39584": "PB", "39647": "SB", "39730": "LG", "39748": "TPB", "40109": "ZQ", "40479": "ND", + "40516": "HG", "40536": "HG", "40583": "QJ", "40765": "YQ", "40784": "QJ", "40840": "YK", "40863": "QJG" }; + +// Program that returns the first letter array of Chinese characters +export function makePy(str) { + if (typeof(str) != "string") + throw new Error("函数makePy需要字符串类型参数!"); + var arrResult = []; + // Convert string to array + for (var i = 0, len = str.length; i < len; i++) { + var ch = str.charAt(i); + arrResult.push(checkCh(ch)); + } + return mkRslt(arrResult); +} + +// Check processing Chinese characters +function checkCh(ch) { + var uni = ch.charCodeAt(Constants.CHAR_CODE); + // If it is not within the scope of Chinese character processing, return the original character, and you can also call your own processing function + if (uni > Constants.UNI_MAX || uni < Constants.UNI_MIN) + return ch; //dealWithOthers(ch); + // Check whether it is a polyphonic word, it is processed as a polyphonic word, if not, just find the corresponding first letter in the strChineseFirstPY string. + return (oMultiDiff[uni] ? oMultiDiff[uni] : (strChineseFirstPY.charAt(uni - Constants.UNI_MIN))); +} + +// Process the characters and return an array of letters +function mkRslt(arr) { + var arrRslt = [""]; + for (var i = 0, len = arr.length; i < len; i++) { + var str = arr[i]; + var strlen = str.length; + if (strlen == 1) { + for (var k = 0; k < arrRslt.length; k++) { + arrRslt[k] += str; + } + } else { + var tmpArr = arrRslt.slice(0); + arrRslt = []; + for (k = 0; k < strlen; k++) { + // Copy an identical arrRslt + var tmp = tmpArr.slice(0); + // Add the current character str[k] to the end of each element + for (var j = 0; j < tmp.length; j++) { + tmp[j] += str.charAt(k); + } + // Concatenate the copied and modified array to arrRslt + arrRslt = arrRslt.concat(tmp); + } + } + } + return arrRslt; +} + +/** + * Get the corresponding permission group id according to the permission + * @param {String} permission app name id + * @return {Number} groupId + */ +export function getPermissionGroup(permission: string) { + for (var i = 0; i < permissionGroups.length; i++) { + if (permissionGroups[i].permissionName == permission) { + if(permissionGroups[i].groupName == 'OTHER') { + return { + "name": permissionGroups[i].groupName, + "groupName": permissionGroups[i].label, + "label": permissionGroups[i].text, + "icon": permissionGroups[i].icon, + "description": '', + "permissions": [ + permissionGroups[i].permissionName + ] + } + }else { + return groups[permissionGroups[i].groupId] + } + } + } +} + +const TAG = 'PermissionManager_Log'; + +export class Log { + static info(log) { + console.info(`Info: ${TAG} ${log}`) + } + + static error(log) { + console.error(`Error: ${TAG} ${log}`) + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/application-secondary.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/application-secondary.ets index 6ff3deb72f928a82c9aee361ad2a9bb41d1d1a2c..e7dcc0ea9e15ec1a09237dbb4a94917a68016aa7 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/application-secondary.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/application-secondary.ets @@ -1,346 +1,346 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { backBar } from "../common/components/backBar"; -import router from '@system.router'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import { groups } from "../common/model/permissionGroup"; -import Constants from '../common/utils/constant'; - -var TAG = 'PermissionManager_MainAbility:' - -const allowedStatus = 0; // Status: Allowed -const bannedStatus = 1; // Status: Banned - -class AllowedObj { - groupName: string; - permission: string[]; - constructor(groupName: string, permission: string[]) { - this.groupName = groupName; - this.permission = permission; - } -} // Class Allowed -class BannedObj { - groupName: string; - permission: string[]; - constructor(groupName: string, permission: string[]) { - this.groupName = groupName; - this.permission = permission; - } -} // Class Banned - -@Entry -@Component -struct appNamePlusPage { - @State allowedListItem: AllowedObj[] = []; // Array of allowed permissions - @State bannedListItem: BannedObj[] = []; // array of forbidden permissions - private routerData = router.getParams().routerData; // Routing jump data - - @Builder ListItemLayout(item, index, status) { - ListItem() { - Row() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Text(item.groupName) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontColor($r('app.color.text_color')) - .fontWeight(FontWeight.Medium) - .flexGrow(Constants.FLEX_GROW) - Image($r('app.media.rightarrow')) - .objectFit(ImageFit.Contain) - .height(Constants.IMAGE_HEIGHT) - .width(Constants.IMAGE_WIDTH) - } - .width(Constants.FULL_WIDTH) - .height(Constants.LISTITEM_ROW_HEIGHT) - } - if (!index) { - Row() { - Column() - .backgroundColor($r('app.color.text_decoration_color')) - .width(Constants.FULL_WIDTH) - .height(Constants.TEXT_DECORATION_HEIGHT) - } - } - }.onClick(() => { - if (status === 'allow') { - if (item.groupName == "其他权限") { - router.push({ - uri: 'pages/other-permissions', - params: { - routerData: this.routerData.bundleName, - backTitle: item.groupName, - permission: item.permission, - status: allowedStatus, - tokenId: this.routerData.tokenId - } - }); - } else { - router.push({ - uri: 'pages/application-tertiary', - params: { - routerData: this.routerData.bundleName, - backTitle: item.groupName, - permission: item.permission, - status: allowedStatus - } - }); - } - } - else if (status === 'banned') { - if (item.groupName == "其他权限") { - router.push({ - uri: 'pages/other-permissions', - params: { - routerData: this.routerData.bundleName, - backTitle: item.groupName, - permission: item.permission, - status: bannedStatus, - tokenId: this.routerData.tokenId - } - }); - } else { - router.push({ - uri: 'pages/application-tertiary', - params: { - routerData: this.routerData.bundleName, - backTitle: item.groupName, - permission: item.permission, - status: bannedStatus - } - }); - } - } - }) - } - }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) - } - - /** - * Initialize permission status information and group permission information - */ - async initialPermissions() { - var reqPermissions = this.routerData.permissions; - var reqGroupIds = this.routerData.groupId; - - if (!reqGroupIds.length) { - this.allowedListItem = []; - this.bannedListItem = []; - return; - } - - for (let i = 0; i < reqGroupIds.length; i++) { - let id = reqGroupIds[i]; - let groupName = groups[id].groupName; - let groupReqPermissons = []; - for (let j = 0; j < reqPermissions.length; j++) { - let permission = reqPermissions[j]; - if (groups[id].permissions.indexOf(permission) != -1) { - groupReqPermissons.push(permission) - } - } - let isGranted = true; - for (let i = 0; i < groupReqPermissons.length; i++) { - let permission = groupReqPermissons[i] - let res = await abilityAccessCtrl.createAtManager().verifyAccessToken( - this.routerData.tokenId, permission); - if (res != 0) { - isGranted = false; - } - } - - if (isGranted) { - this.allowedListItem.push(new AllowedObj(groupName, groupReqPermissons)); - } else { - this.bannedListItem.push(new BannedObj(groupName, groupReqPermissons)); - } - } - } - - /** - * Lifecycle function, triggered once when this page is displayed - */ - onPageShow() { - console.log(TAG + 'onPageShow application-secondary') - this.initialPermissions(); - } - - /** - * Lifecycle function, triggered once when this page disappears - */ - onPageHide() { - console.log(TAG + 'onPageHide application-secondary') - setTimeout(()=> { - this.allowedListItem = []; - this.bannedListItem = []; - }, Constants.DELAY_TIME) - } - - build() { - Column(){ - GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { - Row({}) { - Row() - .useSizeType({ - xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, - sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, - md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, - lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() { - Column() { - Row() { - backBar({ title: JSON.stringify(this.routerData.labelId), recordable: false }) - } - Row() { - Column() { - if (!this.allowedListItem.length && !this.bannedListItem.length) { - Row() { - List() { - ListItem() { - Row() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Text($r('app.string.no_permission')) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontColor($r('app.color.text_color')) - }.margin({ top: Constants.FLEX_MARGIN_TOP, bottom: Constants.FLEX_MARGIN_BOTTOM }) - }.height(Constants.FULL_HEIGHT) - }.flexGrow(Constants.FLEX_GROW) - .constraintSize({minHeight: Constants.CONSTRAINTSIZE_MINHEIGHT }) - } - .width(Constants.FULL_WIDTH) - .height(Constants.LISTITEM_ROW_HEIGHT) - } - } - } - }.padding({ left: Constants.LISTITEM_PADDING_LEFT, right: Constants.LISTITEM_PADDING_RIGHT }) - } - .backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.margin({ top: Constants.ROW_MARGIN_TOP }) - .padding({ left: Constants.SECONDARY_LIST_PADDING_LEFT, right: Constants.SECONDARY_LIST_PADDING_RIGHT }) - } else { - Scroll() { - List() { - if (this.allowedListItem.length) { - ListItem() { - Row() { - Text($r('app.string.allowed')) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .fontWeight(FontWeight.Medium) - .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) - }.constraintSize({ minHeight: Constants.SUBTITLE_MIN_HEIGHT }) - .padding({ top: Constants.SUBTITLE_PADDING_TOP, bottom: Constants.SUBTITLE_PADDING_BOTTOM, - left: Constants.SECONDARY_TEXT_MARGIN_LEFT}) - } - - ListItem() { - Row() { - List() { - ForEach(this.allowedListItem.slice(Constants.SLICE_START, this.allowedListItem.length - 1), - (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX, 'allow') - }, item => item.toString()) - ForEach(this.allowedListItem.slice(Constants.SLICE_END), (item, index) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX, 'allow') - }, item => item.toString()) - } - .backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.margin({ top: Constants.ROW_MARGIN_TOP }) - .padding({ - left: Constants.SECONDARY_LIST_PADDING_LEFT, - right: Constants.SECONDARY_LIST_PADDING_RIGHT - }) - } - } - if (this.bannedListItem.length) { - ListItem() { - Row() { - Text($r('app.string.banned')) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .fontWeight(FontWeight.Medium) - .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) - }.constraintSize({ minHeight: Constants.SUBTITLE_MIN_HEIGHT }) - .padding({ top: Constants.SUBTITLE_PADDING_TOP, bottom: Constants.SUBTITLE_PADDING_BOTTOM, - left: Constants.SECONDARY_TEXT_MARGIN_LEFT}) - } - - ListItem() { - Row() { - List() { - ForEach(this.bannedListItem.slice(Constants.SLICE_START, this.bannedListItem.length - 1), - (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX, 'banned') - }, item => item.toString()) - ForEach(this.bannedListItem.slice(Constants.SLICE_END), (item) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX, 'banned') - }, item => item.toString()) - } - .backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.margin({ top: Constants.ROW_MARGIN_TOP }) - .padding({ - left: Constants.SECONDARY_LIST_PADDING_LEFT, - right: Constants.SECONDARY_LIST_PADDING_RIGHT - }) - } - } - } - }.scrollBar(BarState.Off) - } - } - .width(Constants.FULL_WIDTH) - .height(Constants.FULL_HEIGHT) - } - .layoutWeight(Constants.LAYOUT_WEIGHT) - } - } - .useSizeType({ - xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, - sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, - md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, - lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() - .useSizeType({ - xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, - sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, - md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, - lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - } - .height(Constants.FULL_HEIGHT) - .width(Constants.FULL_WIDTH) - .backgroundColor($r("sys.color.ohos_id_color_sub_background")) - .opacity(Constants.MANAGEMENT_TRANSPARENCY) - } - } - } -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { backBar } from "../common/components/backBar"; +import router from '@system.router'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import { groups } from "../common/model/permissionGroup"; +import Constants from '../common/utils/constant'; + +var TAG = 'PermissionManager_MainAbility:' + +const allowedStatus = 0; // Status: Allowed +const bannedStatus = 1; // Status: Banned + +class AllowedObj { + groupName: string; + permission: string[]; + constructor(groupName: string, permission: string[]) { + this.groupName = groupName; + this.permission = permission; + } +} // Class Allowed +class BannedObj { + groupName: string; + permission: string[]; + constructor(groupName: string, permission: string[]) { + this.groupName = groupName; + this.permission = permission; + } +} // Class Banned + +@Entry +@Component +struct appNamePlusPage { + @State allowedListItem: AllowedObj[] = []; // Array of allowed permissions + @State bannedListItem: BannedObj[] = []; // array of forbidden permissions + private routerData = router.getParams().routerData; // Routing jump data + + @Builder ListItemLayout(item, index, status) { + ListItem() { + Row() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Text(item.groupName) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontColor($r('app.color.text_color')) + .fontWeight(FontWeight.Medium) + .flexGrow(Constants.FLEX_GROW) + Image($r('app.media.rightarrow')) + .objectFit(ImageFit.Contain) + .height(Constants.IMAGE_HEIGHT) + .width(Constants.IMAGE_WIDTH) + } + .width(Constants.FULL_WIDTH) + .height(Constants.LISTITEM_ROW_HEIGHT) + } + if (!index) { + Row() { + Column() + .backgroundColor($r('app.color.text_decoration_color')) + .width(Constants.FULL_WIDTH) + .height(Constants.TEXT_DECORATION_HEIGHT) + } + } + }.onClick(() => { + if (status === 'allow') { + if (item.groupName == "其他权限") { + router.push({ + uri: 'pages/other-permissions', + params: { + routerData: this.routerData.bundleName, + backTitle: item.groupName, + permission: item.permission, + status: allowedStatus, + tokenId: this.routerData.tokenId + } + }); + } else { + router.push({ + uri: 'pages/application-tertiary', + params: { + routerData: this.routerData.bundleName, + backTitle: item.groupName, + permission: item.permission, + status: allowedStatus + } + }); + } + } + else if (status === 'banned') { + if (item.groupName == "其他权限") { + router.push({ + uri: 'pages/other-permissions', + params: { + routerData: this.routerData.bundleName, + backTitle: item.groupName, + permission: item.permission, + status: bannedStatus, + tokenId: this.routerData.tokenId + } + }); + } else { + router.push({ + uri: 'pages/application-tertiary', + params: { + routerData: this.routerData.bundleName, + backTitle: item.groupName, + permission: item.permission, + status: bannedStatus + } + }); + } + } + }) + } + }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) + } + + /** + * Initialize permission status information and group permission information + */ + async initialPermissions() { + var reqPermissions = this.routerData.permissions; + var reqGroupIds = this.routerData.groupId; + + if (!reqGroupIds.length) { + this.allowedListItem = []; + this.bannedListItem = []; + return; + } + + for (let i = 0; i < reqGroupIds.length; i++) { + let id = reqGroupIds[i]; + let groupName = groups[id].groupName; + let groupReqPermissons = []; + for (let j = 0; j < reqPermissions.length; j++) { + let permission = reqPermissions[j]; + if (groups[id].permissions.indexOf(permission) != -1) { + groupReqPermissons.push(permission) + } + } + let isGranted = true; + for (let i = 0; i < groupReqPermissons.length; i++) { + let permission = groupReqPermissons[i] + let res = await abilityAccessCtrl.createAtManager().verifyAccessToken( + this.routerData.tokenId, permission); + if (res != 0) { + isGranted = false; + } + } + + if (isGranted) { + this.allowedListItem.push(new AllowedObj(groupName, groupReqPermissons)); + } else { + this.bannedListItem.push(new BannedObj(groupName, groupReqPermissons)); + } + } + } + + /** + * Lifecycle function, triggered once when this page is displayed + */ + onPageShow() { + console.log(TAG + 'onPageShow application-secondary') + this.initialPermissions(); + } + + /** + * Lifecycle function, triggered once when this page disappears + */ + onPageHide() { + console.log(TAG + 'onPageHide application-secondary') + setTimeout(()=> { + this.allowedListItem = []; + this.bannedListItem = []; + }, Constants.DELAY_TIME) + } + + build() { + Column(){ + GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { + Row({}) { + Row() + .useSizeType({ + xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, + sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, + md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, + lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() { + Column() { + Row() { + backBar({ title: JSON.stringify(this.routerData.labelId), recordable: false }) + } + Row() { + Column() { + if (!this.allowedListItem.length && !this.bannedListItem.length) { + Row() { + List() { + ListItem() { + Row() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Text($r('app.string.no_permission')) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontColor($r('app.color.text_color')) + }.margin({ top: Constants.FLEX_MARGIN_TOP, bottom: Constants.FLEX_MARGIN_BOTTOM }) + }.height(Constants.FULL_HEIGHT) + }.flexGrow(Constants.FLEX_GROW) + .constraintSize({minHeight: Constants.CONSTRAINTSIZE_MINHEIGHT }) + } + .width(Constants.FULL_WIDTH) + .height(Constants.LISTITEM_ROW_HEIGHT) + } + } + } + }.padding({ left: Constants.LISTITEM_PADDING_LEFT, right: Constants.LISTITEM_PADDING_RIGHT }) + } + .backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.margin({ top: Constants.ROW_MARGIN_TOP }) + .padding({ left: Constants.SECONDARY_LIST_PADDING_LEFT, right: Constants.SECONDARY_LIST_PADDING_RIGHT }) + } else { + Scroll() { + List() { + if (this.allowedListItem.length) { + ListItem() { + Row() { + Text($r('app.string.allowed')) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .fontWeight(FontWeight.Medium) + .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) + }.constraintSize({ minHeight: Constants.SUBTITLE_MIN_HEIGHT }) + .padding({ top: Constants.SUBTITLE_PADDING_TOP, bottom: Constants.SUBTITLE_PADDING_BOTTOM, + left: Constants.SECONDARY_TEXT_MARGIN_LEFT}) + } + + ListItem() { + Row() { + List() { + ForEach(this.allowedListItem.slice(Constants.SLICE_START, this.allowedListItem.length - 1), + (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX, 'allow') + }, item => item.toString()) + ForEach(this.allowedListItem.slice(Constants.SLICE_END), (item, index) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX, 'allow') + }, item => item.toString()) + } + .backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.margin({ top: Constants.ROW_MARGIN_TOP }) + .padding({ + left: Constants.SECONDARY_LIST_PADDING_LEFT, + right: Constants.SECONDARY_LIST_PADDING_RIGHT + }) + } + } + if (this.bannedListItem.length) { + ListItem() { + Row() { + Text($r('app.string.banned')) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .fontWeight(FontWeight.Medium) + .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) + }.constraintSize({ minHeight: Constants.SUBTITLE_MIN_HEIGHT }) + .padding({ top: Constants.SUBTITLE_PADDING_TOP, bottom: Constants.SUBTITLE_PADDING_BOTTOM, + left: Constants.SECONDARY_TEXT_MARGIN_LEFT}) + } + + ListItem() { + Row() { + List() { + ForEach(this.bannedListItem.slice(Constants.SLICE_START, this.bannedListItem.length - 1), + (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX, 'banned') + }, item => item.toString()) + ForEach(this.bannedListItem.slice(Constants.SLICE_END), (item) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX, 'banned') + }, item => item.toString()) + } + .backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.margin({ top: Constants.ROW_MARGIN_TOP }) + .padding({ + left: Constants.SECONDARY_LIST_PADDING_LEFT, + right: Constants.SECONDARY_LIST_PADDING_RIGHT + }) + } + } + } + }.scrollBar(BarState.Off) + } + } + .width(Constants.FULL_WIDTH) + .height(Constants.FULL_HEIGHT) + } + .layoutWeight(Constants.LAYOUT_WEIGHT) + } + } + .useSizeType({ + xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, + sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, + md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, + lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() + .useSizeType({ + xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, + sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, + md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, + lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + } + .height(Constants.FULL_HEIGHT) + .width(Constants.FULL_WIDTH) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .opacity(Constants.MANAGEMENT_TRANSPARENCY) + } + } + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/application-tertiary.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/application-tertiary.ets index e4d4e0c5258a83dc22bb58dbeca54f13fa49ae7f..e5b47e7638dbfda8281c7d7f89de3656527dbf62 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/application-tertiary.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/application-tertiary.ets @@ -1,431 +1,431 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { backBar } from "../common/components/backBar"; -import router from '@system.router'; -import bundle from "@ohos.bundle"; -import { getAppLabel, getAppIcon, verifyAccessToken } from "../common/utils/utils"; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import Resmgr from '@ohos.resourceManager' -import { authorizeDialog } from "../common/components/dialog"; -import { permissionDescriptions, permissionGroups, showSubpermissionsGrop } from "../common/model/permissionGroup"; -import Constants from '../common/utils/constant'; - -var TAG = 'PermissionManager_MainAbility:' - -let routerData = router.getParams().routerData; // Routing jump data -let backTitle = router.getParams().backTitle; // return title name -let status = router.getParams().status; // Status: Allowed, Forbidden -let permissions = router.getParams().permission; // permissions name -let nowGrantResult = Constants.PERMISSION_NUM; // Authorization results now -let nowRevokeResult = Constants.PERMISSION_NUM; // Now deauthorize results -let GrantResultFlag = []; // Authorization result Flag -let RevokeResultFlag = []; // Cancel authorization result Flag -let reason = null // Authorized reason -class MeidaDocObj { - name: string - index: number - groupName: string - accessTokenId: string - permissions: [] - constructor( - name: string, - index: number, - groupName: string, - accessTokenId: string, - permissions: [] - ) { - this.name = name - this.index = index - this.groupName = groupName - this.accessTokenId = accessTokenId - this.permissions = permissions - } -}; // permission information class -class MediaListObj { - labelId: string - iconId: string - versionName: string - description: string - constructor( - labelId: string, - iconId: string, - versionName: string, - description: string - ) { - this.labelId = labelId - this.iconId = iconId - this.versionName = versionName - this.description = description - } -}; // Permission application information class - -@Entry -@Component -struct mediaDocumentPage { - build() { - Column() { - GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { - Row() { - Row() - .useSizeType({ - xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, - sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, - md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, - lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() { - Column() { - Row() { - backBar({ title: JSON.stringify(backTitle), recordable: false }) - } - Row() { - Column() { - mediaDocumentItem() - }.width(Constants.FULL_WIDTH) - } - .margin({ top: Constants.TITLE_MARGIN_BOTTOM }) - .layoutWeight(Constants.LAYOUT_WEIGHT) - } - } - .useSizeType({ - xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, - sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, - md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, - lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() - .useSizeType({ - xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, - sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, - md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, - lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - } - .height(Constants.FULL_HEIGHT) - .width(Constants.FULL_WIDTH) - .backgroundColor($r("sys.color.ohos_id_color_sub_background")) - .opacity(Constants.MANAGEMENT_TRANSPARENCY) - } - } - } -} - -@Component -struct mediaDocumentItem { - @State mediaDocListItem: MeidaDocObj[] = []; // Permission information array - @State mediaListItem: MediaListObj = { - labelId: '', - iconId: '', - versionName: '', - description: '' - }; // application info array - @State isCheckList: boolean[] = []; // Permission status array - - authorizeDialogController: CustomDialogController = new CustomDialogController({ - builder: authorizeDialog({ }), - autoCancel: true, - alignment: DialogAlignment.Center - }); - - /** - * Grant permissions to the app - * @param {Number} accessTokenId - * @param {String} permission permission name - */ - grantUserGrantedPermission(accessTokenId, permission) { - abilityAccessCtrl.createAtManager().grantUserGrantedPermission( - accessTokenId, permission, Constants.PERMISSION_FLAG).then((result) => { - nowGrantResult = result; - }) - .catch((error) => { - console.error(TAG + 'grantUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); - }) - } - - /** - * Deauthorize the app - * @param {Number} accessTokenId - * @param {String} permission permission name - */ - revokeUserGrantedPermission(accessTokenId, permission) { - abilityAccessCtrl.createAtManager().revokeUserGrantedPermission( - accessTokenId, permission, Constants.PERMISSION_FLAG).then((result) => { - nowRevokeResult = result; - }) - .catch((error) => { - console.error(TAG + 'revokeUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); - }) - } - - /** - * Lifecycle function, executed when the page is initialized - */ - aboutToAppear() { - let permissionDescription = permissionDescriptions[backTitle]; - if(showSubpermissionsGrop.indexOf(backTitle) != -1) { - reason = [] - permissions.forEach(permission => { - permissionGroups.forEach(permissionGroup => { - if(permissionGroup.permissionName == permission) { - reason.push(permissionGroup.label) - } - }) - }) - Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { - Promise.all([item.getString($r("app.string.separator").id), - item.getString($r("app.string.reason_suffix").id)]) - .then(values => { - reason = reason.join(values[0]) - reason += values[1] - }) - }) - }else { - reason = '' - } - let hasReason = false - bundle.getBundleInfo(routerData, Constants.PARMETER_BUNDLE_FLAG).then(res => { - permissions.forEach(permission => { - res.reqPermissionDetails.forEach(reqPermissionDetail => { - if(reqPermissionDetail.name == permission) { - Resmgr.getResourceManager(globalThis.context, routerData).then(item => { - item.getString(reqPermissionDetail.reasonId, (err, value) => { - if (value !== undefined && !hasReason) { - reason += value.slice(Constants.START_SUBSCRIPT, Constants.END_SUBSCRIPT) - hasReason = true - } - }) - }) - } - }) - }) - Promise.all([getAppLabel(res.appInfo.labelId, res.name), - getAppIcon(res.appInfo.iconId, res.name)]) - .then((values) => { - this.mediaListItem = new MediaListObj( - String(values[0]), String(values[1]), res.versionName, permissionDescription); - }) - this.mediaDocListItem.push( - new MeidaDocObj( - Constants.RADIO_ALLOW_NAME, - Constants.RADIO_ALLOW_INDEX, - Constants.RADIO_ALLOW_GROUP_NAME, - res.appInfo.accessTokenId, - permissions - ) - ); - this.mediaDocListItem.push( - new MeidaDocObj( - Constants.RADIO_BAN_NAME, - Constants.RADIO_BAN_INDEX, - Constants.RADIO_BAN_GROUP_NAME, - res.appInfo.accessTokenId, - permissions - ) - ); - }).catch((error) => { - console.error(TAG + 'bundle.getBundleInfo failed. Cause: ' + JSON.stringify(error)); - this.mediaListItem = new MediaListObj('', '', '', permissionDescription); - this.mediaDocListItem.push( - new MeidaDocObj(Constants.RADIO_ALLOW_NAME, Constants.RADIO_ALLOW_INDEX, - Constants.RADIO_ALLOW_GROUP_NAME, '', permissions) - ); - this.mediaDocListItem.push( - new MeidaDocObj(Constants.RADIO_BAN_NAME, Constants.RADIO_BAN_INDEX, - Constants.RADIO_BAN_GROUP_NAME, '', permissions) - ); - }) - // Get permission status - if (!status) { - this.isCheckList = [true, false]; - } else { - this.isCheckList = [false, true]; - } - } - - build(){ - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image(this.mediaListItem.iconId) - .width(Constants.TERTIARY_IMAGE_WIDTH) - .height(Constants.TERTIARY_IMAGE_HEIGHT) - .margin({ left: Constants.TERTIARY_IMAGE_MARGIN_LEFT, right: Constants.TERTIARY_IMAGE_MARGIN_RIGHT }) - Column() { - Row() { - Text(this.mediaListItem.labelId) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontColor($r('app.color.label_color')) - .fontWeight(FontWeight.Bold) - .textAlign(TextAlign.Start) - } - .width(Constants.TERTIARY_HALF_WIDTH) - .margin({ bottom: Constants.TERTIARY_LABEL_MARGIN_BOTTOM }) - Row() { - Text(this.mediaListItem.versionName) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .textAlign(TextAlign.Start) - } - .width(Constants.TERTIARY_HALF_WIDTH) - } - }.margin({ left: Constants.TERTIARY_MARGIN_LEFT }) - } - if(reason) { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Text(reason) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .textAlign(TextAlign.Start) - }.margin({ left: Constants.TERTIARY_IMAGE_MARGIN_LEFT, right: Constants.TERTIARY_IMAGE_MARGIN_RIGHT }) - } - } - .margin({ top: Constants.TERTIARY_ROW_MARGIN_TOP, left: Constants.TERTIARY_MARGIN_LEFT }) - } - Row() { - Text(backTitle) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .fontWeight(FontWeight.Medium) - .textAlign(TextAlign.Start) - .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) - Text($r('app.string.access_permission')) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .fontWeight(FontWeight.Medium) - .textAlign(TextAlign.Start) - .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) - }.width(Constants.FULL_WIDTH) - .constraintSize({ minHeight: Constants.SUBTITLE_MIN_HEIGHT }) - .padding({ top: Constants.SUBTITLE_PADDING_TOP, bottom: Constants.SUBTITLE_PADDING_BOTTOM, - left: Constants.TERTIARY_TEXT_MARGIN_LEFT, right: Constants.TERTIARY_IMAGE_MARGIN_RIGHT}) - .margin({ top: Constants.TERTIARY_PERMISSION_ROW_MARGIN_TOP }) - Column() { - List() { - ForEach(this.mediaDocListItem, (item) => { - ListItem() { - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Text(item.name) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontColor($r('app.color.label_color')) - .fontWeight(FontWeight.Medium) - .flexGrow(Constants.FLEX_GROW) - if (this.isCheckList[item.index] === true) { - Shape() { - Circle().width(Constants.SHAPE_DIA).height(Constants.SHAPE_DIA) - .fill($r("app.color.shape_allow_color")).offset({ x: 0, y: 0 }) - Circle().width(Constants.SHAPE_ALLOW_DIA).height(Constants.SHAPE_ALLOW_DIA) - .fill($r("app.color.default_background_color")) - .offset({ x: Constants.SHAPE_ALLOW_OFFSET, y: Constants.SHAPE_ALLOW_OFFSET }) - } - } else if (this.isCheckList[item.index] === false) { - Shape() { - Circle().width(Constants.SHAPE_DIA).height(Constants.SHAPE_DIA) - .fill($r("app.color.shape_ban_color")).offset({ x: 0, y: 0 }) - Circle().width(Constants.SHAPE_BAN_DIA).height(Constants.SHAPE_BAN_DIA) - .fill($r("app.color.default_background_color")) - .offset({ x: Constants.SHAPE_BAN_OFFSET, y: Constants.SHAPE_BAN_OFFSET }) - } - } - } - .width(Constants.FULL_WIDTH) - .height(Constants.LISTITEM_ROW_HEIGHT) - .onClick(() => { - item.permissions.forEach((permission) => { - if (!item.index) { - this.grantUserGrantedPermission(item.accessTokenId, permission) - if (nowGrantResult != Constants.PERMISSION_INDEX) { - GrantResultFlag.push(-1) - }else{ - GrantResultFlag.push(0) - } - } else { - this.revokeUserGrantedPermission(item.accessTokenId, permission) - if (nowRevokeResult != Constants.PERMISSION_INDEX) { - RevokeResultFlag.push(-1) - this.authorizeDialogController.open(); - setTimeout(()=> { - this.authorizeDialogController.close(); - }, Constants.DELAY_TIME) - }else{ - RevokeResultFlag.push(0) - } - } - }) - if (!item.index) { - if(GrantResultFlag.indexOf(-1) > -1){ - this.authorizeDialogController.open(); - setTimeout(()=> { - this.authorizeDialogController.close(); - }, Constants.DELAY_TIME) - }else{ - this.isCheckList = [true, false]; - } - }else{ - if (RevokeResultFlag.indexOf(-1) > -1){ - this.authorizeDialogController.open(); - setTimeout(()=> { - this.authorizeDialogController.close(); - }, Constants.DELAY_TIME) - }else{ - this.isCheckList = [false, true]; - } - } - }) - } - } - if (!item.index) { - Row() { - Column() - .backgroundColor($r('app.color.text_decoration_color')) - .width(Constants.FULL_WIDTH) - .height(Constants.TEXT_DECORATION_HEIGHT) - } - } - } - .onClick(() => { - }) - } - .padding({ - left: Constants.DEFAULT_PADDING_START, - right: Constants.DEFAULT_PADDING_END - }) - .margin({ top: Constants.TERTIARY_LISTITEM_MARGIN_TOP }) - }, item => item.toString()) - } - .borderRadius(Constants.BORDER_RADIUS) - .backgroundColor($r('app.color.default_background_color')) - .padding({ - top: Constants.TERTIARY_LIST_PADDING_TOP, bottom: Constants.TERTIARY_LIST_PADDING_BOTTOM - }) - } - .padding({ - left: Constants.LIST_PADDING_LEFT, - right: Constants.LIST_PADDING_LEFT - }) - .width(Constants.FULL_WIDTH) - .height(Constants.FULL_HEIGHT) - } - .width(Constants.FULL_WIDTH) - } -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { backBar } from "../common/components/backBar"; +import router from '@system.router'; +import bundle from "@ohos.bundle"; +import { getAppLabel, getAppIcon, verifyAccessToken } from "../common/utils/utils"; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import Resmgr from '@ohos.resourceManager' +import { authorizeDialog } from "../common/components/dialog"; +import { permissionDescriptions, permissionGroups, showSubpermissionsGrop } from "../common/model/permissionGroup"; +import Constants from '../common/utils/constant'; + +var TAG = 'PermissionManager_MainAbility:' + +let routerData = router.getParams().routerData; // Routing jump data +let backTitle = router.getParams().backTitle; // return title name +let status = router.getParams().status; // Status: Allowed, Forbidden +let permissions = router.getParams().permission; // permissions name +let nowGrantResult = Constants.PERMISSION_NUM; // Authorization results now +let nowRevokeResult = Constants.PERMISSION_NUM; // Now deauthorize results +let GrantResultFlag = []; // Authorization result Flag +let RevokeResultFlag = []; // Cancel authorization result Flag +let reason = null // Authorized reason +class MeidaDocObj { + name: string + index: number + groupName: string + accessTokenId: string + permissions: [] + constructor( + name: string, + index: number, + groupName: string, + accessTokenId: string, + permissions: [] + ) { + this.name = name + this.index = index + this.groupName = groupName + this.accessTokenId = accessTokenId + this.permissions = permissions + } +}; // permission information class +class MediaListObj { + labelId: string + iconId: string + versionName: string + description: string + constructor( + labelId: string, + iconId: string, + versionName: string, + description: string + ) { + this.labelId = labelId + this.iconId = iconId + this.versionName = versionName + this.description = description + } +}; // Permission application information class + +@Entry +@Component +struct mediaDocumentPage { + build() { + Column() { + GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { + Row() { + Row() + .useSizeType({ + xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, + sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, + md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, + lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() { + Column() { + Row() { + backBar({ title: JSON.stringify(backTitle), recordable: false }) + } + Row() { + Column() { + mediaDocumentItem() + }.width(Constants.FULL_WIDTH) + } + .margin({ top: Constants.TITLE_MARGIN_BOTTOM }) + .layoutWeight(Constants.LAYOUT_WEIGHT) + } + } + .useSizeType({ + xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, + sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, + md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, + lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() + .useSizeType({ + xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, + sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, + md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, + lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + } + .height(Constants.FULL_HEIGHT) + .width(Constants.FULL_WIDTH) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .opacity(Constants.MANAGEMENT_TRANSPARENCY) + } + } + } +} + +@Component +struct mediaDocumentItem { + @State mediaDocListItem: MeidaDocObj[] = []; // Permission information array + @State mediaListItem: MediaListObj = { + labelId: '', + iconId: '', + versionName: '', + description: '' + }; // application info array + @State isCheckList: boolean[] = []; // Permission status array + + authorizeDialogController: CustomDialogController = new CustomDialogController({ + builder: authorizeDialog({ }), + autoCancel: true, + alignment: DialogAlignment.Center + }); + + /** + * Grant permissions to the app + * @param {Number} accessTokenId + * @param {String} permission permission name + */ + grantUserGrantedPermission(accessTokenId, permission) { + abilityAccessCtrl.createAtManager().grantUserGrantedPermission( + accessTokenId, permission, Constants.PERMISSION_FLAG).then((result) => { + nowGrantResult = result; + }) + .catch((error) => { + console.error(TAG + 'grantUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); + }) + } + + /** + * Deauthorize the app + * @param {Number} accessTokenId + * @param {String} permission permission name + */ + revokeUserGrantedPermission(accessTokenId, permission) { + abilityAccessCtrl.createAtManager().revokeUserGrantedPermission( + accessTokenId, permission, Constants.PERMISSION_FLAG).then((result) => { + nowRevokeResult = result; + }) + .catch((error) => { + console.error(TAG + 'revokeUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); + }) + } + + /** + * Lifecycle function, executed when the page is initialized + */ + aboutToAppear() { + let permissionDescription = permissionDescriptions[backTitle]; + if(showSubpermissionsGrop.indexOf(backTitle) != -1) { + reason = [] + permissions.forEach(permission => { + permissionGroups.forEach(permissionGroup => { + if(permissionGroup.permissionName == permission) { + reason.push(permissionGroup.label) + } + }) + }) + Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { + Promise.all([item.getString($r("app.string.separator").id), + item.getString($r("app.string.reason_suffix").id)]) + .then(values => { + reason = reason.join(values[0]) + reason += values[1] + }) + }) + }else { + reason = '' + } + let hasReason = false + bundle.getBundleInfo(routerData, Constants.PARMETER_BUNDLE_FLAG).then(res => { + permissions.forEach(permission => { + res.reqPermissionDetails.forEach(reqPermissionDetail => { + if(reqPermissionDetail.name == permission) { + Resmgr.getResourceManager(globalThis.context, routerData).then(item => { + item.getString(reqPermissionDetail.reasonId, (err, value) => { + if (value !== undefined && !hasReason) { + reason += value.slice(Constants.START_SUBSCRIPT, Constants.END_SUBSCRIPT) + hasReason = true + } + }) + }) + } + }) + }) + Promise.all([getAppLabel(res.appInfo.labelId, res.name), + getAppIcon(res.appInfo.iconId, res.name)]) + .then((values) => { + this.mediaListItem = new MediaListObj( + String(values[0]), String(values[1]), res.versionName, permissionDescription); + }) + this.mediaDocListItem.push( + new MeidaDocObj( + Constants.RADIO_ALLOW_NAME, + Constants.RADIO_ALLOW_INDEX, + Constants.RADIO_ALLOW_GROUP_NAME, + res.appInfo.accessTokenId, + permissions + ) + ); + this.mediaDocListItem.push( + new MeidaDocObj( + Constants.RADIO_BAN_NAME, + Constants.RADIO_BAN_INDEX, + Constants.RADIO_BAN_GROUP_NAME, + res.appInfo.accessTokenId, + permissions + ) + ); + }).catch((error) => { + console.error(TAG + 'bundle.getBundleInfo failed. Cause: ' + JSON.stringify(error)); + this.mediaListItem = new MediaListObj('', '', '', permissionDescription); + this.mediaDocListItem.push( + new MeidaDocObj(Constants.RADIO_ALLOW_NAME, Constants.RADIO_ALLOW_INDEX, + Constants.RADIO_ALLOW_GROUP_NAME, '', permissions) + ); + this.mediaDocListItem.push( + new MeidaDocObj(Constants.RADIO_BAN_NAME, Constants.RADIO_BAN_INDEX, + Constants.RADIO_BAN_GROUP_NAME, '', permissions) + ); + }) + // Get permission status + if (!status) { + this.isCheckList = [true, false]; + } else { + this.isCheckList = [false, true]; + } + } + + build(){ + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Image(this.mediaListItem.iconId) + .width(Constants.TERTIARY_IMAGE_WIDTH) + .height(Constants.TERTIARY_IMAGE_HEIGHT) + .margin({ left: Constants.TERTIARY_IMAGE_MARGIN_LEFT, right: Constants.TERTIARY_IMAGE_MARGIN_RIGHT }) + Column() { + Row() { + Text(this.mediaListItem.labelId) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontColor($r('app.color.label_color')) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + } + .width(Constants.TERTIARY_HALF_WIDTH) + .margin({ bottom: Constants.TERTIARY_LABEL_MARGIN_BOTTOM }) + Row() { + Text(this.mediaListItem.versionName) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .textAlign(TextAlign.Start) + } + .width(Constants.TERTIARY_HALF_WIDTH) + } + }.margin({ left: Constants.TERTIARY_MARGIN_LEFT }) + } + if(reason) { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Text(reason) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .textAlign(TextAlign.Start) + }.margin({ left: Constants.TERTIARY_IMAGE_MARGIN_LEFT, right: Constants.TERTIARY_IMAGE_MARGIN_RIGHT }) + } + } + .margin({ top: Constants.TERTIARY_ROW_MARGIN_TOP, left: Constants.TERTIARY_MARGIN_LEFT }) + } + Row() { + Text(backTitle) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .fontWeight(FontWeight.Medium) + .textAlign(TextAlign.Start) + .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) + Text($r('app.string.access_permission')) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .fontWeight(FontWeight.Medium) + .textAlign(TextAlign.Start) + .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) + }.width(Constants.FULL_WIDTH) + .constraintSize({ minHeight: Constants.SUBTITLE_MIN_HEIGHT }) + .padding({ top: Constants.SUBTITLE_PADDING_TOP, bottom: Constants.SUBTITLE_PADDING_BOTTOM, + left: Constants.TERTIARY_TEXT_MARGIN_LEFT, right: Constants.TERTIARY_IMAGE_MARGIN_RIGHT}) + .margin({ top: Constants.TERTIARY_PERMISSION_ROW_MARGIN_TOP }) + Column() { + List() { + ForEach(this.mediaDocListItem, (item) => { + ListItem() { + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Text(item.name) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontColor($r('app.color.label_color')) + .fontWeight(FontWeight.Medium) + .flexGrow(Constants.FLEX_GROW) + if (this.isCheckList[item.index] === true) { + Shape() { + Circle().width(Constants.SHAPE_DIA).height(Constants.SHAPE_DIA) + .fill($r("app.color.shape_allow_color")).offset({ x: 0, y: 0 }) + Circle().width(Constants.SHAPE_ALLOW_DIA).height(Constants.SHAPE_ALLOW_DIA) + .fill($r("app.color.default_background_color")) + .offset({ x: Constants.SHAPE_ALLOW_OFFSET, y: Constants.SHAPE_ALLOW_OFFSET }) + } + } else if (this.isCheckList[item.index] === false) { + Shape() { + Circle().width(Constants.SHAPE_DIA).height(Constants.SHAPE_DIA) + .fill($r("app.color.shape_ban_color")).offset({ x: 0, y: 0 }) + Circle().width(Constants.SHAPE_BAN_DIA).height(Constants.SHAPE_BAN_DIA) + .fill($r("app.color.default_background_color")) + .offset({ x: Constants.SHAPE_BAN_OFFSET, y: Constants.SHAPE_BAN_OFFSET }) + } + } + } + .width(Constants.FULL_WIDTH) + .height(Constants.LISTITEM_ROW_HEIGHT) + .onClick(() => { + item.permissions.forEach((permission) => { + if (!item.index) { + this.grantUserGrantedPermission(item.accessTokenId, permission) + if (nowGrantResult != Constants.PERMISSION_INDEX) { + GrantResultFlag.push(-1) + }else{ + GrantResultFlag.push(0) + } + } else { + this.revokeUserGrantedPermission(item.accessTokenId, permission) + if (nowRevokeResult != Constants.PERMISSION_INDEX) { + RevokeResultFlag.push(-1) + this.authorizeDialogController.open(); + setTimeout(()=> { + this.authorizeDialogController.close(); + }, Constants.DELAY_TIME) + }else{ + RevokeResultFlag.push(0) + } + } + }) + if (!item.index) { + if(GrantResultFlag.indexOf(-1) > -1){ + this.authorizeDialogController.open(); + setTimeout(()=> { + this.authorizeDialogController.close(); + }, Constants.DELAY_TIME) + }else{ + this.isCheckList = [true, false]; + } + }else{ + if (RevokeResultFlag.indexOf(-1) > -1){ + this.authorizeDialogController.open(); + setTimeout(()=> { + this.authorizeDialogController.close(); + }, Constants.DELAY_TIME) + }else{ + this.isCheckList = [false, true]; + } + } + }) + } + } + if (!item.index) { + Row() { + Column() + .backgroundColor($r('app.color.text_decoration_color')) + .width(Constants.FULL_WIDTH) + .height(Constants.TEXT_DECORATION_HEIGHT) + } + } + } + .onClick(() => { + }) + } + .padding({ + left: Constants.DEFAULT_PADDING_START, + right: Constants.DEFAULT_PADDING_END + }) + .margin({ top: Constants.TERTIARY_LISTITEM_MARGIN_TOP }) + }, item => item.toString()) + } + .borderRadius(Constants.BORDER_RADIUS) + .backgroundColor($r('app.color.default_background_color')) + .padding({ + top: Constants.TERTIARY_LIST_PADDING_TOP, bottom: Constants.TERTIARY_LIST_PADDING_BOTTOM + }) + } + .padding({ + left: Constants.LIST_PADDING_LEFT, + right: Constants.LIST_PADDING_LEFT + }) + .width(Constants.FULL_WIDTH) + .height(Constants.FULL_HEIGHT) + } + .width(Constants.FULL_WIDTH) + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-management.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-management.ets index a1e25356287db91257a9e2a493dfc2e9a0c673fa..10c7318b21dc4209197451a9f755bb235fee6b08 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-management.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-management.ets @@ -1,715 +1,715 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { backBar } from "../common/components/backBar"; -import { alphabetIndexerComponent } from "../common/components/alphabeticalIndex"; -import { textInput } from "../common/components/search"; -import router from '@system.router'; -import bundle from "@ohos.bundle"; -import Resmgr from '@ohos.resourceManager'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import { groups, userGrantPermissions, permissionGroupPermissions, noNeedDisplayApp } from "../common/model/permissionGroup"; -import { permissionGroups, permissionPermissionGroup, permissionGroupIds } from "../common/model/permissionGroup"; -import { makePy } from "../common/utils/utils"; -import Constants from '../common/utils/constant'; - -var TAG = 'PermissionManager_MainAbility:' - -@Extend(Image) function customizeImage(width: number, height: number) { - .objectFit(ImageFit.Contain) - .width(width) - .height(height) -}; - -interface applicationPermissions { - 'bundleName': string, - 'iconId': string, - 'permissions': string[], - 'labelId': string, - 'tokenId': number, - 'groupId': number[] -}; - -interface permissionApplications { - 'permission': string, - 'groupName': string, - 'bundleNames': string[], - 'icon': string -}; - -interface groupPermission { - 'group': string, - 'permissions': string[], - 'groupName': string, - 'icon': string, - 'isShow':boolean -}; - -let bundleInfosList: any[] = []; // Permission information array -let textInput_placeholder: any = '' - -@Entry -@Component -struct authorityManagementPage { - @Builder ListItemLayout(item, index) { - ListItem() { - Row() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Image(item.icon) - .customizeImage(Constants.MANAGEMENT_IMAGE_WIDTH, Constants.MANAGEMENT_IMAGE_HEIGHT) - .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT }) - Text(item.groupName) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontWeight(FontWeight.Medium) - .fontColor($r('app.color.label_color')) - .flexGrow(Constants.FLEX_GROW) - Image($r('app.media.rightarrow')) - .customizeImage(Constants.IMAGE_WIDTH, Constants.IMAGE_HEIGHT) - } - .width(Constants.FULL_WIDTH) - .height(Constants.MANAGEMENT_ROW_HEIGHT) - } - if (!index) { - Row() { - Flex() { - Column().width(Constants.MANAGEMENT_TEXT_DECORATION_MARGIN_LEFT) - Column() - .backgroundColor($r('app.color.text_decoration_color')) - .height(Constants.TEXT_DECORATION_HEIGHT) - .flexGrow(Constants.FLEX_GROW) - } - } - } - }.onClick(() => { - if (item.groupName === '其他权限' || item.groupName === '电话' || item.groupName === '通讯录' || item.groupName === '信息' - || item.groupName === '通话记录' || item.groupName === '日历') { - router.push({ - uri: 'pages/authority-secondary', - params: { routerData: this.allPermissionApplications, backTitle: item.groupName } - }) - } else { - var dataList = this.allPermissionApplications.filter((ele) => { - return ele.groupName === item.group - }) - - router.push({ - uri: 'pages/authority-tertiary-groups', - params: { routerData: dataList, backTitle: item.groupName } - }) - } - }) - } - }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) - } - - @State allApplicationPermissions: applicationPermissions[] = []; // All permissions apply - @State allPermissions: string[] = []; // All permissions - @State allSystemPermissions: string[] = []; // All system permissions - @State allUserPermissions: string[] = []; // All user rights - @State allPermissionApplications: permissionApplications [] = [] // All app permissions - @State allGroups: string[] = [] // All groups - @State allGroupPermission: groupPermission[] = [] // All group permissions - @State currentIndex: number = 0 - @Builder TabBuilder(index: number) { - Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(index ? $r('app.string.application') : $r('app.string.authority')) - .fontColor(this.currentIndex == index ? $r('app.color.button_color') : $r('app.color.label_color')) - .fontWeight(this.currentIndex == index ? FontWeight.Bold : FontWeight.Regular) - .lineHeight(Constants.TEXT_LINE_HEIGHT) - if(this.currentIndex == index) { - Row().width(Constants.FULL_WIDTH).height(Constants.TAB_DECORATION_HEIGHT) - .backgroundColor($r('app.color.button_color')) - .position({ y: Constants.TAB_DECORATION_POSITION_Y }) - } - }.height(Constants.TAB_HEIGHT) - } - - /** - * Convert the permission array into key, value key-value objects for easy sorting - * @param {Array} order User rights - * @return {Object} return the processed object - */ - orderDict(order) { - let result = {}; - for (let i = 0; i < order.length; i++) { - let key = order[i]; - result[key] = i; - } - return result; - } - - /** - * Compare and sort the permission array according to the permission key value - * @param {String} prop Sort by permission - * @param {Object} orderSort objects to be sorted - * @return {Array} Returns a sorted array of permissions - */ - compare(prop, orderSort) { - return function(a, b) { - let aSortValue = orderSort[a[prop]]; - let bSortValue = orderSort[b[prop]]; - if (aSortValue == undefined) { - throw new Error('当前的字段不在排序列表里:' + a[prop]); - } - if (bSortValue == undefined) { - throw new Error('当前的字段不在排序列表里:' + b[prop]); - } - return aSortValue - bSortValue; - } - } - - /** - * Get all app permission information - * @param {Array} allPermissions All permissions - * @param {Object} allApplicationPermissions All app permissions - */ - getAllBundlePermissions(allPermissions: string[], allApplicationPermissions: applicationPermissions[]) { - bundle.getAllBundleInfo(Constants.PARMETER_BUNDLE_FLAG).then(async(res) => { - const bundleInfos = res; - var count = bundleInfos.length; - if (count <= 0) { - console.info(TAG + 'bundle.getAllBundleInfo result.length less than or equal to zero'); - return; - } - var infoIndex = 0; - for (let i = 0; i < count; i++) { - var info = bundleInfos[i]; - // Filter blank icon icon and text label resources - try { - const ret = await bundle.queryAbilityByWant({ - bundleName: info.name, - action: "action.system.home", - entities: ["entity.system.home"] - }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION, Constants.USERID); - } catch(e) { - console.log(TAG + 'queryAbilityByWant catch error: ' + JSON.stringify(e)) - continue; - } - - if (noNeedDisplayApp.indexOf(info.name) != -1) { - continue; - } - await this.deduplicationPermissions(info, allPermissions, allApplicationPermissions); - this.updateAppLabel(infoIndex, info.name, info.appInfo.label); - this.updateAppIcon(infoIndex, info.name); - infoIndex = infoIndex + 1; - } - this.getAllPermissionApplications(); - let orderSort = this.orderDict(userGrantPermissions); - this.allPermissionApplications.sort(this.compare('permission', orderSort)); - this.getAllGroupPermission(); - bundleInfosList = this.allApplicationPermissions; - bundleInfosList.forEach((item) => { - if (!isNaN(item.labelId)) { - item.alphabeticalIndex = ''; - } else { - item.alphabeticalIndex = makePy(item.labelId)[0].slice(0, 1); // Get the first letter in the returned initials array - } - }) - }) - .catch((error) => { - console.error(TAG + 'bundle.getAllBundleInfo failed. Cause: ' + JSON.stringify(error)); - }) - } - - /** - * Get the corresponding permission group id according to the permission - * @param {String} permission app name id - * @return {Number} groupId - */ - getPermissionGroupByPermission(permission: string) { - for (let i = 0; i < permissionGroups.length; i++) { - if (permissionGroups[i].permissionName == permission) { - return groups[permissionGroups[i].groupId]; - } - } - } - - /** - * Get all app permission information - */ - getAllPermissionApplications() { - const this_ = this; - var leng = this_.allPermissions.length; - if (leng > 0) { - for (let i = 0; i < leng; i++) { - if (userGrantPermissions.indexOf(this_.allPermissions[i]) == -1) { - this_.allSystemPermissions.push(this_.allPermissions[i]); - } else { - this_.allUserPermissions.push(this_.allPermissions[i]); - } - } - } - for (let i = 0; i < this_.allUserPermissions.length; i++) { - var permissionGroup = this_.getPermissionGroupByPermission(this_.allUserPermissions[i]); - var icon: string = permissionGroup.icon; - var bundleNames: string[] = []; - for (let j = 0; j < this_.allApplicationPermissions.length; j++) { - if (this_.allApplicationPermissions[j].permissions.indexOf(this_.allUserPermissions[i]) != -1) { - bundleNames.push(this_.allApplicationPermissions[j].bundleName); - } - } - var pa: permissionApplications = { - 'permission': this_.allUserPermissions[i], - 'groupName': permissionGroup.name, - 'bundleNames': bundleNames, - 'icon': icon - }; - this_.allPermissionApplications.push(pa); - } - } - - /** - * Get permission group information - */ - getAllGroupPermission() { - const this_ = this; - var temp1 = []; - temp1 = ["LOCATION","CAMERA","MICROPHONE","MEDIA","CALENDAR","SPORT","HEALTH"]; - groups.forEach((item) => { - if (temp1.indexOf(item.name) > -1) { - var gp: groupPermission = { - "group": item.name, - "permissions": item.permissions, - 'groupName': item.groupName, - 'icon': item.icon, - 'isShow': item.isShow - }; - this_.allGroupPermission.push(gp); - } - }) - let temp2 = []; - groups.forEach((item) => { - if (item.isShow && temp1.indexOf(item.name) === -1) { - var gp: groupPermission = { - "group": item.name, - "permissions": item.permissions, - 'groupName': item.groupName, - 'icon': item.icon, - 'isShow': item.isShow - }; - temp2.push(item.name); - this_.allGroupPermission.push(gp); - } - }) - for (let i = 0; i < this_.allPermissionApplications.length; i++) { - if (this_.allGroups.indexOf(this_.allPermissionApplications[i].groupName) == -1 - && temp1.indexOf(this_.allPermissionApplications[i].groupName) == -1) { - this_.allGroups.push(this_.allPermissionApplications[i].groupName); - } - } - // Permission layout - var temp = this_.allGroups; - temp = temp.filter(function(item) { - return temp1.indexOf(item) == -1 && temp2.indexOf(item) == -1; - }); - if (temp.indexOf("OTHER") > -1) { - temp.splice(temp.indexOf("OTHER"),1); - temp.push("OTHER"); - }else { - temp.push("OTHER"); - } - this_.allGroups = temp; - for (let i = 0; i < this_.allGroups.length; i++) { - var permissions: string[] = permissionGroupPermissions[this_.allGroups[i]]; - var gp: groupPermission = { - "group": this_.allGroups[i], - "permissions": permissions, - 'groupName': '', - 'icon': '', - 'isShow': false - }; - this_.allGroupPermission.push(gp); - } - this.allGroupPermission.forEach((ele) => { - groups.forEach((item) => { - if (ele.group === item.name) { - ele.groupName = item.groupName; - ele.icon = item.icon; - ele.isShow = item.isShow; - } - }); - }) - } - - /** - * Deduplicate permission information and permission group information - * @param {Object} info bundleInfos Application Information - * @param {Array} allPermissions All permissions - * @param {Array} allApplicationPermissions All permissions apply - */ - async deduplicationPermissions(info, allPermissions, allApplicationPermissions) { - var reqPermissionsLen = info.reqPermissions.length; - var reqUserPermissions: string[] = []; - var acManager = abilityAccessCtrl.createAtManager() - if (reqPermissionsLen > 0) { - for (let j = 0; j < info.reqPermissions.length; j++) { - var permission = info.reqPermissions[j]; - var flag = await acManager.getPermissionFlags(info.appInfo.accessTokenId, permission) - if(flag == Constants.PRE_AUTHORIZATION_NOT_MODIFIED) { - continue - } - if (allPermissions.indexOf(permission) == -1) { - allPermissions.push(permission); - } - if (userGrantPermissions.indexOf(permission) != -1) { - reqUserPermissions.push(permission); - } - } - } - let dePermissions = []; - let groupIds = []; - for (let i = 0; i < reqUserPermissions.length; i++) { - if(dePermissions.indexOf(permissionPermissionGroup[reqUserPermissions[i]]) == -1){ - dePermissions.push(permissionPermissionGroup[reqUserPermissions[i]]); - } - if(groupIds.indexOf(permissionGroupIds[reqUserPermissions[i]]) == -1){ - groupIds.push(permissionGroupIds[reqUserPermissions[i]]); - } - } - - // adapt different api - if (info.compatibleVersion >= Constants.API_VERSION_SUPPORT_STAGE) { - info.appInfo.iconId = info.hapModuleInfos[0].abilityInfo[0].iconId; - } - - var ap: applicationPermissions = { - 'bundleName': info.name, - 'tokenId': info.appInfo.accessTokenId, - 'iconId': info.appInfo.iconId, - 'labelId': info.appInfo.labelId, - 'permissions': reqUserPermissions, - 'groupId': groupIds - }; - allApplicationPermissions.push(ap); - } - - /** - * Get app name resource - * @param {Number} index index of all app permissions array - * @param {String} bundleName Package names - * @param {String} labelName Application Name - */ - updateAppLabel(index, bundleName, labelName) { - Resmgr.getResourceManager(globalThis.context, bundleName).then(item => { - if (index >= this.allApplicationPermissions.length) { - return; - } - var info = this.allApplicationPermissions[index]; - item.getString(info['labelId'], (error, value) => { - if (value == undefined) { - info['labelId'] = labelName; - } else { - info['labelId'] = value; - } - }) - }).catch(error => { - console.error(TAG + 'Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); - }) - } - - /** - * Get app icon resources - * @param {Number} index index of all app permissions array - * @param {String} bundleName Package names - */ - updateAppIcon(index, bundleName) { - Resmgr.getResourceManager(globalThis.context, bundleName).then(item => { - if (index >= this.allApplicationPermissions.length) { - return; - } - var info = this.allApplicationPermissions[index]; - item.getMediaBase64(info['iconId'], (error, value) => { - info['iconId'] = value; - }) - }).catch(error => { - console.error(TAG + 'Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); - }) - } - - /** - * Lifecycle function, executed when the page is initialized - */ - aboutToAppear() { - console.log(TAG + 'on aboutToAppear, version 1.01'); - this.getAllBundlePermissions(this.allPermissions, this.allApplicationPermissions); - Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { - item.getString($r("app.string.textInput_placeholder").id, (err, val) => { - textInput_placeholder = val - }) - }) - } - - getPermissionGroup(allGroup, order) { - var fixedName: string[] = ['LOCATION', 'CAMERA', 'MICROPHONE'] - var fixedGroup: any[] = [] - var changeGroup: any[] = [] - var otherGroup: any[] = [] - - allGroup.forEach(group => { - if(fixedName.indexOf(group.group) !== -1) { - fixedGroup.push(group) - }else if(group.group == 'OTHER') { - otherGroup.push(group) - }else { - changeGroup.push(group) - } - }) - - if(order == Constants.FIXED_GROUP){ - return fixedGroup - }else if(order == Constants.CHANGE_GROUP) { - return changeGroup - }else if(order == Constants.OTHER_GROUP) { - return otherGroup - } - } - - build() { - GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { - Row() { - Row() - .useSizeType({ - xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, - sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, - md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, - lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() { - Column() { - Row() { - backBar( { title: JSON.stringify($r('app.string.authority_management')), recordable: true }) - } - Row() { - Column() { - Column() { - Stack() { - if(this.allGroupPermission.length) { - Tabs() { - TabContent() { - Row() { - Column() { - Scroll() { - Column() { - List() { - ListItem() { - List() { - ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.FIXED_GROUP).slice(Constants.SLICE_START, - this.getPermissionGroup(this.allGroupPermission, Constants.FIXED_GROUP).length - 1), (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX) - }, item => item.toString()) - ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.FIXED_GROUP).slice(Constants.SLICE_END), (item, index) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX) - }, item => item.toString()) - }.backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - .margin({ bottom: Constants.LIST_MARGIN_BOTTOM }) - } - - ListItem() { - List() { - ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.CHANGE_GROUP).slice(Constants.SLICE_START, - this.getPermissionGroup(this.allGroupPermission, Constants.CHANGE_GROUP).length - 1), (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX) - }, item => item.toString()) - ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.CHANGE_GROUP).slice(Constants.SLICE_END), (item, index) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX) - }, item => item.toString()) - }.backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - .margin({ bottom: Constants.LIST_MARGIN_BOTTOM }) - } - - ListItem() { - List() { - ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.OTHER_GROUP), (item) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX) - }, item => item.toString()) - }.backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - } - }.height(Constants.FULL_HEIGHT) - .borderRadius(Constants.BORDER_RADIUS) - .clip(true) - }.padding({ - left: Constants.MANAGEMENT_ROW_PADDING_LEFT, - right: Constants.MANAGEMENT_ROW_PADDING_RIGHT, - }) - }.scrollBar(BarState.Off) - .margin({ top: Constants.MANAGEMENT_ROW_PADDING_TOP }) - }.width(Constants.FULL_WIDTH) - } - }.tabBar(this.TabBuilder(0)) - TabContent() { - applicationItem() - }.tabBar(this.TabBuilder(1)) - } - .barWidth(Constants.BAR_WIDTH) - .barMode(BarMode.Fixed) - .onChange((index) => { - this.currentIndex = index - }) - }else { - LoadingProgress().width(Constants.LOADING_WIDTH) - } - }.height(Constants.FULL_HEIGHT) - } - } - } - .layoutWeight(Constants.LAYOUT_WEIGHT) - } - } - .useSizeType({ - xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, - sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, - md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, - lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() - .useSizeType({ - xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, - sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, - md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, - lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - } - .height(Constants.FULL_HEIGHT) - .width(Constants.FULL_WIDTH) - .backgroundColor($r("sys.color.ohos_id_color_sub_background")) - .opacity(Constants.MANAGEMENT_TRANSPARENCY) - } - } -} - -@Component -struct applicationItem { - @State applicationItem: any[] = bundleInfosList // application info array - @State oldApplicationItem: any[] = bundleInfosList // Original application information array - @State searchResult: boolean = true // search results - - @Builder ListItemLayout(item, index) { - ListItem() { - Row() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Image(item.iconId) - .customizeImage(Constants.APPLICATION_IMAGE_WIDTH, Constants.APPLICATION_IMAGE_HEIGHT) - .margin({ right: Constants.APPLICATION_IMAGE_MARGIN_RIGHT }) - Text(item.labelId) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontWeight(FontWeight.Medium) - .fontColor($r('app.color.label_color')) - .flexGrow(Constants.FLEX_GROW) - Text(item.groupId.length + '项权限') - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_lighter')) - .margin({ right: Constants.APPLICATION_TEXT_MARGIN_RIGHT }) - Image($r('app.media.rightarrow')) - .customizeImage(Constants.IMAGE_WIDTH, Constants.IMAGE_HEIGHT) - } - .width(Constants.FULL_WIDTH) - .height(Constants.AUTHORITY_ROW_HEIGHT) - .constraintSize({ minHeight: Constants.AUTHORITY_CONSTRAINTSIZE_MINHEIGHT }) - } - if (!index) { - Row() { - Flex() { - Column().width(Constants.APPLICATION_TEXT_DECORATION_MARGIN_LEFT) - Column() - .backgroundColor($r('app.color.text_decoration_color')) - .height(Constants.TEXT_DECORATION_HEIGHT) - .flexGrow(Constants.FLEX_GROW) - } - } - } - }.onClick(() => { - router.push({ - uri: 'pages/application-secondary', - params: { routerData: item } - }); - }) - } - }.padding({ - left: Constants.DEFAULT_PADDING_START, - right: Constants.DEFAULT_PADDING_END - }) - } - - build() { - Column() { - Row() { - textInput({ - placeholder: textInput_placeholder, - applicationItem: $applicationItem, - oldApplicationItem: $oldApplicationItem, - searchResult: $searchResult - }) - }.padding({ - left: Constants.APPLICATION_TEXTINPUT_PADDING_LEFT, - top: Constants.APPLICATION_TEXTINPUT_PADDING_TOP, - right: Constants.APPLICATION_TEXTINPUT_PADDING_RIGHT - }) - Row() { - Flex({ alignItems: ItemAlign.Start }) { - Column() { - Column() { - if (!this.applicationItem.length) { - Row() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Image($r('app.media.searchnoresult')) - .customizeImage(Constants.SEARCHNORESULT_IMAGE_WIDTH, Constants.SEARCHNORESULT_IMAGE_HEIGHT) - } - }.margin({ top: Constants.MANAGEMENT_ROW_MARGIN_TOP }) - .padding({ left: Constants.MANAGEMENT_ROW_PADDING_LEFT }) - } else { - Row() { - Scroll() { - List() { - ForEach(this.applicationItem.slice(Constants.SLICE_START, this.applicationItem.length - 1), - (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX) - }, item => item.toString()) - ForEach(this.applicationItem.slice(Constants.SLICE_END), (item, index) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX) - }, item => item.toString()) - }.backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.scrollBar(BarState.Off) - }.margin({ left: Constants.MANAGEMENT_ROW_PADDING_LEFT }) - .borderRadius(Constants.BORDER_RADIUS) - .clip(true) - } - }.backgroundColor($r('app.color.background_color')) - .height(Constants.FULL_HEIGHT) - }.margin({ top: Constants.MANAGEMENT_ROW_MARGIN_TOP, bottom: Constants.APPLICATION_LIST_MARGIN_BOTTOM }) - Column() { - alphabetIndexerComponent({ applicationItem: $applicationItem, oldApplicationItem: $oldApplicationItem }) - }.margin({ top: Constants.APPLICATION_ALPHABETINDEX_MARGIN_TOP }) - .width(Constants.APPLICATION_ALPHABETINDEX_WIDTH) - } - } - } - } -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { backBar } from "../common/components/backBar"; +import { alphabetIndexerComponent } from "../common/components/alphabeticalIndex"; +import { textInput } from "../common/components/search"; +import router from '@system.router'; +import bundle from "@ohos.bundle"; +import Resmgr from '@ohos.resourceManager'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import { groups, userGrantPermissions, permissionGroupPermissions, noNeedDisplayApp } from "../common/model/permissionGroup"; +import { permissionGroups, permissionPermissionGroup, permissionGroupIds } from "../common/model/permissionGroup"; +import { makePy } from "../common/utils/utils"; +import Constants from '../common/utils/constant'; + +var TAG = 'PermissionManager_MainAbility:' + +@Extend(Image) function customizeImage(width: number, height: number) { + .objectFit(ImageFit.Contain) + .width(width) + .height(height) +}; + +interface applicationPermissions { + 'bundleName': string, + 'iconId': string, + 'permissions': string[], + 'labelId': string, + 'tokenId': number, + 'groupId': number[] +}; + +interface permissionApplications { + 'permission': string, + 'groupName': string, + 'bundleNames': string[], + 'icon': string +}; + +interface groupPermission { + 'group': string, + 'permissions': string[], + 'groupName': string, + 'icon': string, + 'isShow':boolean +}; + +let bundleInfosList: any[] = []; // Permission information array +let textInput_placeholder: any = '' + +@Entry +@Component +struct authorityManagementPage { + @Builder ListItemLayout(item, index) { + ListItem() { + Row() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Image(item.icon) + .customizeImage(Constants.MANAGEMENT_IMAGE_WIDTH, Constants.MANAGEMENT_IMAGE_HEIGHT) + .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT }) + Text(item.groupName) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.label_color')) + .flexGrow(Constants.FLEX_GROW) + Image($r('app.media.rightarrow')) + .customizeImage(Constants.IMAGE_WIDTH, Constants.IMAGE_HEIGHT) + } + .width(Constants.FULL_WIDTH) + .height(Constants.MANAGEMENT_ROW_HEIGHT) + } + if (!index) { + Row() { + Flex() { + Column().width(Constants.MANAGEMENT_TEXT_DECORATION_MARGIN_LEFT) + Column() + .backgroundColor($r('app.color.text_decoration_color')) + .height(Constants.TEXT_DECORATION_HEIGHT) + .flexGrow(Constants.FLEX_GROW) + } + } + } + }.onClick(() => { + if (item.groupName === '其他权限' || item.groupName === '电话' || item.groupName === '通讯录' || item.groupName === '信息' + || item.groupName === '通话记录' || item.groupName === '日历') { + router.push({ + uri: 'pages/authority-secondary', + params: { routerData: this.allPermissionApplications, backTitle: item.groupName } + }) + } else { + var dataList = this.allPermissionApplications.filter((ele) => { + return ele.groupName === item.group + }) + + router.push({ + uri: 'pages/authority-tertiary-groups', + params: { routerData: dataList, backTitle: item.groupName } + }) + } + }) + } + }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) + } + + @State allApplicationPermissions: applicationPermissions[] = []; // All permissions apply + @State allPermissions: string[] = []; // All permissions + @State allSystemPermissions: string[] = []; // All system permissions + @State allUserPermissions: string[] = []; // All user rights + @State allPermissionApplications: permissionApplications [] = [] // All app permissions + @State allGroups: string[] = [] // All groups + @State allGroupPermission: groupPermission[] = [] // All group permissions + @State currentIndex: number = 0 + @Builder TabBuilder(index: number) { + Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(index ? $r('app.string.application') : $r('app.string.authority')) + .fontColor(this.currentIndex == index ? $r('app.color.button_color') : $r('app.color.label_color')) + .fontWeight(this.currentIndex == index ? FontWeight.Bold : FontWeight.Regular) + .lineHeight(Constants.TEXT_LINE_HEIGHT) + if(this.currentIndex == index) { + Row().width(Constants.FULL_WIDTH).height(Constants.TAB_DECORATION_HEIGHT) + .backgroundColor($r('app.color.button_color')) + .position({ y: Constants.TAB_DECORATION_POSITION_Y }) + } + }.height(Constants.TAB_HEIGHT) + } + + /** + * Convert the permission array into key, value key-value objects for easy sorting + * @param {Array} order User rights + * @return {Object} return the processed object + */ + orderDict(order) { + let result = {}; + for (let i = 0; i < order.length; i++) { + let key = order[i]; + result[key] = i; + } + return result; + } + + /** + * Compare and sort the permission array according to the permission key value + * @param {String} prop Sort by permission + * @param {Object} orderSort objects to be sorted + * @return {Array} Returns a sorted array of permissions + */ + compare(prop, orderSort) { + return function(a, b) { + let aSortValue = orderSort[a[prop]]; + let bSortValue = orderSort[b[prop]]; + if (aSortValue == undefined) { + throw new Error('当前的字段不在排序列表里:' + a[prop]); + } + if (bSortValue == undefined) { + throw new Error('当前的字段不在排序列表里:' + b[prop]); + } + return aSortValue - bSortValue; + } + } + + /** + * Get all app permission information + * @param {Array} allPermissions All permissions + * @param {Object} allApplicationPermissions All app permissions + */ + getAllBundlePermissions(allPermissions: string[], allApplicationPermissions: applicationPermissions[]) { + bundle.getAllBundleInfo(Constants.PARMETER_BUNDLE_FLAG).then(async(res) => { + const bundleInfos = res; + var count = bundleInfos.length; + if (count <= 0) { + console.info(TAG + 'bundle.getAllBundleInfo result.length less than or equal to zero'); + return; + } + var infoIndex = 0; + for (let i = 0; i < count; i++) { + var info = bundleInfos[i]; + // Filter blank icon icon and text label resources + try { + const ret = await bundle.queryAbilityByWant({ + bundleName: info.name, + action: "action.system.home", + entities: ["entity.system.home"] + }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION, Constants.USERID); + } catch(e) { + console.log(TAG + 'queryAbilityByWant catch error: ' + JSON.stringify(e)) + continue; + } + + if (noNeedDisplayApp.indexOf(info.name) != -1) { + continue; + } + await this.deduplicationPermissions(info, allPermissions, allApplicationPermissions); + this.updateAppLabel(infoIndex, info.name, info.appInfo.label); + this.updateAppIcon(infoIndex, info.name); + infoIndex = infoIndex + 1; + } + this.getAllPermissionApplications(); + let orderSort = this.orderDict(userGrantPermissions); + this.allPermissionApplications.sort(this.compare('permission', orderSort)); + this.getAllGroupPermission(); + bundleInfosList = this.allApplicationPermissions; + bundleInfosList.forEach((item) => { + if (!isNaN(item.labelId)) { + item.alphabeticalIndex = ''; + } else { + item.alphabeticalIndex = makePy(item.labelId)[0].slice(0, 1); // Get the first letter in the returned initials array + } + }) + }) + .catch((error) => { + console.error(TAG + 'bundle.getAllBundleInfo failed. Cause: ' + JSON.stringify(error)); + }) + } + + /** + * Get the corresponding permission group id according to the permission + * @param {String} permission app name id + * @return {Number} groupId + */ + getPermissionGroupByPermission(permission: string) { + for (let i = 0; i < permissionGroups.length; i++) { + if (permissionGroups[i].permissionName == permission) { + return groups[permissionGroups[i].groupId]; + } + } + } + + /** + * Get all app permission information + */ + getAllPermissionApplications() { + const this_ = this; + var leng = this_.allPermissions.length; + if (leng > 0) { + for (let i = 0; i < leng; i++) { + if (userGrantPermissions.indexOf(this_.allPermissions[i]) == -1) { + this_.allSystemPermissions.push(this_.allPermissions[i]); + } else { + this_.allUserPermissions.push(this_.allPermissions[i]); + } + } + } + for (let i = 0; i < this_.allUserPermissions.length; i++) { + var permissionGroup = this_.getPermissionGroupByPermission(this_.allUserPermissions[i]); + var icon: string = permissionGroup.icon; + var bundleNames: string[] = []; + for (let j = 0; j < this_.allApplicationPermissions.length; j++) { + if (this_.allApplicationPermissions[j].permissions.indexOf(this_.allUserPermissions[i]) != -1) { + bundleNames.push(this_.allApplicationPermissions[j].bundleName); + } + } + var pa: permissionApplications = { + 'permission': this_.allUserPermissions[i], + 'groupName': permissionGroup.name, + 'bundleNames': bundleNames, + 'icon': icon + }; + this_.allPermissionApplications.push(pa); + } + } + + /** + * Get permission group information + */ + getAllGroupPermission() { + const this_ = this; + var temp1 = []; + temp1 = ["LOCATION","CAMERA","MICROPHONE","MEDIA","CALENDAR","SPORT","HEALTH"]; + groups.forEach((item) => { + if (temp1.indexOf(item.name) > -1) { + var gp: groupPermission = { + "group": item.name, + "permissions": item.permissions, + 'groupName': item.groupName, + 'icon': item.icon, + 'isShow': item.isShow + }; + this_.allGroupPermission.push(gp); + } + }) + let temp2 = []; + groups.forEach((item) => { + if (item.isShow && temp1.indexOf(item.name) === -1) { + var gp: groupPermission = { + "group": item.name, + "permissions": item.permissions, + 'groupName': item.groupName, + 'icon': item.icon, + 'isShow': item.isShow + }; + temp2.push(item.name); + this_.allGroupPermission.push(gp); + } + }) + for (let i = 0; i < this_.allPermissionApplications.length; i++) { + if (this_.allGroups.indexOf(this_.allPermissionApplications[i].groupName) == -1 + && temp1.indexOf(this_.allPermissionApplications[i].groupName) == -1) { + this_.allGroups.push(this_.allPermissionApplications[i].groupName); + } + } + // Permission layout + var temp = this_.allGroups; + temp = temp.filter(function(item) { + return temp1.indexOf(item) == -1 && temp2.indexOf(item) == -1; + }); + if (temp.indexOf("OTHER") > -1) { + temp.splice(temp.indexOf("OTHER"),1); + temp.push("OTHER"); + }else { + temp.push("OTHER"); + } + this_.allGroups = temp; + for (let i = 0; i < this_.allGroups.length; i++) { + var permissions: string[] = permissionGroupPermissions[this_.allGroups[i]]; + var gp: groupPermission = { + "group": this_.allGroups[i], + "permissions": permissions, + 'groupName': '', + 'icon': '', + 'isShow': false + }; + this_.allGroupPermission.push(gp); + } + this.allGroupPermission.forEach((ele) => { + groups.forEach((item) => { + if (ele.group === item.name) { + ele.groupName = item.groupName; + ele.icon = item.icon; + ele.isShow = item.isShow; + } + }); + }) + } + + /** + * Deduplicate permission information and permission group information + * @param {Object} info bundleInfos Application Information + * @param {Array} allPermissions All permissions + * @param {Array} allApplicationPermissions All permissions apply + */ + async deduplicationPermissions(info, allPermissions, allApplicationPermissions) { + var reqPermissionsLen = info.reqPermissions.length; + var reqUserPermissions: string[] = []; + var acManager = abilityAccessCtrl.createAtManager() + if (reqPermissionsLen > 0) { + for (let j = 0; j < info.reqPermissions.length; j++) { + var permission = info.reqPermissions[j]; + var flag = await acManager.getPermissionFlags(info.appInfo.accessTokenId, permission) + if(flag == Constants.PRE_AUTHORIZATION_NOT_MODIFIED) { + continue + } + if (allPermissions.indexOf(permission) == -1) { + allPermissions.push(permission); + } + if (userGrantPermissions.indexOf(permission) != -1) { + reqUserPermissions.push(permission); + } + } + } + let dePermissions = []; + let groupIds = []; + for (let i = 0; i < reqUserPermissions.length; i++) { + if(dePermissions.indexOf(permissionPermissionGroup[reqUserPermissions[i]]) == -1){ + dePermissions.push(permissionPermissionGroup[reqUserPermissions[i]]); + } + if(groupIds.indexOf(permissionGroupIds[reqUserPermissions[i]]) == -1){ + groupIds.push(permissionGroupIds[reqUserPermissions[i]]); + } + } + + // adapt different api + if (info.compatibleVersion >= Constants.API_VERSION_SUPPORT_STAGE) { + info.appInfo.iconId = info.hapModuleInfos[0].abilityInfo[0].iconId; + } + + var ap: applicationPermissions = { + 'bundleName': info.name, + 'tokenId': info.appInfo.accessTokenId, + 'iconId': info.appInfo.iconId, + 'labelId': info.appInfo.labelId, + 'permissions': reqUserPermissions, + 'groupId': groupIds + }; + allApplicationPermissions.push(ap); + } + + /** + * Get app name resource + * @param {Number} index index of all app permissions array + * @param {String} bundleName Package names + * @param {String} labelName Application Name + */ + updateAppLabel(index, bundleName, labelName) { + Resmgr.getResourceManager(globalThis.context, bundleName).then(item => { + if (index >= this.allApplicationPermissions.length) { + return; + } + var info = this.allApplicationPermissions[index]; + item.getString(info['labelId'], (error, value) => { + if (value == undefined) { + info['labelId'] = labelName; + } else { + info['labelId'] = value; + } + }) + }).catch(error => { + console.error(TAG + 'Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); + }) + } + + /** + * Get app icon resources + * @param {Number} index index of all app permissions array + * @param {String} bundleName Package names + */ + updateAppIcon(index, bundleName) { + Resmgr.getResourceManager(globalThis.context, bundleName).then(item => { + if (index >= this.allApplicationPermissions.length) { + return; + } + var info = this.allApplicationPermissions[index]; + item.getMediaBase64(info['iconId'], (error, value) => { + info['iconId'] = value; + }) + }).catch(error => { + console.error(TAG + 'Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); + }) + } + + /** + * Lifecycle function, executed when the page is initialized + */ + aboutToAppear() { + console.log(TAG + 'on aboutToAppear, version 1.01'); + this.getAllBundlePermissions(this.allPermissions, this.allApplicationPermissions); + Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { + item.getString($r("app.string.textInput_placeholder").id, (err, val) => { + textInput_placeholder = val + }) + }) + } + + getPermissionGroup(allGroup, order) { + var fixedName: string[] = ['LOCATION', 'CAMERA', 'MICROPHONE'] + var fixedGroup: any[] = [] + var changeGroup: any[] = [] + var otherGroup: any[] = [] + + allGroup.forEach(group => { + if(fixedName.indexOf(group.group) !== -1) { + fixedGroup.push(group) + }else if(group.group == 'OTHER') { + otherGroup.push(group) + }else { + changeGroup.push(group) + } + }) + + if(order == Constants.FIXED_GROUP){ + return fixedGroup + }else if(order == Constants.CHANGE_GROUP) { + return changeGroup + }else if(order == Constants.OTHER_GROUP) { + return otherGroup + } + } + + build() { + GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { + Row() { + Row() + .useSizeType({ + xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, + sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, + md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, + lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() { + Column() { + Row() { + backBar( { title: JSON.stringify($r('app.string.authority_management')), recordable: true }) + } + Row() { + Column() { + Column() { + Stack() { + if(this.allGroupPermission.length) { + Tabs() { + TabContent() { + Row() { + Column() { + Scroll() { + Column() { + List() { + ListItem() { + List() { + ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.FIXED_GROUP).slice(Constants.SLICE_START, + this.getPermissionGroup(this.allGroupPermission, Constants.FIXED_GROUP).length - 1), (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX) + }, item => item.toString()) + ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.FIXED_GROUP).slice(Constants.SLICE_END), (item, index) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX) + }, item => item.toString()) + }.backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + .margin({ bottom: Constants.LIST_MARGIN_BOTTOM }) + } + + ListItem() { + List() { + ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.CHANGE_GROUP).slice(Constants.SLICE_START, + this.getPermissionGroup(this.allGroupPermission, Constants.CHANGE_GROUP).length - 1), (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX) + }, item => item.toString()) + ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.CHANGE_GROUP).slice(Constants.SLICE_END), (item, index) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX) + }, item => item.toString()) + }.backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + .margin({ bottom: Constants.LIST_MARGIN_BOTTOM }) + } + + ListItem() { + List() { + ForEach(this.getPermissionGroup(this.allGroupPermission, Constants.OTHER_GROUP), (item) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX) + }, item => item.toString()) + }.backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + } + }.height(Constants.FULL_HEIGHT) + .borderRadius(Constants.BORDER_RADIUS) + .clip(true) + }.padding({ + left: Constants.MANAGEMENT_ROW_PADDING_LEFT, + right: Constants.MANAGEMENT_ROW_PADDING_RIGHT, + }) + }.scrollBar(BarState.Off) + .margin({ top: Constants.MANAGEMENT_ROW_PADDING_TOP }) + }.width(Constants.FULL_WIDTH) + } + }.tabBar(this.TabBuilder(0)) + TabContent() { + applicationItem() + }.tabBar(this.TabBuilder(1)) + } + .barWidth(Constants.BAR_WIDTH) + .barMode(BarMode.Fixed) + .onChange((index) => { + this.currentIndex = index + }) + }else { + LoadingProgress().width(Constants.LOADING_WIDTH) + } + }.height(Constants.FULL_HEIGHT) + } + } + } + .layoutWeight(Constants.LAYOUT_WEIGHT) + } + } + .useSizeType({ + xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, + sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, + md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, + lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() + .useSizeType({ + xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, + sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, + md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, + lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + } + .height(Constants.FULL_HEIGHT) + .width(Constants.FULL_WIDTH) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .opacity(Constants.MANAGEMENT_TRANSPARENCY) + } + } +} + +@Component +struct applicationItem { + @State applicationItem: any[] = bundleInfosList // application info array + @State oldApplicationItem: any[] = bundleInfosList // Original application information array + @State searchResult: boolean = true // search results + + @Builder ListItemLayout(item, index) { + ListItem() { + Row() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Image(item.iconId) + .customizeImage(Constants.APPLICATION_IMAGE_WIDTH, Constants.APPLICATION_IMAGE_HEIGHT) + .margin({ right: Constants.APPLICATION_IMAGE_MARGIN_RIGHT }) + Text(item.labelId) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.label_color')) + .flexGrow(Constants.FLEX_GROW) + Text(item.groupId.length + '项权限') + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_lighter')) + .margin({ right: Constants.APPLICATION_TEXT_MARGIN_RIGHT }) + Image($r('app.media.rightarrow')) + .customizeImage(Constants.IMAGE_WIDTH, Constants.IMAGE_HEIGHT) + } + .width(Constants.FULL_WIDTH) + .height(Constants.AUTHORITY_ROW_HEIGHT) + .constraintSize({ minHeight: Constants.AUTHORITY_CONSTRAINTSIZE_MINHEIGHT }) + } + if (!index) { + Row() { + Flex() { + Column().width(Constants.APPLICATION_TEXT_DECORATION_MARGIN_LEFT) + Column() + .backgroundColor($r('app.color.text_decoration_color')) + .height(Constants.TEXT_DECORATION_HEIGHT) + .flexGrow(Constants.FLEX_GROW) + } + } + } + }.onClick(() => { + router.push({ + uri: 'pages/application-secondary', + params: { routerData: item } + }); + }) + } + }.padding({ + left: Constants.DEFAULT_PADDING_START, + right: Constants.DEFAULT_PADDING_END + }) + } + + build() { + Column() { + Row() { + textInput({ + placeholder: textInput_placeholder, + applicationItem: $applicationItem, + oldApplicationItem: $oldApplicationItem, + searchResult: $searchResult + }) + }.padding({ + left: Constants.APPLICATION_TEXTINPUT_PADDING_LEFT, + top: Constants.APPLICATION_TEXTINPUT_PADDING_TOP, + right: Constants.APPLICATION_TEXTINPUT_PADDING_RIGHT + }) + Row() { + Flex({ alignItems: ItemAlign.Start }) { + Column() { + Column() { + if (!this.applicationItem.length) { + Row() { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image($r('app.media.searchnoresult')) + .customizeImage(Constants.SEARCHNORESULT_IMAGE_WIDTH, Constants.SEARCHNORESULT_IMAGE_HEIGHT) + } + }.margin({ top: Constants.MANAGEMENT_ROW_MARGIN_TOP }) + .padding({ left: Constants.MANAGEMENT_ROW_PADDING_LEFT }) + } else { + Row() { + Scroll() { + List() { + ForEach(this.applicationItem.slice(Constants.SLICE_START, this.applicationItem.length - 1), + (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX) + }, item => item.toString()) + ForEach(this.applicationItem.slice(Constants.SLICE_END), (item, index) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX) + }, item => item.toString()) + }.backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.scrollBar(BarState.Off) + }.margin({ left: Constants.MANAGEMENT_ROW_PADDING_LEFT }) + .borderRadius(Constants.BORDER_RADIUS) + .clip(true) + } + }.backgroundColor($r('app.color.background_color')) + .height(Constants.FULL_HEIGHT) + }.margin({ top: Constants.MANAGEMENT_ROW_MARGIN_TOP, bottom: Constants.APPLICATION_LIST_MARGIN_BOTTOM }) + Column() { + alphabetIndexerComponent({ applicationItem: $applicationItem, oldApplicationItem: $oldApplicationItem }) + }.margin({ top: Constants.APPLICATION_ALPHABETINDEX_MARGIN_TOP }) + .width(Constants.APPLICATION_ALPHABETINDEX_WIDTH) + } + } + } + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-secondary.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-secondary.ets index 21480ad4ce0d66bcd44ef4e1dff49aa5f8f26e56..d3256f8c4b078b867d11960a9fba26b343a0a1f6 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-secondary.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-secondary.ets @@ -1,177 +1,177 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { backBar } from "../common/components/backBar"; -import { permissionGroups, groups } from "../common/model/permissionGroup"; -import router from '@system.router'; -import Constants from '../common/utils/constant'; - -var TAG = 'PermissionManager_MainAbility:' - -class CalendarObj { - permissionName: string - groupName: string - description: string - label: string - index: number - constructor(permissionName: string, groupName: string, description: string, label: string, index: number) { - this.permissionName = permissionName - this.groupName = groupName - this.description = description - this.label = label - this.index = index - } -} // Permission management secondary interface data class - -@Entry -@Component -struct appNamePage { - private backTitle = router.getParams().backTitle; // return title name - - build() { - GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { - Row() { - Row() - .useSizeType({ - xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, - sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, - md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, - lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() { - Column() { - Row() { - backBar({ title: JSON.stringify(this.backTitle), recordable: false }) - } - Row() { - Column() { - Scroll() { - appNameItem() - } - } - }.layoutWeight(Constants.LAYOUT_WEIGHT) - } - } - .useSizeType({ - xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, - sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, - md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, - lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() - .useSizeType({ - xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, - sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, - md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, - lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - } - .height(Constants.FULL_HEIGHT) - .width(Constants.FULL_WIDTH) - .backgroundColor($r("sys.color.ohos_id_color_sub_background")) - .opacity(Constants.MANAGEMENT_TRANSPARENCY) - } - } -} - -@Component -struct appNameItem { - @State calendarListItem: CalendarObj[] = []; // Permission management secondary interface data array - private routerData = router.getParams().routerData; // Routing jump data - private backTitle = router.getParams().backTitle; // return title name - private allPermissionApplications = router.getParams().allPermissionApplications; // Array of all app permission names - - @Builder ListItemLayout(item, index) { - ListItem() { - Row() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Text(item.label) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontColor($r('app.color.label_color')) - .fontWeight(FontWeight.Medium) - .flexGrow(Constants.FLEX_GROW) - Image($r('app.media.rightarrow')) - .objectFit(ImageFit.Contain) - .height(Constants.IMAGE_HEIGHT) - .width(Constants.IMAGE_WIDTH) - } - .width(Constants.FULL_WIDTH) - .height(Constants.LISTITEM_ROW_HEIGHT) - } - if (!index) { - Row() { - Column() - .backgroundColor($r('app.color.text_decoration_color')) - .width(Constants.FULL_WIDTH) - .height(Constants.TEXT_DECORATION_HEIGHT) - } - } - }.onClick(() => { - var dataList = this.routerData.filter((ele) => { - return ele.groupName === item.groupName; - }) - router.push({ - uri: 'pages/authority-tertiary', - params: { routerData: [dataList[item.index]], backTitle: item.label } - }); - }) - } - }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) - } - - /** - * Lifecycle function, executed when the page is initialized - */ - aboutToAppear() { - var permissionsList = groups.filter((item) => { - return item.groupName === this.backTitle - }) - for (let i = 0; i < permissionsList[0].permissions.length; i++) { - permissionGroups.forEach((item) => { - if (item.permissionName === permissionsList[0].permissions[i]) { - this.calendarListItem.push( - new CalendarObj(item.permissionName, item.groupName, item.description, item.label, i) - ) - } - }) - } - } - - build() { - Row() { - Column() { - Row() { - List() { - ForEach(this.calendarListItem.slice(Constants.SLICE_START, this.calendarListItem.length - 1), (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX) - }, item => item.toString()) - ForEach(this.calendarListItem.slice(Constants.SLICE_END), (item, index) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX) - }, item => item.toString()) - }.backgroundColor($r('app.color.default_background_color')).borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.margin({ top: Constants.ROW_MARGIN_TOP }) - .padding({ left: Constants.LIST_PADDING_LEFT, right: Constants.LISTITEM_PADDING_RIGHT }) - } - .width(Constants.FULL_WIDTH) - .height(Constants.FULL_HEIGHT) - } - } -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { backBar } from "../common/components/backBar"; +import { permissionGroups, groups } from "../common/model/permissionGroup"; +import router from '@system.router'; +import Constants from '../common/utils/constant'; + +var TAG = 'PermissionManager_MainAbility:' + +class CalendarObj { + permissionName: string + groupName: string + description: string + label: string + index: number + constructor(permissionName: string, groupName: string, description: string, label: string, index: number) { + this.permissionName = permissionName + this.groupName = groupName + this.description = description + this.label = label + this.index = index + } +} // Permission management secondary interface data class + +@Entry +@Component +struct appNamePage { + private backTitle = router.getParams().backTitle; // return title name + + build() { + GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { + Row() { + Row() + .useSizeType({ + xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, + sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, + md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, + lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() { + Column() { + Row() { + backBar({ title: JSON.stringify(this.backTitle), recordable: false }) + } + Row() { + Column() { + Scroll() { + appNameItem() + } + } + }.layoutWeight(Constants.LAYOUT_WEIGHT) + } + } + .useSizeType({ + xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, + sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, + md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, + lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() + .useSizeType({ + xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, + sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, + md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, + lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + } + .height(Constants.FULL_HEIGHT) + .width(Constants.FULL_WIDTH) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .opacity(Constants.MANAGEMENT_TRANSPARENCY) + } + } +} + +@Component +struct appNameItem { + @State calendarListItem: CalendarObj[] = []; // Permission management secondary interface data array + private routerData = router.getParams().routerData; // Routing jump data + private backTitle = router.getParams().backTitle; // return title name + private allPermissionApplications = router.getParams().allPermissionApplications; // Array of all app permission names + + @Builder ListItemLayout(item, index) { + ListItem() { + Row() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Text(item.label) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontColor($r('app.color.label_color')) + .fontWeight(FontWeight.Medium) + .flexGrow(Constants.FLEX_GROW) + Image($r('app.media.rightarrow')) + .objectFit(ImageFit.Contain) + .height(Constants.IMAGE_HEIGHT) + .width(Constants.IMAGE_WIDTH) + } + .width(Constants.FULL_WIDTH) + .height(Constants.LISTITEM_ROW_HEIGHT) + } + if (!index) { + Row() { + Column() + .backgroundColor($r('app.color.text_decoration_color')) + .width(Constants.FULL_WIDTH) + .height(Constants.TEXT_DECORATION_HEIGHT) + } + } + }.onClick(() => { + var dataList = this.routerData.filter((ele) => { + return ele.groupName === item.groupName; + }) + router.push({ + uri: 'pages/authority-tertiary', + params: { routerData: [dataList[item.index]], backTitle: item.label } + }); + }) + } + }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) + } + + /** + * Lifecycle function, executed when the page is initialized + */ + aboutToAppear() { + var permissionsList = groups.filter((item) => { + return item.groupName === this.backTitle + }) + for (let i = 0; i < permissionsList[0].permissions.length; i++) { + permissionGroups.forEach((item) => { + if (item.permissionName === permissionsList[0].permissions[i]) { + this.calendarListItem.push( + new CalendarObj(item.permissionName, item.groupName, item.description, item.label, i) + ) + } + }) + } + } + + build() { + Row() { + Column() { + Row() { + List() { + ForEach(this.calendarListItem.slice(Constants.SLICE_START, this.calendarListItem.length - 1), (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX) + }, item => item.toString()) + ForEach(this.calendarListItem.slice(Constants.SLICE_END), (item, index) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX) + }, item => item.toString()) + }.backgroundColor($r('app.color.default_background_color')).borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.margin({ top: Constants.ROW_MARGIN_TOP }) + .padding({ left: Constants.LIST_PADDING_LEFT, right: Constants.LISTITEM_PADDING_RIGHT }) + } + .width(Constants.FULL_WIDTH) + .height(Constants.FULL_HEIGHT) + } + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets index 44cd9224d2b33bf31ef301dcab55c2462ce5f621..ed7d009dbbf2d79bec2564ec3bec0ec1f8448610 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets @@ -1,403 +1,403 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { backBar } from "../common/components/backBar"; -import { alphabetIndexerComponent } from "../common/components/alphabeticalIndex"; -import { textInput } from "../common/components/search"; -import router from '@system.router'; -import bundle from "@ohos.bundle"; -import Resmgr from '@ohos.resourceManager'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import { getAppLabel, getAppIcon, verifyAccessToken} from "../common/utils/utils"; -import { makePy } from "../common/utils/utils"; -import { authorizeDialog } from "../common/components/dialog"; -import Constants from '../common/utils/constant'; - -var TAG = 'PermissionManager_MainAbility:' - -@Extend(Image) function customizeImage(width: number, height: number) { - .objectFit(ImageFit.Contain) - .width(width) - .height(height) -} - -let routerData = router.getParams().routerData; // Routing jump data -let backTitle = router.getParams().backTitle; // return title name -let nowGrantResult = Constants.PERMISSION_NUM; // Authorization results now -let nowRevokeResult = Constants.PERMISSION_NUM; // Now deauthorize results -let GrantResultFlag = []; // Authorization result Flag -let RevokeResultFlag = []; // Cancel authorization result Flag - -class ApplicationObj { - labelId: string - iconId: string - index: number - accessTokenId: number - permission: string - alphabeticalIndex: string - constructor( - labelId: string, - iconId: string, - index: number, - accessTokenId: number, - permission: string, - alphabeticalIndex: string) { - this.labelId = labelId - this.iconId = iconId - this.index = index - this.accessTokenId = accessTokenId - this.permission = permission - this.alphabeticalIndex = alphabeticalIndex - } -} // application information - -@Entry -@Component -struct locationInfoPage { - build() { - GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { - Row() { - Row() - .useSizeType({ - xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, - sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, - md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, - lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() { - Column() { - Row() { - backBar({ title: JSON.stringify(backTitle), recordable: false }) - } - Row() { - Column() { - applicationItem() - - }.width(Constants.FULL_WIDTH) - } - .layoutWeight(Constants.LAYOUT_WEIGHT) - } - } - .useSizeType({ - xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, - sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, - md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, - lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() - .useSizeType({ - xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, - sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, - md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, - lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - } - .height(Constants.FULL_HEIGHT) - .width(Constants.FULL_WIDTH) - .backgroundColor($r("sys.color.ohos_id_color_sub_background")) - .opacity(Constants.MANAGEMENT_TRANSPARENCY) - } - } -} - -@Component -struct applicationItem { - @State permissionNum: number = Constants.PERMISSION_NUM; // permission num - @State toggleIsOn: object = {}; // toggle switch state array - @State applicationList: ApplicationObj[] = []; // application info array - @State oldApplicationItem: ApplicationObj[] = []; // Original application information array - @State searchResult: boolean = true; // search results - @State placeholder: string = '' - - authorizeDialogController: CustomDialogController = new CustomDialogController({ - builder: authorizeDialog({ }), - autoCancel: true, - alignment: DialogAlignment.Center - }); - - @Builder ListItemLayout(item, index) { - ListItem() { - Row() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Image(item.iconId) - .customizeImage(Constants.AUTHORITY_IMAGE_WIDTH, Constants.AUTHORITY_IMAGE_HEIGHT) - .margin({ right: Constants.AUTHORITY_IMAGE_MARGIN_RIGHT }) - Text(item.labelId) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontColor($r('app.color.text_color')) - .flexGrow(Constants.FLEX_GROW) - Toggle({ type: ToggleType.Switch, isOn: this.toggleIsOn[item.index] }) - .selectedColor($r('app.color.toggle_color')) - .width(Constants.AUTHORITY_TOGGLE_WIDTH) - .height(Constants.AUTHORITY_TOGGLE_HEIGHT) - .onChange((isOn: boolean) => { - if (item.accessTokenId === '' || item.permission === '') { - return; - } - let _this = this; - if (isOn) { - let promises = routerData.map(it => new Promise((resolve, reject) => { - _this.grantUserGrantedPermission(item.accessTokenId, it.permission, item.index, resolve); - })); - Promise.all(promises).then(function(results) { - if(results.indexOf(-1) != -1) { - _this.authorizeDialogController.open(); - _this.toggleIsOn[item.index] = false; - setTimeout(()=> { - _this.authorizeDialogController.close(); - }, Constants.DELAY_TIME) - } else { - _this.toggleIsOn[item.index] = true; - } - let num = Constants.PERMISSION_NUM; - for(let key in _this.toggleIsOn){ - if(_this.toggleIsOn[key]){ - num++; - } - } - _this.permissionNum = num; - }); - } else { - let promises = routerData.map(it => new Promise((resolve, reject) => { - _this.revokeUserGrantedPermission(item.accessTokenId, it.permission, item.index, resolve); - })); - Promise.all(promises).then(function(results) { - if(results.indexOf(-1) != -1) { - _this.authorizeDialogController.open(); - _this.toggleIsOn[item.index] = true; - setTimeout(()=> { - _this.authorizeDialogController.close(); - }, Constants.DELAY_TIME) - } else { - _this.toggleIsOn[item.index] = false; - } - let num = Constants.PERMISSION_NUM; - for(let key in _this.toggleIsOn){ - if(_this.toggleIsOn[key]){ - num++; - } - } - _this.permissionNum = num; - }); - } - }) - } - .width(Constants.FULL_WIDTH) - .height(Constants.AUTHORITY_ROW_HEIGHT) - .constraintSize({ minHeight: Constants.AUTHORITY_CONSTRAINTSIZE_MINHEIGHT }) - } - if (!index) { - Row() { - Flex() { - Column().width(Constants.APPLICATION_TEXT_DECORATION_MARGIN_LEFT) - Column() - .backgroundColor($r('app.color.text_decoration_color')) - .height(Constants.TEXT_DECORATION_HEIGHT) - .flexGrow(Constants.FLEX_GROW) - } - } - } - }.onClick(() => { - }) - } - }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) - } - - /** - * Grant permissions to the app - * @param {Number} accessTokenId - * @param {String} permission permission name - * @param {Number} index Array index to modify permission status - */ - grantUserGrantedPermission(accessTokenId, permission, index, resolve) { - abilityAccessCtrl.createAtManager().grantUserGrantedPermission( - accessTokenId, permission, Constants.PERMISSION_FLAG).then(result => { - // result: 0 Authorization succeeded; result: -1 Authorization failed - resolve(result); - }).catch(error => { - resolve(-1); - console.error(TAG + 'abilityAccessCtrl.createAtManager.grantUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); - }) - } - - /** - * Deauthorize the app - * @param {Number} accessTokenId - * @param {String} permission permission name - * @param {Number} index Array index to modify permission status - */ - revokeUserGrantedPermission(accessTokenId, permission, index, resolve) { - abilityAccessCtrl.createAtManager().revokeUserGrantedPermission( - accessTokenId, permission, Constants.PERMISSION_FLAG).then(result => { - // result: 0 successfully cancel the authorization; result: -1 cancel the authorization failed - resolve(result); - }).catch(error => { - resolve(-1); - console.error(TAG + 'abilityAccessCtrl.createAtManager.revokeUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); - }) - } - - /** - * Lifecycle function, executed when the page is initialized - */ - aboutToAppear() { - var bundleNames = [] - routerData.forEach(permissionmanager => { - permissionmanager.bundleNames.forEach( bundleName => { - if (bundleNames.indexOf(bundleName) == -1) { - bundleNames.push(bundleName) - } - }) - }) - - Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { - item.getString($r("app.string.textInput_placeholder").id, (err, val) => { - this.placeholder = val - }) - }) - - // initial then fill values when sync return which may cause sync panic - for (let i = 0; i < bundleNames.length; i++) { - this.applicationList.push( - new ApplicationObj('', '', i, 0, '', '')); - this.oldApplicationItem.push( - new ApplicationObj('', '', i, 0, '', '')); - } - - for (let i = 0; i < bundleNames.length; i++) { - // Get BundleInfo based on bundle name - bundle.getBundleInfo(bundleNames[i], Constants.PARMETER_BUNDLE_FLAG).then(res => { - Promise.all([getAppLabel(res.appInfo.labelId, res.name), - getAppIcon(res.appInfo.iconId, res.name) - ]) - .then((values) => { - this.applicationList[i] = ( - new ApplicationObj( - String(values[0]), - String(values[1]), - i, - res.appInfo.accessTokenId, - routerData[0].permission, - makePy(values[0])[0].slice(0, 1)) // Get the first letter in the returned initials array - ); - this.oldApplicationItem[i] = ( - new ApplicationObj( - String(values[0]), - String(values[1]), - i, - res.appInfo.accessTokenId, - routerData[0].permission, - makePy(values[0])[0].slice(0, 1)) // Get the first letter in the returned initials array - ); - }); - // 0: have permission; -1: no permission - var boole = true; - this.permissionNum++; - for (let j = 0; j < routerData.length; j++) { - if (res.reqPermissions.indexOf(routerData[j].permission) == -1) { - continue - } - verifyAccessToken(res.appInfo.accessTokenId, routerData[j].permission).then((access) => { - if (Number(access) === Constants.PERMISSION_INDEX) { - if(boole){ - this.toggleIsOn[i] = true; - } - } else { - if(boole){ - this.permissionNum-- - } - boole = false; - this.toggleIsOn[i] = false; - } - }); - } - }).catch(error => { - console.log(TAG + bundleNames[i] + "getBundleInfo failed, cause: " + JSON.stringify(error)); - }) - } - } - - build() { - Column() { - Row() { - textInput({ - placeholder: this.placeholder, - applicationItem: $applicationList, - oldApplicationItem: $oldApplicationItem, - searchResult: $searchResult - }) - }.padding({ - left: Constants.AUTHORITY_TEXTINPUT_PADDING_LEFT, - right: Constants.AUTHORITY_TEXTINPUT_PADDING_RIGHT - }) - Row() { - Flex({ alignItems:ItemAlign.Start, justifyContent: FlexAlign.Start }) { - Column() { - Flex({ justifyContent: FlexAlign.Start }) { - Text(this.permissionNum + '个应用获取此权限') - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.secondary_font_color')) - .margin({ top: Constants.AUTHORITY_TEXT_MARGIN_TOP, left: Constants.AUTHORITY_TEXT_MARGIN_LEFT }) - } - Scroll() { - Row() { - Column() { - if (!this.applicationList.length) { - if (this.searchResult) { - Row() { - }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) - } else { - Row() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Image($r('app.media.searchnoresult')) - .customizeImage(Constants.SEARCHNORESULT_IMAGE_WIDTH, Constants.SEARCHNORESULT_IMAGE_HEIGHT) - } - }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) - } - } else { - Row() { - List() { - ForEach(this.applicationList.slice(Constants.SLICE_START, this.applicationList.length - 1), - (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX) - }, item => item.toString()) - ForEach(this.applicationList.slice(Constants.SLICE_END), (item, index) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX) - }, item => item.toString()) - } - .backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) - } - }.width(Constants.FULL_WIDTH) - .height(Constants.AUTHORITY_COLUMN_HEIGHT) - } - } - }.padding({ left: Constants.AUTHORITY_LISTITEM_PADDING_LEFT }) - Column() { - alphabetIndexerComponent({ applicationItem: $applicationList, oldApplicationItem: $oldApplicationItem }) - }.width(Constants.AUTHORITY_ALPHABETINDEX_WIDTH) - .padding({ top: Constants.AUTHORITY_ALPHABETINDEX_PADDING_TOP }) - } - } - } - } -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { backBar } from "../common/components/backBar"; +import { alphabetIndexerComponent } from "../common/components/alphabeticalIndex"; +import { textInput } from "../common/components/search"; +import router from '@system.router'; +import bundle from "@ohos.bundle"; +import Resmgr from '@ohos.resourceManager'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import { getAppLabel, getAppIcon, verifyAccessToken} from "../common/utils/utils"; +import { makePy } from "../common/utils/utils"; +import { authorizeDialog } from "../common/components/dialog"; +import Constants from '../common/utils/constant'; + +var TAG = 'PermissionManager_MainAbility:' + +@Extend(Image) function customizeImage(width: number, height: number) { + .objectFit(ImageFit.Contain) + .width(width) + .height(height) +} + +let routerData = router.getParams().routerData; // Routing jump data +let backTitle = router.getParams().backTitle; // return title name +let nowGrantResult = Constants.PERMISSION_NUM; // Authorization results now +let nowRevokeResult = Constants.PERMISSION_NUM; // Now deauthorize results +let GrantResultFlag = []; // Authorization result Flag +let RevokeResultFlag = []; // Cancel authorization result Flag + +class ApplicationObj { + labelId: string + iconId: string + index: number + accessTokenId: number + permission: string + alphabeticalIndex: string + constructor( + labelId: string, + iconId: string, + index: number, + accessTokenId: number, + permission: string, + alphabeticalIndex: string) { + this.labelId = labelId + this.iconId = iconId + this.index = index + this.accessTokenId = accessTokenId + this.permission = permission + this.alphabeticalIndex = alphabeticalIndex + } +} // application information + +@Entry +@Component +struct locationInfoPage { + build() { + GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { + Row() { + Row() + .useSizeType({ + xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, + sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, + md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, + lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() { + Column() { + Row() { + backBar({ title: JSON.stringify(backTitle), recordable: false }) + } + Row() { + Column() { + applicationItem() + + }.width(Constants.FULL_WIDTH) + } + .layoutWeight(Constants.LAYOUT_WEIGHT) + } + } + .useSizeType({ + xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, + sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, + md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, + lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() + .useSizeType({ + xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, + sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, + md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, + lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + } + .height(Constants.FULL_HEIGHT) + .width(Constants.FULL_WIDTH) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .opacity(Constants.MANAGEMENT_TRANSPARENCY) + } + } +} + +@Component +struct applicationItem { + @State permissionNum: number = Constants.PERMISSION_NUM; // permission num + @State toggleIsOn: object = {}; // toggle switch state array + @State applicationList: ApplicationObj[] = []; // application info array + @State oldApplicationItem: ApplicationObj[] = []; // Original application information array + @State searchResult: boolean = true; // search results + @State placeholder: string = '' + + authorizeDialogController: CustomDialogController = new CustomDialogController({ + builder: authorizeDialog({ }), + autoCancel: true, + alignment: DialogAlignment.Center + }); + + @Builder ListItemLayout(item, index) { + ListItem() { + Row() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Image(item.iconId) + .customizeImage(Constants.AUTHORITY_IMAGE_WIDTH, Constants.AUTHORITY_IMAGE_HEIGHT) + .margin({ right: Constants.AUTHORITY_IMAGE_MARGIN_RIGHT }) + Text(item.labelId) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontColor($r('app.color.text_color')) + .flexGrow(Constants.FLEX_GROW) + Toggle({ type: ToggleType.Switch, isOn: this.toggleIsOn[item.index] }) + .selectedColor($r('app.color.toggle_color')) + .width(Constants.AUTHORITY_TOGGLE_WIDTH) + .height(Constants.AUTHORITY_TOGGLE_HEIGHT) + .onChange((isOn: boolean) => { + if (item.accessTokenId === '' || item.permission === '') { + return; + } + let _this = this; + if (isOn) { + let promises = routerData.map(it => new Promise((resolve, reject) => { + _this.grantUserGrantedPermission(item.accessTokenId, it.permission, item.index, resolve); + })); + Promise.all(promises).then(function(results) { + if(results.indexOf(-1) != -1) { + _this.authorizeDialogController.open(); + _this.toggleIsOn[item.index] = false; + setTimeout(()=> { + _this.authorizeDialogController.close(); + }, Constants.DELAY_TIME) + } else { + _this.toggleIsOn[item.index] = true; + } + let num = Constants.PERMISSION_NUM; + for(let key in _this.toggleIsOn){ + if(_this.toggleIsOn[key]){ + num++; + } + } + _this.permissionNum = num; + }); + } else { + let promises = routerData.map(it => new Promise((resolve, reject) => { + _this.revokeUserGrantedPermission(item.accessTokenId, it.permission, item.index, resolve); + })); + Promise.all(promises).then(function(results) { + if(results.indexOf(-1) != -1) { + _this.authorizeDialogController.open(); + _this.toggleIsOn[item.index] = true; + setTimeout(()=> { + _this.authorizeDialogController.close(); + }, Constants.DELAY_TIME) + } else { + _this.toggleIsOn[item.index] = false; + } + let num = Constants.PERMISSION_NUM; + for(let key in _this.toggleIsOn){ + if(_this.toggleIsOn[key]){ + num++; + } + } + _this.permissionNum = num; + }); + } + }) + } + .width(Constants.FULL_WIDTH) + .height(Constants.AUTHORITY_ROW_HEIGHT) + .constraintSize({ minHeight: Constants.AUTHORITY_CONSTRAINTSIZE_MINHEIGHT }) + } + if (!index) { + Row() { + Flex() { + Column().width(Constants.APPLICATION_TEXT_DECORATION_MARGIN_LEFT) + Column() + .backgroundColor($r('app.color.text_decoration_color')) + .height(Constants.TEXT_DECORATION_HEIGHT) + .flexGrow(Constants.FLEX_GROW) + } + } + } + }.onClick(() => { + }) + } + }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) + } + + /** + * Grant permissions to the app + * @param {Number} accessTokenId + * @param {String} permission permission name + * @param {Number} index Array index to modify permission status + */ + grantUserGrantedPermission(accessTokenId, permission, index, resolve) { + abilityAccessCtrl.createAtManager().grantUserGrantedPermission( + accessTokenId, permission, Constants.PERMISSION_FLAG).then(result => { + // result: 0 Authorization succeeded; result: -1 Authorization failed + resolve(result); + }).catch(error => { + resolve(-1); + console.error(TAG + 'abilityAccessCtrl.createAtManager.grantUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); + }) + } + + /** + * Deauthorize the app + * @param {Number} accessTokenId + * @param {String} permission permission name + * @param {Number} index Array index to modify permission status + */ + revokeUserGrantedPermission(accessTokenId, permission, index, resolve) { + abilityAccessCtrl.createAtManager().revokeUserGrantedPermission( + accessTokenId, permission, Constants.PERMISSION_FLAG).then(result => { + // result: 0 successfully cancel the authorization; result: -1 cancel the authorization failed + resolve(result); + }).catch(error => { + resolve(-1); + console.error(TAG + 'abilityAccessCtrl.createAtManager.revokeUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); + }) + } + + /** + * Lifecycle function, executed when the page is initialized + */ + aboutToAppear() { + var bundleNames = [] + routerData.forEach(permissionmanager => { + permissionmanager.bundleNames.forEach( bundleName => { + if (bundleNames.indexOf(bundleName) == -1) { + bundleNames.push(bundleName) + } + }) + }) + + Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { + item.getString($r("app.string.textInput_placeholder").id, (err, val) => { + this.placeholder = val + }) + }) + + // initial then fill values when sync return which may cause sync panic + for (let i = 0; i < bundleNames.length; i++) { + this.applicationList.push( + new ApplicationObj('', '', i, 0, '', '')); + this.oldApplicationItem.push( + new ApplicationObj('', '', i, 0, '', '')); + } + + for (let i = 0; i < bundleNames.length; i++) { + // Get BundleInfo based on bundle name + bundle.getBundleInfo(bundleNames[i], Constants.PARMETER_BUNDLE_FLAG).then(res => { + Promise.all([getAppLabel(res.appInfo.labelId, res.name), + getAppIcon(res.appInfo.iconId, res.name) + ]) + .then((values) => { + this.applicationList[i] = ( + new ApplicationObj( + String(values[0]), + String(values[1]), + i, + res.appInfo.accessTokenId, + routerData[0].permission, + makePy(values[0])[0].slice(0, 1)) // Get the first letter in the returned initials array + ); + this.oldApplicationItem[i] = ( + new ApplicationObj( + String(values[0]), + String(values[1]), + i, + res.appInfo.accessTokenId, + routerData[0].permission, + makePy(values[0])[0].slice(0, 1)) // Get the first letter in the returned initials array + ); + }); + // 0: have permission; -1: no permission + var boole = true; + this.permissionNum++; + for (let j = 0; j < routerData.length; j++) { + if (res.reqPermissions.indexOf(routerData[j].permission) == -1) { + continue + } + verifyAccessToken(res.appInfo.accessTokenId, routerData[j].permission).then((access) => { + if (Number(access) === Constants.PERMISSION_INDEX) { + if(boole){ + this.toggleIsOn[i] = true; + } + } else { + if(boole){ + this.permissionNum-- + } + boole = false; + this.toggleIsOn[i] = false; + } + }); + } + }).catch(error => { + console.log(TAG + bundleNames[i] + "getBundleInfo failed, cause: " + JSON.stringify(error)); + }) + } + } + + build() { + Column() { + Row() { + textInput({ + placeholder: this.placeholder, + applicationItem: $applicationList, + oldApplicationItem: $oldApplicationItem, + searchResult: $searchResult + }) + }.padding({ + left: Constants.AUTHORITY_TEXTINPUT_PADDING_LEFT, + right: Constants.AUTHORITY_TEXTINPUT_PADDING_RIGHT + }) + Row() { + Flex({ alignItems:ItemAlign.Start, justifyContent: FlexAlign.Start }) { + Column() { + Flex({ justifyContent: FlexAlign.Start }) { + Text(this.permissionNum + '个应用获取此权限') + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.secondary_font_color')) + .margin({ top: Constants.AUTHORITY_TEXT_MARGIN_TOP, left: Constants.AUTHORITY_TEXT_MARGIN_LEFT }) + } + Scroll() { + Row() { + Column() { + if (!this.applicationList.length) { + if (this.searchResult) { + Row() { + }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) + } else { + Row() { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image($r('app.media.searchnoresult')) + .customizeImage(Constants.SEARCHNORESULT_IMAGE_WIDTH, Constants.SEARCHNORESULT_IMAGE_HEIGHT) + } + }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) + } + } else { + Row() { + List() { + ForEach(this.applicationList.slice(Constants.SLICE_START, this.applicationList.length - 1), + (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX) + }, item => item.toString()) + ForEach(this.applicationList.slice(Constants.SLICE_END), (item, index) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX) + }, item => item.toString()) + } + .backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) + } + }.width(Constants.FULL_WIDTH) + .height(Constants.AUTHORITY_COLUMN_HEIGHT) + } + } + }.padding({ left: Constants.AUTHORITY_LISTITEM_PADDING_LEFT }) + Column() { + alphabetIndexerComponent({ applicationItem: $applicationList, oldApplicationItem: $oldApplicationItem }) + }.width(Constants.AUTHORITY_ALPHABETINDEX_WIDTH) + .padding({ top: Constants.AUTHORITY_ALPHABETINDEX_PADDING_TOP }) + } + } + } + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-tertiary.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-tertiary.ets index 040934f2f1e43bbf73319726c379dbc818b4097c..38dcd5b8a6521f4e19b6937ce5b035183d39bd80 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-tertiary.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/authority-tertiary.ets @@ -1,363 +1,363 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { backBar } from "../common/components/backBar"; -import { alphabetIndexerComponent } from "../common/components/alphabeticalIndex"; -import { textInput } from "../common/components/search"; -import router from '@system.router'; -import bundle from "@ohos.bundle"; -import Resmgr from '@ohos.resourceManager'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import { getAppLabel, getAppIcon, verifyAccessToken } from "../common/utils/utils"; -import { makePy } from "../common/utils/utils"; -import { authorizeDialog } from "../common/components/dialog"; -import Constants from '../common/utils/constant'; - -var TAG = 'PermissionManager_MainAbility:' - -@Extend(Image) function customizeImage(width: number, height: number) { - .objectFit(ImageFit.Contain) - .width(width) - .height(height) -} - -let routerData = router.getParams().routerData; // Routing jump data -let backTitle = router.getParams().backTitle; // return title name -class ApplicationObj { - labelId: string - iconId: string - index: number - accessTokenId: number - permission: string - alphabeticalIndex: string - constructor( - labelId: string, - iconId: string, - index: number, - accessTokenId: number, - permission: string, - alphabeticalIndex: string) { - this.labelId = labelId - this.iconId = iconId - this.index = index - this.accessTokenId = accessTokenId - this.permission = permission - this.alphabeticalIndex = alphabeticalIndex - } -} // application information - -@Entry -@Component -struct locationInfoPage { - build() { - GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { - Row() { - Row() - .useSizeType({ - xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, - sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, - md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, - lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() { - Column() { - Row() { - backBar({ title: JSON.stringify(backTitle), recordable: false }) - } - Row() { - Column() { - applicationItem() - - }.width(Constants.FULL_WIDTH) - } - .layoutWeight(Constants.LAYOUT_WEIGHT) - } - } - .useSizeType({ - xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, - sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, - md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, - lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() - .useSizeType({ - xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, - sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, - md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, - lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - } - .height(Constants.FULL_HEIGHT) - .width(Constants.FULL_WIDTH) - .backgroundColor($r("sys.color.ohos_id_color_sub_background")) - .opacity(Constants.MANAGEMENT_TRANSPARENCY) - } - } -} - -@Component -struct applicationItem { - @State permissionNum: number = Constants.PERMISSION_NUM; // permission num - @State toggleIsOn: object = {}; // toggle switch state array - @State applicationList: ApplicationObj[] = []; // application info array - @State oldApplicationItem: ApplicationObj[] = []; // Original application information array - @State searchResult: boolean = true; // search results - @State placeholder: string = '' - - authorizeDialogController: CustomDialogController = new CustomDialogController({ - builder: authorizeDialog({ }), - autoCancel: true, - alignment: DialogAlignment.Center - }); - - @Builder ListItemLayout(item, index) { - ListItem() { - Row() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Image(item.iconId) - .customizeImage(Constants.AUTHORITY_IMAGE_WIDTH, Constants.AUTHORITY_IMAGE_HEIGHT) - .margin({ right: Constants.AUTHORITY_IMAGE_MARGIN_RIGHT }) - Text(item.labelId) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontWeight(FontWeight.Medium) - .fontColor($r('app.color.label_color')) - .flexGrow(Constants.FLEX_GROW) - Toggle({ type: ToggleType.Switch, isOn: this.toggleIsOn[item.index] }) - .selectedColor($r('app.color.toggle_color')) - .width(Constants.AUTHORITY_TOGGLE_WIDTH) - .height(Constants.AUTHORITY_TOGGLE_HEIGHT) - .onChange((isOn: boolean) => { - if (item.accessTokenId === '' || item.permission === '') { - return; - } - if (isOn) { - this.grantUserGrantedPermission(item.accessTokenId, item.permission, item.index); - } else { - this.revokeUserGrantedPermission(item.accessTokenId, item.permission, item.index); - } - }) - } - .width(Constants.FULL_WIDTH) - .height(Constants.AUTHORITY_ROW_HEIGHT) - .constraintSize({ minHeight: Constants.AUTHORITY_CONSTRAINTSIZE_MINHEIGHT }) - } - if (!index) { - Row() { - Flex() { - Column().width(Constants.APPLICATION_TEXT_DECORATION_MARGIN_LEFT) - Column() - .backgroundColor($r('app.color.text_decoration_color')) - .height(Constants.TEXT_DECORATION_HEIGHT) - .flexGrow(Constants.FLEX_GROW) - } - } - } - }.onClick(() => { - }) - } - }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) - } - - /** - * Grant permissions to the app - * @param {Number} accessTokenId - * @param {String} permission permission name - * @param {Number} index Array index to modify permission status - */ - grantUserGrantedPermission(accessTokenId, permission, index) { - abilityAccessCtrl.createAtManager().grantUserGrantedPermission( - accessTokenId, permission, Constants.PERMISSION_FLAG).then(result => { - // result: 0 Authorization succeeded; result: -1 Authorization failed - if (result !== Constants.PERMISSION_INDEX) { - this.authorizeDialogController.open(); - this.toggleIsOn[index] = false; - setTimeout(()=> { - this.authorizeDialogController.close(); - }, Constants.DELAY_TIME) - } else { - this.toggleIsOn[index] = true; - } - let num = Constants.PERMISSION_NUM; - for(let key in this.toggleIsOn){ - if(this.toggleIsOn[key]){ - num++; - } - } - this.permissionNum = num; - }).catch(error => { - console.error(TAG + 'abilityAccessCtrl.createAtManager.grantUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); - }) - } - - /** - * Deauthorize the app - * @param {Number} accessTokenId - * @param {String} permission permission name - * @param {Number} index Array index to modify permission status - */ - revokeUserGrantedPermission(accessTokenId, permission, index) { - abilityAccessCtrl.createAtManager().revokeUserGrantedPermission( - accessTokenId, permission, Constants.PERMISSION_FLAG).then(result => { - // result: 0 successfully cancel the authorization; result: -1 cancel the authorization failed - if (result !== Constants.PERMISSION_INDEX) { - this.authorizeDialogController.open(); - this.toggleIsOn[index] = true; - setTimeout(()=> { - this.authorizeDialogController.close(); - }, Constants.DELAY_TIME) - } else { - this.toggleIsOn[index] = false; - } - let num = Constants.PERMISSION_NUM; - for(let key in this.toggleIsOn){ - if(this.toggleIsOn[key]){ - num++; - } - } - this.permissionNum = num; - }) - } - - /** - * Lifecycle function, executed when the page is initialized - */ - aboutToAppear() { - let bundleNames = routerData[0].bundleNames; - - Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { - item.getString($r("app.string.textInput_placeholder").id, (err, val) => { - this.placeholder = val - }) - }) - - // initial then fill values when sync return which may cause sync panic - for (let i = 0; i < bundleNames.length; i++) { - this.applicationList.push( - new ApplicationObj('', '', i, 0, '', '')); - this.oldApplicationItem.push( - new ApplicationObj('', '', i, 0, '', '')); - } - - for (let i = 0; i < bundleNames.length; i++) { - // Get BundleInfo based on bundle name - bundle.getBundleInfo(bundleNames[i], Constants.PARMETER_BUNDLE_FLAG).then(res => { - Promise.all([getAppLabel(res.appInfo.labelId, res.name), - getAppIcon(res.appInfo.iconId, res.name), - verifyAccessToken(res.appInfo.accessTokenId, routerData[0].permission)]) - .then((values) => { - this.applicationList[i] = ( - new ApplicationObj( - String(values[0]), - String(values[1]), - i, - res.appInfo.accessTokenId, - routerData[0].permission, - makePy(values[0])[0].slice(0, 1)) // Get the first letter in the returned initials array - ); - this.oldApplicationItem[i] = ( - new ApplicationObj( - String(values[0]), - String(values[1]), - i, - res.appInfo.accessTokenId, - routerData[0].permission, - makePy(values[0])[0].slice(0, 1)) // Get the first letter in the returned initials array - ); - // 0: have permission; -1: no permission - if (values[2] === Constants.PERMISSION_INDEX) { - this.toggleIsOn[i] = true; - this.permissionNum++; - } else { - this.toggleIsOn[i] = false; - } - }); - }).catch(error => { - console.log(TAG + bundleNames[i] + "getBundleInfo failed, cause: " + JSON.stringify(error)); - }) - } - } - - build() { - Column() { - Row() { - textInput({ - placeholder: this.placeholder, - applicationItem: $applicationList, - oldApplicationItem: $oldApplicationItem, - searchResult: $searchResult - }) - }.padding({ - left: Constants.AUTHORITY_TEXTINPUT_PADDING_LEFT, - right: Constants.AUTHORITY_TEXTINPUT_PADDING_RIGHT - }) - Row() { - Flex({ alignItems:ItemAlign.Start, justifyContent: FlexAlign.Start }) { - Column() { - Flex({ justifyContent: FlexAlign.Start }) { - Text(this.permissionNum + '个应用获取此权限') - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.secondary_font_color')) - .margin({ top: Constants.AUTHORITY_TEXT_MARGIN_TOP, left: Constants.AUTHORITY_TEXT_MARGIN_LEFT }) - } - Scroll() { - Row() { - Column() { - if (!this.applicationList.length) { - if (this.searchResult) { - Row() { - }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) - } else { - Row() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Image($r('app.media.searchnoresult')) - .customizeImage(Constants.SEARCHNORESULT_IMAGE_WIDTH, Constants.SEARCHNORESULT_IMAGE_HEIGHT) - } - }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) - } - } else { - Row() { - List() { - ForEach(this.applicationList.slice(Constants.SLICE_START, this.applicationList.length - 1), - (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX) - }, item => item.toString()) - ForEach(this.applicationList.slice(Constants.SLICE_END), (item, index) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX) - }, item => item.toString()) - } - .backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) - } - }.width(Constants.FULL_WIDTH) - .height(Constants.AUTHORITY_COLUMN_HEIGHT) - } - } - }.padding({ left: Constants.AUTHORITY_LISTITEM_PADDING_LEFT }) - Column() { - alphabetIndexerComponent({ applicationItem: $applicationList, oldApplicationItem: $oldApplicationItem }) - }.width(Constants.AUTHORITY_ALPHABETINDEX_WIDTH) - .padding({ top: Constants.AUTHORITY_ALPHABETINDEX_PADDING_TOP }) - } - } - } - } -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { backBar } from "../common/components/backBar"; +import { alphabetIndexerComponent } from "../common/components/alphabeticalIndex"; +import { textInput } from "../common/components/search"; +import router from '@system.router'; +import bundle from "@ohos.bundle"; +import Resmgr from '@ohos.resourceManager'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import { getAppLabel, getAppIcon, verifyAccessToken } from "../common/utils/utils"; +import { makePy } from "../common/utils/utils"; +import { authorizeDialog } from "../common/components/dialog"; +import Constants from '../common/utils/constant'; + +var TAG = 'PermissionManager_MainAbility:' + +@Extend(Image) function customizeImage(width: number, height: number) { + .objectFit(ImageFit.Contain) + .width(width) + .height(height) +} + +let routerData = router.getParams().routerData; // Routing jump data +let backTitle = router.getParams().backTitle; // return title name +class ApplicationObj { + labelId: string + iconId: string + index: number + accessTokenId: number + permission: string + alphabeticalIndex: string + constructor( + labelId: string, + iconId: string, + index: number, + accessTokenId: number, + permission: string, + alphabeticalIndex: string) { + this.labelId = labelId + this.iconId = iconId + this.index = index + this.accessTokenId = accessTokenId + this.permission = permission + this.alphabeticalIndex = alphabeticalIndex + } +} // application information + +@Entry +@Component +struct locationInfoPage { + build() { + GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { + Row() { + Row() + .useSizeType({ + xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, + sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, + md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, + lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() { + Column() { + Row() { + backBar({ title: JSON.stringify(backTitle), recordable: false }) + } + Row() { + Column() { + applicationItem() + + }.width(Constants.FULL_WIDTH) + } + .layoutWeight(Constants.LAYOUT_WEIGHT) + } + } + .useSizeType({ + xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, + sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, + md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, + lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() + .useSizeType({ + xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, + sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, + md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, + lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + } + .height(Constants.FULL_HEIGHT) + .width(Constants.FULL_WIDTH) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .opacity(Constants.MANAGEMENT_TRANSPARENCY) + } + } +} + +@Component +struct applicationItem { + @State permissionNum: number = Constants.PERMISSION_NUM; // permission num + @State toggleIsOn: object = {}; // toggle switch state array + @State applicationList: ApplicationObj[] = []; // application info array + @State oldApplicationItem: ApplicationObj[] = []; // Original application information array + @State searchResult: boolean = true; // search results + @State placeholder: string = '' + + authorizeDialogController: CustomDialogController = new CustomDialogController({ + builder: authorizeDialog({ }), + autoCancel: true, + alignment: DialogAlignment.Center + }); + + @Builder ListItemLayout(item, index) { + ListItem() { + Row() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Image(item.iconId) + .customizeImage(Constants.AUTHORITY_IMAGE_WIDTH, Constants.AUTHORITY_IMAGE_HEIGHT) + .margin({ right: Constants.AUTHORITY_IMAGE_MARGIN_RIGHT }) + Text(item.labelId) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.label_color')) + .flexGrow(Constants.FLEX_GROW) + Toggle({ type: ToggleType.Switch, isOn: this.toggleIsOn[item.index] }) + .selectedColor($r('app.color.toggle_color')) + .width(Constants.AUTHORITY_TOGGLE_WIDTH) + .height(Constants.AUTHORITY_TOGGLE_HEIGHT) + .onChange((isOn: boolean) => { + if (item.accessTokenId === '' || item.permission === '') { + return; + } + if (isOn) { + this.grantUserGrantedPermission(item.accessTokenId, item.permission, item.index); + } else { + this.revokeUserGrantedPermission(item.accessTokenId, item.permission, item.index); + } + }) + } + .width(Constants.FULL_WIDTH) + .height(Constants.AUTHORITY_ROW_HEIGHT) + .constraintSize({ minHeight: Constants.AUTHORITY_CONSTRAINTSIZE_MINHEIGHT }) + } + if (!index) { + Row() { + Flex() { + Column().width(Constants.APPLICATION_TEXT_DECORATION_MARGIN_LEFT) + Column() + .backgroundColor($r('app.color.text_decoration_color')) + .height(Constants.TEXT_DECORATION_HEIGHT) + .flexGrow(Constants.FLEX_GROW) + } + } + } + }.onClick(() => { + }) + } + }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) + } + + /** + * Grant permissions to the app + * @param {Number} accessTokenId + * @param {String} permission permission name + * @param {Number} index Array index to modify permission status + */ + grantUserGrantedPermission(accessTokenId, permission, index) { + abilityAccessCtrl.createAtManager().grantUserGrantedPermission( + accessTokenId, permission, Constants.PERMISSION_FLAG).then(result => { + // result: 0 Authorization succeeded; result: -1 Authorization failed + if (result !== Constants.PERMISSION_INDEX) { + this.authorizeDialogController.open(); + this.toggleIsOn[index] = false; + setTimeout(()=> { + this.authorizeDialogController.close(); + }, Constants.DELAY_TIME) + } else { + this.toggleIsOn[index] = true; + } + let num = Constants.PERMISSION_NUM; + for(let key in this.toggleIsOn){ + if(this.toggleIsOn[key]){ + num++; + } + } + this.permissionNum = num; + }).catch(error => { + console.error(TAG + 'abilityAccessCtrl.createAtManager.grantUserGrantedPermission failed. Cause: ' + JSON.stringify(error)); + }) + } + + /** + * Deauthorize the app + * @param {Number} accessTokenId + * @param {String} permission permission name + * @param {Number} index Array index to modify permission status + */ + revokeUserGrantedPermission(accessTokenId, permission, index) { + abilityAccessCtrl.createAtManager().revokeUserGrantedPermission( + accessTokenId, permission, Constants.PERMISSION_FLAG).then(result => { + // result: 0 successfully cancel the authorization; result: -1 cancel the authorization failed + if (result !== Constants.PERMISSION_INDEX) { + this.authorizeDialogController.open(); + this.toggleIsOn[index] = true; + setTimeout(()=> { + this.authorizeDialogController.close(); + }, Constants.DELAY_TIME) + } else { + this.toggleIsOn[index] = false; + } + let num = Constants.PERMISSION_NUM; + for(let key in this.toggleIsOn){ + if(this.toggleIsOn[key]){ + num++; + } + } + this.permissionNum = num; + }) + } + + /** + * Lifecycle function, executed when the page is initialized + */ + aboutToAppear() { + let bundleNames = routerData[0].bundleNames; + + Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { + item.getString($r("app.string.textInput_placeholder").id, (err, val) => { + this.placeholder = val + }) + }) + + // initial then fill values when sync return which may cause sync panic + for (let i = 0; i < bundleNames.length; i++) { + this.applicationList.push( + new ApplicationObj('', '', i, 0, '', '')); + this.oldApplicationItem.push( + new ApplicationObj('', '', i, 0, '', '')); + } + + for (let i = 0; i < bundleNames.length; i++) { + // Get BundleInfo based on bundle name + bundle.getBundleInfo(bundleNames[i], Constants.PARMETER_BUNDLE_FLAG).then(res => { + Promise.all([getAppLabel(res.appInfo.labelId, res.name), + getAppIcon(res.appInfo.iconId, res.name), + verifyAccessToken(res.appInfo.accessTokenId, routerData[0].permission)]) + .then((values) => { + this.applicationList[i] = ( + new ApplicationObj( + String(values[0]), + String(values[1]), + i, + res.appInfo.accessTokenId, + routerData[0].permission, + makePy(values[0])[0].slice(0, 1)) // Get the first letter in the returned initials array + ); + this.oldApplicationItem[i] = ( + new ApplicationObj( + String(values[0]), + String(values[1]), + i, + res.appInfo.accessTokenId, + routerData[0].permission, + makePy(values[0])[0].slice(0, 1)) // Get the first letter in the returned initials array + ); + // 0: have permission; -1: no permission + if (values[2] === Constants.PERMISSION_INDEX) { + this.toggleIsOn[i] = true; + this.permissionNum++; + } else { + this.toggleIsOn[i] = false; + } + }); + }).catch(error => { + console.log(TAG + bundleNames[i] + "getBundleInfo failed, cause: " + JSON.stringify(error)); + }) + } + } + + build() { + Column() { + Row() { + textInput({ + placeholder: this.placeholder, + applicationItem: $applicationList, + oldApplicationItem: $oldApplicationItem, + searchResult: $searchResult + }) + }.padding({ + left: Constants.AUTHORITY_TEXTINPUT_PADDING_LEFT, + right: Constants.AUTHORITY_TEXTINPUT_PADDING_RIGHT + }) + Row() { + Flex({ alignItems:ItemAlign.Start, justifyContent: FlexAlign.Start }) { + Column() { + Flex({ justifyContent: FlexAlign.Start }) { + Text(this.permissionNum + '个应用获取此权限') + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.secondary_font_color')) + .margin({ top: Constants.AUTHORITY_TEXT_MARGIN_TOP, left: Constants.AUTHORITY_TEXT_MARGIN_LEFT }) + } + Scroll() { + Row() { + Column() { + if (!this.applicationList.length) { + if (this.searchResult) { + Row() { + }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) + } else { + Row() { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image($r('app.media.searchnoresult')) + .customizeImage(Constants.SEARCHNORESULT_IMAGE_WIDTH, Constants.SEARCHNORESULT_IMAGE_HEIGHT) + } + }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) + } + } else { + Row() { + List() { + ForEach(this.applicationList.slice(Constants.SLICE_START, this.applicationList.length - 1), + (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX) + }, item => item.toString()) + ForEach(this.applicationList.slice(Constants.SLICE_END), (item, index) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX) + }, item => item.toString()) + } + .backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.margin({ top: Constants.AUTHORITY_ROW_MARGIN_TOP }) + } + }.width(Constants.FULL_WIDTH) + .height(Constants.AUTHORITY_COLUMN_HEIGHT) + } + } + }.padding({ left: Constants.AUTHORITY_LISTITEM_PADDING_LEFT }) + Column() { + alphabetIndexerComponent({ applicationItem: $applicationList, oldApplicationItem: $oldApplicationItem }) + }.width(Constants.AUTHORITY_ALPHABETINDEX_WIDTH) + .padding({ top: Constants.AUTHORITY_ALPHABETINDEX_PADDING_TOP }) + } + } + } + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/dialogPlus.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/dialogPlus.ets index a56068a7223ded5d18965f4530906d85fbd97424..a57f2a437cd248c1e35baac39787570e34404d45 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/dialogPlus.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/dialogPlus.ets @@ -1,344 +1,344 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import bundle from '@ohos.bundle'; -import Resmgr from '@ohos.resourceManager' -import rpc from '@ohos.rpc'; -import { Log, getPermissionGroup } from '../common/utils/utils' -import Constants from '../common/utils/constant' -import { BundleFlag } from '../common/model/bundle' -import { permissionGroups, showSubpermissionsGrop } from '../common/model/permissionGroup' - -@Extend(Button) function customizeButton() { - .backgroundColor($r('app.color.default_background_color')) - .fontColor($r('app.color.button_color')) - .fontWeight(FontWeight.Medium) - .height(Constants.BUTTON_HEIGHT) - .width(Constants.BUTTON_WIDTH) -} - -@Entry -@Component -struct dialogPlusPage { - @State count: number = 0 - @State result: Array = [] - @State accessTokenId: number = 0 - @State initStatus: number = Constants.INIT_NEED_TO_WAIT - @State reqPerms: Array = [] - @State grantGroups: Array = [] - @State userFixedFlag: number = 2 // means user fixed - @State appName: string = "" - @State win: any = "" - @State proxy: any = '' - - build() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Column() { - if ((this.initStatus != Constants.INIT_NEED_TO_WAIT) && this.verify()) { - Image(this.grantGroups[this.count].icon) - .width(Constants.DIALOG_ICON_WIDTH) - .height(Constants.DIALOG_ICON_HEIGHT) - .fillColor($r("app.color.first_font_color")) - .margin({ - top: Constants.DIALOG_ICON_MARGIN_TOP - }) - Text(`${this.count + 1} / ${this.grantGroups.length}`) - .fontSize(Constants.DIALOG_LABEL_FONT_SIZE) - .fontColor($r('app.color.text_secondary_color')) - .lineHeight(Constants.DIALOG_LABEL_LINE_HEIGHT) - .margin({ - top: Constants.DIALOG_LABEL_MARGIN_TOP - }) - Column() { - Row() { - Flex({ justifyContent: FlexAlign.Start }) { - Text("是否允许" + this.appName + - this.grantGroups[this.count].label) - .fontSize(Constants.DIALOG_REQ_FONT_SIZE) - .fontColor($r('app.color.first_font_color')) - .fontWeight(FontWeight.Medium) - .fontSize(Constants.DIALOG_REQ_FONT_SIZE) - .lineHeight(Constants.DIALOG_REQ_LINE_HEIGHT) - .margin({ - top: Constants.DIALOG_REQ_MARGIN_TOP, - left: Constants.DIALOG_REQ_MARGIN_LEFT - }) - } - } - - Row() { - Flex({ justifyContent: FlexAlign.Start }) { - Text(this.grantGroups[this.count].description) - .fontSize(Constants.DIALOG_DESP_FONT_SIZE) - .fontColor($r('app.color.text_secondary_color')) - .fontSize(Constants.DIALOG_DESP_FONT_SIZE) - .lineHeight(Constants.DIALOG_DESP_LINE_HEIGHT) - .margin({ - top: Constants.DIALOG_DESP_MARGIN_TOP, - left: Constants.DIALOG_DESP_MARGIN_LEFT, - right: Constants.DIALOG_DESP_MARGIN_RIGHT, - bottom: Constants.DIALOG_DESP_MARGIN_BOTTOM - }) - } - } - } - } - Row() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { - Button('禁止') - .fontSize(Constants.BUTTON_FONT_SIZE) - .onClick(() => { - this.privacyCancel(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag) - }).customizeButton().margin({ left: Constants.BUTTON_MARGIN_LEFT }) - Text('|').fontSize(Constants.BUTTON_DIVIDER_FONT_SIZE).fontColor($r('app.color.divider_color')) - Button('允许') - .fontSize(Constants.BUTTON_FONT_SIZE) - .onClick(() => { - this.privacyAccept(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag) - }).customizeButton().margin({ right: Constants.BUTTON_MARGIN_RIGHT }) - } - } - } - .backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.DIALOG_PRIVACY_BORDER_RADIUS) - .width(Constants.DIALOG_PRIVACY_WIDTH) - .padding({ bottom: Constants.DIALOG_PADDING_BOTTOM }) - }.width(Constants.FULL_WIDTH) - .height(Constants.FULL_HEIGHT) - } - - verify() { - if((this.initStatus == Constants.INIT_NEED_TO_TERMINATED) || (this.count >= this.grantGroups.length)) { - this.answerRequest() - this.initStatus = Constants.INIT_NEED_TO_WAIT - return false - } - return true - } - - answerRequest() { - var ret: number = Constants.RESULT_SUCCESS - if (this.initStatus == Constants.INIT_NEED_TO_TERMINATED) { - ret = Constants.RESULT_FAILURE - } - this.answer(ret, this.reqPerms) - } - - answer(ret, reqPerms) { - Log.info("code:" + ret + ", perms="+ JSON.stringify(reqPerms) +", result=" + JSON.stringify(this.result)) - var perms = [] - var results = [] - reqPerms.forEach(perm => { - perms.push(perm) - }) - this.result.forEach(result => { - results.push(result) - }) - let option = new rpc.MessageOption() - let data = new rpc.MessageParcel() - let reply = new rpc.MessageParcel() - Promise.all([data.writeInterfaceToken(Constants.ACCESS_TOKEN), - data.writeStringArray(perms), - data.writeIntArray(results) - ]).then(() => { - this.proxy.sendRequest(Constants.RESULT_CODE, data, reply, option) - this.destruction() - }).catch(() => { - Log.error('write result failed!') - this.destruction() - }) - } - - destruction() { - this.win.destroy() - globalThis.windowNum -- - Log.info("windowNum:" + globalThis.windowNum) - if(globalThis.windowNum == 0) { - globalThis.extensionContext.terminateSelf() - } - } - - async privacyAccept(group, accessTokenId, permissionList, userFixedFlag) { - var acManager = abilityAccessCtrl.createAtManager() - var num = 0 - group.permissions.forEach(async permission => { - let result - if(showSubpermissionsGrop.indexOf(group.groupName) == -1) { - result = await acManager.grantUserGrantedPermission(accessTokenId, permission, userFixedFlag) - }else { - if(permissionList.includes(permission)) { - result = await acManager.grantUserGrantedPermission(accessTokenId, permission, userFixedFlag) - } - } - num ++ - Log.info("grant permission result:" + result + "permission" + permission) - if (result == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { - permissionList.forEach((req, idx) => { - if(req == permission) { - this.result[idx] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; - } - }) - Log.info("grant permission success:" + permission) - } else { - Log.error("failed to grant permission:" + permission + " ret:" + result) - } - if(num == group.permissions.length) { - this.count ++ - } - }) - } - - async privacyCancel(group, accessTokenId, permissionList, userFixedFlag) { - var acManager = abilityAccessCtrl.createAtManager() - group.permissions.forEach(async permission => { - let result - if(showSubpermissionsGrop.indexOf(group.groupName) == -1) { - result = await acManager.revokeUserGrantedPermission(accessTokenId, permission, userFixedFlag) - }else { - if(permissionList.includes(permission)) { - result = await acManager.revokeUserGrantedPermission(accessTokenId, permission, userFixedFlag) - } - } - Log.info("revoke permission result:" + result + "permission" + permission); - }) - this.count ++ - } - - getgrantGroups(stateGroup) { - this.reqPerms.forEach((permission, idx) => { - //已授权 - if(stateGroup[idx] == Constants.PASS_OPER) { - Log.info("permission has been fixed:" + permission) - this.result[idx] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; - //待授权 - }else if(stateGroup[idx] == Constants.DYNAMIC_OPER) { - var group = getPermissionGroup(permission) - if(!group) { - Log.info("permission not find:" + permission) - }else { - var exist = this.grantGroups.find(grantGroup => grantGroup.name == group.name) - //判断是否为需要展示子权限的权限组 - if(showSubpermissionsGrop.indexOf(group.groupName) != -1) { - var permissionDetail - permissionGroups.forEach(permissionGroup => { - if(permissionGroup.permissionName == permission) { - //获取授权的权限信息 - permissionDetail = permissionGroup - } - }) - //权限组已存在的情况 - if(!exist) { - group.description = [permissionDetail.label] - this.grantGroups.push(group) - }else { - if(exist.description.indexOf(permissionDetail.label) == -1) { - exist.description.push(permissionDetail.label) - } - } - }else { - if(!exist) { - this.grantGroups.push(group) - } - } - } - } - }) - this.initStatus = Constants.INIT_NEED_TO_VERIFY - } - - getApplicationName(uid) { - bundle.getNameForUid(uid).then((data) => { - Log.info("getApplicationName bundleName:" + data) - Log.info("getApplicationName userId:" + Math.floor(uid/200000)) - bundle.getApplicationInfo(data, BundleFlag.GET_BUNDLE_DEFAULT, Math.floor(uid/200000)).then(applicationInfo => { - Resmgr.getResourceManager(globalThis.extensionContext, data).then(item => { - item.getString(applicationInfo.labelId, (err, value) => { - if (value == undefined) { - this.appName = applicationInfo.label - } else { - this.appName = value - } - Log.info("hap label:" + applicationInfo.label + ", value:"+this.appName) - }) - }) - }).catch(err => { - Log.error("applicationInfo error :" + err) - this.initStatus = Constants.INIT_NEED_TO_TERMINATED - }) - bundle.getBundleInfo(data, Constants.PARMETER_BUNDLE_FLAG).then(bundleInfo => { - this.grantGroups.forEach((group, idx) => { - if(group.description) { - Resmgr.getResourceManager(globalThis.extensionContext, Constants.BUNDLE_NAME).then(item => { - Promise.all([item.getString($r("app.string.separator").id), - item.getString($r("app.string.reason_suffix").id)]) - .then(values => { - group.description = group.description.join(values[0]) - group.description += values[1] - this.getReason(group, bundleInfo, data) - }) - }) - }else { - this.getReason(group, bundleInfo, data) - } - }) - }) - }).catch(err => { - Log.error("getNameForUid error :" + JSON.stringify(err)) - this.initStatus = Constants.INIT_NEED_TO_TERMINATED - }) - } - - getReason(group, bundleInfo, bundleName) { - group.permissions.forEach(permission => { - if(this.reqPerms.indexOf(permission) != -1) { - bundleInfo.reqPermissionDetails.forEach(reqPermissionDetail => { - if(reqPermissionDetail.name == permission) { - Resmgr.getResourceManager(globalThis.extensionContext, bundleName).then(item => { - item.getString(reqPermissionDetail.reasonId, (err, value) => { - this.initStatus = Constants.INIT_NEED_TO_REFRESH - if (value !== undefined && !group.hasReason) { - group.description += value.slice(Constants.START_SUBSCRIPT, Constants.END_SUBSCRIPT) - group.hasReason = true - } - }) - }) - } - }) - } - }) - } - - aboutToAppear() { - this.count = 0; - this.initStatus = Constants.INIT_NEED_TO_WAIT - this.result = [] - this.reqPerms = globalThis.abilityWant.parameters['ohos.user.grant.permission'] - this.accessTokenId = globalThis.abilityWant.parameters['ohos.aafwk.param.callerToken'] - this.proxy = globalThis.abilityWant.parameters['ohos.ability.params.callback'].value - this.win = globalThis.extensionWin - if (this.reqPerms == undefined || this.accessTokenId == undefined || this.reqPerms.length == 0) { - Log.info("invalid parameters") - this.initStatus = Constants.INIT_NEED_TO_TERMINATED - return - } - Log.info("request permission=" + JSON.stringify(this.reqPerms) + ", tokenId = " + this.accessTokenId) - Log.info("permission state=" + JSON.stringify(globalThis.abilityWant.parameters['ohos.user.grant.permission.state'])); - this.result = new Array(this.reqPerms.length).fill(-1); - this.getgrantGroups(globalThis.abilityWant.parameters['ohos.user.grant.permission.state']); - this.getApplicationName(globalThis.abilityWant.parameters['ohos.aafwk.param.callerUid']) - } -} - +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import bundle from '@ohos.bundle'; +import Resmgr from '@ohos.resourceManager' +import rpc from '@ohos.rpc'; +import { Log, getPermissionGroup } from '../common/utils/utils' +import Constants from '../common/utils/constant' +import { BundleFlag } from '../common/model/bundle' +import { permissionGroups, showSubpermissionsGrop } from '../common/model/permissionGroup' + +@Extend(Button) function customizeButton() { + .backgroundColor($r('app.color.default_background_color')) + .fontColor($r('app.color.button_color')) + .fontWeight(FontWeight.Medium) + .height(Constants.BUTTON_HEIGHT) + .width(Constants.BUTTON_WIDTH) +} + +@Entry +@Component +struct dialogPlusPage { + @State count: number = 0 + @State result: Array = [] + @State accessTokenId: number = 0 + @State initStatus: number = Constants.INIT_NEED_TO_WAIT + @State reqPerms: Array = [] + @State grantGroups: Array = [] + @State userFixedFlag: number = 2 // means user fixed + @State appName: string = "" + @State win: any = "" + @State proxy: any = '' + + build() { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Column() { + if ((this.initStatus != Constants.INIT_NEED_TO_WAIT) && this.verify()) { + Image(this.grantGroups[this.count].icon) + .width(Constants.DIALOG_ICON_WIDTH) + .height(Constants.DIALOG_ICON_HEIGHT) + .fillColor($r("app.color.first_font_color")) + .margin({ + top: Constants.DIALOG_ICON_MARGIN_TOP + }) + Text(`${this.count + 1} / ${this.grantGroups.length}`) + .fontSize(Constants.DIALOG_LABEL_FONT_SIZE) + .fontColor($r('app.color.text_secondary_color')) + .lineHeight(Constants.DIALOG_LABEL_LINE_HEIGHT) + .margin({ + top: Constants.DIALOG_LABEL_MARGIN_TOP + }) + Column() { + Row() { + Flex({ justifyContent: FlexAlign.Start }) { + Text("是否允许" + this.appName + + this.grantGroups[this.count].label) + .fontSize(Constants.DIALOG_REQ_FONT_SIZE) + .fontColor($r('app.color.first_font_color')) + .fontWeight(FontWeight.Medium) + .fontSize(Constants.DIALOG_REQ_FONT_SIZE) + .lineHeight(Constants.DIALOG_REQ_LINE_HEIGHT) + .margin({ + top: Constants.DIALOG_REQ_MARGIN_TOP, + left: Constants.DIALOG_REQ_MARGIN_LEFT + }) + } + } + + Row() { + Flex({ justifyContent: FlexAlign.Start }) { + Text(this.grantGroups[this.count].description) + .fontSize(Constants.DIALOG_DESP_FONT_SIZE) + .fontColor($r('app.color.text_secondary_color')) + .fontSize(Constants.DIALOG_DESP_FONT_SIZE) + .lineHeight(Constants.DIALOG_DESP_LINE_HEIGHT) + .margin({ + top: Constants.DIALOG_DESP_MARGIN_TOP, + left: Constants.DIALOG_DESP_MARGIN_LEFT, + right: Constants.DIALOG_DESP_MARGIN_RIGHT, + bottom: Constants.DIALOG_DESP_MARGIN_BOTTOM + }) + } + } + } + } + Row() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Button('禁止') + .fontSize(Constants.BUTTON_FONT_SIZE) + .onClick(() => { + this.privacyCancel(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag) + }).customizeButton().margin({ left: Constants.BUTTON_MARGIN_LEFT }) + Text('|').fontSize(Constants.BUTTON_DIVIDER_FONT_SIZE).fontColor($r('app.color.divider_color')) + Button('允许') + .fontSize(Constants.BUTTON_FONT_SIZE) + .onClick(() => { + this.privacyAccept(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag) + }).customizeButton().margin({ right: Constants.BUTTON_MARGIN_RIGHT }) + } + } + } + .backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.DIALOG_PRIVACY_BORDER_RADIUS) + .width(Constants.DIALOG_PRIVACY_WIDTH) + .padding({ bottom: Constants.DIALOG_PADDING_BOTTOM }) + }.width(Constants.FULL_WIDTH) + .height(Constants.FULL_HEIGHT) + } + + verify() { + if((this.initStatus == Constants.INIT_NEED_TO_TERMINATED) || (this.count >= this.grantGroups.length)) { + this.answerRequest() + this.initStatus = Constants.INIT_NEED_TO_WAIT + return false + } + return true + } + + answerRequest() { + var ret: number = Constants.RESULT_SUCCESS + if (this.initStatus == Constants.INIT_NEED_TO_TERMINATED) { + ret = Constants.RESULT_FAILURE + } + this.answer(ret, this.reqPerms) + } + + answer(ret, reqPerms) { + Log.info("code:" + ret + ", perms="+ JSON.stringify(reqPerms) +", result=" + JSON.stringify(this.result)) + var perms = [] + var results = [] + reqPerms.forEach(perm => { + perms.push(perm) + }) + this.result.forEach(result => { + results.push(result) + }) + let option = new rpc.MessageOption() + let data = new rpc.MessageParcel() + let reply = new rpc.MessageParcel() + Promise.all([data.writeInterfaceToken(Constants.ACCESS_TOKEN), + data.writeStringArray(perms), + data.writeIntArray(results) + ]).then(() => { + this.proxy.sendRequest(Constants.RESULT_CODE, data, reply, option) + this.destruction() + }).catch(() => { + Log.error('write result failed!') + this.destruction() + }) + } + + destruction() { + this.win.destroy() + globalThis.windowNum -- + Log.info("windowNum:" + globalThis.windowNum) + if(globalThis.windowNum == 0) { + globalThis.extensionContext.terminateSelf() + } + } + + async privacyAccept(group, accessTokenId, permissionList, userFixedFlag) { + var acManager = abilityAccessCtrl.createAtManager() + var num = 0 + group.permissions.forEach(async permission => { + let result + if(showSubpermissionsGrop.indexOf(group.groupName) == -1) { + result = await acManager.grantUserGrantedPermission(accessTokenId, permission, userFixedFlag) + }else { + if(permissionList.includes(permission)) { + result = await acManager.grantUserGrantedPermission(accessTokenId, permission, userFixedFlag) + } + } + num ++ + Log.info("grant permission result:" + result + "permission" + permission) + if (result == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { + permissionList.forEach((req, idx) => { + if(req == permission) { + this.result[idx] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; + } + }) + Log.info("grant permission success:" + permission) + } else { + Log.error("failed to grant permission:" + permission + " ret:" + result) + } + if(num == group.permissions.length) { + this.count ++ + } + }) + } + + async privacyCancel(group, accessTokenId, permissionList, userFixedFlag) { + var acManager = abilityAccessCtrl.createAtManager() + group.permissions.forEach(async permission => { + let result + if(showSubpermissionsGrop.indexOf(group.groupName) == -1) { + result = await acManager.revokeUserGrantedPermission(accessTokenId, permission, userFixedFlag) + }else { + if(permissionList.includes(permission)) { + result = await acManager.revokeUserGrantedPermission(accessTokenId, permission, userFixedFlag) + } + } + Log.info("revoke permission result:" + result + "permission" + permission); + }) + this.count ++ + } + + getgrantGroups(stateGroup) { + this.reqPerms.forEach((permission, idx) => { + //已授权 + if(stateGroup[idx] == Constants.PASS_OPER) { + Log.info("permission has been fixed:" + permission) + this.result[idx] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; + //待授权 + }else if(stateGroup[idx] == Constants.DYNAMIC_OPER) { + var group = getPermissionGroup(permission) + if(!group) { + Log.info("permission not find:" + permission) + }else { + var exist = this.grantGroups.find(grantGroup => grantGroup.name == group.name) + //判断是否为需要展示子权限的权限组 + if(showSubpermissionsGrop.indexOf(group.groupName) != -1) { + var permissionDetail + permissionGroups.forEach(permissionGroup => { + if(permissionGroup.permissionName == permission) { + //获取授权的权限信息 + permissionDetail = permissionGroup + } + }) + //权限组已存在的情况 + if(!exist) { + group.description = [permissionDetail.label] + this.grantGroups.push(group) + }else { + if(exist.description.indexOf(permissionDetail.label) == -1) { + exist.description.push(permissionDetail.label) + } + } + }else { + if(!exist) { + this.grantGroups.push(group) + } + } + } + } + }) + this.initStatus = Constants.INIT_NEED_TO_VERIFY + } + + getApplicationName(uid) { + bundle.getNameForUid(uid).then((data) => { + Log.info("getApplicationName bundleName:" + data) + Log.info("getApplicationName userId:" + Math.floor(uid/200000)) + bundle.getApplicationInfo(data, BundleFlag.GET_BUNDLE_DEFAULT, Math.floor(uid/200000)).then(applicationInfo => { + Resmgr.getResourceManager(globalThis.extensionContext, data).then(item => { + item.getString(applicationInfo.labelId, (err, value) => { + if (value == undefined) { + this.appName = applicationInfo.label + } else { + this.appName = value + } + Log.info("hap label:" + applicationInfo.label + ", value:"+this.appName) + }) + }) + }).catch(err => { + Log.error("applicationInfo error :" + err) + this.initStatus = Constants.INIT_NEED_TO_TERMINATED + }) + bundle.getBundleInfo(data, Constants.PARMETER_BUNDLE_FLAG).then(bundleInfo => { + this.grantGroups.forEach((group, idx) => { + if(group.description) { + Resmgr.getResourceManager(globalThis.extensionContext, Constants.BUNDLE_NAME).then(item => { + Promise.all([item.getString($r("app.string.separator").id), + item.getString($r("app.string.reason_suffix").id)]) + .then(values => { + group.description = group.description.join(values[0]) + group.description += values[1] + this.getReason(group, bundleInfo, data) + }) + }) + }else { + this.getReason(group, bundleInfo, data) + } + }) + }) + }).catch(err => { + Log.error("getNameForUid error :" + JSON.stringify(err)) + this.initStatus = Constants.INIT_NEED_TO_TERMINATED + }) + } + + getReason(group, bundleInfo, bundleName) { + group.permissions.forEach(permission => { + if(this.reqPerms.indexOf(permission) != -1) { + bundleInfo.reqPermissionDetails.forEach(reqPermissionDetail => { + if(reqPermissionDetail.name == permission) { + Resmgr.getResourceManager(globalThis.extensionContext, bundleName).then(item => { + item.getString(reqPermissionDetail.reasonId, (err, value) => { + this.initStatus = Constants.INIT_NEED_TO_REFRESH + if (value !== undefined && !group.hasReason) { + group.description += value.slice(Constants.START_SUBSCRIPT, Constants.END_SUBSCRIPT) + group.hasReason = true + } + }) + }) + } + }) + } + }) + } + + aboutToAppear() { + this.count = 0; + this.initStatus = Constants.INIT_NEED_TO_WAIT + this.result = [] + this.reqPerms = globalThis.abilityWant.parameters['ohos.user.grant.permission'] + this.accessTokenId = globalThis.abilityWant.parameters['ohos.aafwk.param.callerToken'] + this.proxy = globalThis.abilityWant.parameters['ohos.ability.params.callback'].value + this.win = globalThis.extensionWin + if (this.reqPerms == undefined || this.accessTokenId == undefined || this.reqPerms.length == 0) { + Log.info("invalid parameters") + this.initStatus = Constants.INIT_NEED_TO_TERMINATED + return + } + Log.info("request permission=" + JSON.stringify(this.reqPerms) + ", tokenId = " + this.accessTokenId) + Log.info("permission state=" + JSON.stringify(globalThis.abilityWant.parameters['ohos.user.grant.permission.state'])); + this.result = new Array(this.reqPerms.length).fill(-1); + this.getgrantGroups(globalThis.abilityWant.parameters['ohos.user.grant.permission.state']); + this.getApplicationName(globalThis.abilityWant.parameters['ohos.aafwk.param.callerUid']) + } +} + diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/other-permissions.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/other-permissions.ets index 1de45de538c1eb26f07fc85971a161bbaf78d65c..3dca02a1f68eda1c8e34066914d93fc1c6a13c99 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/other-permissions.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/other-permissions.ets @@ -1,170 +1,170 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { backBar } from "../common/components/backBar"; -import router from '@system.router'; -import Constants from '../common/utils/constant'; -import { otherPermissionsLabel } from '../common/model/permissionGroup' -import abilityAccessCtrl from '@ohos.abilityAccessCtrl' - -var TAG = 'PermissionManager_MainAbility:' - -let routerData = router.getParams().routerData; // Routing jump data -let tokenId: any = router.getParams().tokenId; // tokenId for verify permission -let backTitle = router.getParams().backTitle; // return title name -let status = router.getParams().status; // Status: Allowed, Forbidden -let permissions: any = router.getParams().permission; // permissions name -let otherPermissionList = []; // otherPermission List -for (let i = 0; i < permissions.length; i++) { - otherPermissionList.push({ - permissionLabel: otherPermissionsLabel[permissions[i]], - permission: permissions[i] - }) -} - -@Entry -@Component -struct appNamePage { - build() { - GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { - Row() { - Row() - .useSizeType({ - xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, - sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, - md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, - lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() { - Column() { - Row() { - backBar({ title: JSON.stringify(backTitle), recordable: false }) - } - Row() { - Column() { - Scroll() { - appNameItem() - } - } - }.layoutWeight(Constants.LAYOUT_WEIGHT) - } - } - .useSizeType({ - xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, - sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, - md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, - lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() - .useSizeType({ - xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, - sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, - md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, - lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - } - .height(Constants.FULL_HEIGHT) - .width(Constants.FULL_WIDTH) - .backgroundColor($r("sys.color.ohos_id_color_sub_background")) - .opacity(Constants.MANAGEMENT_TRANSPARENCY) - } - } - -/** - * Lifecycle function, triggered once when this page is displayed - */ - onPageShow() { - console.log(TAG + 'onPageShow other-permissions') - let isGranted = true; - permissions.forEach(permission => { - abilityAccessCtrl.createAtManager().verifyAccessToken(tokenId, permission).then(res => { - status = res; - }) - .catch(err => { - console.error(TAG + 'verifyAccessToken occure error: ' + JSON.stringify(err)) - }) - }) - } -} - -@Component -struct appNameItem { - @State otherPermissionListItem: string[] = otherPermissionList; // Other permission interface data array - @Builder ListItemLayout(item, index) { - ListItem() { - Row() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - Text(item.permissionLabel) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontColor($r('app.color.text_color')) - .flexGrow(Constants.FLEX_GROW) - Image($r('app.media.rightarrow')) - .objectFit(ImageFit.Contain) - .height(Constants.IMAGE_HEIGHT) - .width(Constants.IMAGE_WIDTH) - } - .width(Constants.FULL_WIDTH) - .height(Constants.LISTITEM_ROW_HEIGHT) - } - if (!index) { - Row() { - Column() - .backgroundColor($r('app.color.text_decoration_color')) - .width(Constants.FULL_WIDTH) - .height(Constants.TEXT_DECORATION_HEIGHT) - } - } - }.onClick(() => { - router.push({ - uri: 'pages/application-tertiary', - params: { - routerData: routerData, - backTitle: item.permissionLabel, - permission: [item.permission], - status: status - } - }); - }) - } - }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) - } - - build() { - Row() { - Column() { - Row() { - List() { - ForEach(this.otherPermissionListItem.slice(Constants.SLICE_START, this.otherPermissionListItem.length - 1), - (item) => { - this.ListItemLayout(item, Constants.SLICE_START_INDEX) - }, item => item.toString()) - ForEach(this.otherPermissionListItem.slice(Constants.SLICE_END), (item, index) => { - this.ListItemLayout(item, Constants.SLICE_END_INDEX) - }, item => item.toString()) - }.backgroundColor($r('app.color.default_background_color')).borderRadius(Constants.BORDER_RADIUS) - .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.margin({ top: Constants.ROW_MARGIN_TOP }) - .padding({ left: Constants.LIST_PADDING_LEFT, right: Constants.LISTITEM_PADDING_RIGHT }) - } - .width(Constants.FULL_WIDTH) - .height(Constants.FULL_HEIGHT) - } - } -} +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { backBar } from "../common/components/backBar"; +import router from '@system.router'; +import Constants from '../common/utils/constant'; +import { otherPermissionsLabel } from '../common/model/permissionGroup' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' + +var TAG = 'PermissionManager_MainAbility:' + +let routerData = router.getParams().routerData; // Routing jump data +let tokenId: any = router.getParams().tokenId; // tokenId for verify permission +let backTitle = router.getParams().backTitle; // return title name +let status = router.getParams().status; // Status: Allowed, Forbidden +let permissions: any = router.getParams().permission; // permissions name +let otherPermissionList = []; // otherPermission List +for (let i = 0; i < permissions.length; i++) { + otherPermissionList.push({ + permissionLabel: otherPermissionsLabel[permissions[i]], + permission: permissions[i] + }) +} + +@Entry +@Component +struct appNamePage { + build() { + GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { + Row() { + Row() + .useSizeType({ + xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, + sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, + md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, + lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() { + Column() { + Row() { + backBar({ title: JSON.stringify(backTitle), recordable: false }) + } + Row() { + Column() { + Scroll() { + appNameItem() + } + } + }.layoutWeight(Constants.LAYOUT_WEIGHT) + } + } + .useSizeType({ + xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, + sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, + md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, + lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() + .useSizeType({ + xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, + sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, + md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, + lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + } + .height(Constants.FULL_HEIGHT) + .width(Constants.FULL_WIDTH) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .opacity(Constants.MANAGEMENT_TRANSPARENCY) + } + } + +/** + * Lifecycle function, triggered once when this page is displayed + */ + onPageShow() { + console.log(TAG + 'onPageShow other-permissions') + let isGranted = true; + permissions.forEach(permission => { + abilityAccessCtrl.createAtManager().verifyAccessToken(tokenId, permission).then(res => { + status = res; + }) + .catch(err => { + console.error(TAG + 'verifyAccessToken occure error: ' + JSON.stringify(err)) + }) + }) + } +} + +@Component +struct appNameItem { + @State otherPermissionListItem: string[] = otherPermissionList; // Other permission interface data array + @Builder ListItemLayout(item, index) { + ListItem() { + Row() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Text(item.permissionLabel) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontColor($r('app.color.text_color')) + .flexGrow(Constants.FLEX_GROW) + Image($r('app.media.rightarrow')) + .objectFit(ImageFit.Contain) + .height(Constants.IMAGE_HEIGHT) + .width(Constants.IMAGE_WIDTH) + } + .width(Constants.FULL_WIDTH) + .height(Constants.LISTITEM_ROW_HEIGHT) + } + if (!index) { + Row() { + Column() + .backgroundColor($r('app.color.text_decoration_color')) + .width(Constants.FULL_WIDTH) + .height(Constants.TEXT_DECORATION_HEIGHT) + } + } + }.onClick(() => { + router.push({ + uri: 'pages/application-tertiary', + params: { + routerData: routerData, + backTitle: item.permissionLabel, + permission: [item.permission], + status: status + } + }); + }) + } + }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END }) + } + + build() { + Row() { + Column() { + Row() { + List() { + ForEach(this.otherPermissionListItem.slice(Constants.SLICE_START, this.otherPermissionListItem.length - 1), + (item) => { + this.ListItemLayout(item, Constants.SLICE_START_INDEX) + }, item => item.toString()) + ForEach(this.otherPermissionListItem.slice(Constants.SLICE_END), (item, index) => { + this.ListItemLayout(item, Constants.SLICE_END_INDEX) + }, item => item.toString()) + }.backgroundColor($r('app.color.default_background_color')).borderRadius(Constants.BORDER_RADIUS) + .padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.margin({ top: Constants.ROW_MARGIN_TOP }) + .padding({ left: Constants.LIST_PADDING_LEFT, right: Constants.LISTITEM_PADDING_RIGHT }) + } + .width(Constants.FULL_WIDTH) + .height(Constants.FULL_HEIGHT) + } + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/permission-access-record.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/permission-access-record.ets index 529f738d3dedfe370b02364f40be1945fade07de..1430122fe084ef1f891f96e5501181329f696b05 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/permission-access-record.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/pages/permission-access-record.ets @@ -1,533 +1,533 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import bundle from '@ohos.bundle'; -import router from '@system.router'; -import Resmgr from '@ohos.resourceManager' -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import privacyManager from '@ohos.privacyManager' -import { backBar } from "../common/components/backBar"; -import Constants from '../common/utils/constant'; -import { noNeedDisplayApp, userGrantPermissions, permissionGroupIds } from "../common/model/permissionGroup"; -import { getPermissionGroup } from '../common/utils/utils' - -var TAG = 'PermissionManager_MainAbility:' - -@Extend(Image) function customizeImage(width: number, height: number) { - .objectFit(ImageFit.Contain) - .width(width) - .height(height) -}; - -@Entry -@Component -struct permissionRecordPage { - @State groups: any[] = [] - @State applicationInfos: any[] = [] - @State permissionApplications: any[] = [] - @State permissionIndex: number = -1 - @State applicationIndex: number = -1 - @State strings: any = {} - @State currentIndex: number = 0 - @Builder TabBuilder(index: number) { - Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(index ? $r('app.string.application') : $r('app.string.authority')) - .fontColor(this.currentIndex == index ? $r('app.color.button_color') : $r('app.color.label_color')) - .fontWeight(this.currentIndex == index ? FontWeight.Bold : FontWeight.Regular) - .lineHeight(Constants.TEXT_LINE_HEIGHT) - if(this.currentIndex == index) { - Row().width(Constants.FULL_WIDTH).height(Constants.TAB_DECORATION_HEIGHT) - .backgroundColor($r('app.color.button_color')) - .position({ y: Constants.TAB_DECORATION_POSITION_Y }) - } - }.height(Constants.TAB_HEIGHT) - } - - @Builder ListItemLayout(item, index, dimension) { - ListItem() { - Column() { - Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Row() { - if(dimension) { - Image(item.icon) - .customizeImage(Constants.MANAGEMENT_IMAGE_WIDTH, Constants.MANAGEMENT_IMAGE_HEIGHT) - .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT_RECORD, left: Constants.MANAGEMENT_IMAGE_MARGIN_LEFT }) - }else { - Image(item.icon) - .customizeImage(Constants.APPLICATION_IMAGE_WIDTH, Constants.APPLICATION_IMAGE_HEIGHT) - .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT }) - } - Column() { - Text(item.groupName) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontWeight(FontWeight.Medium) - .fontColor($r('app.color.label_color')) - .lineHeight(Constants.TEXT_LINE_HEIGHT) - .margin({ bottom: Constants.TERTIARY_LABEL_MARGIN_BOTTOM }) - if(dimension) { - Text(this.strings.visits + item.sum) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .lineHeight(Constants.TEXT_SMALL_LINE_HEIGHT) - }else { - Row() { - if (item.permissions) { - ForEach(item.permissions, permission => { - Image(permission.icon) - .customizeImage(Constants.IMAGE_WIDTH_RECORD_APPLICATION, Constants.IMAGE_HEIGHT_RECORD_APPLICATION) - .margin({ right: Constants.APPLICATION_TEXT_MARGIN_RIGHT }) - }) - } - } - } - }.flexGrow(Constants.FLEX_GROW) - .alignItems(HorizontalAlign.Start) - if(dimension) { - if(index == this.permissionIndex) { - Image($r('app.media.xiangshangjiantou')) - .customizeImage(Constants.IMAGE_WIDTH_RECORD, Constants.IMAGE_HEIGHT_RECORD) - }else { - Image($r('app.media.xiangxiajiantou')) - .customizeImage(Constants.IMAGE_WIDTH_RECORD, Constants.IMAGE_HEIGHT_RECORD) - } - }else { - if(index == this.applicationIndex) { - Image($r('app.media.xiangshangjiantou')) - .customizeImage(Constants.IMAGE_WIDTH_RECORD, Constants.IMAGE_HEIGHT_RECORD) - }else { - Image($r('app.media.xiangxiajiantou')) - .customizeImage(Constants.IMAGE_WIDTH_RECORD, Constants.IMAGE_HEIGHT_RECORD) - } - } - } - .width(Constants.FULL_WIDTH) - .height(dimension ? Constants.LISTITEM_HEIGHT_PERMISSION : Constants.LISTITEM_HEIGHT_APPLICATION) - } - }.onClick(() => { - dimension ? - (this.permissionIndex = this.permissionIndex == index ? -1 : index) : - (this.applicationIndex = this.applicationIndex == index ? -1 : index) - if(dimension) { - this.permissionApplications = this.applicationInfos.filter(appInfo => { - return appInfo.groupNames.includes(item.groupName) - }) - } - }) - if(dimension && (index == this.permissionIndex)) { - List() { - ForEach(this.permissionApplications, (permissionApplication) => { - ListItem() { - Row() { - Image(permissionApplication.icon) - .customizeImage(Constants.APPLICATION_IMAGE_WIDTH, Constants.APPLICATION_IMAGE_HEIGHT) - .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT }) - Column() { - Row().width(Constants.FULL_WIDTH).height(Constants.TEXT_DECORATION_HEIGHT) - .backgroundColor($r("app.color.label_color_lightest")) - .margin({ bottom: Constants.LISTITEM_MARGIN_BOTTOM_PERMISSION }) - Text(permissionApplication.groupName) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontWeight(FontWeight.Medium) - .fontColor($r('app.color.label_color')) - .lineHeight(Constants.TEXT_LINE_HEIGHT) - .margin({ bottom: Constants.TERTIARY_LABEL_MARGIN_BOTTOM }) - Text(this.strings.visits + this.getAppRecords(permissionApplication, item.groupName, true) + - this.strings.recent_visit + this.getTime(this.getAppRecords(permissionApplication, item.groupName, false))) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .lineHeight(Constants.TEXT_SMALL_LINE_HEIGHT) - }.alignItems(HorizontalAlign.Start) - .height(Constants.FULL_HEIGHT) - } - }.height(Constants.LISTITEM_HEIGHT_APPLICATION) - .onClick(() => { - router.push({ - uri: 'pages/application-secondary', - params: { routerData: { - 'bundleName': permissionApplication.name, - 'tokenId': permissionApplication.accessTokenId, - 'iconId': permissionApplication.icon, - 'labelId': permissionApplication.groupName, - 'permissions': permissionApplication.reqUserPermissions, - 'groupId': permissionApplication.groupIds - } } - }); - }) - }) - } - } - if(!dimension && (index == this.applicationIndex)) { - List() { - ForEach(item.permissions, (permission) => { - ListItem() { - Row() { - Image(permission.icon) - .customizeImage(Constants.MANAGEMENT_IMAGE_WIDTH, Constants.MANAGEMENT_IMAGE_HEIGHT) - .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT_RECORD, left: Constants.MANAGEMENT_IMAGE_MARGIN_LEFT }) - Column() { - Row().width(Constants.FULL_WIDTH).height(Constants.TEXT_DECORATION_HEIGHT) - .backgroundColor($r("app.color.label_color_lightest")) - .margin({ bottom: Constants.LISTITEM_MARGIN_BOTTOM_APPLICATION }) - Text(permission.groupName) - .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) - .fontWeight(FontWeight.Medium) - .fontColor($r('app.color.label_color')) - .lineHeight(Constants.TEXT_LINE_HEIGHT) - .margin({ bottom: Constants.TERTIARY_LABEL_MARGIN_BOTTOM }) - Text(this.strings.visits + permission['count' + item.accessTokenId] - + this.strings.recent_visit + this.getTime(permission['lastTime' + item.accessTokenId])) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .lineHeight(Constants.TEXT_SMALL_LINE_HEIGHT) - }.alignItems(HorizontalAlign.Start) - .height(Constants.FULL_HEIGHT) - } - }.height(Constants.LISTITEM_HEIGHT_PERMISSION) - .onClick(() => { - router.push({ - uri: 'pages/application-secondary', - params: { routerData: { - 'bundleName': item.name, - 'tokenId': item.accessTokenId, - 'iconId': item.icon, - 'labelId': item.groupName, - 'permissions': item.reqUserPermissions, - 'groupId': item.groupIds - } } - }); - }) - }) - } - } - } - }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END, - top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - .margin({ bottom: Constants.LISTITEM_MARGIN_BOTTOM }) - .backgroundColor($r('app.color.default_background_color')) - .borderRadius(Constants.BORDER_RADIUS) - } - - build() { - GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { - Row() { - Row() - .useSizeType({ - xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, - sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, - md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, - lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() { - Column() { - Row() { - backBar( { title: JSON.stringify($r('app.string.permission_access_record')), recordable: false }) - } - Row() { - Column() { - Column() { - Flex({ justifyContent: FlexAlign.Start }) { - Text($r('app.string.record_time_limit')) - .margin({ left: Constants.BACKBAR_IMAGE_MARGIN_LEFT }) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) - }.constraintSize({ minHeight: Constants.SUBTITLE_MIN_HEIGHT }) - .padding({ top: Constants.SUBTITLE_PADDING_TOP, bottom: Constants.SUBTITLE_PADDING_BOTTOM }) - if(this.groups.length) { - Stack() { - Tabs() { - TabContent() { - Row() { - Column() { - Scroll() { - Row() { - List() { - ForEach(this.groups, (item, index) => { - this.ListItemLayout(item, index, Constants.PERMISSION) - }, item => item.toString()) - }.padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.padding({ - left: Constants.MANAGEMENT_ROW_PADDING_LEFT, - right: Constants.MANAGEMENT_ROW_PADDING_RIGHT, - top: Constants.MANAGEMENT_ROW_PADDING_TOP - }) - }.scrollBar(BarState.Off) - }.width(Constants.FULL_WIDTH) - } - }.tabBar(this.TabBuilder(0)) - TabContent() { - Row() { - Column() { - Scroll() { - Row() { - List() { - ForEach(this.applicationInfos, (item, index) => { - this.ListItemLayout(item, index, Constants.APPLICATION) - }, item => item.toString()) - }.padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) - }.padding({ - left: Constants.MANAGEMENT_ROW_PADDING_LEFT, - right: Constants.MANAGEMENT_ROW_PADDING_RIGHT, - top: Constants.MANAGEMENT_ROW_PADDING_TOP - }) - }.scrollBar(BarState.Off) - }.width(Constants.FULL_WIDTH) - } - }.tabBar(this.TabBuilder(1)) - } - .barWidth(Constants.BAR_WIDTH) - .barMode(BarMode.Fixed) - .onChange((index) => { - this.currentIndex = index - }) - }.height(Constants.FULL_HEIGHT) - }else { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, direction: FlexDirection.Column }) { - Image($r('app.media.noRecord')) - .customizeImage(Constants.NORECORD_IMAGE_WIDTH, Constants.NORECORD_IMAGE_HEIGHT) - .margin({ left: Constants.NORECORD_IMAGE_MARGIN_LEFT }) - Text($r('app.string.no_record')).margin({ top: Constants.DIALOG_REQ_MARGIN_TOP }) - .fontSize(Constants.TEXT_SMAL_FONT_SIZE) - .fontColor($r('app.color.label_color_light')) - }.width(Constants.FULL_WIDTH).height(Constants.FULL_HEIGHT) - .padding({ bottom: Constants.RECORD_PADDING_BOTTOM }) - } - } - } - } - .layoutWeight(Constants.LAYOUT_WEIGHT) - } - } - .useSizeType({ - xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, - sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, - md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, - lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - Row() - .useSizeType({ - xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, - sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, - md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, - lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } - }) - .height(Constants.FULL_HEIGHT) - } - .height(Constants.FULL_HEIGHT) - .width(Constants.FULL_WIDTH) - .backgroundColor($r("sys.color.ohos_id_color_sub_background")) - .opacity(Constants.MANAGEMENT_TRANSPARENCY) - } - } - - /** - * Get time - * @param {Number} The time stamp - */ - getTime(time, format='MM月DD日 NNHH:mm') { - if(this.strings.morning == 'am') { format = 'MM/DD HH:mm NN' } - let date = new Date(time * 1000) - let config = { - MM: date.getMonth() + 1, - DD: date.getDate(), - NN: date.getHours() >= 12 ? this.strings.afternoon : this.strings.morning, - HH: date.getHours() >= 12 ? date.getHours() - 12 : date.getHours(), - mm: date.getMinutes() > 10 ? date.getMinutes() : '0' + date.getMinutes(), - } - - for(const key in config){ - format = format.replace(key,config[key]) - } - return format - } - - /** - * Get application record info - * @param {Object} application info - * @param {String} groupName - * @param {Boolean} true: count, false: lastTime - */ - getAppRecords(appInfo, groupName, option) { - var record = appInfo.permissions.filter(permission => { - return permission.groupName == groupName - }) - return option ? record[0]['count' + appInfo.accessTokenId] : record[0]['lastTime' + appInfo.accessTokenId] - } - - getStrings() { - Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { - item.getString($r("app.string.visits").id, (err, val) => { - this.strings.visits = val - }) - item.getString($r("app.string.recent_visit").id, (err, val) => { - this.strings.recent_visit = val - }) - item.getString($r("app.string.morning").id, (err, val) => { - this.strings.morning = val - }) - item.getString($r("app.string.afternoon").id, (err, val) => { - this.strings.afternoon = val - }) - }).catch(error => { - console.error(TAG + 'Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); - }) - } - - getInfo(record, sortFlag) { - bundle.getBundleInfo(record.bundleName, Constants.PARMETER_BUNDLE_FLAG).then(async info => { - var reqUserPermissions: string[] = []; - var reqUserRecords: any[] = []; - var permissionGroups: any[] = []; - var acManager = abilityAccessCtrl.createAtManager() - var appInfo: any = {} - for (let j = 0; j < record.permissionRecords.length; j++) { - var permission = record.permissionRecords[j].permissionName; - var flag = await acManager.getPermissionFlags(info.appInfo.accessTokenId, permission) - if(flag == Constants.PRE_AUTHORIZATION_NOT_MODIFIED) { - continue - } - if (userGrantPermissions.indexOf(permission) != -1) { - reqUserRecords.push(record.permissionRecords[j]) - } - } - for (let k = 0; k < info.reqPermissions.length; k++) { - var reqPermission = info.reqPermissions[k]; - var reqFlag = await acManager.getPermissionFlags(info.appInfo.accessTokenId, reqPermission) - if(reqFlag == Constants.PRE_AUTHORIZATION_NOT_MODIFIED) { - continue - } - if (userGrantPermissions.indexOf(reqPermission) != -1) { - reqUserPermissions.push(reqPermission); - } - } - - let groupNames = []; - let appLastTime = 0; - reqUserRecords.forEach(reqUserRecord => { - var group = getPermissionGroup(reqUserRecord.permissionName) - if(!group) { - console.info(TAG + "permission not find:" + reqUserRecord.permissionName) - }else { - var existing = permissionGroups.find(permissionGroup => permissionGroup.name == group.name) - var lastTime = reqUserRecord.lastAccessTime - lastTime > appLastTime ? appLastTime = lastTime : '' - if(!existing) { - group['count' + record.tokenId] = reqUserRecord.accessCount - group['lastTime' + record.tokenId] = lastTime - permissionGroups.push(group) - groupNames.push(group.groupName) - }else { - existing['count' + record.tokenId] += reqUserRecord.accessCount - lastTime > existing['lastTime' + record.tokenId] ? existing['lastTime' + record.tokenId] = lastTime : '' - } - } - }) - - let groupIds = []; - for (let i = 0; i < reqUserPermissions.length; i++) { - if(groupIds.indexOf(permissionGroupIds[reqUserPermissions[i]]) == -1){ - groupIds.push(permissionGroupIds[reqUserPermissions[i]]); - } - } - - await Resmgr.getResourceManager(globalThis.context, info.name).then(item => { - item.getString(info.appInfo['labelId'], (error, value) => { - if (value == undefined) { - appInfo['groupName'] = info.appInfo.label; - } else { - appInfo['groupName'] = value; - } - }) - - item.getMediaBase64(info.appInfo['iconId'], (error, value) => { - appInfo['icon'] = value; - }) - }) - - appInfo.name = info.appInfo.name - appInfo.accessTokenId = info.appInfo.accessTokenId - appInfo.reqUserPermissions = reqUserPermissions - appInfo.permissions = permissionGroups - appInfo.groupNames = groupNames - appInfo.groupIds = groupIds - appInfo.appLastTime = appLastTime - this.applicationInfos.push(appInfo) - if(sortFlag) { - var appInfos: any[] = [] - this.applicationInfos.forEach(item => { appInfos.push(item) }) - appInfos.sort((a, b) => { return b.appLastTime - a.appLastTime }) - this.applicationInfos = appInfos - } - }) - } - - getAllRecords() { - let request = { - "tokenId": 0, - "isRemote": false, - "permissionNames": [], - "beginTime": 0, - "endTime": 0, - "flag": 1 - } - privacyManager.getPermissionUsedRecords(request).then(async records => { - console.info(TAG + "records: " + JSON.stringify(records.bundleRecords)) - var groupArray: any[] = [] - for (let i = 0; i < records.bundleRecords.length; i++) { - var record = records.bundleRecords[i] - try { - const ret = await bundle.queryAbilityByWant({ - bundleName: record.bundleName, - action: "action.system.home", - entities: ["entity.system.home"] - }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION, Constants.USERID); - } catch(e) { - continue; - } - if (noNeedDisplayApp.indexOf(record.bundleName) != -1) { - continue; - } - console.info(TAG + "record: " + JSON.stringify(record)) - this.getInfo(record, (i + 1) == records.bundleRecords.length) - - record.permissionRecords.forEach(permissionRecord => { - var group = getPermissionGroup(permissionRecord.permissionName) - if(group) { - var exist = groupArray.find(permissionGroup => permissionGroup.name == group.name) - var lastTime = permissionRecord.lastAccessTime - if(!exist) { - group.sum = permissionRecord.accessCount - group.recentVisit = lastTime - groupArray.push(group) - }else { - exist.sum += permissionRecord.accessCount - lastTime > exist.recentVisit ? exist.recentVisit = lastTime : '' - } - } - }) - } - groupArray.sort((a, b) => { return b.recentVisit - a.recentVisit }) - this.groups = groupArray - }) - } - - aboutToAppear() { - this.getStrings() - this.getAllRecords() - } -} +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import bundle from '@ohos.bundle'; +import router from '@system.router'; +import Resmgr from '@ohos.resourceManager' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import privacyManager from '@ohos.privacyManager' +import { backBar } from "../common/components/backBar"; +import Constants from '../common/utils/constant'; +import { noNeedDisplayApp, userGrantPermissions, permissionGroupIds } from "../common/model/permissionGroup"; +import { getPermissionGroup } from '../common/utils/utils' + +var TAG = 'PermissionManager_MainAbility:' + +@Extend(Image) function customizeImage(width: number, height: number) { + .objectFit(ImageFit.Contain) + .width(width) + .height(height) +}; + +@Entry +@Component +struct permissionRecordPage { + @State groups: any[] = [] + @State applicationInfos: any[] = [] + @State permissionApplications: any[] = [] + @State permissionIndex: number = -1 + @State applicationIndex: number = -1 + @State strings: any = {} + @State currentIndex: number = 0 + @Builder TabBuilder(index: number) { + Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(index ? $r('app.string.application') : $r('app.string.authority')) + .fontColor(this.currentIndex == index ? $r('app.color.button_color') : $r('app.color.label_color')) + .fontWeight(this.currentIndex == index ? FontWeight.Bold : FontWeight.Regular) + .lineHeight(Constants.TEXT_LINE_HEIGHT) + if(this.currentIndex == index) { + Row().width(Constants.FULL_WIDTH).height(Constants.TAB_DECORATION_HEIGHT) + .backgroundColor($r('app.color.button_color')) + .position({ y: Constants.TAB_DECORATION_POSITION_Y }) + } + }.height(Constants.TAB_HEIGHT) + } + + @Builder ListItemLayout(item, index, dimension) { + ListItem() { + Column() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + if(dimension) { + Image(item.icon) + .customizeImage(Constants.MANAGEMENT_IMAGE_WIDTH, Constants.MANAGEMENT_IMAGE_HEIGHT) + .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT_RECORD, left: Constants.MANAGEMENT_IMAGE_MARGIN_LEFT }) + }else { + Image(item.icon) + .customizeImage(Constants.APPLICATION_IMAGE_WIDTH, Constants.APPLICATION_IMAGE_HEIGHT) + .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT }) + } + Column() { + Text(item.groupName) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.label_color')) + .lineHeight(Constants.TEXT_LINE_HEIGHT) + .margin({ bottom: Constants.TERTIARY_LABEL_MARGIN_BOTTOM }) + if(dimension) { + Text(this.strings.visits + item.sum) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .lineHeight(Constants.TEXT_SMALL_LINE_HEIGHT) + }else { + Row() { + if (item.permissions) { + ForEach(item.permissions, permission => { + Image(permission.icon) + .customizeImage(Constants.IMAGE_WIDTH_RECORD_APPLICATION, Constants.IMAGE_HEIGHT_RECORD_APPLICATION) + .margin({ right: Constants.APPLICATION_TEXT_MARGIN_RIGHT }) + }) + } + } + } + }.flexGrow(Constants.FLEX_GROW) + .alignItems(HorizontalAlign.Start) + if(dimension) { + if(index == this.permissionIndex) { + Image($r('app.media.xiangshangjiantou')) + .customizeImage(Constants.IMAGE_WIDTH_RECORD, Constants.IMAGE_HEIGHT_RECORD) + }else { + Image($r('app.media.xiangxiajiantou')) + .customizeImage(Constants.IMAGE_WIDTH_RECORD, Constants.IMAGE_HEIGHT_RECORD) + } + }else { + if(index == this.applicationIndex) { + Image($r('app.media.xiangshangjiantou')) + .customizeImage(Constants.IMAGE_WIDTH_RECORD, Constants.IMAGE_HEIGHT_RECORD) + }else { + Image($r('app.media.xiangxiajiantou')) + .customizeImage(Constants.IMAGE_WIDTH_RECORD, Constants.IMAGE_HEIGHT_RECORD) + } + } + } + .width(Constants.FULL_WIDTH) + .height(dimension ? Constants.LISTITEM_HEIGHT_PERMISSION : Constants.LISTITEM_HEIGHT_APPLICATION) + } + }.onClick(() => { + dimension ? + (this.permissionIndex = this.permissionIndex == index ? -1 : index) : + (this.applicationIndex = this.applicationIndex == index ? -1 : index) + if(dimension) { + this.permissionApplications = this.applicationInfos.filter(appInfo => { + return appInfo.groupNames.includes(item.groupName) + }) + } + }) + if(dimension && (index == this.permissionIndex)) { + List() { + ForEach(this.permissionApplications, (permissionApplication) => { + ListItem() { + Row() { + Image(permissionApplication.icon) + .customizeImage(Constants.APPLICATION_IMAGE_WIDTH, Constants.APPLICATION_IMAGE_HEIGHT) + .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT }) + Column() { + Row().width(Constants.FULL_WIDTH).height(Constants.TEXT_DECORATION_HEIGHT) + .backgroundColor($r("app.color.label_color_lightest")) + .margin({ bottom: Constants.LISTITEM_MARGIN_BOTTOM_PERMISSION }) + Text(permissionApplication.groupName) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.label_color')) + .lineHeight(Constants.TEXT_LINE_HEIGHT) + .margin({ bottom: Constants.TERTIARY_LABEL_MARGIN_BOTTOM }) + Text(this.strings.visits + this.getAppRecords(permissionApplication, item.groupName, true) + + this.strings.recent_visit + this.getTime(this.getAppRecords(permissionApplication, item.groupName, false))) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .lineHeight(Constants.TEXT_SMALL_LINE_HEIGHT) + }.alignItems(HorizontalAlign.Start) + .height(Constants.FULL_HEIGHT) + } + }.height(Constants.LISTITEM_HEIGHT_APPLICATION) + .onClick(() => { + router.push({ + uri: 'pages/application-secondary', + params: { routerData: { + 'bundleName': permissionApplication.name, + 'tokenId': permissionApplication.accessTokenId, + 'iconId': permissionApplication.icon, + 'labelId': permissionApplication.groupName, + 'permissions': permissionApplication.reqUserPermissions, + 'groupId': permissionApplication.groupIds + } } + }); + }) + }) + } + } + if(!dimension && (index == this.applicationIndex)) { + List() { + ForEach(item.permissions, (permission) => { + ListItem() { + Row() { + Image(permission.icon) + .customizeImage(Constants.MANAGEMENT_IMAGE_WIDTH, Constants.MANAGEMENT_IMAGE_HEIGHT) + .margin({ right: Constants.MANAGEMENT_IMAGE_MARGIN_RIGHT_RECORD, left: Constants.MANAGEMENT_IMAGE_MARGIN_LEFT }) + Column() { + Row().width(Constants.FULL_WIDTH).height(Constants.TEXT_DECORATION_HEIGHT) + .backgroundColor($r("app.color.label_color_lightest")) + .margin({ bottom: Constants.LISTITEM_MARGIN_BOTTOM_APPLICATION }) + Text(permission.groupName) + .fontSize(Constants.TEXT_MIDDLE_FONT_SIZE) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.label_color')) + .lineHeight(Constants.TEXT_LINE_HEIGHT) + .margin({ bottom: Constants.TERTIARY_LABEL_MARGIN_BOTTOM }) + Text(this.strings.visits + permission['count' + item.accessTokenId] + + this.strings.recent_visit + this.getTime(permission['lastTime' + item.accessTokenId])) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .lineHeight(Constants.TEXT_SMALL_LINE_HEIGHT) + }.alignItems(HorizontalAlign.Start) + .height(Constants.FULL_HEIGHT) + } + }.height(Constants.LISTITEM_HEIGHT_PERMISSION) + .onClick(() => { + router.push({ + uri: 'pages/application-secondary', + params: { routerData: { + 'bundleName': item.name, + 'tokenId': item.accessTokenId, + 'iconId': item.icon, + 'labelId': item.groupName, + 'permissions': item.reqUserPermissions, + 'groupId': item.groupIds + } } + }); + }) + }) + } + } + } + }.padding({ left: Constants.DEFAULT_PADDING_START, right: Constants.DEFAULT_PADDING_END, + top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + .margin({ bottom: Constants.LISTITEM_MARGIN_BOTTOM }) + .backgroundColor($r('app.color.default_background_color')) + .borderRadius(Constants.BORDER_RADIUS) + } + + build() { + GridContainer({ gutter: Constants.GUTTER, margin: Constants.GRID_MARGIN }) { + Row() { + Row() + .useSizeType({ + xs: { span: Constants.LEFT_XS_SPAN, offset: Constants.LEFT_XS_OFFSET }, + sm: { span: Constants.LEFT_SM_SPAN, offset: Constants.LEFT_SM_OFFSET }, + md: { span: Constants.LEFT_MD_SPAN, offset: Constants.LEFT_MD_OFFSET }, + lg: { span: Constants.LEFT_LG_SPAN, offset: Constants.LEFT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() { + Column() { + Row() { + backBar( { title: JSON.stringify($r('app.string.permission_access_record')), recordable: false }) + } + Row() { + Column() { + Column() { + Flex({ justifyContent: FlexAlign.Start }) { + Text($r('app.string.record_time_limit')) + .margin({ left: Constants.BACKBAR_IMAGE_MARGIN_LEFT }) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + .lineHeight(Constants.SUBTITLE_LINE_HEIGHT) + }.constraintSize({ minHeight: Constants.SUBTITLE_MIN_HEIGHT }) + .padding({ top: Constants.SUBTITLE_PADDING_TOP, bottom: Constants.SUBTITLE_PADDING_BOTTOM }) + if(this.groups.length) { + Stack() { + Tabs() { + TabContent() { + Row() { + Column() { + Scroll() { + Row() { + List() { + ForEach(this.groups, (item, index) => { + this.ListItemLayout(item, index, Constants.PERMISSION) + }, item => item.toString()) + }.padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.padding({ + left: Constants.MANAGEMENT_ROW_PADDING_LEFT, + right: Constants.MANAGEMENT_ROW_PADDING_RIGHT, + top: Constants.MANAGEMENT_ROW_PADDING_TOP + }) + }.scrollBar(BarState.Off) + }.width(Constants.FULL_WIDTH) + } + }.tabBar(this.TabBuilder(0)) + TabContent() { + Row() { + Column() { + Scroll() { + Row() { + List() { + ForEach(this.applicationInfos, (item, index) => { + this.ListItemLayout(item, index, Constants.APPLICATION) + }, item => item.toString()) + }.padding({ top: Constants.LIST_PADDING_TOP, bottom: Constants.LIST_PADDING_BOTTOM }) + }.padding({ + left: Constants.MANAGEMENT_ROW_PADDING_LEFT, + right: Constants.MANAGEMENT_ROW_PADDING_RIGHT, + top: Constants.MANAGEMENT_ROW_PADDING_TOP + }) + }.scrollBar(BarState.Off) + }.width(Constants.FULL_WIDTH) + } + }.tabBar(this.TabBuilder(1)) + } + .barWidth(Constants.BAR_WIDTH) + .barMode(BarMode.Fixed) + .onChange((index) => { + this.currentIndex = index + }) + }.height(Constants.FULL_HEIGHT) + }else { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, direction: FlexDirection.Column }) { + Image($r('app.media.noRecord')) + .customizeImage(Constants.NORECORD_IMAGE_WIDTH, Constants.NORECORD_IMAGE_HEIGHT) + .margin({ left: Constants.NORECORD_IMAGE_MARGIN_LEFT }) + Text($r('app.string.no_record')).margin({ top: Constants.DIALOG_REQ_MARGIN_TOP }) + .fontSize(Constants.TEXT_SMAL_FONT_SIZE) + .fontColor($r('app.color.label_color_light')) + }.width(Constants.FULL_WIDTH).height(Constants.FULL_HEIGHT) + .padding({ bottom: Constants.RECORD_PADDING_BOTTOM }) + } + } + } + } + .layoutWeight(Constants.LAYOUT_WEIGHT) + } + } + .useSizeType({ + xs: { span: Constants.MIDDLE_XS_SPAN, offset: Constants.MIDDLE_XS_OFFSET }, + sm: { span: Constants.MIDDLE_SM_SPAN, offset: Constants.MIDDLE_SM_OFFSET }, + md: { span: Constants.MIDDLE_MD_SPAN, offset: Constants.MIDDLE_MD_OFFSET }, + lg: { span: Constants.MIDDLE_LG_SPAN, offset: Constants.MIDDLE_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + Row() + .useSizeType({ + xs: { span: Constants.RIGHT_XS_SPAN, offset: Constants.RIGHT_XS_OFFSET }, + sm: { span: Constants.RIGHT_SM_SPAN, offset: Constants.RIGHT_SM_OFFSET }, + md: { span: Constants.RIGHT_MD_SPAN, offset: Constants.RIGHT_MD_OFFSET }, + lg: { span: Constants.RIGHT_LG_SPAN, offset: Constants.RIGHT_LG_OFFSET } + }) + .height(Constants.FULL_HEIGHT) + } + .height(Constants.FULL_HEIGHT) + .width(Constants.FULL_WIDTH) + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .opacity(Constants.MANAGEMENT_TRANSPARENCY) + } + } + + /** + * Get time + * @param {Number} The time stamp + */ + getTime(time, format='MM月DD日 NNHH:mm') { + if(this.strings.morning == 'am') { format = 'MM/DD HH:mm NN' } + let date = new Date(time * 1000) + let config = { + MM: date.getMonth() + 1, + DD: date.getDate(), + NN: date.getHours() >= 12 ? this.strings.afternoon : this.strings.morning, + HH: date.getHours() >= 12 ? date.getHours() - 12 : date.getHours(), + mm: date.getMinutes() > 10 ? date.getMinutes() : '0' + date.getMinutes(), + } + + for(const key in config){ + format = format.replace(key,config[key]) + } + return format + } + + /** + * Get application record info + * @param {Object} application info + * @param {String} groupName + * @param {Boolean} true: count, false: lastTime + */ + getAppRecords(appInfo, groupName, option) { + var record = appInfo.permissions.filter(permission => { + return permission.groupName == groupName + }) + return option ? record[0]['count' + appInfo.accessTokenId] : record[0]['lastTime' + appInfo.accessTokenId] + } + + getStrings() { + Resmgr.getResourceManager(globalThis.context, Constants.BUNDLE_NAME).then(item => { + item.getString($r("app.string.visits").id, (err, val) => { + this.strings.visits = val + }) + item.getString($r("app.string.recent_visit").id, (err, val) => { + this.strings.recent_visit = val + }) + item.getString($r("app.string.morning").id, (err, val) => { + this.strings.morning = val + }) + item.getString($r("app.string.afternoon").id, (err, val) => { + this.strings.afternoon = val + }) + }).catch(error => { + console.error(TAG + 'Resmgr.getResourceManager failed. Cause: ' + JSON.stringify(error)); + }) + } + + getInfo(record, sortFlag) { + bundle.getBundleInfo(record.bundleName, Constants.PARMETER_BUNDLE_FLAG).then(async info => { + var reqUserPermissions: string[] = []; + var reqUserRecords: any[] = []; + var permissionGroups: any[] = []; + var acManager = abilityAccessCtrl.createAtManager() + var appInfo: any = {} + for (let j = 0; j < record.permissionRecords.length; j++) { + var permission = record.permissionRecords[j].permissionName; + var flag = await acManager.getPermissionFlags(info.appInfo.accessTokenId, permission) + if(flag == Constants.PRE_AUTHORIZATION_NOT_MODIFIED) { + continue + } + if (userGrantPermissions.indexOf(permission) != -1) { + reqUserRecords.push(record.permissionRecords[j]) + } + } + for (let k = 0; k < info.reqPermissions.length; k++) { + var reqPermission = info.reqPermissions[k]; + var reqFlag = await acManager.getPermissionFlags(info.appInfo.accessTokenId, reqPermission) + if(reqFlag == Constants.PRE_AUTHORIZATION_NOT_MODIFIED) { + continue + } + if (userGrantPermissions.indexOf(reqPermission) != -1) { + reqUserPermissions.push(reqPermission); + } + } + + let groupNames = []; + let appLastTime = 0; + reqUserRecords.forEach(reqUserRecord => { + var group = getPermissionGroup(reqUserRecord.permissionName) + if(!group) { + console.info(TAG + "permission not find:" + reqUserRecord.permissionName) + }else { + var existing = permissionGroups.find(permissionGroup => permissionGroup.name == group.name) + var lastTime = reqUserRecord.lastAccessTime + lastTime > appLastTime ? appLastTime = lastTime : '' + if(!existing) { + group['count' + record.tokenId] = reqUserRecord.accessCount + group['lastTime' + record.tokenId] = lastTime + permissionGroups.push(group) + groupNames.push(group.groupName) + }else { + existing['count' + record.tokenId] += reqUserRecord.accessCount + lastTime > existing['lastTime' + record.tokenId] ? existing['lastTime' + record.tokenId] = lastTime : '' + } + } + }) + + let groupIds = []; + for (let i = 0; i < reqUserPermissions.length; i++) { + if(groupIds.indexOf(permissionGroupIds[reqUserPermissions[i]]) == -1){ + groupIds.push(permissionGroupIds[reqUserPermissions[i]]); + } + } + + await Resmgr.getResourceManager(globalThis.context, info.name).then(item => { + item.getString(info.appInfo['labelId'], (error, value) => { + if (value == undefined) { + appInfo['groupName'] = info.appInfo.label; + } else { + appInfo['groupName'] = value; + } + }) + + item.getMediaBase64(info.appInfo['iconId'], (error, value) => { + appInfo['icon'] = value; + }) + }) + + appInfo.name = info.appInfo.name + appInfo.accessTokenId = info.appInfo.accessTokenId + appInfo.reqUserPermissions = reqUserPermissions + appInfo.permissions = permissionGroups + appInfo.groupNames = groupNames + appInfo.groupIds = groupIds + appInfo.appLastTime = appLastTime + this.applicationInfos.push(appInfo) + if(sortFlag) { + var appInfos: any[] = [] + this.applicationInfos.forEach(item => { appInfos.push(item) }) + appInfos.sort((a, b) => { return b.appLastTime - a.appLastTime }) + this.applicationInfos = appInfos + } + }) + } + + getAllRecords() { + let request = { + "tokenId": 0, + "isRemote": false, + "permissionNames": [], + "beginTime": 0, + "endTime": 0, + "flag": 1 + } + privacyManager.getPermissionUsedRecords(request).then(async records => { + console.info(TAG + "records: " + JSON.stringify(records.bundleRecords)) + var groupArray: any[] = [] + for (let i = 0; i < records.bundleRecords.length; i++) { + var record = records.bundleRecords[i] + try { + const ret = await bundle.queryAbilityByWant({ + bundleName: record.bundleName, + action: "action.system.home", + entities: ["entity.system.home"] + }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION, Constants.USERID); + } catch(e) { + continue; + } + if (noNeedDisplayApp.indexOf(record.bundleName) != -1) { + continue; + } + console.info(TAG + "record: " + JSON.stringify(record)) + this.getInfo(record, (i + 1) == records.bundleRecords.length) + + record.permissionRecords.forEach(permissionRecord => { + var group = getPermissionGroup(permissionRecord.permissionName) + if(group) { + var exist = groupArray.find(permissionGroup => permissionGroup.name == group.name) + var lastTime = permissionRecord.lastAccessTime + if(!exist) { + group.sum = permissionRecord.accessCount + group.recentVisit = lastTime + groupArray.push(group) + }else { + exist.sum += permissionRecord.accessCount + lastTime > exist.recentVisit ? exist.recentVisit = lastTime : '' + } + } + }) + } + groupArray.sort((a, b) => { return b.recentVisit - a.recentVisit }) + this.groups = groupArray + }) + } + + aboutToAppear() { + this.getStrings() + this.getAllRecords() + } +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/module.json5 b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/module.json5 index 321012a87b49e95d14594c2c1bad781d16e7e044..a94e682c0be8c9b9b4318e482118b39e131fc70f 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/module.json5 +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/module.json5 @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "permissionmanager", - "type": "feature", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:permissionmanager_desc", - "mainElement": "MainAbility", - "deviceTypes": [ - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "com.ohos.permissionmanager.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:MainAbility_desc", - "icon": "$media:icon", - "label": "$string:MainAbility_label", - "visible": true, - "launchType": "standard" - } - ], - "extensionAbilities": [ - { - "icon": "$media:icon", - "name": "com.ohos.permissionmanager.GrantAbility", - "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts", - "type": "service", - "visible": true - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_SENSITIVE_PERMISSIONS", - }, - { - "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.PERMISSION_USED_STATS" - } - ] - } +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "permissionmanager", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:permissionmanager_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.ohos.permissionmanager.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "launchType": "standard" + } + ], + "extensionAbilities": [ + { + "icon": "$media:icon", + "name": "com.ohos.permissionmanager.GrantAbility", + "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts", + "type": "service", + "visible": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_SENSITIVE_PERMISSIONS", + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.PERMISSION_USED_STATS" + } + ] + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/ar/profile/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/ar/profile/string.json index c3a6df19ca632072f943b0fba85ac22aec902416..4dff0010889f0b4a72670ec7eff9e07b70343ca8 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/ar/profile/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/ar/profile/string.json @@ -1,14 +1,14 @@ -{ - "strings": { - "app_name": "CategoryPage", - "describe": "describe", - "category": "Category", - "itemChild": "ItemChild", - "item": "Item", - "search": "search...", - "you_search": "You search ", - "you_clicked": "You clicked ", - "tab": "Tab", - "more": "< more" - } +{ + "strings": { + "app_name": "CategoryPage", + "describe": "describe", + "category": "Category", + "itemChild": "ItemChild", + "item": "Item", + "search": "search...", + "you_search": "You search ", + "you_clicked": "You clicked ", + "tab": "Tab", + "more": "< more" + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/color.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/color.json index d9c648ab678d07802b9a9470d730d98fa6b30ab1..84c9609ba04d5ab2c7c16b01a73e16f54f26e042 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/color.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/color.json @@ -1,112 +1,112 @@ -{ - "color": [ - { - "name": "text_color", - "value": "#E5000000" - }, - { - "name": "label_color", - "value": "#182431" - }, - { - "name": "label_color_light", - "value": "#99182431" - }, - { - "name": "label_color_lighter", - "value": "#66182431" - }, - { - "name": "label_color_20", - "value": "#33182431" - }, - { - "name": "label_color_lightest", - "value": "#0D182431" - }, - { - "name": "background_color", - "value": "#F4F5F7" - }, - { - "name": "list_background_color", - "value": "#FDFDFD" - }, - { - "name": "text_secondary_color", - "value": "#99000000" - }, - { - "name": "active_background_color", - "value": "#e5f3ff" - }, - { - "name": "divider_color", - "value": "#f3f4f6" - }, - { - "name": "text_decoration_color", - "value": "#f3f4f6" - }, - { - "name": "default_background_color", - "value": "#ffffff" - }, - { - "name": "button_color", - "value": "#007DFF" - }, - { - "name": "shape_allow_color", - "value": "#1856D4" - }, - { - "name": "shape_ban_color", - "value": "#000000" - }, - { - "name": "first_font_color", - "value": "#E6000000" - }, - { - "name": "secondary_font_color", - "value": "#66000000" - }, - { - "name": "toggle_color", - "value": "#409eff" - }, - { - "name": "color_Primary", - "value": "#E5000000" - }, - { - "name": "color_Secondary", - "value": "#99000000" - }, - { - "name": "color_Tertiary", - "value": "#66000000" - }, - { - "name": "color_Fourth", - "value": "#33000000" - }, - { - "name": "selected_Color", - "value": "#ffffff" - }, - { - "name": "popup_Color", - "value": "#FFFAF0" - }, - { - "name": "selected_Background_Color", - "value": "#CCCCCC" - }, - { - "name": "popup_Background_Color", - "value": "#D2B48C" - } - ] +{ + "color": [ + { + "name": "text_color", + "value": "#E5000000" + }, + { + "name": "label_color", + "value": "#182431" + }, + { + "name": "label_color_light", + "value": "#99182431" + }, + { + "name": "label_color_lighter", + "value": "#66182431" + }, + { + "name": "label_color_20", + "value": "#33182431" + }, + { + "name": "label_color_lightest", + "value": "#0D182431" + }, + { + "name": "background_color", + "value": "#F4F5F7" + }, + { + "name": "list_background_color", + "value": "#FDFDFD" + }, + { + "name": "text_secondary_color", + "value": "#99000000" + }, + { + "name": "active_background_color", + "value": "#e5f3ff" + }, + { + "name": "divider_color", + "value": "#f3f4f6" + }, + { + "name": "text_decoration_color", + "value": "#f3f4f6" + }, + { + "name": "default_background_color", + "value": "#ffffff" + }, + { + "name": "button_color", + "value": "#007DFF" + }, + { + "name": "shape_allow_color", + "value": "#1856D4" + }, + { + "name": "shape_ban_color", + "value": "#000000" + }, + { + "name": "first_font_color", + "value": "#E6000000" + }, + { + "name": "secondary_font_color", + "value": "#66000000" + }, + { + "name": "toggle_color", + "value": "#409eff" + }, + { + "name": "color_Primary", + "value": "#E5000000" + }, + { + "name": "color_Secondary", + "value": "#99000000" + }, + { + "name": "color_Tertiary", + "value": "#66000000" + }, + { + "name": "color_Fourth", + "value": "#33000000" + }, + { + "name": "selected_Color", + "value": "#ffffff" + }, + { + "name": "popup_Color", + "value": "#FFFAF0" + }, + { + "name": "selected_Background_Color", + "value": "#CCCCCC" + }, + { + "name": "popup_Background_Color", + "value": "#D2B48C" + } + ] } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json index a1b07a9814be99a34db87663861cb91508d60029..58fe2e88a06c43134dfdb23c1786a71b4f3c74bd 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/element/string.json @@ -1,92 +1,92 @@ -{ - "string": [ - { - "name": "permissionmanager_desc", - "value": "permissionmanager" - }, - { - "name": "MainAbility_desc", - "value": "manage the permissions of all applications from the permission and application dimensions" - }, - { - "name": "MainAbility_label", - "value": "permission manage" - }, - { - "name": "no_permission", - "value": "no permission" - }, - { - "name": "access_permission", - "value": "access permission" - }, - { - "name": "permission_access_record", - "value": "permission access record" - }, - { - "name": "authority_management", - "value": "authority management" - }, - { - "name": "other_permissions", - "value": "other permissions" - }, - { - "name": "application", - "value": "application" - }, - { - "name": "authority", - "value": "authority" - }, - { - "name": "textInput_placeholder", - "value": "search application" - }, - { - "name": "allowed", - "value": "allowed" - }, - { - "name": "banned", - "value": "banned" - }, - { - "name": "Authorization_failed", - "value": "Authorization failure!" - }, - { - "name": "reason_suffix", - "value": " and other permissions." - }, - { - "name": "separator", - "value": "," - }, - { - "name": "visits", - "value": "Number of visits:" - }, - { - "name": "recent_visit", - "value": ";Recent visits:" - }, - { - "name": "morning", - "value": "am" - }, - { - "name": "afternoon", - "value": "pm" - }, - { - "name": "no_record", - "value": "No permission access record" - }, - { - "name": "record_time_limit", - "value": "Access records in the last 7 days" - } - ] +{ + "string": [ + { + "name": "permissionmanager_desc", + "value": "permissionmanager" + }, + { + "name": "MainAbility_desc", + "value": "manage the permissions of all applications from the permission and application dimensions" + }, + { + "name": "MainAbility_label", + "value": "permission manage" + }, + { + "name": "no_permission", + "value": "no permission" + }, + { + "name": "access_permission", + "value": "access permission" + }, + { + "name": "permission_access_record", + "value": "permission access record" + }, + { + "name": "authority_management", + "value": "authority management" + }, + { + "name": "other_permissions", + "value": "other permissions" + }, + { + "name": "application", + "value": "application" + }, + { + "name": "authority", + "value": "authority" + }, + { + "name": "textInput_placeholder", + "value": "search application" + }, + { + "name": "allowed", + "value": "allowed" + }, + { + "name": "banned", + "value": "banned" + }, + { + "name": "Authorization_failed", + "value": "Authorization failure!" + }, + { + "name": "reason_suffix", + "value": " and other permissions." + }, + { + "name": "separator", + "value": "," + }, + { + "name": "visits", + "value": "Number of visits:" + }, + { + "name": "recent_visit", + "value": ";Recent visits:" + }, + { + "name": "morning", + "value": "am" + }, + { + "name": "afternoon", + "value": "pm" + }, + { + "name": "no_record", + "value": "No permission access record" + }, + { + "name": "record_time_limit", + "value": "Access records in the last 7 days" + } + ] } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg index 8826af67d0e4851e4e05dee9af0e815b36ca8715..ecc0e208f4fd8f0766901e9191c3a9a55c5aac8f 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg @@ -1,15 +1,15 @@ - - - - - - - + + + + + + + diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_dropzone.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_dropzone.svg index 960483f7f3398245eafe7c9d6182419a32ebeb05..15ca115db85ae3d092c7249a3425482f97e2c37f 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_dropzone.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_dropzone.svg @@ -1,19 +1,19 @@ - - - IC/ic_floatingwindow - - - - - - - - - - - - - - - + + + IC/ic_floatingwindow + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_exercise.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_exercise.svg index e31feee74b4025b3e79e1a9484b07c7c1e427a3f..8a40c789c8a8770f4b491d5011b7de17936eed76 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_exercise.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_exercise.svg @@ -1,15 +1,15 @@ - - - - + + + + diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_forward.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_forward.svg index ddf503e7c61949920511d3a53d4cffd0c120cf5d..2ee2264b584edcd8da27c2c5cb1c1cd8fbdf34b7 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_forward.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_forward.svg @@ -1,13 +1,13 @@ - - - - - - - + + + + + + + diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_more.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_more.svg index 73ab2493876c2c2770b0329aa1652b9c5b72f946..87c4bafe0c7a4a4538de279d43dce64247aac765 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_more.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_more.svg @@ -1,7 +1,7 @@ - - - HM/ic/24x24/more1.5 - - - + + + HM/ic/24x24/more1.5 + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_multi_device_vector.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_multi_device_vector.svg index b85bdf10aa90c6406df61166bd13ca9392785729..82a186f7f0e04f4d8ca6e310c05c575d50963ad5 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_multi_device_vector.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_multi_device_vector.svg @@ -1,7 +1,7 @@ - - - HM/ic/24x24/Multi-device vector - - - + + + HM/ic/24x24/Multi-device vector + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_nearby.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_nearby.svg index 4b201c865105325c085d7c761baef6087e4e57d3..37c6c67449bfeb1ed404c5c90453e043206b2afa 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_nearby.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_nearby.svg @@ -1,7 +1,7 @@ - - - HM/ic/24x24/ic_nearby - - - + + + HM/ic/24x24/ic_nearby + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_calendar.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_calendar.svg index bfb163637ada7dffff34bdc44ada22a1dbb7537b..af519b323a5a2d24edf1c56c2263ce9fa48a3cda 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_calendar.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_calendar.svg @@ -1,13 +1,13 @@ - - - Public/ic_public_calendar - - - - - - - - - + + + Public/ic_public_calendar + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_camera.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_camera.svg index 535b7a305c97bdf9b89f721677b258440eadb8ca..56a0c74330c32eb3028298a223ab9705af436b91 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_camera.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_camera.svg @@ -1,13 +1,13 @@ - - - Public/ic_public_camera - - - - - - - - - + + + Public/ic_public_camera + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_contacts_group.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_contacts_group.svg index e01910786672f291f336e87ef79ea34ff1a6841f..35329fd29f42732c0c5b59d3550fa4d835a089b1 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_contacts_group.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_contacts_group.svg @@ -1,13 +1,13 @@ - - - Public/ic_public_contacts_group - - - - - - - - - + + + Public/ic_public_contacts_group + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_folder.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_folder.svg index 01a9fae004cf330b53f98d2b72c294fa1465c88e..fb107a15a2553d3996d793155869dbaad9af7738 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_folder.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_folder.svg @@ -1,13 +1,13 @@ - - - Public/ic_public_folder - - - - - - - - - + + + Public/ic_public_folder + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_gps.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_gps.svg index 738516f856e056c84f33287f5e00ac34b6234b49..c78bc694da7bbc3a596d92bffabadfa6c0682989 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_gps.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_gps.svg @@ -1,13 +1,13 @@ - - - Public/ic_public_gps - - - - - - - - - + + + Public/ic_public_gps + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_message.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_message.svg index 79f77f671e5db7a338aaa32dd37bc3e83dd4e647..be86b32981900198aca0a184b24d5999d955eda4 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_message.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_message.svg @@ -1,13 +1,13 @@ - - - Public/ic_public_message - - - - - - - - - + + + Public/ic_public_message + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_phone.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_phone.svg index df52fe39ccfecf5ac9f7ece40bb50377e79dffd1..755c8b7c8b04c3895f8b990c8026b2f87206185e 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_phone.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_phone.svg @@ -1,13 +1,13 @@ - - - Public/ic_public_phone - - - - - - - - - + + + Public/ic_public_phone + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_voice.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_voice.svg index 257ae0605e3c1fbb5370efec92c502f3a6e77157..10e4ce3e3e9a47305d119fbedaadad8d9153619d 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_voice.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_public_voice.svg @@ -1,13 +1,13 @@ - - - Public/ic_public_voice - - - - - - - - - + + + Public/ic_public_voice + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_sport.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_sport.svg index e9ed5719d253468323a09b2ff0ea6ca4dfc6d3a0..4cac184ae9c9102ea615a0b1d6fd096f7f8985de 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_sport.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_sport.svg @@ -1,7 +1,7 @@ - - - HM/ic/24x24/s0324ok - - - + + + HM/ic/24x24/s0324ok + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_ssensor.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_ssensor.svg index 51b9c504f6188b15e678baa2e7d7da89756790fc..d16bf7dccb911dc4ae1dab1ba3ade66a117d2ec4 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_ssensor.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_ssensor.svg @@ -1,9 +1,9 @@ - - - HM/ic/24x24/ssensor - - - - - + + + HM/ic/24x24/ssensor + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/in_app_installations.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/in_app_installations.svg index c40993ab5cedaefb586f94faf4c578f8faa93c57..802cfb438128d68a06add4d59fe12bf40f2bf983 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/in_app_installations.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/in_app_installations.svg @@ -1,13 +1,13 @@ - - - HM/ic/24x24/in-app installations - - - - - - - - - + + + HM/ic/24x24/in-app installations + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/noRecord.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/noRecord.svg index bc844b75803d1679ef7a1eed6bab6d8afea73c92..6abcd9ac8e7e64049d41135a0bb32d721c5ae3cd 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/noRecord.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/noRecord.svg @@ -1,20 +1,20 @@ - - - EmptyPage/04 NoRecord - - - - - - - - - - - - - - - - + + + EmptyPage/04 NoRecord + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/noinstallationpackage.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/noinstallationpackage.svg index 5b10a66c6b63e6d73bfb96492ec59a900ed5335c..7482b2ef3ffaefa6baec907c8799ec3e4bc86987 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/noinstallationpackage.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/noinstallationpackage.svg @@ -1,17 +1,17 @@ - - - EmptyPage/08 NoInstallationPackage - - - - - - - - - - - - - + + + EmptyPage/08 NoInstallationPackage + + + + + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/nopermission.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/nopermission.svg index fe47a1df835fe7c7a296aa92bf009875373f30ad..b15b3756efcf2e289f375f5ce1ca33dfb9c2844b 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/nopermission.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/nopermission.svg @@ -1,16 +1,16 @@ - - - EmptyPage/18 NoPermission - - - - - - - - - - - - + + + EmptyPage/18 NoPermission + + + + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/searchnoresult.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/searchnoresult.svg index e948acc0bbb8bc715385ff841418b60b81eb0997..86d078ff666d7e4d77898d861205e1f7d994fc19 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/searchnoresult.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/searchnoresult.svg @@ -1,22 +1,22 @@ - - - EmptyPage/05 SearchNoResult - - - - - - - - - - - - - - - - - - + + + EmptyPage/05 SearchNoResult + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/profile/main_pages.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/profile/main_pages.json index c2e856f093e10b849d7a39aff19a40ab42378454..8d7d10dba96af760acd49dae99e711a7ded32611 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/profile/main_pages.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/profile/main_pages.json @@ -1,13 +1,13 @@ -{ - "src": [ - "pages/authority-management", - "pages/application-secondary", - "pages/authority-secondary", - "pages/authority-tertiary", - "pages/application-tertiary", - "pages/other-permissions", - "pages/authority-tertiary-groups", - "pages/permission-access-record", - "pages/dialogPlus" - ] -} +{ + "src": [ + "pages/authority-management", + "pages/application-secondary", + "pages/authority-secondary", + "pages/authority-tertiary", + "pages/application-tertiary", + "pages/other-permissions", + "pages/authority-tertiary-groups", + "pages/permission-access-record", + "pages/dialogPlus" + ] +} diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/dark/profile/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/dark/profile/string.json index ddc52a17f97a258671b91d1f14330a673df33285..d7a74c41d6465558a0355552c4a1760e7c72b5e6 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/dark/profile/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/dark/profile/string.json @@ -1,7 +1,7 @@ -{ - "colors": { - "colorSubBackground": "#000000", - "appbar_subtitle_color": "#99ffffff", - "text_color": "#ffffff" - } +{ + "colors": { + "colorSubBackground": "#000000", + "appbar_subtitle_color": "#99ffffff", + "text_color": "#ffffff" + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/en/profile/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/en/profile/string.json index 319b5d66eabfb2e956923d29ef1f267e48bafbc8..a312eeb3302ba74317579187199f9de625018b49 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/en/profile/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/en/profile/string.json @@ -1,14 +1,14 @@ -{ - "strings": { - "app_name": "CategoryPage", - "describe": "describe", - "category": "Category", - "itemChild": "ItemChild", - "item": "Item", - "search": "search...", - "you_search": "You search ", - "you_clicked": "You clicked ", - "tab": "Tab", - "more": "more >" - } +{ + "strings": { + "app_name": "CategoryPage", + "describe": "describe", + "category": "Category", + "itemChild": "ItemChild", + "item": "Item", + "search": "search...", + "you_search": "You search ", + "you_clicked": "You clicked ", + "tab": "Tab", + "more": "more >" + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/light/profile/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/light/profile/string.json index 4b9482c8f2954ce8b38cb37addef4d297b33a279..2c94e0786fb5b453a61689df2cd603c78937011b 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/light/profile/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/light/profile/string.json @@ -1,7 +1,7 @@ -{ - "colors": { - "colorSubBackground": "#f1f3f5", - "appbar_subtitle_color": "#99000000", - "text_color": "#000000" - } +{ + "colors": { + "colorSubBackground": "#f1f3f5", + "appbar_subtitle_color": "#99000000", + "text_color": "#000000" + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/zh/profile/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/zh/profile/string.json index 4ca364c6261d5db6919dbaf791b5432bc0c7e0da..82a144d6676c601a1c74866bc34d7092fad1d5b5 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/zh/profile/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/zh/profile/string.json @@ -1,14 +1,14 @@ -{ - "strings": { - "app_name": "分类页", - "describe": "描述", - "category": "分类", - "itemChild": "子类", - "item": "类型", - "search": "搜索...", - "you_search": "你搜索了", - "you_clicked": "你点击了", - "tab": "分页", - "more": "更多 >" - } +{ + "strings": { + "app_name": "分类页", + "describe": "描述", + "category": "分类", + "itemChild": "子类", + "item": "类型", + "search": "搜索...", + "you_search": "你搜索了", + "you_clicked": "你点击了", + "tab": "分页", + "more": "更多 >" + } } \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/zh_CN/element/string.json b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/zh_CN/element/string.json index e92d068a4ca22b1e67d5ebfdd2884414be207b05..ee595d17b8aa05b31ef4840d211e4e5e909b9874 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/zh_CN/element/string.json +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/zh_CN/element/string.json @@ -1,92 +1,92 @@ -{ - "string": [ - { - "name": "permissionmanager_desc", - "value": "权限管理" - }, - { - "name": "MainAbility_desc", - "value": "从权限和应用两个维度来管理所有应用申请的权限。" - }, - { - "name": "MainAbility_label", - "value": "权限管理" - }, - { - "name": "no_permission", - "value": "暂无权限" - }, - { - "name": "access_permission", - "value": "访问权限" - }, - { - "name": "permission_access_record", - "value": "权限访问记录" - }, - { - "name": "authority_management", - "value": "权限管理" - }, - { - "name": "other_permissions", - "value": "其它权限" - }, - { - "name": "application", - "value": "应用" - }, - { - "name": "authority", - "value": "权限" - }, - { - "name": "textInput_placeholder", - "value": "搜索应用" - }, - { - "name": "allowed", - "value": "已允许" - }, - { - "name": "banned", - "value": "已禁止" - }, - { - "name": "Authorization_failed", - "value": "授权失败!" - }, - { - "name": "reason_suffix", - "value": "等权限。" - }, - { - "name": "separator", - "value": "、" - }, - { - "name": "visits", - "value": "访问次数:" - }, - { - "name": "recent_visit", - "value": ";最近访问:" - }, - { - "name": "morning", - "value": "上午" - }, - { - "name": "afternoon", - "value": "下午" - }, - { - "name": "no_record", - "value": "没有权限访问记录" - }, - { - "name": "record_time_limit", - "value": "近7天访问记录" - } - ] +{ + "string": [ + { + "name": "permissionmanager_desc", + "value": "权限管理" + }, + { + "name": "MainAbility_desc", + "value": "从权限和应用两个维度来管理所有应用申请的权限。" + }, + { + "name": "MainAbility_label", + "value": "权限管理" + }, + { + "name": "no_permission", + "value": "暂无权限" + }, + { + "name": "access_permission", + "value": "访问权限" + }, + { + "name": "permission_access_record", + "value": "权限访问记录" + }, + { + "name": "authority_management", + "value": "权限管理" + }, + { + "name": "other_permissions", + "value": "其它权限" + }, + { + "name": "application", + "value": "应用" + }, + { + "name": "authority", + "value": "权限" + }, + { + "name": "textInput_placeholder", + "value": "搜索应用" + }, + { + "name": "allowed", + "value": "已允许" + }, + { + "name": "banned", + "value": "已禁止" + }, + { + "name": "Authorization_failed", + "value": "授权失败!" + }, + { + "name": "reason_suffix", + "value": "等权限。" + }, + { + "name": "separator", + "value": "、" + }, + { + "name": "visits", + "value": "访问次数:" + }, + { + "name": "recent_visit", + "value": ";最近访问:" + }, + { + "name": "morning", + "value": "上午" + }, + { + "name": "afternoon", + "value": "下午" + }, + { + "name": "no_record", + "value": "没有权限访问记录" + }, + { + "name": "record_time_limit", + "value": "近7天访问记录" + } + ] } \ No newline at end of file diff --git a/frameworks/common/BUILD.gn b/frameworks/common/BUILD.gn index 3970b261d89776d1a2f08aac024dc9bb01b47527..8293c0151697b1c91d3edd9b3f647d271e813235 100644 --- a/frameworks/common/BUILD.gn +++ b/frameworks/common/BUILD.gn @@ -1,48 +1,48 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -config("accesstoken_common_cxx_public_config") { - visibility = [ ":*" ] - include_dirs = [ "include" ] -} - -ohos_shared_library("accesstoken_common_cxx") { - subsystem_name = "security" - part_name = "access_token" - - public_configs = [ ":accesstoken_common_cxx_public_config" ] - - include_dirs = [ - "include", - "//utils/system/safwk/native/include", - "//third_party/mbedtls/include", - "//base/security/access_token/interfaces/innerkits/accesstoken/include", - ] - - sources = [ - "src/constant_common.cpp", - "src/data_validator.cpp", - "src/random_mbedtls.cpp", - ] - - deps = [ "//third_party/mbedtls:mbedtls_shared" ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "init:libbegetutil", - ] - - cflags_cc = [ "-DHILOG_ENABLE" ] -} +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +config("accesstoken_common_cxx_public_config") { + visibility = [ ":*" ] + include_dirs = [ "include" ] +} + +ohos_shared_library("accesstoken_common_cxx") { + subsystem_name = "security" + part_name = "access_token" + + public_configs = [ ":accesstoken_common_cxx_public_config" ] + + include_dirs = [ + "include", + "//utils/system/safwk/native/include", + "//third_party/mbedtls/include", + "//base/security/access_token/interfaces/innerkits/accesstoken/include", + ] + + sources = [ + "src/constant_common.cpp", + "src/data_validator.cpp", + "src/random_mbedtls.cpp", + ] + + deps = [ "//third_party/mbedtls:mbedtls_shared" ] + external_deps = [ + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "init:libbegetutil", + ] + + cflags_cc = [ "-DHILOG_ENABLE" ] +} diff --git a/frameworks/common/include/accesstoken_log.h b/frameworks/common/include/accesstoken_log.h index 8f0c43b2d1dc4585a0fe714402a889a446fb963e..5b4f940151483d9ea0e5d11ef77e8ebeeb81c1a4 100644 --- a/frameworks/common/include/accesstoken_log.h +++ b/frameworks/common/include/accesstoken_log.h @@ -1,69 +1,69 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACCESSTOKEN_LOG_H -#define ACCESSTOKEN_LOG_H - -#ifdef HILOG_ENABLE - -#include "hilog/log.h" - -#ifndef __cplusplus - -#define ACCESSTOKEN_LOG_DEBUG(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_INFO(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_WARN(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) - -#else - -#define ACCESSTOKEN_LOG_DEBUG(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Debug(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_INFO(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Info(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_WARN(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Warn(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_ERROR(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Error(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_FATAL(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Fatal(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) - -#endif // __cplusplus - -/* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */ -#undef LOG_TAG -#undef LOG_DOMAIN - -static constexpr unsigned int SECURITY_DOMAIN_ACCESSTOKEN = 0xD002F01; -static constexpr unsigned int SECURITY_DOMAIN_PRIVACY = 0xD002F03; - -#else - -#include -#include - -/* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */ -#undef LOG_TAG - -#define ACCESSTOKEN_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) -#define ACCESSTOKEN_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) - -#endif // HILOG_ENABLE - -#endif // ACCESSTOKEN_LOG_H +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ACCESSTOKEN_LOG_H +#define ACCESSTOKEN_LOG_H + +#ifdef HILOG_ENABLE + +#include "hilog/log.h" + +#ifndef __cplusplus + +#define ACCESSTOKEN_LOG_DEBUG(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_INFO(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_WARN(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) + +#else + +#define ACCESSTOKEN_LOG_DEBUG(label, fmt, ...) \ + OHOS::HiviewDFX::HiLog::Debug(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_INFO(label, fmt, ...) \ + OHOS::HiviewDFX::HiLog::Info(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_WARN(label, fmt, ...) \ + OHOS::HiviewDFX::HiLog::Warn(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_ERROR(label, fmt, ...) \ + OHOS::HiviewDFX::HiLog::Error(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_FATAL(label, fmt, ...) \ + OHOS::HiviewDFX::HiLog::Fatal(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) + +#endif // __cplusplus + +/* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */ +#undef LOG_TAG +#undef LOG_DOMAIN + +static constexpr unsigned int SECURITY_DOMAIN_ACCESSTOKEN = 0xD002F01; +static constexpr unsigned int SECURITY_DOMAIN_PRIVACY = 0xD002F03; + +#else + +#include +#include + +/* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */ +#undef LOG_TAG + +#define ACCESSTOKEN_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) +#define ACCESSTOKEN_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) + +#endif // HILOG_ENABLE + +#endif // ACCESSTOKEN_LOG_H diff --git a/frameworks/common/include/constant_common.h b/frameworks/common/include/constant_common.h index 8651f5d4e77c956572bfb92bd1cbb4c724d6fc9e..b533824a5141207673523992551b8743266e4935 100644 --- a/frameworks/common/include/constant_common.h +++ b/frameworks/common/include/constant_common.h @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef FRAMEWORK_CONSTANT_COMMON_H -#define FRAMEWORK_CONSTANT_COMMON_H - -#include -#include - -namespace OHOS { -namespace Security { -namespace AccessToken { -class ConstantCommon { -public: - /** - * Device id length. - */ - const static int32_t DEVICE_UUID_LENGTH = 65; - static constexpr int32_t MINDEVICEIDLEN = 8; - static constexpr int32_t ENCRYPTLEN = 4; - static constexpr int32_t ENCRYPTBEGIN = 0; - static constexpr int32_t ENCRYPTEND = 3; - static std::string EncryptDevId(std::string deviceId); - - /** - * GetLocalDeviceId - */ - static std::string GetLocalDeviceId(); -}; -} -} -} +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef FRAMEWORK_CONSTANT_COMMON_H +#define FRAMEWORK_CONSTANT_COMMON_H + +#include +#include + +namespace OHOS { +namespace Security { +namespace AccessToken { +class ConstantCommon { +public: + /** + * Device id length. + */ + const static int32_t DEVICE_UUID_LENGTH = 65; + static constexpr int32_t MINDEVICEIDLEN = 8; + static constexpr int32_t ENCRYPTLEN = 4; + static constexpr int32_t ENCRYPTBEGIN = 0; + static constexpr int32_t ENCRYPTEND = 3; + static std::string EncryptDevId(std::string deviceId); + + /** + * GetLocalDeviceId + */ + static std::string GetLocalDeviceId(); +}; +} +} +} #endif \ No newline at end of file diff --git a/frameworks/common/include/data_validator.h b/frameworks/common/include/data_validator.h index bea3c582a507a6ff1b77d669a0e34fcfa424df0f..334dfeb37c2bdb649d2a5d1d06e9a58bb0edb8fd 100644 --- a/frameworks/common/include/data_validator.h +++ b/frameworks/common/include/data_validator.h @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DATA_VALIDATOR_H -#define DATA_VALIDATOR_H - -#include -#include "access_token.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class DataValidator final { -public: - static bool IsBundleNameValid(const std::string& bundleName); - - static bool IsPermissionNameValid(const std::string& permissionName); - - static bool IsUserIdValid(const int userId); - - static bool IsAppIDDescValid(const std::string& appIDDesc); - - static bool IsDomainValid(const std::string& domain); - - static bool IsAplNumValid(const int apl); - - static bool IsProcessNameValid(const std::string& processName); - - static bool IsDeviceIdValid(const std::string& deviceId); - - static bool IsLabelValid(const std::string& label); - - static bool IsDescValid(const std::string& desc); - static bool IsPermissionFlagValid(int flag); - static bool IsDcapValid(const std::string& dcap); - static bool IsTokenIDValid(AccessTokenID id); - static bool IsDlpTypeValid(int dlpType); - -private: - const static int MAX_LENGTH = 256; - const static int MAX_APPIDDESC_LENGTH = 10240; - const static int MAX_DCAP_LENGTH = 1024; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // DATA_VALIDATOR_H +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DATA_VALIDATOR_H +#define DATA_VALIDATOR_H + +#include +#include "access_token.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class DataValidator final { +public: + static bool IsBundleNameValid(const std::string& bundleName); + + static bool IsPermissionNameValid(const std::string& permissionName); + + static bool IsUserIdValid(const int userId); + + static bool IsAppIDDescValid(const std::string& appIDDesc); + + static bool IsDomainValid(const std::string& domain); + + static bool IsAplNumValid(const int apl); + + static bool IsProcessNameValid(const std::string& processName); + + static bool IsDeviceIdValid(const std::string& deviceId); + + static bool IsLabelValid(const std::string& label); + + static bool IsDescValid(const std::string& desc); + static bool IsPermissionFlagValid(int flag); + static bool IsDcapValid(const std::string& dcap); + static bool IsTokenIDValid(AccessTokenID id); + static bool IsDlpTypeValid(int dlpType); + +private: + const static int MAX_LENGTH = 256; + const static int MAX_APPIDDESC_LENGTH = 10240; + const static int MAX_DCAP_LENGTH = 1024; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // DATA_VALIDATOR_H diff --git a/frameworks/common/include/parcel_utils.h b/frameworks/common/include/parcel_utils.h index d6b7e8b6b56f3dbc7133fad4555428a10f0d36d9..512a2a60b132ff3375b8ad0d984bc9e56b4cdcdc 100644 --- a/frameworks/common/include/parcel_utils.h +++ b/frameworks/common/include/parcel_utils.h @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PARCEL_UTILS_H -#define PARCEL_UTILS_H -#define MAX_PERMLIST_SIZE 256 -namespace OHOS { -namespace Security { -namespace AccessToken { -#define RETURN_IF_FALSE(expr) \ - if (!(expr)) { \ - return false; \ - } - -#define RELEASE_IF_FALSE(expr, obj) \ - if (!(expr)) { \ - if ((obj) != nullptr) { \ - delete (obj); \ - (obj) = nullptr; \ - } \ - return (obj); \ - } -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PARCEL_UTILS_H +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PARCEL_UTILS_H +#define PARCEL_UTILS_H +#define MAX_PERMLIST_SIZE 256 +namespace OHOS { +namespace Security { +namespace AccessToken { +#define RETURN_IF_FALSE(expr) \ + if (!(expr)) { \ + return false; \ + } + +#define RELEASE_IF_FALSE(expr, obj) \ + if (!(expr)) { \ + if ((obj) != nullptr) { \ + delete (obj); \ + (obj) = nullptr; \ + } \ + return (obj); \ + } +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PARCEL_UTILS_H diff --git a/frameworks/common/include/random.h b/frameworks/common/include/random.h index 29d2e637ff8e56ddeba6f5f1319e3df828a35593..ddb1b54a28f0794d78518f35a3890ba858a221c6 100644 --- a/frameworks/common/include/random.h +++ b/frameworks/common/include/random.h @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACCESSTOKEN_RANDOM_H -#define ACCESSTOKEN_RANDOM_H - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif - -unsigned int GetRandomUint32(void); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ -#endif /* ACCESSTOKEN_RANDOM_H */ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ACCESSTOKEN_RANDOM_H +#define ACCESSTOKEN_RANDOM_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +unsigned int GetRandomUint32(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ +#endif /* ACCESSTOKEN_RANDOM_H */ diff --git a/frameworks/common/include/random_mbedtls.h b/frameworks/common/include/random_mbedtls.h index d9461c734a277e015371d2a74d51e979fb75ec27..7faf53e7fcad41ea7274376b96b9d7afad0dd68b 100644 --- a/frameworks/common/include/random_mbedtls.h +++ b/frameworks/common/include/random_mbedtls.h @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACCESS_TOKEN_RANDOM_MBEDTLS -#define ACCESS_TOKEN_RANDOM_MBEDTLS - -#include "rwlock.h" -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/entropy.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class RandomMbedtls { -public: - static RandomMbedtls& GetInstance(); - int GenerateRandomArray(unsigned char *randStr, unsigned int len); - ~RandomMbedtls() {} - static unsigned int GetRandomUint32(); - -private: - RandomMbedtls() : initFlag_(false) {} - mbedtls_entropy_context entropy_; - mbedtls_ctr_drbg_context ctrDrbg_; - OHOS::Utils::RWLock randomLock_; - bool initFlag_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // ACCESS_TOKEN_RANDOM_MBEDTLS +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ACCESS_TOKEN_RANDOM_MBEDTLS +#define ACCESS_TOKEN_RANDOM_MBEDTLS + +#include "rwlock.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/entropy.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class RandomMbedtls { +public: + static RandomMbedtls& GetInstance(); + int GenerateRandomArray(unsigned char *randStr, unsigned int len); + ~RandomMbedtls() {} + static unsigned int GetRandomUint32(); + +private: + RandomMbedtls() : initFlag_(false) {} + mbedtls_entropy_context entropy_; + mbedtls_ctr_drbg_context ctrDrbg_; + OHOS::Utils::RWLock randomLock_; + bool initFlag_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // ACCESS_TOKEN_RANDOM_MBEDTLS diff --git a/frameworks/common/src/constant_common.cpp b/frameworks/common/src/constant_common.cpp index 736a66ce0f070143bc4f4840f37a0d1923243807..36e1123c1fd90458cd5bc886d1906e27bdf19c5e 100644 --- a/frameworks/common/src/constant_common.cpp +++ b/frameworks/common/src/constant_common.cpp @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "constant_common.h" -#include -#include "parameter.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static const std::string REPLACE_TARGET = "****"; -static const std::string REPLACE_TARGET_LESS_THAN_MINLEN = "*******"; -} // namespace -std::string ConstantCommon::EncryptDevId(std::string deviceId) -{ - std::string result = deviceId; - if (deviceId.empty()) { - return result; - } - if (deviceId.size() > MINDEVICEIDLEN) { - result.replace(ENCRYPTBEGIN + ENCRYPTLEN, deviceId.size() - MINDEVICEIDLEN, REPLACE_TARGET); - } else { - result.replace(ENCRYPTBEGIN + 1, deviceId.size()-1, REPLACE_TARGET_LESS_THAN_MINLEN); - } - return result; -} - -std::string ConstantCommon::GetLocalDeviceId() -{ - static std::string localDeviceId; - if (!localDeviceId.empty()) { - return localDeviceId; - } - const int32_t DEVICE_UUID_LENGTH = 65; - char udid[DEVICE_UUID_LENGTH] = {0}; - if (GetDevUdid(udid, DEVICE_UUID_LENGTH) == 0) { - localDeviceId = udid; - } - return localDeviceId; -} -} // namespace AccessToken -} // namespace Security +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "constant_common.h" +#include +#include "parameter.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static const std::string REPLACE_TARGET = "****"; +static const std::string REPLACE_TARGET_LESS_THAN_MINLEN = "*******"; +} // namespace +std::string ConstantCommon::EncryptDevId(std::string deviceId) +{ + std::string result = deviceId; + if (deviceId.empty()) { + return result; + } + if (deviceId.size() > MINDEVICEIDLEN) { + result.replace(ENCRYPTBEGIN + ENCRYPTLEN, deviceId.size() - MINDEVICEIDLEN, REPLACE_TARGET); + } else { + result.replace(ENCRYPTBEGIN + 1, deviceId.size()-1, REPLACE_TARGET_LESS_THAN_MINLEN); + } + return result; +} + +std::string ConstantCommon::GetLocalDeviceId() +{ + static std::string localDeviceId; + if (!localDeviceId.empty()) { + return localDeviceId; + } + const int32_t DEVICE_UUID_LENGTH = 65; + char udid[DEVICE_UUID_LENGTH] = {0}; + if (GetDevUdid(udid, DEVICE_UUID_LENGTH) == 0) { + localDeviceId = udid; + } + return localDeviceId; +} +} // namespace AccessToken +} // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/frameworks/common/src/data_validator.cpp b/frameworks/common/src/data_validator.cpp index 80fde5efa0d466653c23ab75670c0b8e6342378d..95422a586124602a58c284ca8b3383adb0624510 100644 --- a/frameworks/common/src/data_validator.cpp +++ b/frameworks/common/src/data_validator.cpp @@ -1,99 +1,99 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "data_validator.h" -#include "access_token.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool DataValidator::IsBundleNameValid(const std::string& bundleName) -{ - return !bundleName.empty() && (bundleName.length() <= MAX_LENGTH); -} - -bool DataValidator::IsLabelValid(const std::string& label) -{ - return label.length() <= MAX_LENGTH; -} - -bool DataValidator::IsDescValid(const std::string& desc) -{ - return desc.length() <= MAX_LENGTH; -} - -bool DataValidator::IsPermissionNameValid(const std::string& permissionName) -{ - return !permissionName.empty() && (permissionName.length() <= MAX_LENGTH); -} - -bool DataValidator::IsUserIdValid(const int userId) -{ - return userId >= 0; -} - -bool DataValidator::IsAppIDDescValid(const std::string& appIDDesc) -{ - return !appIDDesc.empty() && (appIDDesc.length() <= MAX_APPIDDESC_LENGTH); -} - -bool DataValidator::IsDomainValid(const std::string& domain) -{ - return !domain.empty() && (domain.length() <= MAX_LENGTH); -} - -bool DataValidator::IsAplNumValid(const int apl) -{ - return (apl == APL_NORMAL || apl == APL_SYSTEM_BASIC || apl == APL_SYSTEM_CORE); -} - -bool DataValidator::IsProcessNameValid(const std::string& processName) -{ - return !processName.empty() && (processName.length() <= MAX_LENGTH); -} - -bool DataValidator::IsDeviceIdValid(const std::string& deviceId) -{ - return !deviceId.empty() && (deviceId.length() <= MAX_LENGTH); -} - -bool DataValidator::IsDcapValid(const std::string& dcap) -{ - return !dcap.empty() && (dcap.length() <= MAX_DCAP_LENGTH); -} - -bool DataValidator::IsPermissionFlagValid(int flag) -{ - uint32_t unmaskedFlag = - static_cast(flag) & (~PermissionFlag::PERMISSION_GRANTED_BY_POLICY); - - return unmaskedFlag == PermissionFlag::PERMISSION_DEFAULT_FLAG || - unmaskedFlag == PermissionFlag::PERMISSION_USER_SET || - unmaskedFlag == PermissionFlag::PERMISSION_USER_FIXED || - unmaskedFlag == PermissionFlag::PERMISSION_SYSTEM_FIXED; -} - -bool DataValidator::IsTokenIDValid(AccessTokenID id) -{ - return id != 0; -} - -bool DataValidator::IsDlpTypeValid(int dlpType) -{ - return ((dlpType == DLP_COMMON) || (dlpType == DLP_READ) || (dlpType == DLP_FULL_CONTROL)); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "data_validator.h" +#include "access_token.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool DataValidator::IsBundleNameValid(const std::string& bundleName) +{ + return !bundleName.empty() && (bundleName.length() <= MAX_LENGTH); +} + +bool DataValidator::IsLabelValid(const std::string& label) +{ + return label.length() <= MAX_LENGTH; +} + +bool DataValidator::IsDescValid(const std::string& desc) +{ + return desc.length() <= MAX_LENGTH; +} + +bool DataValidator::IsPermissionNameValid(const std::string& permissionName) +{ + return !permissionName.empty() && (permissionName.length() <= MAX_LENGTH); +} + +bool DataValidator::IsUserIdValid(const int userId) +{ + return userId >= 0; +} + +bool DataValidator::IsAppIDDescValid(const std::string& appIDDesc) +{ + return !appIDDesc.empty() && (appIDDesc.length() <= MAX_APPIDDESC_LENGTH); +} + +bool DataValidator::IsDomainValid(const std::string& domain) +{ + return !domain.empty() && (domain.length() <= MAX_LENGTH); +} + +bool DataValidator::IsAplNumValid(const int apl) +{ + return (apl == APL_NORMAL || apl == APL_SYSTEM_BASIC || apl == APL_SYSTEM_CORE); +} + +bool DataValidator::IsProcessNameValid(const std::string& processName) +{ + return !processName.empty() && (processName.length() <= MAX_LENGTH); +} + +bool DataValidator::IsDeviceIdValid(const std::string& deviceId) +{ + return !deviceId.empty() && (deviceId.length() <= MAX_LENGTH); +} + +bool DataValidator::IsDcapValid(const std::string& dcap) +{ + return !dcap.empty() && (dcap.length() <= MAX_DCAP_LENGTH); +} + +bool DataValidator::IsPermissionFlagValid(int flag) +{ + uint32_t unmaskedFlag = + static_cast(flag) & (~PermissionFlag::PERMISSION_GRANTED_BY_POLICY); + + return unmaskedFlag == PermissionFlag::PERMISSION_DEFAULT_FLAG || + unmaskedFlag == PermissionFlag::PERMISSION_USER_SET || + unmaskedFlag == PermissionFlag::PERMISSION_USER_FIXED || + unmaskedFlag == PermissionFlag::PERMISSION_SYSTEM_FIXED; +} + +bool DataValidator::IsTokenIDValid(AccessTokenID id) +{ + return id != 0; +} + +bool DataValidator::IsDlpTypeValid(int dlpType) +{ + return ((dlpType == DLP_COMMON) || (dlpType == DLP_READ) || (dlpType == DLP_FULL_CONTROL)); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/common/src/random_mbedtls.cpp b/frameworks/common/src/random_mbedtls.cpp index 1a6ad4013f32d63d3f96f7412bbe802cd98c426a..aa58074ef94a823c9f3f6949c71c7170f35048e9 100644 --- a/frameworks/common/src/random_mbedtls.cpp +++ b/frameworks/common/src/random_mbedtls.cpp @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "random_mbedtls.h" -#include "access_token.h" - -using OHOS::Security::AccessToken::RandomMbedtls; -using OHOS::Security::AccessToken::RET_SUCCESS; - -namespace OHOS { -namespace Security { -namespace AccessToken { -extern "C" unsigned int GetRandomUint32() -{ - unsigned int rand; - int ret = RandomMbedtls::GetInstance().GenerateRandomArray((unsigned char *)&rand, sizeof(rand)); - if (ret != RET_SUCCESS) { - return 0; - } - return rand; -} - -int RandomMbedtls::GenerateRandomArray(unsigned char *randStr, unsigned int len) -{ - if (randStr == nullptr || len == 0) { - return RET_FAILED; - } - int ret; - - Utils::UniqueWriteGuard infoGuard(this->randomLock_); - if (!initFlag_) { - mbedtls_ctr_drbg_init(&ctrDrbg_); - mbedtls_entropy_init(&entropy_); - ret = mbedtls_ctr_drbg_seed(&ctrDrbg_, mbedtls_entropy_func, &entropy_, NULL, 0); - if (ret != 0) { - return RET_FAILED; - } - initFlag_ = true; - } - - ret = mbedtls_ctr_drbg_random(&ctrDrbg_, randStr, len); - if (ret != 0) { - return RET_FAILED; - } - return RET_SUCCESS; -} - -RandomMbedtls& RandomMbedtls::GetInstance() -{ - static RandomMbedtls instance; - return instance; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "random_mbedtls.h" +#include "access_token.h" + +using OHOS::Security::AccessToken::RandomMbedtls; +using OHOS::Security::AccessToken::RET_SUCCESS; + +namespace OHOS { +namespace Security { +namespace AccessToken { +extern "C" unsigned int GetRandomUint32() +{ + unsigned int rand; + int ret = RandomMbedtls::GetInstance().GenerateRandomArray((unsigned char *)&rand, sizeof(rand)); + if (ret != RET_SUCCESS) { + return 0; + } + return rand; +} + +int RandomMbedtls::GenerateRandomArray(unsigned char *randStr, unsigned int len) +{ + if (randStr == nullptr || len == 0) { + return RET_FAILED; + } + int ret; + + Utils::UniqueWriteGuard infoGuard(this->randomLock_); + if (!initFlag_) { + mbedtls_ctr_drbg_init(&ctrDrbg_); + mbedtls_entropy_init(&entropy_); + ret = mbedtls_ctr_drbg_seed(&ctrDrbg_, mbedtls_entropy_func, &entropy_, NULL, 0); + if (ret != 0) { + return RET_FAILED; + } + initFlag_ = true; + } + + ret = mbedtls_ctr_drbg_random(&ctrDrbg_, randStr, len); + if (ret != 0) { + return RET_FAILED; + } + return RET_SUCCESS; +} + +RandomMbedtls& RandomMbedtls::GetInstance() +{ + static RandomMbedtls instance; + return instance; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/privacy/BUILD.gn b/frameworks/privacy/BUILD.gn index e721025514c3b6b9cb4139b702574334541bf9f7..70f65f8e5b8fc27deabab8373f4c14e4668c46a6 100644 --- a/frameworks/privacy/BUILD.gn +++ b/frameworks/privacy/BUILD.gn @@ -1,41 +1,41 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -ohos_shared_library("privacy_communication_adapter_cxx") { - subsystem_name = "security" - part_name = "access_token" - - include_dirs = [ - "include", - "//base/security/access_token/interfaces/innerkits/accesstoken/include", - "//base/security/access_token/interfaces/innerkits/privacy/include", - "//base/security/access_token/frameworks/common/include", - "//commonlibrary/c_utils/base/include", - ] - - sources = [ - "src/bundle_used_record_parcel.cpp", - "src/perm_active_response_parcel.cpp", - "src/permission_used_record_parcel.cpp", - "src/permission_used_request_parcel.cpp", - "src/permission_used_result_parcel.cpp", - "src/used_record_detail_parcel.cpp", - ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_core", - ] -} +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +ohos_shared_library("privacy_communication_adapter_cxx") { + subsystem_name = "security" + part_name = "access_token" + + include_dirs = [ + "include", + "//base/security/access_token/interfaces/innerkits/accesstoken/include", + "//base/security/access_token/interfaces/innerkits/privacy/include", + "//base/security/access_token/frameworks/common/include", + "//commonlibrary/c_utils/base/include", + ] + + sources = [ + "src/bundle_used_record_parcel.cpp", + "src/perm_active_response_parcel.cpp", + "src/permission_used_record_parcel.cpp", + "src/permission_used_request_parcel.cpp", + "src/permission_used_result_parcel.cpp", + "src/used_record_detail_parcel.cpp", + ] + + external_deps = [ + "c_utils:utils", + "ipc:ipc_core", + ] +} diff --git a/frameworks/privacy/include/bundle_used_record_parcel.h b/frameworks/privacy/include/bundle_used_record_parcel.h index d94e185e86e65f7a561fd076ea9ca403450d75ae..aeeb8488b1d721b701b622493bf0a25e16f857b8 100644 --- a/frameworks/privacy/include/bundle_used_record_parcel.h +++ b/frameworks/privacy/include/bundle_used_record_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BUNDLE_USED_RECORD_PARCEL_H -#define BUNDLE_USED_RECORD_PARCEL_H - -#include "parcel.h" -#include "permission_used_result.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct BundleUsedRecordParcel final : public Parcelable { - BundleUsedRecordParcel() = default; - - ~BundleUsedRecordParcel() override = default; - - bool Marshalling(Parcel& out) const override; - - static BundleUsedRecordParcel* Unmarshalling(Parcel& in); - - BundleUsedRecord bundleRecord; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // BUNDLE_USED_RECORD_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BUNDLE_USED_RECORD_PARCEL_H +#define BUNDLE_USED_RECORD_PARCEL_H + +#include "parcel.h" +#include "permission_used_result.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct BundleUsedRecordParcel final : public Parcelable { + BundleUsedRecordParcel() = default; + + ~BundleUsedRecordParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static BundleUsedRecordParcel* Unmarshalling(Parcel& in); + + BundleUsedRecord bundleRecord; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // BUNDLE_USED_RECORD_PARCEL_H diff --git a/frameworks/privacy/include/i_privacy_manager.h b/frameworks/privacy/include/i_privacy_manager.h index ff8bebda82f39a273b4e9568985444c7b3d7800f..3d2646e6f4de1390f2e676b9edb910b24fae9dd1 100644 --- a/frameworks/privacy/include/i_privacy_manager.h +++ b/frameworks/privacy/include/i_privacy_manager.h @@ -1,67 +1,70 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef I_PRIVACY_MANAGER_H -#define I_PRIVACY_MANAGER_H - -#include - -#include "access_token.h" -#include "errors.h" -#include "iremote_broker.h" - -#include "on_permission_used_record_callback.h" -#include "permission_used_request_parcel.h" -#include "permission_used_result_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class IPrivacyManager : public IRemoteBroker { -public: - static const int32_t SA_ID_PRIVACY_MANAGER_SERVICE = 3505; - - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.IPrivacyManager"); - - virtual int32_t AddPermissionUsedRecord( - AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) = 0; - virtual int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) = 0; - virtual int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) = 0; - virtual int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) = 0; - virtual int32_t GetPermissionUsedRecords( - const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) = 0; - virtual int32_t GetPermissionUsedRecords( - const PermissionUsedRequestParcel& request, const sptr& callback) = 0; - virtual std::string DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) = 0; - virtual int32_t RegisterPermActiveStatusCallback( - std::vector& permList, const sptr& callback) = 0; - virtual int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) = 0; - enum class InterfaceCode { - ADD_PERMISSION_USED_RECORD = 0xf001, - START_USING_PERMISSION = 0xf002, - STOP_USING_PERMISSION = 0xf003, - DELETE_PERMISSION_USED_RECORDS = 0xf004, - GET_PERMISSION_USED_RECORDS = 0xf005, - GET_PERMISSION_USED_RECORDS_ASYNC = 0xf006, - DUMP_RECORD_INFO = 0xf007, - REGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK = 0xf008, - UNREGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK = 0xf009, - }; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // I_PRIVACY_MANAGER_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef I_PRIVACY_MANAGER_H +#define I_PRIVACY_MANAGER_H + +#include + +#include "access_token.h" +#include "errors.h" +#include "iremote_broker.h" + +#include "on_permission_used_record_callback.h" +#include "permission_used_request_parcel.h" +#include "permission_used_result_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class IPrivacyManager : public IRemoteBroker { +public: + static const int32_t SA_ID_PRIVACY_MANAGER_SERVICE = 3505; + + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.IPrivacyManager"); + + virtual int32_t AddPermissionUsedRecord( + AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) = 0; + virtual int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) = 0; + virtual int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) = 0; + virtual int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) = 0; + virtual int32_t GetPermissionUsedRecords( + const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) = 0; + virtual int32_t GetPermissionUsedRecords( + const PermissionUsedRequestParcel& request, const sptr& callback) = 0; + virtual std::string DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) = 0; + virtual int32_t RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) = 0; + virtual int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) = 0; + virtual bool IsAllowUsingPermission(AccessTokenID tokenID, const std::string& permissionName) = 0; + + enum class InterfaceCode { + ADD_PERMISSION_USED_RECORD = 0xf001, + START_USING_PERMISSION = 0xf002, + STOP_USING_PERMISSION = 0xf003, + DELETE_PERMISSION_USED_RECORDS = 0xf004, + GET_PERMISSION_USED_RECORDS = 0xf005, + GET_PERMISSION_USED_RECORDS_ASYNC = 0xf006, + DUMP_RECORD_INFO = 0xf007, + REGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK = 0xf008, + UNREGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK = 0xf009, + IS_ALLOW_USING_PERMISSION = 0xf010, + }; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // I_PRIVACY_MANAGER_H diff --git a/frameworks/privacy/include/perm_active_response_parcel.h b/frameworks/privacy/include/perm_active_response_parcel.h index 706d9fa4bde0eedb5f98d2457ce4ea5248cfc420..66187ea77f63c64a19cbc23525453a9b96d17e34 100644 --- a/frameworks/privacy/include/perm_active_response_parcel.h +++ b/frameworks/privacy/include/perm_active_response_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERM_ACTIVE_RESPONES_PARCEL_H -#define PERM_ACTIVE_RESPONES_PARCEL_H - -#include "active_change_response_info.h" -#include "parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct ActiveChangeResponseParcel final : public Parcelable { - ActiveChangeResponseParcel() = default; - - ~ActiveChangeResponseParcel() override = default; - - bool Marshalling(Parcel& out) const override; - - static ActiveChangeResponseParcel* Unmarshalling(Parcel& in); - - ActiveChangeResponse changeResponse; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // PERM_ACTIVE_RESPONES_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERM_ACTIVE_RESPONES_PARCEL_H +#define PERM_ACTIVE_RESPONES_PARCEL_H + +#include "active_change_response_info.h" +#include "parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct ActiveChangeResponseParcel final : public Parcelable { + ActiveChangeResponseParcel() = default; + + ~ActiveChangeResponseParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static ActiveChangeResponseParcel* Unmarshalling(Parcel& in); + + ActiveChangeResponse changeResponse; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERM_ACTIVE_RESPONES_PARCEL_H diff --git a/frameworks/privacy/include/permission_used_record_parcel.h b/frameworks/privacy/include/permission_used_record_parcel.h index c2a24dcce5c50f2be0e00e5ccead0008ea070193..ac805c04355b805ed4bd020029390fdaffde6ec5 100644 --- a/frameworks/privacy/include/permission_used_record_parcel.h +++ b/frameworks/privacy/include/permission_used_record_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_USED_RECORD_PARCEL_H -#define PERMISSION_USED_RECORD_PARCEL_H - -#include "parcel.h" -#include "permission_used_result.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionUsedRecordParcel final : public Parcelable { - PermissionUsedRecordParcel() = default; - - ~PermissionUsedRecordParcel() override = default; - - bool Marshalling(Parcel& out) const override; - - static PermissionUsedRecordParcel* Unmarshalling(Parcel& in); - - PermissionUsedRecord permissionRecord; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // PERMISSION_USED_RECORD_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_USED_RECORD_PARCEL_H +#define PERMISSION_USED_RECORD_PARCEL_H + +#include "parcel.h" +#include "permission_used_result.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionUsedRecordParcel final : public Parcelable { + PermissionUsedRecordParcel() = default; + + ~PermissionUsedRecordParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static PermissionUsedRecordParcel* Unmarshalling(Parcel& in); + + PermissionUsedRecord permissionRecord; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERMISSION_USED_RECORD_PARCEL_H diff --git a/frameworks/privacy/include/permission_used_request_parcel.h b/frameworks/privacy/include/permission_used_request_parcel.h index e0146d5218af02289faf259cfe6414960ae48dce..9ebb748d896e5db1879215365a47c8e6188a66d7 100644 --- a/frameworks/privacy/include/permission_used_request_parcel.h +++ b/frameworks/privacy/include/permission_used_request_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_USED_REQUEST_PARCEL_H -#define PERMISSION_USED_REQUEST_PARCEL_H - -#include "parcel.h" -#include "permission_used_request.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionUsedRequestParcel final : public Parcelable { - PermissionUsedRequestParcel() = default; - - ~PermissionUsedRequestParcel() override = default; - - bool Marshalling(Parcel& out) const override; - - static PermissionUsedRequestParcel* Unmarshalling(Parcel& in); - - PermissionUsedRequest request; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // PERMISSION_USED_REQUEST_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_USED_REQUEST_PARCEL_H +#define PERMISSION_USED_REQUEST_PARCEL_H + +#include "parcel.h" +#include "permission_used_request.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionUsedRequestParcel final : public Parcelable { + PermissionUsedRequestParcel() = default; + + ~PermissionUsedRequestParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static PermissionUsedRequestParcel* Unmarshalling(Parcel& in); + + PermissionUsedRequest request; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERMISSION_USED_REQUEST_PARCEL_H diff --git a/frameworks/privacy/include/permission_used_result_parcel.h b/frameworks/privacy/include/permission_used_result_parcel.h index 40e3d01fd51187fcdfefa687315b886464fa00da..950baf112f000b2c48c51c28be1e780d911ecb3d 100644 --- a/frameworks/privacy/include/permission_used_result_parcel.h +++ b/frameworks/privacy/include/permission_used_result_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_USED_RESPONSE_PARCEL_H -#define PERMISSION_USED_RESPONSE_PARCEL_H - -#include "parcel.h" -#include "permission_used_result.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionUsedResultParcel final : public Parcelable { - PermissionUsedResultParcel() = default; - - ~PermissionUsedResultParcel() override = default; - - bool Marshalling(Parcel& out) const override; - - static PermissionUsedResultParcel* Unmarshalling(Parcel& in); - - PermissionUsedResult result; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // PERMISSION_USED_RESPONSE_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_USED_RESPONSE_PARCEL_H +#define PERMISSION_USED_RESPONSE_PARCEL_H + +#include "parcel.h" +#include "permission_used_result.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionUsedResultParcel final : public Parcelable { + PermissionUsedResultParcel() = default; + + ~PermissionUsedResultParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static PermissionUsedResultParcel* Unmarshalling(Parcel& in); + + PermissionUsedResult result; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERMISSION_USED_RESPONSE_PARCEL_H diff --git a/frameworks/privacy/include/used_record_detail_parcel.h b/frameworks/privacy/include/used_record_detail_parcel.h index 8922fc222149ca57e5b8115406fb00be3ab2f526..105cf943d23dea07851e7a03e54649dce2676ca2 100644 --- a/frameworks/privacy/include/used_record_detail_parcel.h +++ b/frameworks/privacy/include/used_record_detail_parcel.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef USED_RECORD_DETAIL_PARCEL_H -#define USED_RECORD_DETAIL_PARCEL_H - -#include "parcel.h" -#include "permission_used_result.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct UsedRecordDetailParcel final : public Parcelable { - UsedRecordDetailParcel() = default; - - ~UsedRecordDetailParcel() override = default; - - bool Marshalling(Parcel& out) const override; - - static UsedRecordDetailParcel* Unmarshalling(Parcel& in); - - UsedRecordDetail detail; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // USED_RECORD_DETAIL_PARCEL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef USED_RECORD_DETAIL_PARCEL_H +#define USED_RECORD_DETAIL_PARCEL_H + +#include "parcel.h" +#include "permission_used_result.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct UsedRecordDetailParcel final : public Parcelable { + UsedRecordDetailParcel() = default; + + ~UsedRecordDetailParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static UsedRecordDetailParcel* Unmarshalling(Parcel& in); + + UsedRecordDetail detail; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // USED_RECORD_DETAIL_PARCEL_H diff --git a/frameworks/privacy/src/bundle_used_record_parcel.cpp b/frameworks/privacy/src/bundle_used_record_parcel.cpp index 529c386e17179df14f2324847ead17459c1dda8f..3b8fe754e805f5af106b00bc2d1baa300116b124 100644 --- a/frameworks/privacy/src/bundle_used_record_parcel.cpp +++ b/frameworks/privacy/src/bundle_used_record_parcel.cpp @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "bundle_used_record_parcel.h" -#include "refbase.h" -#include "parcel_utils.h" -#include "permission_used_record_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool BundleUsedRecordParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteUint32(this->bundleRecord.tokenId)); - RETURN_IF_FALSE(out.WriteBool(this->bundleRecord.isRemote)); - RETURN_IF_FALSE(out.WriteString(this->bundleRecord.deviceId)); - RETURN_IF_FALSE(out.WriteString(this->bundleRecord.bundleName)); - - RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->bundleRecord.permissionRecords.size()))); - for (const auto& permRecord : this->bundleRecord.permissionRecords) { - PermissionUsedRecordParcel permRecordParcel; - permRecordParcel.permissionRecord = permRecord; - out.WriteParcelable(&permRecordParcel); - } - return true; -} - -BundleUsedRecordParcel* BundleUsedRecordParcel::Unmarshalling(Parcel& in) -{ - auto* bundleRecordParcel = new (std::nothrow) BundleUsedRecordParcel(); - RELEASE_IF_FALSE(bundleRecordParcel != nullptr, bundleRecordParcel); - - RELEASE_IF_FALSE(in.ReadUint32(bundleRecordParcel->bundleRecord.tokenId), bundleRecordParcel); - RELEASE_IF_FALSE(in.ReadBool(bundleRecordParcel->bundleRecord.isRemote), bundleRecordParcel); - RELEASE_IF_FALSE(in.ReadString(bundleRecordParcel->bundleRecord.deviceId), bundleRecordParcel); - RELEASE_IF_FALSE(in.ReadString(bundleRecordParcel->bundleRecord.bundleName), bundleRecordParcel); - - int32_t permRecordSize = 0; - RELEASE_IF_FALSE(in.ReadInt32(permRecordSize), bundleRecordParcel); - for (int32_t i = 0; i < permRecordSize; i++) { - sptr permRecord = in.ReadParcelable(); - RELEASE_IF_FALSE(permRecord != nullptr, bundleRecordParcel); - bundleRecordParcel->bundleRecord.permissionRecords.emplace_back(permRecord->permissionRecord); - } - return bundleRecordParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "bundle_used_record_parcel.h" +#include "refbase.h" +#include "parcel_utils.h" +#include "permission_used_record_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool BundleUsedRecordParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteUint32(this->bundleRecord.tokenId)); + RETURN_IF_FALSE(out.WriteBool(this->bundleRecord.isRemote)); + RETURN_IF_FALSE(out.WriteString(this->bundleRecord.deviceId)); + RETURN_IF_FALSE(out.WriteString(this->bundleRecord.bundleName)); + + RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->bundleRecord.permissionRecords.size()))); + for (const auto& permRecord : this->bundleRecord.permissionRecords) { + PermissionUsedRecordParcel permRecordParcel; + permRecordParcel.permissionRecord = permRecord; + out.WriteParcelable(&permRecordParcel); + } + return true; +} + +BundleUsedRecordParcel* BundleUsedRecordParcel::Unmarshalling(Parcel& in) +{ + auto* bundleRecordParcel = new (std::nothrow) BundleUsedRecordParcel(); + RELEASE_IF_FALSE(bundleRecordParcel != nullptr, bundleRecordParcel); + + RELEASE_IF_FALSE(in.ReadUint32(bundleRecordParcel->bundleRecord.tokenId), bundleRecordParcel); + RELEASE_IF_FALSE(in.ReadBool(bundleRecordParcel->bundleRecord.isRemote), bundleRecordParcel); + RELEASE_IF_FALSE(in.ReadString(bundleRecordParcel->bundleRecord.deviceId), bundleRecordParcel); + RELEASE_IF_FALSE(in.ReadString(bundleRecordParcel->bundleRecord.bundleName), bundleRecordParcel); + + int32_t permRecordSize = 0; + RELEASE_IF_FALSE(in.ReadInt32(permRecordSize), bundleRecordParcel); + for (int32_t i = 0; i < permRecordSize; i++) { + sptr permRecord = in.ReadParcelable(); + RELEASE_IF_FALSE(permRecord != nullptr, bundleRecordParcel); + bundleRecordParcel->bundleRecord.permissionRecords.emplace_back(permRecord->permissionRecord); + } + return bundleRecordParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/privacy/src/perm_active_response_parcel.cpp b/frameworks/privacy/src/perm_active_response_parcel.cpp index 49617f9d70b046a6d95d7f96d61725d3786744b8..957972401a55058548ec23049d85854e80012190 100644 --- a/frameworks/privacy/src/perm_active_response_parcel.cpp +++ b/frameworks/privacy/src/perm_active_response_parcel.cpp @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "parcel_utils.h" -#include "perm_active_response_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool ActiveChangeResponseParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteUint32(this->changeResponse.tokenID)); - RETURN_IF_FALSE(out.WriteString(this->changeResponse.permissionName)); - RETURN_IF_FALSE(out.WriteString(this->changeResponse.deviceId)); - RETURN_IF_FALSE(out.WriteInt32(this->changeResponse.type)); - return true; -} - -ActiveChangeResponseParcel* ActiveChangeResponseParcel::Unmarshalling(Parcel& in) -{ - auto* activeChangeResponseParcel = new (std::nothrow) ActiveChangeResponseParcel(); - if (activeChangeResponseParcel == nullptr) { - return nullptr; - } - - RELEASE_IF_FALSE(in.ReadUint32(activeChangeResponseParcel->changeResponse.tokenID), activeChangeResponseParcel); - RELEASE_IF_FALSE(in.ReadString(activeChangeResponseParcel->changeResponse.permissionName), - activeChangeResponseParcel); - RELEASE_IF_FALSE(in.ReadString(activeChangeResponseParcel->changeResponse.deviceId), activeChangeResponseParcel); - - int32_t type; - RELEASE_IF_FALSE(in.ReadInt32(type), activeChangeResponseParcel); - activeChangeResponseParcel->changeResponse.type = static_cast(type); - return activeChangeResponseParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "parcel_utils.h" +#include "perm_active_response_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool ActiveChangeResponseParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteUint32(this->changeResponse.tokenID)); + RETURN_IF_FALSE(out.WriteString(this->changeResponse.permissionName)); + RETURN_IF_FALSE(out.WriteString(this->changeResponse.deviceId)); + RETURN_IF_FALSE(out.WriteInt32(this->changeResponse.type)); + return true; +} + +ActiveChangeResponseParcel* ActiveChangeResponseParcel::Unmarshalling(Parcel& in) +{ + auto* activeChangeResponseParcel = new (std::nothrow) ActiveChangeResponseParcel(); + if (activeChangeResponseParcel == nullptr) { + return nullptr; + } + + RELEASE_IF_FALSE(in.ReadUint32(activeChangeResponseParcel->changeResponse.tokenID), activeChangeResponseParcel); + RELEASE_IF_FALSE(in.ReadString(activeChangeResponseParcel->changeResponse.permissionName), + activeChangeResponseParcel); + RELEASE_IF_FALSE(in.ReadString(activeChangeResponseParcel->changeResponse.deviceId), activeChangeResponseParcel); + + int32_t type; + RELEASE_IF_FALSE(in.ReadInt32(type), activeChangeResponseParcel); + activeChangeResponseParcel->changeResponse.type = static_cast(type); + return activeChangeResponseParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/privacy/src/permission_used_record_parcel.cpp b/frameworks/privacy/src/permission_used_record_parcel.cpp index 135e4a918100c15603ab8dd0ddb1c71125eb1f3f..682994e7563408319a8d1476a14b676922d8c4fa 100644 --- a/frameworks/privacy/src/permission_used_record_parcel.cpp +++ b/frameworks/privacy/src/permission_used_record_parcel.cpp @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_used_record_parcel.h" -#include "refbase.h" -#include "parcel_utils.h" -#include "used_record_detail_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool PermissionUsedRecordParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteString(this->permissionRecord.permissionName)); - RETURN_IF_FALSE(out.WriteInt32(this->permissionRecord.accessCount)); - RETURN_IF_FALSE(out.WriteInt32(this->permissionRecord.rejectCount)); - RETURN_IF_FALSE(out.WriteInt64(this->permissionRecord.lastAccessTime)); - RETURN_IF_FALSE(out.WriteInt64(this->permissionRecord.lastRejectTime)); - RETURN_IF_FALSE(out.WriteInt64(this->permissionRecord.lastAccessDuration)); - - RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permissionRecord.accessRecords.size()))); - for (const auto& accRecord : this->permissionRecord.accessRecords) { - UsedRecordDetailParcel detailParcel; - detailParcel.detail = accRecord; - out.WriteParcelable(&detailParcel); - } - - RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permissionRecord.rejectRecords.size()))); - for (const auto& rejRecord : this->permissionRecord.rejectRecords) { - UsedRecordDetailParcel detailParcel; - detailParcel.detail = rejRecord; - out.WriteParcelable(&detailParcel); - } - return true; -} - -PermissionUsedRecordParcel* PermissionUsedRecordParcel::Unmarshalling(Parcel& in) -{ - auto* permissionRecordParcel = new (std::nothrow) PermissionUsedRecordParcel(); - RELEASE_IF_FALSE(permissionRecordParcel != nullptr, permissionRecordParcel); - - RELEASE_IF_FALSE(in.ReadString(permissionRecordParcel->permissionRecord.permissionName), permissionRecordParcel); - RELEASE_IF_FALSE(in.ReadInt32(permissionRecordParcel->permissionRecord.accessCount), permissionRecordParcel); - RELEASE_IF_FALSE(in.ReadInt32(permissionRecordParcel->permissionRecord.rejectCount), permissionRecordParcel); - RELEASE_IF_FALSE(in.ReadInt64(permissionRecordParcel->permissionRecord.lastAccessTime), permissionRecordParcel); - RELEASE_IF_FALSE(in.ReadInt64(permissionRecordParcel->permissionRecord.lastRejectTime), permissionRecordParcel); - RELEASE_IF_FALSE(in.ReadInt64(permissionRecordParcel->permissionRecord.lastAccessDuration), permissionRecordParcel); - - int32_t accRecordSize = 0; - RELEASE_IF_FALSE(in.ReadInt32(accRecordSize), permissionRecordParcel); - for (int32_t i = 0; i < accRecordSize; i++) { - sptr detailParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(detailParcel != nullptr, permissionRecordParcel); - permissionRecordParcel->permissionRecord.accessRecords.emplace_back(detailParcel->detail); - } - - int32_t rejRecordSize = 0; - RELEASE_IF_FALSE(in.ReadInt32(rejRecordSize), permissionRecordParcel); - for (int32_t i = 0; i < rejRecordSize; i++) { - sptr detailParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(detailParcel != nullptr, permissionRecordParcel); - permissionRecordParcel->permissionRecord.rejectRecords.emplace_back(detailParcel->detail); - } - return permissionRecordParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_used_record_parcel.h" +#include "refbase.h" +#include "parcel_utils.h" +#include "used_record_detail_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool PermissionUsedRecordParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteString(this->permissionRecord.permissionName)); + RETURN_IF_FALSE(out.WriteInt32(this->permissionRecord.accessCount)); + RETURN_IF_FALSE(out.WriteInt32(this->permissionRecord.rejectCount)); + RETURN_IF_FALSE(out.WriteInt64(this->permissionRecord.lastAccessTime)); + RETURN_IF_FALSE(out.WriteInt64(this->permissionRecord.lastRejectTime)); + RETURN_IF_FALSE(out.WriteInt64(this->permissionRecord.lastAccessDuration)); + + RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permissionRecord.accessRecords.size()))); + for (const auto& accRecord : this->permissionRecord.accessRecords) { + UsedRecordDetailParcel detailParcel; + detailParcel.detail = accRecord; + out.WriteParcelable(&detailParcel); + } + + RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->permissionRecord.rejectRecords.size()))); + for (const auto& rejRecord : this->permissionRecord.rejectRecords) { + UsedRecordDetailParcel detailParcel; + detailParcel.detail = rejRecord; + out.WriteParcelable(&detailParcel); + } + return true; +} + +PermissionUsedRecordParcel* PermissionUsedRecordParcel::Unmarshalling(Parcel& in) +{ + auto* permissionRecordParcel = new (std::nothrow) PermissionUsedRecordParcel(); + RELEASE_IF_FALSE(permissionRecordParcel != nullptr, permissionRecordParcel); + + RELEASE_IF_FALSE(in.ReadString(permissionRecordParcel->permissionRecord.permissionName), permissionRecordParcel); + RELEASE_IF_FALSE(in.ReadInt32(permissionRecordParcel->permissionRecord.accessCount), permissionRecordParcel); + RELEASE_IF_FALSE(in.ReadInt32(permissionRecordParcel->permissionRecord.rejectCount), permissionRecordParcel); + RELEASE_IF_FALSE(in.ReadInt64(permissionRecordParcel->permissionRecord.lastAccessTime), permissionRecordParcel); + RELEASE_IF_FALSE(in.ReadInt64(permissionRecordParcel->permissionRecord.lastRejectTime), permissionRecordParcel); + RELEASE_IF_FALSE(in.ReadInt64(permissionRecordParcel->permissionRecord.lastAccessDuration), permissionRecordParcel); + + int32_t accRecordSize = 0; + RELEASE_IF_FALSE(in.ReadInt32(accRecordSize), permissionRecordParcel); + for (int32_t i = 0; i < accRecordSize; i++) { + sptr detailParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(detailParcel != nullptr, permissionRecordParcel); + permissionRecordParcel->permissionRecord.accessRecords.emplace_back(detailParcel->detail); + } + + int32_t rejRecordSize = 0; + RELEASE_IF_FALSE(in.ReadInt32(rejRecordSize), permissionRecordParcel); + for (int32_t i = 0; i < rejRecordSize; i++) { + sptr detailParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(detailParcel != nullptr, permissionRecordParcel); + permissionRecordParcel->permissionRecord.rejectRecords.emplace_back(detailParcel->detail); + } + return permissionRecordParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/privacy/src/permission_used_request_parcel.cpp b/frameworks/privacy/src/permission_used_request_parcel.cpp index e4eac2bce76576d3ddee9bbfb973df058400566c..1ae64d9d1c46bd6426053ad0b8ae6b46d87216a9 100644 --- a/frameworks/privacy/src/permission_used_request_parcel.cpp +++ b/frameworks/privacy/src/permission_used_request_parcel.cpp @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_used_request_parcel.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool PermissionUsedRequestParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteUint32(this->request.tokenId)); - RETURN_IF_FALSE(out.WriteBool(this->request.isRemote)); - RETURN_IF_FALSE(out.WriteString(this->request.deviceId)); - RETURN_IF_FALSE(out.WriteString(this->request.bundleName)); - - RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->request.permissionList.size()))); - for (const auto& perm : this->request.permissionList) { - RETURN_IF_FALSE(out.WriteString(perm)); - } - RETURN_IF_FALSE(out.WriteInt64(this->request.beginTimeMillis)); - RETURN_IF_FALSE(out.WriteInt64(this->request.endTimeMillis)); - RETURN_IF_FALSE(out.WriteInt32(this->request.flag)); - return true; -} - -PermissionUsedRequestParcel* PermissionUsedRequestParcel::Unmarshalling(Parcel& in) -{ - auto* requestParcel = new (std::nothrow) PermissionUsedRequestParcel(); - RELEASE_IF_FALSE(requestParcel != nullptr, requestParcel); - - RELEASE_IF_FALSE(in.ReadUint32(requestParcel->request.tokenId), requestParcel); - RELEASE_IF_FALSE(in.ReadBool (requestParcel->request.isRemote), requestParcel); - RELEASE_IF_FALSE(in.ReadString(requestParcel->request.deviceId), requestParcel); - RELEASE_IF_FALSE(in.ReadString(requestParcel->request.bundleName), requestParcel); - - int32_t permSize = 0; - RELEASE_IF_FALSE(in.ReadInt32(permSize), requestParcel); - for (int32_t i = 0; i < permSize; i++) { - std::string perm; - RELEASE_IF_FALSE(in.ReadString(perm), requestParcel); - requestParcel->request.permissionList.emplace_back(perm); - } - RELEASE_IF_FALSE(in.ReadInt64(requestParcel->request.beginTimeMillis), requestParcel); - RELEASE_IF_FALSE(in.ReadInt64(requestParcel->request.endTimeMillis), requestParcel); - int32_t flag; - RELEASE_IF_FALSE(in.ReadInt32(flag), requestParcel); - requestParcel->request.flag = static_cast(flag); - return requestParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_used_request_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool PermissionUsedRequestParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteUint32(this->request.tokenId)); + RETURN_IF_FALSE(out.WriteBool(this->request.isRemote)); + RETURN_IF_FALSE(out.WriteString(this->request.deviceId)); + RETURN_IF_FALSE(out.WriteString(this->request.bundleName)); + + RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->request.permissionList.size()))); + for (const auto& perm : this->request.permissionList) { + RETURN_IF_FALSE(out.WriteString(perm)); + } + RETURN_IF_FALSE(out.WriteInt64(this->request.beginTimeMillis)); + RETURN_IF_FALSE(out.WriteInt64(this->request.endTimeMillis)); + RETURN_IF_FALSE(out.WriteInt32(this->request.flag)); + return true; +} + +PermissionUsedRequestParcel* PermissionUsedRequestParcel::Unmarshalling(Parcel& in) +{ + auto* requestParcel = new (std::nothrow) PermissionUsedRequestParcel(); + RELEASE_IF_FALSE(requestParcel != nullptr, requestParcel); + + RELEASE_IF_FALSE(in.ReadUint32(requestParcel->request.tokenId), requestParcel); + RELEASE_IF_FALSE(in.ReadBool (requestParcel->request.isRemote), requestParcel); + RELEASE_IF_FALSE(in.ReadString(requestParcel->request.deviceId), requestParcel); + RELEASE_IF_FALSE(in.ReadString(requestParcel->request.bundleName), requestParcel); + + int32_t permSize = 0; + RELEASE_IF_FALSE(in.ReadInt32(permSize), requestParcel); + for (int32_t i = 0; i < permSize; i++) { + std::string perm; + RELEASE_IF_FALSE(in.ReadString(perm), requestParcel); + requestParcel->request.permissionList.emplace_back(perm); + } + RELEASE_IF_FALSE(in.ReadInt64(requestParcel->request.beginTimeMillis), requestParcel); + RELEASE_IF_FALSE(in.ReadInt64(requestParcel->request.endTimeMillis), requestParcel); + int32_t flag; + RELEASE_IF_FALSE(in.ReadInt32(flag), requestParcel); + requestParcel->request.flag = static_cast(flag); + return requestParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/privacy/src/permission_used_result_parcel.cpp b/frameworks/privacy/src/permission_used_result_parcel.cpp index 8dec895ab8d786c5a46d28ffe4179d515d608cb2..0ff3d5dd8be51e02a0960d0e812bdfacd93d1599 100644 --- a/frameworks/privacy/src/permission_used_result_parcel.cpp +++ b/frameworks/privacy/src/permission_used_result_parcel.cpp @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_used_result_parcel.h" -#include "refbase.h" -#include "bundle_used_record_parcel.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool PermissionUsedResultParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteInt64(this->result.beginTimeMillis)); - RETURN_IF_FALSE(out.WriteInt64(this->result.endTimeMillis)); - - RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->result.bundleRecords.size()))); - for (const auto& bundRecord : this->result.bundleRecords) { - BundleUsedRecordParcel bundleParcel; - bundleParcel.bundleRecord = bundRecord; - out.WriteParcelable(&bundleParcel); - } - return true; -} - -PermissionUsedResultParcel* PermissionUsedResultParcel::Unmarshalling(Parcel& in) -{ - auto* resultParcel = new (std::nothrow) PermissionUsedResultParcel(); - RELEASE_IF_FALSE(resultParcel != nullptr, resultParcel); - - RELEASE_IF_FALSE(in.ReadInt64(resultParcel->result.beginTimeMillis), resultParcel); - RELEASE_IF_FALSE(in.ReadInt64(resultParcel->result.endTimeMillis), resultParcel); - - int32_t bundResponseSize = 0; - RELEASE_IF_FALSE(in.ReadInt32(bundResponseSize), resultParcel); - for (int32_t i = 0; i < bundResponseSize; i++) { - sptr bunRecordParcel = in.ReadParcelable(); - RELEASE_IF_FALSE(bunRecordParcel != nullptr, resultParcel); - resultParcel->result.bundleRecords.emplace_back(bunRecordParcel->bundleRecord); - } - return resultParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_used_result_parcel.h" +#include "refbase.h" +#include "bundle_used_record_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool PermissionUsedResultParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteInt64(this->result.beginTimeMillis)); + RETURN_IF_FALSE(out.WriteInt64(this->result.endTimeMillis)); + + RETURN_IF_FALSE(out.WriteInt32((int32_t)(this->result.bundleRecords.size()))); + for (const auto& bundRecord : this->result.bundleRecords) { + BundleUsedRecordParcel bundleParcel; + bundleParcel.bundleRecord = bundRecord; + out.WriteParcelable(&bundleParcel); + } + return true; +} + +PermissionUsedResultParcel* PermissionUsedResultParcel::Unmarshalling(Parcel& in) +{ + auto* resultParcel = new (std::nothrow) PermissionUsedResultParcel(); + RELEASE_IF_FALSE(resultParcel != nullptr, resultParcel); + + RELEASE_IF_FALSE(in.ReadInt64(resultParcel->result.beginTimeMillis), resultParcel); + RELEASE_IF_FALSE(in.ReadInt64(resultParcel->result.endTimeMillis), resultParcel); + + int32_t bundResponseSize = 0; + RELEASE_IF_FALSE(in.ReadInt32(bundResponseSize), resultParcel); + for (int32_t i = 0; i < bundResponseSize; i++) { + sptr bunRecordParcel = in.ReadParcelable(); + RELEASE_IF_FALSE(bunRecordParcel != nullptr, resultParcel); + resultParcel->result.bundleRecords.emplace_back(bunRecordParcel->bundleRecord); + } + return resultParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/privacy/src/used_record_detail_parcel.cpp b/frameworks/privacy/src/used_record_detail_parcel.cpp index d59512b675091cd60db6ef59b7011106b1cd2567..33a93adebede280652e2011be62eae246abd4f53 100644 --- a/frameworks/privacy/src/used_record_detail_parcel.cpp +++ b/frameworks/privacy/src/used_record_detail_parcel.cpp @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "used_record_detail_parcel.h" -#include "parcel_utils.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -bool UsedRecordDetailParcel::Marshalling(Parcel& out) const -{ - RETURN_IF_FALSE(out.WriteInt32(this->detail.status)); - RETURN_IF_FALSE(out.WriteInt64(this->detail.timestamp)); - RETURN_IF_FALSE(out.WriteInt64(this->detail.accessDuration)); - return true; -} - -UsedRecordDetailParcel* UsedRecordDetailParcel::Unmarshalling(Parcel& in) -{ - auto* detailRecordParcel = new (std::nothrow) UsedRecordDetailParcel(); - RELEASE_IF_FALSE(detailRecordParcel != nullptr, detailRecordParcel); - - RELEASE_IF_FALSE(in.ReadInt32(detailRecordParcel->detail.status), detailRecordParcel); - RELEASE_IF_FALSE(in.ReadInt64(detailRecordParcel->detail.timestamp), detailRecordParcel); - RELEASE_IF_FALSE(in.ReadInt64(detailRecordParcel->detail.accessDuration), detailRecordParcel); - return detailRecordParcel; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "used_record_detail_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool UsedRecordDetailParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteInt32(this->detail.status)); + RETURN_IF_FALSE(out.WriteInt64(this->detail.timestamp)); + RETURN_IF_FALSE(out.WriteInt64(this->detail.accessDuration)); + return true; +} + +UsedRecordDetailParcel* UsedRecordDetailParcel::Unmarshalling(Parcel& in) +{ + auto* detailRecordParcel = new (std::nothrow) UsedRecordDetailParcel(); + RELEASE_IF_FALSE(detailRecordParcel != nullptr, detailRecordParcel); + + RELEASE_IF_FALSE(in.ReadInt32(detailRecordParcel->detail.status), detailRecordParcel); + RELEASE_IF_FALSE(in.ReadInt64(detailRecordParcel->detail.timestamp), detailRecordParcel); + RELEASE_IF_FALSE(in.ReadInt64(detailRecordParcel->detail.accessDuration), detailRecordParcel); + return detailRecordParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/frameworks/tokensync/include/i_token_sync_manager.h b/frameworks/tokensync/include/i_token_sync_manager.h index 9736a6fe229de7bb0d09cd7af6eb8557dfed3ed8..c903c218718773c9a58df6075638b45e0b73a9af 100644 --- a/frameworks/tokensync/include/i_token_sync_manager.h +++ b/frameworks/tokensync/include/i_token_sync_manager.h @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef I_TOKENSYNC_MANAGER_H -#define I_TOKENSYNC_MANAGER_H - -#include - -#include "iremote_broker.h" -#include "errors.h" - -#include "access_token.h" -#include "hap_token_info_for_sync_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class ITokenSyncManager : public IRemoteBroker { -public: - static const int SA_ID_TOKENSYNC_MANAGER_SERVICE = 3504; - - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.ITokenSyncManager"); - - virtual int GetRemoteHapTokenInfo(const std::string& deviceID, AccessTokenID tokenID) = 0; - virtual int DeleteRemoteHapTokenInfo(AccessTokenID tokenID) = 0; - virtual int UpdateRemoteHapTokenInfo(const HapTokenInfoForSync& tokenInfo) = 0; - - enum class InterfaceCode { - GET_REMOTE_HAP_TOKEN_INFO = 0xff01, - DELETE_REMOTE_HAP_TOKEN_INFO = 0xff02, - UPDATE_REMOTE_HAP_TOKEN_INFO = 0xff03 - }; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // I_TOKENSYNC_MANAGER_H +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef I_TOKENSYNC_MANAGER_H +#define I_TOKENSYNC_MANAGER_H + +#include + +#include "iremote_broker.h" +#include "errors.h" + +#include "access_token.h" +#include "hap_token_info_for_sync_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class ITokenSyncManager : public IRemoteBroker { +public: + static const int SA_ID_TOKENSYNC_MANAGER_SERVICE = 3504; + + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.ITokenSyncManager"); + + virtual int GetRemoteHapTokenInfo(const std::string& deviceID, AccessTokenID tokenID) = 0; + virtual int DeleteRemoteHapTokenInfo(AccessTokenID tokenID) = 0; + virtual int UpdateRemoteHapTokenInfo(const HapTokenInfoForSync& tokenInfo) = 0; + + enum class InterfaceCode { + GET_REMOTE_HAP_TOKEN_INFO = 0xff01, + DELETE_REMOTE_HAP_TOKEN_INFO = 0xff02, + UPDATE_REMOTE_HAP_TOKEN_INFO = 0xff03 + }; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // I_TOKENSYNC_MANAGER_H diff --git a/interfaces/innerkits/privacy/BUILD.gn b/interfaces/innerkits/privacy/BUILD.gn index 42ec2da9f8f3cb85ac980618469d97a218a9ab23..b5ec85b41ee57dad4b6452ed4dd6bf64452b05e1 100644 --- a/interfaces/innerkits/privacy/BUILD.gn +++ b/interfaces/innerkits/privacy/BUILD.gn @@ -1,67 +1,67 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -config("pricacy") { - visibility = [ ":*" ] - include_dirs = [ "include" ] -} - -if (is_standard_system) { - ohos_shared_library("libprivacy_sdk") { - subsystem_name = "security" - part_name = "access_token" - - output_name = "libprivacy_sdk" - - public_configs = [ ":pricacy" ] - - include_dirs = [ - "//commonlibrary/c_utils/base/include", - "include", - "src", - "//base/security/access_token/frameworks/privacy/include", - "//base/security/access_token/frameworks/common/include", - "//base/security/access_token/interfaces/innerkits/accesstoken/include", - "//base/security/access_token/interfaces/innerkits/privacy/include", - ] - - sources = [ - "src/perm_active_status_change_callback.cpp", - "src/perm_active_status_change_callback_stub.cpp", - "src/perm_active_status_customized_cbk.cpp", - "src/privacy_death_recipient.cpp", - "src/privacy_kit.cpp", - "src/privacy_manager_client.cpp", - "src/privacy_manager_proxy.cpp", - ] - - deps = [ - "//base/security/access_token/frameworks/common:accesstoken_common_cxx", - "//base/security/access_token/frameworks/privacy:privacy_communication_adapter_cxx", - ] - - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "samgr:samgr_proxy", - ] - - cflags_cc = [ - "-DHILOG_ENABLE", - "-DDEBUG_API_PERFORMANCE", - ] - } -} +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +config("pricacy") { + visibility = [ ":*" ] + include_dirs = [ "include" ] +} + +if (is_standard_system) { + ohos_shared_library("libprivacy_sdk") { + subsystem_name = "security" + part_name = "access_token" + + output_name = "libprivacy_sdk" + + public_configs = [ ":pricacy" ] + + include_dirs = [ + "//commonlibrary/c_utils/base/include", + "include", + "src", + "//base/security/access_token/frameworks/privacy/include", + "//base/security/access_token/frameworks/common/include", + "//base/security/access_token/interfaces/innerkits/accesstoken/include", + "//base/security/access_token/interfaces/innerkits/privacy/include", + ] + + sources = [ + "src/perm_active_status_change_callback.cpp", + "src/perm_active_status_change_callback_stub.cpp", + "src/perm_active_status_customized_cbk.cpp", + "src/privacy_death_recipient.cpp", + "src/privacy_kit.cpp", + "src/privacy_manager_client.cpp", + "src/privacy_manager_proxy.cpp", + ] + + deps = [ + "//base/security/access_token/frameworks/common:accesstoken_common_cxx", + "//base/security/access_token/frameworks/privacy:privacy_communication_adapter_cxx", + ] + + external_deps = [ + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] + + cflags_cc = [ + "-DHILOG_ENABLE", + "-DDEBUG_API_PERFORMANCE", + ] + } +} diff --git a/interfaces/innerkits/privacy/include/on_permission_used_record_callback.h b/interfaces/innerkits/privacy/include/on_permission_used_record_callback.h index acb51194fdcd264f4e76a7a33dea918547132e99..de2d488d4efaba6e700982d63b2b56b8314eaad1 100644 --- a/interfaces/innerkits/privacy/include/on_permission_used_record_callback.h +++ b/interfaces/innerkits/privacy/include/on_permission_used_record_callback.h @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ON_PERMISSION_USED_RECORD_CALLBACK_H -#define ON_PERMISSION_USED_RECORD_CALLBACK_H - -#include "errors.h" -#include "iremote_broker.h" -#include "permission_used_result.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class OnPermissionUsedRecordCallback : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.OnPermissionUsedRecordCallback"); - - virtual void OnQueried(ErrCode code, PermissionUsedResult& result) = 0; - - enum { - ON_QUERIED = 0, - }; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // ON_PERMISSION_USED_RECORD_CALLBACK_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ON_PERMISSION_USED_RECORD_CALLBACK_H +#define ON_PERMISSION_USED_RECORD_CALLBACK_H + +#include "errors.h" +#include "iremote_broker.h" +#include "permission_used_result.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class OnPermissionUsedRecordCallback : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.OnPermissionUsedRecordCallback"); + + virtual void OnQueried(ErrCode code, PermissionUsedResult& result) = 0; + + enum { + ON_QUERIED = 0, + }; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // ON_PERMISSION_USED_RECORD_CALLBACK_H diff --git a/interfaces/innerkits/privacy/include/perm_active_status_change_callback_stub.h b/interfaces/innerkits/privacy/include/perm_active_status_change_callback_stub.h index cc9a6c81ab809d035396254fcf9b5163aaaff40b..74f3e92ae4823bec4bff160efea4a20b804a17e5 100644 --- a/interfaces/innerkits/privacy/include/perm_active_status_change_callback_stub.h +++ b/interfaces/innerkits/privacy/include/perm_active_status_change_callback_stub.h @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H -#define PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H - - -#include "i_perm_active_status_callback.h" - -#include "iremote_stub.h" -#include "nocopyable.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PermActiveStatusChangeCallbackStub : public IRemoteStub { -public: - PermActiveStatusChangeCallbackStub() = default; - virtual ~PermActiveStatusChangeCallbackStub() = default; - - int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H +#define PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H + + +#include "i_perm_active_status_callback.h" + +#include "iremote_stub.h" +#include "nocopyable.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermActiveStatusChangeCallbackStub : public IRemoteStub { +public: + PermActiveStatusChangeCallbackStub() = default; + virtual ~PermActiveStatusChangeCallbackStub() = default; + + int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H diff --git a/interfaces/innerkits/privacy/include/permission_used_request.h b/interfaces/innerkits/privacy/include/permission_used_request.h index 1fcdd9f2d6f4811f516f805d1c3728bde550adc4..fed30f2479ae5deb50cd2c0c12d2f3de2a300a35 100644 --- a/interfaces/innerkits/privacy/include/permission_used_request.h +++ b/interfaces/innerkits/privacy/include/permission_used_request.h @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_USED_REQUEST_H -#define PERMISSION_USED_REQUEST_H - -#include -#include - -#include "access_token.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -typedef enum PermissionUsageFlagEnum { - FLAG_PERMISSION_USAGE_SUMMARY = 0, - FLAG_PERMISSION_USAGE_DETAIL = 1, -} PermissionUsageFlag; - -struct PermissionUsedRequest { - AccessTokenID tokenId = 0; - bool isRemote = false; - std::string deviceId; - std::string bundleName; - std::vector permissionList; - int64_t beginTimeMillis = 0; - int64_t endTimeMillis = 0; - PermissionUsageFlag flag = FLAG_PERMISSION_USAGE_SUMMARY; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_USED_REQUEST_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_USED_REQUEST_H +#define PERMISSION_USED_REQUEST_H + +#include +#include + +#include "access_token.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +typedef enum PermissionUsageFlagEnum { + FLAG_PERMISSION_USAGE_SUMMARY = 0, + FLAG_PERMISSION_USAGE_DETAIL = 1, +} PermissionUsageFlag; + +struct PermissionUsedRequest { + AccessTokenID tokenId = 0; + bool isRemote = false; + std::string deviceId; + std::string bundleName; + std::vector permissionList; + int64_t beginTimeMillis = 0; + int64_t endTimeMillis = 0; + PermissionUsageFlag flag = FLAG_PERMISSION_USAGE_SUMMARY; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERMISSION_USED_REQUEST_H diff --git a/interfaces/innerkits/privacy/include/permission_used_result.h b/interfaces/innerkits/privacy/include/permission_used_result.h index c52a1ccd610a8ff0ebdd6dfb19a199b366029e44..1fec6474e0349b330b60216ba115e1713a815dc7 100644 --- a/interfaces/innerkits/privacy/include/permission_used_result.h +++ b/interfaces/innerkits/privacy/include/permission_used_result.h @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_USED_RESPONSE_H -#define PERMISSION_USED_RESPONSE_H - -#include -#include -#include "access_token.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct UsedRecordDetail { - int32_t status = 0; - int64_t timestamp = 0L; - int64_t accessDuration = 0L; -}; - -struct PermissionUsedRecord { - std::string permissionName; - int32_t accessCount = 0; - int32_t rejectCount = 0; - int64_t lastAccessTime = 0L; - int64_t lastRejectTime = 0L; - int64_t lastAccessDuration = 0L; - std::vector accessRecords; - std::vector rejectRecords; -}; - -struct BundleUsedRecord { - AccessTokenID tokenId; - bool isRemote; - std::string deviceId; - std::string bundleName; - std::vector permissionRecords; -}; - -struct PermissionUsedResult { - int64_t beginTimeMillis = 0L; - int64_t endTimeMillis = 0L; - std::vector bundleRecords; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_USED_RESPONSE_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_USED_RESPONSE_H +#define PERMISSION_USED_RESPONSE_H + +#include +#include +#include "access_token.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct UsedRecordDetail { + int32_t status = 0; + int64_t timestamp = 0L; + int64_t accessDuration = 0L; +}; + +struct PermissionUsedRecord { + std::string permissionName; + int32_t accessCount = 0; + int32_t rejectCount = 0; + int64_t lastAccessTime = 0L; + int64_t lastRejectTime = 0L; + int64_t lastAccessDuration = 0L; + std::vector accessRecords; + std::vector rejectRecords; +}; + +struct BundleUsedRecord { + AccessTokenID tokenId; + bool isRemote; + std::string deviceId; + std::string bundleName; + std::vector permissionRecords; +}; + +struct PermissionUsedResult { + int64_t beginTimeMillis = 0L; + int64_t endTimeMillis = 0L; + std::vector bundleRecords; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERMISSION_USED_RESPONSE_H diff --git a/interfaces/innerkits/privacy/include/privacy_kit.h b/interfaces/innerkits/privacy/include/privacy_kit.h index a06fa1f8c85e10e99c1105a289bcec7624e9e759..cbde1dc8765450ed794d51a823be9e5e2a3b64fa 100644 --- a/interfaces/innerkits/privacy/include/privacy_kit.h +++ b/interfaces/innerkits/privacy/include/privacy_kit.h @@ -1,47 +1,48 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INTERFACES_INNER_KITS_PRIVACY_KIT_H -#define INTERFACES_INNER_KITS_PRIVACY_KIT_H - -#include - -#include "access_token.h" -#include "on_permission_used_record_callback.h" -#include "permission_used_request.h" -#include "permission_used_result.h" -#include "perm_active_status_customized_cbk.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyKit { -public: - static int32_t AddPermissionUsedRecord( - AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount); - static int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName); - static int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName); - static int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID); - static int32_t GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result); - static int32_t GetPermissionUsedRecords( - const PermissionUsedRequest& request, const sptr& callback); - static std::string DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName); - static int32_t RegisterPermActiveStatusCallback(const std::shared_ptr& callback); - static int32_t UnRegisterPermActiveStatusCallback(const std::shared_ptr& callback); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INTERFACES_INNER_KITS_PRIVACY_KIT_H +#define INTERFACES_INNER_KITS_PRIVACY_KIT_H + +#include + +#include "access_token.h" +#include "on_permission_used_record_callback.h" +#include "permission_used_request.h" +#include "permission_used_result.h" +#include "perm_active_status_customized_cbk.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PrivacyKit { +public: + static int32_t AddPermissionUsedRecord( + AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount); + static int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName); + static int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName); + static int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID); + static int32_t GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result); + static int32_t GetPermissionUsedRecords( + const PermissionUsedRequest& request, const sptr& callback); + static std::string DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName); + static int32_t RegisterPermActiveStatusCallback(const std::shared_ptr& callback); + static int32_t UnRegisterPermActiveStatusCallback(const std::shared_ptr& callback); + static bool IsAllowUsingPermission(AccessTokenID tokenID, const std::string& permissionName); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif diff --git a/interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.cpp b/interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.cpp index fa4d4e035dab5d8bf9027c306f05db7f6648eb55..250900ab744838e0bf9547b6470a63ab1ba88372 100644 --- a/interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.cpp +++ b/interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.cpp @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "perm_active_status_change_callback_stub.h" - -#include "accesstoken_log.h" -#include "perm_active_response_parcel.h" -#include "string_ex.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermActiveStatusChangeCallbackStub" -}; -} - -int32_t PermActiveStatusChangeCallbackStub::OnRemoteRequest( - uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -{ - ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, code: 0x%{public}x", code); - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IPermActiveStatusCallback::GetDescriptor()) { - ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor: %{public}s", Str16ToStr8(descriptor).c_str()); - return RET_FAILED; - } - - int32_t msgCode = static_cast(code); - if (msgCode == IPermActiveStatusCallback::PERM_ACTIVE_STATUS_CHANGE) { - sptr resultSptr = data.ReadParcelable(); - if (resultSptr == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable fail"); - return RET_FAILED; - } - - ActiveStatusChangeCallback(resultSptr->changeResponse); - } else { - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - return RET_SUCCESS; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "perm_active_status_change_callback_stub.h" + +#include "accesstoken_log.h" +#include "perm_active_response_parcel.h" +#include "string_ex.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermActiveStatusChangeCallbackStub" +}; +} + +int32_t PermActiveStatusChangeCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, code: 0x%{public}x", code); + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IPermActiveStatusCallback::GetDescriptor()) { + ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor: %{public}s", Str16ToStr8(descriptor).c_str()); + return RET_FAILED; + } + + int32_t msgCode = static_cast(code); + if (msgCode == IPermActiveStatusCallback::PERM_ACTIVE_STATUS_CHANGE) { + sptr resultSptr = data.ReadParcelable(); + if (resultSptr == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable fail"); + return RET_FAILED; + } + + ActiveStatusChangeCallback(resultSptr->changeResponse); + } else { + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return RET_SUCCESS; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/interfaces/innerkits/privacy/src/privacy_death_recipient.cpp b/interfaces/innerkits/privacy/src/privacy_death_recipient.cpp index 6322643b8be21f810ddb9927475e048c49d7e8be..875c61b5cb2640c80eea59f3e490a890fc3545a8 100644 --- a/interfaces/innerkits/privacy/src/privacy_death_recipient.cpp +++ b/interfaces/innerkits/privacy/src/privacy_death_recipient.cpp @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "privacy_death_recipient.h" - -#include "accesstoken_log.h" -#include "privacy_manager_client.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyDeathRecipient" -}; -} // namespace - -void PrivacyDeathRecipient::OnRemoteDied(const wptr& object) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__); - PrivacyManagerClient::GetInstance().OnRemoteDiedHandle(); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "privacy_death_recipient.h" + +#include "accesstoken_log.h" +#include "privacy_manager_client.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyDeathRecipient" +}; +} // namespace + +void PrivacyDeathRecipient::OnRemoteDied(const wptr& object) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__); + PrivacyManagerClient::GetInstance().OnRemoteDiedHandle(); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/interfaces/innerkits/privacy/src/privacy_death_recipient.h b/interfaces/innerkits/privacy/src/privacy_death_recipient.h index 5670393ace16b14f48572fda1a7531dea839cb75..18ed43f63512980395726ceb38cf838fd6ccfef3 100644 --- a/interfaces/innerkits/privacy/src/privacy_death_recipient.h +++ b/interfaces/innerkits/privacy/src/privacy_death_recipient.h @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef PRIVACY_DEATH_RECIPIENT_H -#define PRIVACY_DEATH_RECIPIENT_H - -#include "iremote_object.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyDeathRecipient : public IRemoteObject::DeathRecipient { -public: - PrivacyDeathRecipient() {} - virtual ~PrivacyDeathRecipient() = default; - void OnRemoteDied(const wptr& object) override; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PRIVACY_DEATH_RECIPIENT_H - +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef PRIVACY_DEATH_RECIPIENT_H +#define PRIVACY_DEATH_RECIPIENT_H + +#include "iremote_object.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PrivacyDeathRecipient : public IRemoteObject::DeathRecipient { +public: + PrivacyDeathRecipient() {} + virtual ~PrivacyDeathRecipient() = default; + void OnRemoteDied(const wptr& object) override; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PRIVACY_DEATH_RECIPIENT_H + diff --git a/interfaces/innerkits/privacy/src/privacy_kit.cpp b/interfaces/innerkits/privacy/src/privacy_kit.cpp index b6349f0b74854d561f40e57da995ad0dd769fce5..88c5a93231152e9ddb268ebc2d735022936d0e1c 100644 --- a/interfaces/innerkits/privacy/src/privacy_kit.cpp +++ b/interfaces/innerkits/privacy/src/privacy_kit.cpp @@ -1,91 +1,97 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "privacy_kit.h" - -#include -#include - -#include "accesstoken_log.h" -#include "constant_common.h" -#include "privacy_manager_client.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyKit"}; -} // namespace - -int32_t PrivacyKit::AddPermissionUsedRecord( - AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) -{ - ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=0x%{public}x, permissionName=%{public}s,", - tokenID, permissionName.c_str()); - return PrivacyManagerClient::GetInstance().AddPermissionUsedRecord( - tokenID, permissionName, successCount, failCount); -} - -int32_t PrivacyKit::StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) -{ - ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=0x%{public}x, permissionName=%{public}s", - tokenID, permissionName.c_str()); - return PrivacyManagerClient::GetInstance().StartUsingPermission(tokenID, permissionName); -} - -int32_t PrivacyKit::StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) -{ - ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=0x%{public}x, permissionName=%{public}s", - tokenID, permissionName.c_str()); - return PrivacyManagerClient::GetInstance().StopUsingPermission(tokenID, permissionName); -} - -int32_t PrivacyKit::RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) -{ - ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=0x%{public}x, deviceID=%{public}s", - tokenID, ConstantCommon::EncryptDevId(deviceID).c_str()); - return PrivacyManagerClient::GetInstance().RemovePermissionUsedRecords(tokenID, deviceID); -} - -int32_t PrivacyKit::GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result) -{ - return PrivacyManagerClient::GetInstance().GetPermissionUsedRecords(request, result); -} - -int32_t PrivacyKit::GetPermissionUsedRecords( - const PermissionUsedRequest& request, const sptr& callback) -{ - return PrivacyManagerClient::GetInstance().GetPermissionUsedRecords(request, callback); -} - -std::string PrivacyKit::DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) -{ - ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=%{public}d, permissionName=%{public}s", - tokenID, permissionName.c_str()); - return PrivacyManagerClient::GetInstance().DumpRecordInfo(tokenID, permissionName); -} - -int32_t PrivacyKit::RegisterPermActiveStatusCallback(const std::shared_ptr& callback) -{ - return PrivacyManagerClient::GetInstance().RegisterPermActiveStatusCallback(callback); -} - -int32_t PrivacyKit::UnRegisterPermActiveStatusCallback(const std::shared_ptr& callback) -{ - return PrivacyManagerClient::GetInstance().UnRegisterPermActiveStatusCallback(callback); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "privacy_kit.h" + +#include +#include + +#include "accesstoken_log.h" +#include "constant_common.h" +#include "privacy_manager_client.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyKit"}; +} // namespace + +int32_t PrivacyKit::AddPermissionUsedRecord( + AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=0x%{public}x, permissionName=%{public}s,", + tokenID, permissionName.c_str()); + return PrivacyManagerClient::GetInstance().AddPermissionUsedRecord( + tokenID, permissionName, successCount, failCount); +} + +int32_t PrivacyKit::StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=0x%{public}x, permissionName=%{public}s", + tokenID, permissionName.c_str()); + return PrivacyManagerClient::GetInstance().StartUsingPermission(tokenID, permissionName); +} + +int32_t PrivacyKit::StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=0x%{public}x, permissionName=%{public}s", + tokenID, permissionName.c_str()); + return PrivacyManagerClient::GetInstance().StopUsingPermission(tokenID, permissionName); +} + +int32_t PrivacyKit::RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=0x%{public}x, deviceID=%{public}s", + tokenID, ConstantCommon::EncryptDevId(deviceID).c_str()); + return PrivacyManagerClient::GetInstance().RemovePermissionUsedRecords(tokenID, deviceID); +} + +int32_t PrivacyKit::GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result) +{ + return PrivacyManagerClient::GetInstance().GetPermissionUsedRecords(request, result); +} + +int32_t PrivacyKit::GetPermissionUsedRecords( + const PermissionUsedRequest& request, const sptr& callback) +{ + return PrivacyManagerClient::GetInstance().GetPermissionUsedRecords(request, callback); +} + +std::string PrivacyKit::DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, tokenID=%{public}d, permissionName=%{public}s", + tokenID, permissionName.c_str()); + return PrivacyManagerClient::GetInstance().DumpRecordInfo(tokenID, permissionName); +} + +int32_t PrivacyKit::RegisterPermActiveStatusCallback(const std::shared_ptr& callback) +{ + return PrivacyManagerClient::GetInstance().RegisterPermActiveStatusCallback(callback); +} + +int32_t PrivacyKit::UnRegisterPermActiveStatusCallback(const std::shared_ptr& callback) +{ + return PrivacyManagerClient::GetInstance().UnRegisterPermActiveStatusCallback(callback); +} + +bool PrivacyKit::IsAllowUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + return PrivacyManagerClient::GetInstance().IsAllowUsingPermission(tokenID, permissionName); +} + +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/interfaces/innerkits/privacy/src/privacy_manager_client.cpp b/interfaces/innerkits/privacy/src/privacy_manager_client.cpp index 12ac9e296752de45807a434ade965eee3ee7ba92..0b912ff94ea805c98f33384b4bcd8ac39577edb0 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_client.cpp +++ b/interfaces/innerkits/privacy/src/privacy_manager_client.cpp @@ -1,272 +1,283 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "privacy_manager_client.h" - -#include -#include "accesstoken_log.h" -#include "data_validator.h" -#include "iservice_registry.h" -#include "privacy_manager_proxy.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyManagerClient" -}; -} // namespace - -const static int32_t ERROR = -1; -const static int32_t MAX_PERM_LIST_SIZE = 200; - -PrivacyManagerClient& PrivacyManagerClient::GetInstance() -{ - static PrivacyManagerClient instance; - return instance; -} - -PrivacyManagerClient::PrivacyManagerClient() -{} - -PrivacyManagerClient::~PrivacyManagerClient() -{} - -int32_t PrivacyManagerClient::AddPermissionUsedRecord( - AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) -{ - if (!DataValidator::IsTokenIDValid(tokenID) || !DataValidator::IsPermissionNameValid(permissionName) || - (successCount < 0 || failCount < 0)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "parameter is invalid"); - return ERROR; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ERROR; - } - return proxy->AddPermissionUsedRecord(tokenID, permissionName, successCount, failCount); -} - -int32_t PrivacyManagerClient::StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) -{ - if (!DataValidator::IsTokenIDValid(tokenID) || !DataValidator::IsPermissionNameValid(permissionName)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "parameter is invalid"); - return ERROR; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ERROR; - } - return proxy->StartUsingPermission(tokenID, permissionName); -} - -int32_t PrivacyManagerClient::StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) -{ - if (!DataValidator::IsTokenIDValid(tokenID) || !DataValidator::IsPermissionNameValid(permissionName)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "parameter is invalid"); - return ERROR; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ERROR; - } - return proxy->StopUsingPermission(tokenID, permissionName); -} - -int32_t PrivacyManagerClient::RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) -{ - if (!DataValidator::IsTokenIDValid(tokenID) && !DataValidator::IsDeviceIdValid(deviceID)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "parameter is invalid"); - return ERROR; - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ERROR; - } - return proxy->RemovePermissionUsedRecords(tokenID, deviceID); -} - -int32_t PrivacyManagerClient::GetPermissionUsedRecords( - const PermissionUsedRequest& request, PermissionUsedResult& result) -{ - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ERROR; - } - - PermissionUsedRequestParcel requestParcel; - PermissionUsedResultParcel reultParcel; - requestParcel.request = request; - int32_t ret = proxy->GetPermissionUsedRecords(requestParcel, reultParcel); - result = reultParcel.result; - return ret; -} - -int32_t PrivacyManagerClient::GetPermissionUsedRecords(const PermissionUsedRequest& request, - const sptr& callback) -{ - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ERROR; - } - - PermissionUsedRequestParcel requestParcel; - requestParcel.request = request; - return proxy->GetPermissionUsedRecords(requestParcel, callback); -} - -std::string PrivacyManagerClient::DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) -{ - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ""; - } - - return proxy->DumpRecordInfo(tokenID, permissionName); -} - -int32_t PrivacyManagerClient::CreateActiveStatusChangeCbk( - const std::shared_ptr& callback, sptr& callbackObject) -{ - std::lock_guard lock(activeCbkMutex_); - - if (activeCbkMap_.size() == MAX_PERM_LIST_SIZE) { - ACCESSTOKEN_LOG_ERROR(LABEL, "the maximum number of subscribers has been reached"); - return ERROR; - } - - auto goalCallback = activeCbkMap_.find(callback); - if (goalCallback != activeCbkMap_.end()) { - callbackObject = goalCallback->second->AsObject(); - ACCESSTOKEN_LOG_ERROR(LABEL, "activeCbkMap_ already has such callback"); - return ERROR; - } else { - sptr callbackWraped = - new (std::nothrow) PermActiveStatusChangeCallback(callback); - if (!callbackWraped) { - ACCESSTOKEN_LOG_ERROR(LABEL, "memory allocation for callbackWraped failed!"); - return ERROR; - } - ACCESSTOKEN_LOG_INFO(LABEL, "callbackObject added"); - callbackObject = callbackWraped->AsObject(); - activeCbkMap_[callback] = callbackWraped; - } - return RET_SUCCESS; -} - -int32_t PrivacyManagerClient::RegisterPermActiveStatusCallback( - const std::shared_ptr& callback) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "called!"); - if (callback == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "customizedCb is nullptr"); - return ERROR; - } - - sptr callbackObject = nullptr; - int32_t result = CreateActiveStatusChangeCbk(callback, callbackObject); - if (result != RET_SUCCESS) { - return result; - } - - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ERROR; - } - std::vector permList; - callback->GetPermList(permList); - - return proxy->RegisterPermActiveStatusCallback(permList, callbackObject); -} - -int32_t PrivacyManagerClient::UnRegisterPermActiveStatusCallback( - const std::shared_ptr& callback) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "called!"); - - std::lock_guard lock(activeCbkMutex_); - auto goalCallback = activeCbkMap_.find(callback); - if (goalCallback == activeCbkMap_.end()) { - ACCESSTOKEN_LOG_ERROR(LABEL, "goalCallback already is not exist"); - return ERROR; - } - - auto proxy = GetProxy(); - if (proxy == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); - return ERROR; - } - - int32_t result = proxy->UnRegisterPermActiveStatusCallback(goalCallback->second->AsObject()); - if (result == RET_SUCCESS) { - activeCbkMap_.erase(goalCallback); - } - return result; -} - -void PrivacyManagerClient::InitProxy() -{ - std::lock_guard lock(proxyMutex_); - if (proxy_ == nullptr) { - auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (sam == nullptr) { - ACCESSTOKEN_LOG_DEBUG(LABEL, "GetSystemAbilityManager is null"); - return; - } - auto privacySa = sam->GetSystemAbility(IPrivacyManager::SA_ID_PRIVACY_MANAGER_SERVICE); - if (privacySa == nullptr) { - ACCESSTOKEN_LOG_DEBUG(LABEL, "GetSystemAbility %{public}d is null", - IPrivacyManager::SA_ID_PRIVACY_MANAGER_SERVICE); - return; - } - - serviceDeathObserver_ = new (std::nothrow) PrivacyDeathRecipient(); - if (serviceDeathObserver_ != nullptr) { - privacySa->AddDeathRecipient(serviceDeathObserver_); - } - proxy_ = iface_cast(privacySa); - if (proxy_ == nullptr) { - ACCESSTOKEN_LOG_DEBUG(LABEL, "iface_cast get null"); - } - } -} - -void PrivacyManagerClient::OnRemoteDiedHandle() -{ - { - std::lock_guard lock(proxyMutex_); - proxy_ = nullptr; - } - InitProxy(); -} - -sptr PrivacyManagerClient::GetProxy() -{ - if (proxy_ == nullptr) { - InitProxy(); - } - return proxy_; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "privacy_manager_client.h" + +#include +#include "accesstoken_log.h" +#include "data_validator.h" +#include "iservice_registry.h" +#include "privacy_manager_proxy.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyManagerClient" +}; +} // namespace + +const static int32_t ERROR = -1; +const static int32_t MAX_PERM_LIST_SIZE = 200; + +PrivacyManagerClient& PrivacyManagerClient::GetInstance() +{ + static PrivacyManagerClient instance; + return instance; +} + +PrivacyManagerClient::PrivacyManagerClient() +{} + +PrivacyManagerClient::~PrivacyManagerClient() +{} + +int32_t PrivacyManagerClient::AddPermissionUsedRecord( + AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) +{ + if (!DataValidator::IsTokenIDValid(tokenID) || !DataValidator::IsPermissionNameValid(permissionName) || + (successCount < 0 || failCount < 0)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "parameter is invalid"); + return ERROR; + } + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ERROR; + } + return proxy->AddPermissionUsedRecord(tokenID, permissionName, successCount, failCount); +} + +int32_t PrivacyManagerClient::StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + if (!DataValidator::IsTokenIDValid(tokenID) || !DataValidator::IsPermissionNameValid(permissionName)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "parameter is invalid"); + return ERROR; + } + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ERROR; + } + return proxy->StartUsingPermission(tokenID, permissionName); +} + +int32_t PrivacyManagerClient::StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + if (!DataValidator::IsTokenIDValid(tokenID) || !DataValidator::IsPermissionNameValid(permissionName)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "parameter is invalid"); + return ERROR; + } + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ERROR; + } + return proxy->StopUsingPermission(tokenID, permissionName); +} + +int32_t PrivacyManagerClient::RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) +{ + if (!DataValidator::IsTokenIDValid(tokenID) && !DataValidator::IsDeviceIdValid(deviceID)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "parameter is invalid"); + return ERROR; + } + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ERROR; + } + return proxy->RemovePermissionUsedRecords(tokenID, deviceID); +} + +int32_t PrivacyManagerClient::GetPermissionUsedRecords( + const PermissionUsedRequest& request, PermissionUsedResult& result) +{ + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ERROR; + } + + PermissionUsedRequestParcel requestParcel; + PermissionUsedResultParcel reultParcel; + requestParcel.request = request; + int32_t ret = proxy->GetPermissionUsedRecords(requestParcel, reultParcel); + result = reultParcel.result; + return ret; +} + +int32_t PrivacyManagerClient::GetPermissionUsedRecords(const PermissionUsedRequest& request, + const sptr& callback) +{ + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ERROR; + } + + PermissionUsedRequestParcel requestParcel; + requestParcel.request = request; + return proxy->GetPermissionUsedRecords(requestParcel, callback); +} + +std::string PrivacyManagerClient::DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) +{ + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ""; + } + + return proxy->DumpRecordInfo(tokenID, permissionName); +} + +int32_t PrivacyManagerClient::CreateActiveStatusChangeCbk( + const std::shared_ptr& callback, sptr& callbackObject) +{ + std::lock_guard lock(activeCbkMutex_); + + if (activeCbkMap_.size() == MAX_PERM_LIST_SIZE) { + ACCESSTOKEN_LOG_ERROR(LABEL, "the maximum number of subscribers has been reached"); + return ERROR; + } + + auto goalCallback = activeCbkMap_.find(callback); + if (goalCallback != activeCbkMap_.end()) { + callbackObject = goalCallback->second->AsObject(); + ACCESSTOKEN_LOG_ERROR(LABEL, "activeCbkMap_ already has such callback"); + return ERROR; + } else { + sptr callbackWraped = + new (std::nothrow) PermActiveStatusChangeCallback(callback); + if (!callbackWraped) { + ACCESSTOKEN_LOG_ERROR(LABEL, "memory allocation for callbackWraped failed!"); + return ERROR; + } + ACCESSTOKEN_LOG_INFO(LABEL, "callbackObject added"); + callbackObject = callbackWraped->AsObject(); + activeCbkMap_[callback] = callbackWraped; + } + return RET_SUCCESS; +} + +int32_t PrivacyManagerClient::RegisterPermActiveStatusCallback( + const std::shared_ptr& callback) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "called!"); + if (callback == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "customizedCb is nullptr"); + return ERROR; + } + + sptr callbackObject = nullptr; + int32_t result = CreateActiveStatusChangeCbk(callback, callbackObject); + if (result != RET_SUCCESS) { + return result; + } + + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ERROR; + } + std::vector permList; + callback->GetPermList(permList); + + return proxy->RegisterPermActiveStatusCallback(permList, callbackObject); +} + +int32_t PrivacyManagerClient::UnRegisterPermActiveStatusCallback( + const std::shared_ptr& callback) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "called!"); + + std::lock_guard lock(activeCbkMutex_); + auto goalCallback = activeCbkMap_.find(callback); + if (goalCallback == activeCbkMap_.end()) { + ACCESSTOKEN_LOG_ERROR(LABEL, "goalCallback already is not exist"); + return ERROR; + } + + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return ERROR; + } + + int32_t result = proxy->UnRegisterPermActiveStatusCallback(goalCallback->second->AsObject()); + if (result == RET_SUCCESS) { + activeCbkMap_.erase(goalCallback); + } + return result; +} + +void PrivacyManagerClient::InitProxy() +{ + std::lock_guard lock(proxyMutex_); + if (proxy_ == nullptr) { + auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (sam == nullptr) { + ACCESSTOKEN_LOG_DEBUG(LABEL, "GetSystemAbilityManager is null"); + return; + } + auto privacySa = sam->GetSystemAbility(IPrivacyManager::SA_ID_PRIVACY_MANAGER_SERVICE); + if (privacySa == nullptr) { + ACCESSTOKEN_LOG_DEBUG(LABEL, "GetSystemAbility %{public}d is null", + IPrivacyManager::SA_ID_PRIVACY_MANAGER_SERVICE); + return; + } + + serviceDeathObserver_ = new (std::nothrow) PrivacyDeathRecipient(); + if (serviceDeathObserver_ != nullptr) { + privacySa->AddDeathRecipient(serviceDeathObserver_); + } + proxy_ = iface_cast(privacySa); + if (proxy_ == nullptr) { + ACCESSTOKEN_LOG_DEBUG(LABEL, "iface_cast get null"); + } + } +} + +bool PrivacyManagerClient::IsAllowUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + auto proxy = GetProxy(); + if (proxy == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "proxy is null"); + return false; + } + + return proxy->IsAllowUsingPermission(tokenID, permissionName); +} + +void PrivacyManagerClient::OnRemoteDiedHandle() +{ + { + std::lock_guard lock(proxyMutex_); + proxy_ = nullptr; + } + InitProxy(); +} + +sptr PrivacyManagerClient::GetProxy() +{ + if (proxy_ == nullptr) { + InitProxy(); + } + return proxy_; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/interfaces/innerkits/privacy/src/privacy_manager_client.h b/interfaces/innerkits/privacy/src/privacy_manager_client.h index ee288ad69046c9f73dca259255ab43a13e0366b2..df77b37e0a5740b29c99fd96ca3c8584287b21e1 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_client.h +++ b/interfaces/innerkits/privacy/src/privacy_manager_client.h @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PRIVACY_MANAGER_CLIENT_H -#define PRIVACY_MANAGER_CLIENT_H - -#include -#include -#include -#include - -#include "i_privacy_manager.h" -#include "perm_active_status_change_callback.h" -#include "perm_active_status_customized_cbk.h" -#include "privacy_death_recipient.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyManagerClient final { -public: - static PrivacyManagerClient& GetInstance(); - - virtual ~PrivacyManagerClient(); - - int32_t AddPermissionUsedRecord( - AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount); - int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName); - int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName); - int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID); - int32_t GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result); - int32_t GetPermissionUsedRecords( - const PermissionUsedRequest& request, const sptr& callback); - std::string DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName); - int32_t RegisterPermActiveStatusCallback(const std::shared_ptr& callback); - int32_t UnRegisterPermActiveStatusCallback(const std::shared_ptr& callback); - int32_t CreateActiveStatusChangeCbk( - const std::shared_ptr& callback, sptr& callbackObject); - - void OnRemoteDiedHandle(); -private: - PrivacyManagerClient(); - - DISALLOW_COPY_AND_MOVE(PrivacyManagerClient); - std::mutex proxyMutex_; - sptr proxy_ = nullptr; - sptr serviceDeathObserver_ = nullptr; - void InitProxy(); - sptr GetProxy(); - -private: - std::mutex activeCbkMutex_; - std::map, sptr> activeCbkMap_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PRIVACY_MANAGER_CLIENT_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PRIVACY_MANAGER_CLIENT_H +#define PRIVACY_MANAGER_CLIENT_H + +#include +#include +#include +#include + +#include "i_privacy_manager.h" +#include "perm_active_status_change_callback.h" +#include "perm_active_status_customized_cbk.h" +#include "privacy_death_recipient.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PrivacyManagerClient final { +public: + static PrivacyManagerClient& GetInstance(); + + virtual ~PrivacyManagerClient(); + + int32_t AddPermissionUsedRecord( + AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount); + int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName); + int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName); + int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID); + int32_t GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result); + int32_t GetPermissionUsedRecords( + const PermissionUsedRequest& request, const sptr& callback); + std::string DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName); + int32_t RegisterPermActiveStatusCallback(const std::shared_ptr& callback); + int32_t UnRegisterPermActiveStatusCallback(const std::shared_ptr& callback); + int32_t CreateActiveStatusChangeCbk( + const std::shared_ptr& callback, sptr& callbackObject); + bool IsAllowUsingPermission(AccessTokenID tokenID, const std::string& permissionName); + void OnRemoteDiedHandle(); +private: + PrivacyManagerClient(); + + DISALLOW_COPY_AND_MOVE(PrivacyManagerClient); + std::mutex proxyMutex_; + sptr proxy_ = nullptr; + sptr serviceDeathObserver_ = nullptr; + void InitProxy(); + sptr GetProxy(); + +private: + std::mutex activeCbkMutex_; + std::map, sptr> activeCbkMap_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PRIVACY_MANAGER_CLIENT_H diff --git a/interfaces/innerkits/privacy/src/privacy_manager_proxy.cpp b/interfaces/innerkits/privacy/src/privacy_manager_proxy.cpp index 0014a3c02e8daa7e24f28dc6eb9c0fa2b28b52a2..b57f80e27e4031b56f2911029f9315ba66d70527 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_proxy.cpp +++ b/interfaces/innerkits/privacy/src/privacy_manager_proxy.cpp @@ -1,317 +1,340 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "privacy_manager_proxy.h" - -#include "accesstoken_log.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyManagerProxy" -}; -} - -const static int32_t ERROR = -1; - -PrivacyManagerProxy::PrivacyManagerProxy(const sptr& impl) - : IRemoteProxy(impl) { -} - -PrivacyManagerProxy::~PrivacyManagerProxy() -{} - -int32_t PrivacyManagerProxy::AddPermissionUsedRecord(AccessTokenID tokenID, const std::string& permissionName, - int32_t successCount, int32_t failCount) -{ - MessageParcel data; - data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); - if (!data.WriteUint32(tokenID)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); - return ERROR; - } - if (!data.WriteString(permissionName)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(permissionName)"); - return ERROR; - } - if (!data.WriteInt32(successCount)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(successCount)"); - return ERROR; - } - if (!data.WriteInt32(failCount)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(failCount)"); - return ERROR; - } - - MessageParcel reply; - int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::ADD_PERMISSION_USED_RECORD, data, reply); - if (!requestResult) { - ACCESSTOKEN_LOG_ERROR(LABEL, "add result fail, result: %{public}d", requestResult); - } - int32_t ret = reply.ReadInt32(); - ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); - return ret; -} - -int32_t PrivacyManagerProxy::StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) -{ - MessageParcel data; - data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); - if (!data.WriteUint32(tokenID)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); - return ERROR; - } - if (!data.WriteString(permissionName)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(permissionName)"); - return ERROR; - } - - MessageParcel reply; - int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::START_USING_PERMISSION, data, reply); - if (!requestResult) { - ACCESSTOKEN_LOG_ERROR(LABEL, "add result fail, result: %{public}d", requestResult); - } - int32_t ret = reply.ReadInt32(); - ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); - return ret; -} - -int32_t PrivacyManagerProxy::StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) -{ - MessageParcel data; - data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); - if (!data.WriteUint32(tokenID)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); - return ERROR; - } - if (!data.WriteString(permissionName)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(permissionName)"); - return ERROR; - } - - MessageParcel reply; - int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::STOP_USING_PERMISSION, data, reply); - if (!requestResult) { - ACCESSTOKEN_LOG_ERROR(LABEL, "add result fail, result: %{public}d", requestResult); - } - int32_t ret = reply.ReadInt32(); - ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); - return ret; -} - -int32_t PrivacyManagerProxy::RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) -{ - MessageParcel data; - data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); - if (!data.WriteUint32(tokenID)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); - return ERROR; - } - if (!data.WriteString(deviceID)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(deviceID)"); - return ERROR; - } - - MessageParcel reply; - int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::DELETE_PERMISSION_USED_RECORDS, data, reply); - if (!requestResult) { - ACCESSTOKEN_LOG_ERROR(LABEL, "add result fail, result: %{public}d", requestResult); - } - int32_t ret = reply.ReadInt32(); - ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); - return ret; -} - -int32_t PrivacyManagerProxy::GetPermissionUsedRecords(const PermissionUsedRequestParcel& request, - PermissionUsedResultParcel& result) -{ - MessageParcel data; - data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); - if (!data.WriteParcelable(&request)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable(request)"); - return ERROR; - } - - MessageParcel reply; - int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::GET_PERMISSION_USED_RECORDS, data, reply); - if (!requestResult) { - ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); - return ERROR; - } - - sptr resultSptr = reply.ReadParcelable(); - if (resultSptr == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable fail"); - return ERROR; - } - result = *resultSptr; - int32_t ret = reply.ReadInt32(); - ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); - return ret; -} - -int32_t PrivacyManagerProxy::GetPermissionUsedRecords(const PermissionUsedRequestParcel& request, - const sptr& callback) -{ - MessageParcel data; - data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); - if (!data.WriteParcelable(&request)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable(request)"); - return ERROR; - } - if (!data.WriteRemoteObject(callback->AsObject())) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteRemoteObject(callback)"); - return ERROR; - } - - MessageParcel reply; - int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::GET_PERMISSION_USED_RECORDS_ASYNC, data, reply); - if (!requestResult) { - ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); - return ERROR; - } - int32_t ret = reply.ReadInt32(); - ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); - return ret; -} - -std::string PrivacyManagerProxy::DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) -{ - MessageParcel data; - MessageParcel reply; - data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); - if (!data.WriteUint32(tokenID)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); - return ""; - } - if (!data.WriteString(permissionName)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(%{public}s)", permissionName.c_str()); - return ""; - } - int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::DUMP_RECORD_INFO, data, reply); - if (!requestResult) { - ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); - return ""; - } - std::string dumpInfo = reply.ReadString(); - return dumpInfo; -} - -int32_t PrivacyManagerProxy::RegisterPermActiveStatusCallback( - std::vector& permList, const sptr& callback) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "called."); - MessageParcel data; - if (!data.WriteInterfaceToken(IPrivacyManager::GetDescriptor())) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write WriteInterfaceToken."); - return ERROR; - } - - uint32_t listSize = permList.size(); - if (!data.WriteUint32(listSize)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write listSize"); - return ERROR; - } - for (uint32_t i = 0; i < listSize; i++) { - if (!data.WriteString(permList[i])) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write permList[%{public}d], %{public}s", i, permList[i].c_str()); - return ERROR; - } - } - - if (!data.WriteRemoteObject(callback)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write remote object."); - return ERROR; - } - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); - return ERROR; - } - int32_t requestResult = remote->SendRequest( - static_cast(IPrivacyManager::InterfaceCode::REGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK), - data, reply, option); - if (requestResult != NO_ERROR) { - ACCESSTOKEN_LOG_ERROR(LABEL, "request fail, result: %{public}d.", requestResult); - return ERROR; - } - - int32_t result; - if (!reply.ReadInt32(result)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "ReadInt32 fail"); - return ERROR; - } - return result; -} - -int32_t PrivacyManagerProxy::UnRegisterPermActiveStatusCallback(const sptr& callback) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "called."); - MessageParcel data; - if (!data.WriteInterfaceToken(IPrivacyManager::GetDescriptor())) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write WriteInterfaceToken."); - return ERROR; - } - if (!data.WriteRemoteObject(callback)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write remote object."); - return ERROR; - } - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); - return ERROR; - } - int32_t requestResult = remote->SendRequest( - static_cast(IPrivacyManager::InterfaceCode::UNREGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK), - data, reply, option); - if (requestResult != NO_ERROR) { - ACCESSTOKEN_LOG_ERROR(LABEL, "request fail, result: %{public}d.", requestResult); - return ERROR; - } - - int32_t result; - if (!reply.ReadInt32(result)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "ReadInt32 fail"); - return ERROR; - } - return result; -} - -bool PrivacyManagerProxy::SendRequest( - IPrivacyManager::InterfaceCode code, MessageParcel& data, MessageParcel& reply) -{ - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); - return false; - } - - int32_t result = remote->SendRequest(static_cast(code), data, reply, option); - if (result != NO_ERROR) { - ACCESSTOKEN_LOG_ERROR(LABEL, "SendRequest fail, result: %{public}d", result); - return false; - } - return true; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "privacy_manager_proxy.h" + +#include "accesstoken_log.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyManagerProxy" +}; +} + +const static int32_t ERROR = -1; + +PrivacyManagerProxy::PrivacyManagerProxy(const sptr& impl) + : IRemoteProxy(impl) { +} + +PrivacyManagerProxy::~PrivacyManagerProxy() +{} + +int32_t PrivacyManagerProxy::AddPermissionUsedRecord(AccessTokenID tokenID, const std::string& permissionName, + int32_t successCount, int32_t failCount) +{ + MessageParcel data; + data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); + if (!data.WriteUint32(tokenID)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); + return ERROR; + } + if (!data.WriteString(permissionName)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(permissionName)"); + return ERROR; + } + if (!data.WriteInt32(successCount)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(successCount)"); + return ERROR; + } + if (!data.WriteInt32(failCount)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(failCount)"); + return ERROR; + } + + MessageParcel reply; + int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::ADD_PERMISSION_USED_RECORD, data, reply); + if (!requestResult) { + ACCESSTOKEN_LOG_ERROR(LABEL, "add result fail, result: %{public}d", requestResult); + } + int32_t ret = reply.ReadInt32(); + ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); + return ret; +} + +int32_t PrivacyManagerProxy::StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + MessageParcel data; + data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); + if (!data.WriteUint32(tokenID)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); + return ERROR; + } + if (!data.WriteString(permissionName)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(permissionName)"); + return ERROR; + } + + MessageParcel reply; + int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::START_USING_PERMISSION, data, reply); + if (!requestResult) { + ACCESSTOKEN_LOG_ERROR(LABEL, "add result fail, result: %{public}d", requestResult); + } + int32_t ret = reply.ReadInt32(); + ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); + return ret; +} + +int32_t PrivacyManagerProxy::StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + MessageParcel data; + data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); + if (!data.WriteUint32(tokenID)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); + return ERROR; + } + if (!data.WriteString(permissionName)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(permissionName)"); + return ERROR; + } + + MessageParcel reply; + int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::STOP_USING_PERMISSION, data, reply); + if (!requestResult) { + ACCESSTOKEN_LOG_ERROR(LABEL, "add result fail, result: %{public}d", requestResult); + } + int32_t ret = reply.ReadInt32(); + ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); + return ret; +} + +int32_t PrivacyManagerProxy::RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) +{ + MessageParcel data; + data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); + if (!data.WriteUint32(tokenID)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); + return ERROR; + } + if (!data.WriteString(deviceID)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(deviceID)"); + return ERROR; + } + + MessageParcel reply; + int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::DELETE_PERMISSION_USED_RECORDS, data, reply); + if (!requestResult) { + ACCESSTOKEN_LOG_ERROR(LABEL, "add result fail, result: %{public}d", requestResult); + } + int32_t ret = reply.ReadInt32(); + ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); + return ret; +} + +int32_t PrivacyManagerProxy::GetPermissionUsedRecords(const PermissionUsedRequestParcel& request, + PermissionUsedResultParcel& result) +{ + MessageParcel data; + data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); + if (!data.WriteParcelable(&request)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable(request)"); + return ERROR; + } + + MessageParcel reply; + int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::GET_PERMISSION_USED_RECORDS, data, reply); + if (!requestResult) { + ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); + return ERROR; + } + + sptr resultSptr = reply.ReadParcelable(); + if (resultSptr == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable fail"); + return ERROR; + } + result = *resultSptr; + int32_t ret = reply.ReadInt32(); + ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); + return ret; +} + +int32_t PrivacyManagerProxy::GetPermissionUsedRecords(const PermissionUsedRequestParcel& request, + const sptr& callback) +{ + MessageParcel data; + data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); + if (!data.WriteParcelable(&request)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable(request)"); + return ERROR; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteRemoteObject(callback)"); + return ERROR; + } + + MessageParcel reply; + int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::GET_PERMISSION_USED_RECORDS_ASYNC, data, reply); + if (!requestResult) { + ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); + return ERROR; + } + int32_t ret = reply.ReadInt32(); + ACCESSTOKEN_LOG_DEBUG(LABEL, "get result from server data = %{public}d", ret); + return ret; +} + +std::string PrivacyManagerProxy::DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) +{ + MessageParcel data; + MessageParcel reply; + data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); + if (!data.WriteUint32(tokenID)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); + return ""; + } + if (!data.WriteString(permissionName)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(%{public}s)", permissionName.c_str()); + return ""; + } + int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::DUMP_RECORD_INFO, data, reply); + if (!requestResult) { + ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); + return ""; + } + std::string dumpInfo = reply.ReadString(); + return dumpInfo; +} + +int32_t PrivacyManagerProxy::RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "called."); + MessageParcel data; + if (!data.WriteInterfaceToken(IPrivacyManager::GetDescriptor())) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write WriteInterfaceToken."); + return ERROR; + } + + uint32_t listSize = permList.size(); + if (!data.WriteUint32(listSize)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write listSize"); + return ERROR; + } + for (uint32_t i = 0; i < listSize; i++) { + if (!data.WriteString(permList[i])) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write permList[%{public}d], %{public}s", i, permList[i].c_str()); + return ERROR; + } + } + + if (!data.WriteRemoteObject(callback)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write remote object."); + return ERROR; + } + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + sptr remote = Remote(); + if (remote == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); + return ERROR; + } + int32_t requestResult = remote->SendRequest( + static_cast(IPrivacyManager::InterfaceCode::REGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK), + data, reply, option); + if (requestResult != NO_ERROR) { + ACCESSTOKEN_LOG_ERROR(LABEL, "request fail, result: %{public}d.", requestResult); + return ERROR; + } + + int32_t result; + if (!reply.ReadInt32(result)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "ReadInt32 fail"); + return ERROR; + } + return result; +} + +int32_t PrivacyManagerProxy::UnRegisterPermActiveStatusCallback(const sptr& callback) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "called."); + MessageParcel data; + if (!data.WriteInterfaceToken(IPrivacyManager::GetDescriptor())) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write WriteInterfaceToken."); + return ERROR; + } + if (!data.WriteRemoteObject(callback)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write remote object."); + return ERROR; + } + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + sptr remote = Remote(); + if (remote == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); + return ERROR; + } + int32_t requestResult = remote->SendRequest( + static_cast(IPrivacyManager::InterfaceCode::UNREGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK), + data, reply, option); + if (requestResult != NO_ERROR) { + ACCESSTOKEN_LOG_ERROR(LABEL, "request fail, result: %{public}d.", requestResult); + return ERROR; + } + + int32_t result; + if (!reply.ReadInt32(result)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "ReadInt32 fail"); + return ERROR; + } + return result; +} + +bool PrivacyManagerProxy::IsAllowUsingPermission(AccessTokenID tokenID, const std::string& permissionName) +{ + MessageParcel data; + MessageParcel reply; + data.WriteInterfaceToken(IPrivacyManager::GetDescriptor()); + if (!data.WriteUint32(tokenID)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteUint32(%{public}d)", tokenID); + return false; + } + if (!data.WriteString(permissionName)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteString(%{public}s)", permissionName.c_str()); + return false; + } + int32_t requestResult = SendRequest(IPrivacyManager::InterfaceCode::IS_ALLOW_USING_PERMISSION, data, reply); + if (!requestResult) { + ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); + return false; + } + bool allowperInfo = reply.ReadBool(); + return allowperInfo; +} + + +bool PrivacyManagerProxy::SendRequest( + IPrivacyManager::InterfaceCode code, MessageParcel& data, MessageParcel& reply) +{ + MessageOption option(MessageOption::TF_SYNC); + sptr remote = Remote(); + if (remote == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); + return false; + } + + int32_t result = remote->SendRequest(static_cast(code), data, reply, option); + if (result != NO_ERROR) { + ACCESSTOKEN_LOG_ERROR(LABEL, "SendRequest fail, result: %{public}d", result); + return false; + } + return true; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/interfaces/innerkits/privacy/src/privacy_manager_proxy.h b/interfaces/innerkits/privacy/src/privacy_manager_proxy.h index 5ea5aaa615a6399bc22b7549e1c9f195924a0224..fff84d43d29a5e78844032012d1ed7edf0888de8 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_proxy.h +++ b/interfaces/innerkits/privacy/src/privacy_manager_proxy.h @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PRIVACY_MANAGER_PROXY_H -#define PRIVACY_MANAGER_PROXY_H - -#include - -#include "i_privacy_manager.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyManagerProxy : public IRemoteProxy { -public: - explicit PrivacyManagerProxy(const sptr& impl); - ~PrivacyManagerProxy() override; - - int32_t AddPermissionUsedRecord( - AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) override; - int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) override; - int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) override; - int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) override; - int32_t GetPermissionUsedRecords( - const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) override; - int32_t GetPermissionUsedRecords(const PermissionUsedRequestParcel& request, - const sptr& callback) override; - std::string DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) override; - int32_t RegisterPermActiveStatusCallback( - std::vector& permList, const sptr& callback) override; - int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) override; - -private: - bool SendRequest(IPrivacyManager::InterfaceCode code, MessageParcel& data, MessageParcel& reply); - static inline BrokerDelegator delegator_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PRIVACY_MANAGER_PROXY_H +#define PRIVACY_MANAGER_PROXY_H + +#include + +#include "i_privacy_manager.h" +#include "iremote_proxy.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PrivacyManagerProxy : public IRemoteProxy { +public: + explicit PrivacyManagerProxy(const sptr& impl); + ~PrivacyManagerProxy() override; + + int32_t AddPermissionUsedRecord( + AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) override; + int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) override; + int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) override; + int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) override; + int32_t GetPermissionUsedRecords( + const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) override; + int32_t GetPermissionUsedRecords(const PermissionUsedRequestParcel& request, + const sptr& callback) override; + std::string DumpRecordInfo(AccessTokenID tokenID, const std::string& permissionName) override; + int32_t RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) override; + int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) override; + bool IsAllowUsingPermission(AccessTokenID tokenID, const std::string& permissionName) override; +private: + bool SendRequest(IPrivacyManager::InterfaceCode code, MessageParcel& data, MessageParcel& reply); + static inline BrokerDelegator delegator_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS #endif // PRIVACY_MANAGER_PROXY_H \ No newline at end of file diff --git a/interfaces/innerkits/privacy/test/BUILD.gn b/interfaces/innerkits/privacy/test/BUILD.gn index e5c3925710cdce6cddcbdfd9d57d0a7cb89264d0..bdfae2c860af77a6d4d8d3bd12fed93c51f3bf1a 100644 --- a/interfaces/innerkits/privacy/test/BUILD.gn +++ b/interfaces/innerkits/privacy/test/BUILD.gn @@ -1,53 +1,53 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/test.gni") - -ohos_unittest("libprivacy_sdk_test") { - subsystem_name = "security" - part_name = "access_token" - module_out_path = part_name + "/" + part_name - - include_dirs = [ - "//commonlibrary/c_utils/base/include", - "//third_party/googletest/include", - "//base/security/access_token/interfaces/innerkits/accesstoken/include", - "//base/security/access_token/interfaces/innerkits/nativetoken/include", - "//base/security/access_token/interfaces/innerkits/privacy/include", - "//base/security/access_token/interfaces/innerkits/token_setproc/include", - "//base/security/access_token/services/privacymanager/include/record", - ] - - sources = [ "unittest/src/privacy_kit_test.cpp" ] - - cflags_cc = [ "-DHILOG_ENABLE" ] - - deps = [ - "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk", - "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", - "//base/security/access_token/interfaces/innerkits/privacy:libprivacy_sdk", - "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", - "//base/security/access_token/services/privacymanager:privacy_manager_service", - ] - external_deps = [ - "c_utils:utils", - "init:libbegetutil", - "ipc:ipc_core", - "samgr:samgr_proxy", - ] -} - -group("unittest") { - testonly = true - deps = [ ":libprivacy_sdk_test" ] -} +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") + +ohos_unittest("libprivacy_sdk_test") { + subsystem_name = "security" + part_name = "access_token" + module_out_path = part_name + "/" + part_name + + include_dirs = [ + "//commonlibrary/c_utils/base/include", + "//third_party/googletest/include", + "//base/security/access_token/interfaces/innerkits/accesstoken/include", + "//base/security/access_token/interfaces/innerkits/nativetoken/include", + "//base/security/access_token/interfaces/innerkits/privacy/include", + "//base/security/access_token/interfaces/innerkits/token_setproc/include", + "//base/security/access_token/services/privacymanager/include/record", + ] + + sources = [ "unittest/src/privacy_kit_test.cpp" ] + + cflags_cc = [ "-DHILOG_ENABLE" ] + + deps = [ + "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk", + "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", + "//base/security/access_token/interfaces/innerkits/privacy:libprivacy_sdk", + "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", + "//base/security/access_token/services/privacymanager:privacy_manager_service", + ] + external_deps = [ + "c_utils:utils", + "init:libbegetutil", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] +} + +group("unittest") { + testonly = true + deps = [ ":libprivacy_sdk_test" ] +} diff --git a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp index c19d79fb85a279cd0d86d3dee0e13c0528963649..2cf1fc252bb014a0316e8f9761659b4ec4b24618 100644 --- a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp +++ b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp @@ -1,921 +1,863 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "privacy_kit_test.h" - -#include "accesstoken_kit.h" -#include "nativetoken_kit.h" -#include "parameter.h" -#include "privacy_kit.h" -#include "token_setproc.h" - -using namespace testing::ext; -using namespace OHOS::Security::AccessToken; - -const static int32_t RET_NO_ERROR = 0; -const static int32_t RET_ERROR = -1; - -static HapPolicyParams g_PolicyPramsA = { - .apl = APL_NORMAL, - .domain = "test.domain.A", -}; - -static HapInfoParams g_InfoParmsA = { - .userID = 1, - .bundleName = "ohos.privacy_test.bundleA", - .instIndex = 0, - .appIDDesc = "privacy_test.bundleA" -}; - -static HapPolicyParams g_PolicyPramsB = { - .apl = APL_NORMAL, - .domain = "test.domain.B", -}; - -static HapInfoParams g_InfoParmsB = { - .userID = 1, - .bundleName = "ohos.privacy_test.bundleB", - .instIndex = 0, - .appIDDesc = "privacy_test.bundleB" -}; - -static PermissionStateFull g_infoManagerTestStateA = { - .permissionName = "ohos.permission.CAMERA", - .grantFlags = {1}, - .grantStatus = {PermissionState::PERMISSION_GRANTED}, - .isGeneral = true, - .resDeviceID = {"local"} -}; - -static PermissionStateFull g_infoManagerTestStateB = { - .permissionName = "ohos.permission.MICROPHONE", - .grantFlags = {1}, - .grantStatus = {PermissionState::PERMISSION_GRANTED}, - .isGeneral = true, - .resDeviceID = {"local"} -}; -static HapPolicyParams g_PolicyPramsE = { - .apl = APL_NORMAL, - .domain = "test.domain", - .permList = {}, - .permStateList = {g_infoManagerTestStateA, g_infoManagerTestStateB} -}; -static HapInfoParams g_InfoParmsE = { - .userID = 1, - .bundleName = "ohos.privacy_test.bundleE", - .instIndex = 0, - .appIDDesc = "privacy_test.bundleE" -}; - -static AccessTokenID g_selfTokenId = 0; -static AccessTokenID g_TokenId_A = 0; -static AccessTokenID g_TokenId_B = 0; -static AccessTokenID g_TokenId_E = 0; - -void PrivacyKitTest::SetUpTestCase() -{ - g_selfTokenId = GetSelfTokenID(); -} - -void PrivacyKitTest::TearDownTestCase() -{ -} - -void PrivacyKitTest::SetUp() -{ - AccessTokenKit::AllocHapToken(g_InfoParmsA, g_PolicyPramsA); - AccessTokenKit::AllocHapToken(g_InfoParmsB, g_PolicyPramsB); - AccessTokenKit::AllocHapToken(g_InfoParmsE, g_PolicyPramsE); - - g_TokenId_A = AccessTokenKit::GetHapTokenID(g_InfoParmsA.userID, - g_InfoParmsA.bundleName, - g_InfoParmsA.instIndex); - g_TokenId_B = AccessTokenKit::GetHapTokenID(g_InfoParmsB.userID, - g_InfoParmsB.bundleName, - g_InfoParmsB.instIndex); - g_TokenId_E = AccessTokenKit::GetHapTokenID(g_InfoParmsE.userID, - g_InfoParmsE.bundleName, - g_InfoParmsE.instIndex); - - AccessTokenID tokenId = AccessTokenKit::GetHapTokenID(100, "com.ohos.permissionmanager", 0); // 100 is userID - SetSelfTokenID(tokenId); -} - -void PrivacyKitTest::TearDown() -{ - SetSelfTokenID(g_selfTokenId); - AccessTokenID tokenId = AccessTokenKit::GetHapTokenID(g_InfoParmsA.userID, - g_InfoParmsA.bundleName, - g_InfoParmsA.instIndex); - AccessTokenKit::DeleteToken(tokenId); - - tokenId = AccessTokenKit::GetHapTokenID(g_InfoParmsB.userID, - g_InfoParmsB.bundleName, - g_InfoParmsB.instIndex); - AccessTokenKit::DeleteToken(tokenId); - - tokenId = AccessTokenKit::GetHapTokenID(g_InfoParmsE.userID, - g_InfoParmsE.bundleName, - g_InfoParmsE.instIndex); - AccessTokenKit::DeleteToken(tokenId); -} - -std::string PrivacyKitTest::GetLocalDeviceUdid() -{ - const int32_t DEVICE_UUID_LENGTH = 65; - char udid[DEVICE_UUID_LENGTH] = {0}; - GetDevUdid(udid, DEVICE_UUID_LENGTH); - return udid; -} - -void PrivacyKitTest::BuildQueryRequest(AccessTokenID tokenId, const std::string deviceId, const std::string& bundleName, - const std::vector permissionList, PermissionUsedRequest& request) -{ - request.tokenId = tokenId; - request.isRemote = false; - request.deviceId = deviceId; - request.bundleName = bundleName; - request.permissionList = permissionList; - request.beginTimeMillis = 0; - request.endTimeMillis = 0; - request.flag = FLAG_PERMISSION_USAGE_SUMMARY; -} - -void PrivacyKitTest::CheckPermissionUsedResult(const PermissionUsedRequest& request, const PermissionUsedResult& result, - int32_t permRecordSize, int32_t totalSuccessCount, int32_t totalFailCount) -{ - int32_t successCount = 0; - int32_t failCount = 0; - ASSERT_EQ(request.tokenId, result.bundleRecords[0].tokenId); - ASSERT_EQ(request.isRemote, result.bundleRecords[0].isRemote); - ASSERT_EQ(request.deviceId, result.bundleRecords[0].deviceId); - ASSERT_EQ(request.bundleName, result.bundleRecords[0].bundleName); - ASSERT_EQ(permRecordSize, result.bundleRecords[0].permissionRecords.size()); - for (int32_t i = 0; i < permRecordSize; i++) { - successCount += result.bundleRecords[0].permissionRecords[i].accessCount; - failCount += result.bundleRecords[0].permissionRecords[i].rejectCount; - } - ASSERT_EQ(totalSuccessCount, successCount); - ASSERT_EQ(totalFailCount, failCount); -} - -static void SetTokenID(std::vector& g_InfoParms_List, - std::vector& g_TokenId_List, int32_t number) -{ - SetSelfTokenID(g_selfTokenId); - for (int32_t i = 0; i < number; i++) { - HapInfoParams g_InfoParmsTmp = { - .userID = i, - .bundleName = "ohos.privacy_test.bundle" + std::to_string(i), - .instIndex = i, - .appIDDesc = "privacy_test.bundle" + std::to_string(i) - }; - g_InfoParms_List.push_back(g_InfoParmsTmp); - HapPolicyParams g_PolicyPramsTmp = { - .apl = APL_NORMAL, - .domain = "test.domain." + std::to_string(i) - }; - AccessTokenKit::AllocHapToken(g_InfoParmsTmp, g_PolicyPramsTmp); - AccessTokenID g_TokenId_Tmp = AccessTokenKit::GetHapTokenID(g_InfoParmsTmp.userID, - g_InfoParmsTmp.bundleName, - g_InfoParmsTmp.instIndex); - g_TokenId_List.push_back(g_TokenId_Tmp); - } - AccessTokenID tokenId = AccessTokenKit::GetHapTokenID(100, "com.ohos.permissionmanager", 0); - SetSelfTokenID(tokenId); -} - -static void DeleteTokenID(std::vector& g_InfoParms_List) -{ - SetSelfTokenID(g_selfTokenId); - for (size_t i = 0; i < g_InfoParms_List.size(); i++) { - AccessTokenID g_TokenId_Tmp = AccessTokenKit::GetHapTokenID(g_InfoParms_List[i].userID, - g_InfoParms_List[i].bundleName, - g_InfoParms_List[i].instIndex); - AccessTokenKit::DeleteToken(g_TokenId_Tmp); - } - AccessTokenID tokenId = AccessTokenKit::GetHapTokenID(100, "com.ohos.permissionmanager", 0); - SetSelfTokenID(tokenId); -} - -/** - * @tc.name: AddPermissionUsedRecord001 - * @tc.desc: cannot AddPermissionUsedRecord with illegal tokenId and permission. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord001, TestSize.Level1) -{ - ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord( - 0, "ohos.permission.READ_CONTACTS", 1, 0)); - ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "", 1, 0)); - ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord( - g_TokenId_A, "ohos.permission.READ_CONTACTS", -1, 0)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(0, result.bundleRecords.size()); -} - -/** - * @tc.name: AddPermissionUsedRecord002 - * @tc.desc: cannot AddPermissionUsedRecord with invalid tokenId and permission. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord002, TestSize.Level1) -{ - ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.test", 1, 0)); - ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord(123, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.READ_CONTACTS", 0, 0)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(123, "", "", permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(0, result.bundleRecords.size()); - - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(0, result.bundleRecords.size()); -} - -/** - * @tc.name: AddPermissionUsedRecord003 - * @tc.desc: cannot AddPermissionUsedRecord with native tokenId. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord003, TestSize.Level1) -{ - const char **dcaps = new const char *[2]; - dcaps[0] = "AT_CAP"; - dcaps[1] = "ST_CAP"; - uint64_t tokenId; - const char **acls = new const char *[2]; - acls[0] = "ohos.permission.test1"; - acls[1] = "ohos.permission.test2"; - const char **perms = new const char *[2]; - perms[0] = "ohos.permission.test1"; - perms[1] = "ohos.permission.test2"; - NativeTokenInfoParams infoInstance = { - .dcapsNum = 2, - .permsNum = 2, - .aclsNum = 2, - .dcaps = dcaps, - .perms = perms, - .acls = acls, - .processName = "GetAccessTokenId008", - .aplStr = "system_core", - }; - tokenId = GetAccessTokenId(&infoInstance); - ASSERT_NE(tokenId, 0); - - delete[] perms; - delete[] dcaps; - delete[] acls; - - ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord( - tokenId, "ohos.permission.READ_CONTACTS", 1, 0)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(tokenId, "", "", permissionList, request); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(0, result.bundleRecords.size()); -} - -/** - * @tc.name: AddPermissionUsedRecord004 - * @tc.desc: AddPermissionUsedRecord user_grant permission. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord004, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.WRITE_CONTACTS", 0, 1)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.LOCATION", 1, 1)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - - ASSERT_EQ(1, result.bundleRecords.size()); - CheckPermissionUsedResult(request, result, 3, 2, 2); -} - -/** - * @tc.name: AddPermissionUsedRecord005 - * @tc.desc: AddPermissionUsedRecord user_grant permission. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord005, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.LOCATION", 0, 1)); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_B, "ohos.permission.CAMERA", 0, 1)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_B, "ohos.permission.LOCATION", 1, 0)); - - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - - ASSERT_EQ(1, result.bundleRecords.size()); - CheckPermissionUsedResult(request, result, 2, 1, 1); - - BuildQueryRequest(g_TokenId_B, GetLocalDeviceUdid(), g_InfoParmsB.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - - ASSERT_EQ(1, result.bundleRecords.size()); - CheckPermissionUsedResult(request, result, 2, 1, 1); -} - -/** - * @tc.name: AddPermissionUsedRecord006 - * @tc.desc: AddPermissionUsedRecord permission combine records. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord006, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - request.flag = FLAG_PERMISSION_USAGE_DETAIL; - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - - ASSERT_EQ(1, result.bundleRecords.size()); - ASSERT_EQ(1, result.bundleRecords[0].permissionRecords.size()); - ASSERT_EQ(1, result.bundleRecords[0].permissionRecords[0].accessRecords.size()); - CheckPermissionUsedResult(request, result, 1, 4, 0); - - sleep(61); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(1, result.bundleRecords.size()); - ASSERT_EQ(1, result.bundleRecords[0].permissionRecords.size()); - ASSERT_EQ(2, result.bundleRecords[0].permissionRecords[0].accessRecords.size()); - CheckPermissionUsedResult(request, result, 1, 5, 0); -} - -/** - * @tc.name: AddPermissionUsedRecord007 - * @tc.desc: AddPermissionUsedRecord user_grant permission. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord007, TestSize.Level1) -{ - std::vector g_InfoParms_List; - std::vector g_TokenId_List; - SetTokenID(g_InfoParms_List, g_TokenId_List, 100); - std::vector addPermissionList = { - "ohos.permission.ANSWER_CALL", - "ohos.permission.READ_CALENDAR", - }; - for (int32_t i = 0; i < 200; i++) { - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_List[i % 100], - addPermissionList[i % 2], 1, 0)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_List[i % 100], GetLocalDeviceUdid(), - g_InfoParms_List[i % 100].bundleName, permissionList, request); - request.flag = FLAG_PERMISSION_USAGE_DETAIL; - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - } - sleep(70); - for (int32_t i = 0; i < 100; i++) { - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_List[i], GetLocalDeviceUdid(), - g_InfoParms_List[i].bundleName, permissionList, request); - request.flag = FLAG_PERMISSION_USAGE_DETAIL; - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(1, result.bundleRecords.size()); - ASSERT_EQ(1, result.bundleRecords[0].permissionRecords.size()); - ASSERT_EQ(1, result.bundleRecords[0].permissionRecords[0].accessRecords.size()); - CheckPermissionUsedResult(request, result, 1, 2, 0); - } - DeleteTokenID(g_InfoParms_List); -} - -/** - * @tc.name: RemovePermissionUsedRecords001 - * @tc.desc: cannot RemovePermissionUsedRecords with illegal tokenId and deviceID. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, RemovePermissionUsedRecords001, TestSize.Level1) -{ - ASSERT_EQ(RET_ERROR, PrivacyKit::RemovePermissionUsedRecords(0, "")); -} - -/** - * @tc.name: RemovePermissionUsedRecords002 - * @tc.desc: RemovePermissionUsedRecords with invalid tokenId and deviceID. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, RemovePermissionUsedRecords002, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RemovePermissionUsedRecords(g_TokenId_A, "invalid_device")); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(1, result.bundleRecords.size()); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RemovePermissionUsedRecords(123, GetLocalDeviceUdid())); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(1, result.bundleRecords.size()); -} - -/** - * @tc.name: RemovePermissionUsedRecords003 - * @tc.desc: RemovePermissionUsedRecords with valid tokenId and deviceID. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, RemovePermissionUsedRecords003, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RemovePermissionUsedRecords(g_TokenId_A, "")); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(0, result.bundleRecords.size()); -} - -/** - * @tc.name: GetPermissionUsedRecords001 - * @tc.desc: cannot GetPermissionUsedRecords with invalid query time. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, GetPermissionUsedRecords001, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - request.beginTimeMillis = -1; - request.endTimeMillis = -1; - ASSERT_EQ(RET_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - - request.beginTimeMillis = 3; - request.endTimeMillis = 1; - ASSERT_EQ(RET_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - - request.flag = (PermissionUsageFlag)-1; - ASSERT_EQ(RET_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); -} - -/** - * @tc.name: GetPermissionUsedRecords002 - * @tc.desc: cannot GetPermissionUsedRecords with valid query time. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, GetPermissionUsedRecords002, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.READ_CALENDAR", 1, 0)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - // query by tokenId - BuildQueryRequest(g_TokenId_A, "", "", permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(1, result.bundleRecords.size()); - request.deviceId = GetLocalDeviceUdid(); - request.bundleName = g_InfoParmsA.bundleName; - CheckPermissionUsedResult(request, result, 3, 3, 0); - - // query by unmatched tokenId, deviceId and bundle Name - BuildQueryRequest(123, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(0, result.bundleRecords.size()); - - // query by invalid permission Name - permissionList.clear(); - permissionList.emplace_back("invalid permission"); - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(0, result.bundleRecords.size()); -} - -/** - * @tc.name: GetPermissionUsedRecords003 - * @tc.desc: can GetPermissionUsedRecords with valid query time. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, GetPermissionUsedRecords003, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(1, result.bundleRecords.size()); - CheckPermissionUsedResult(request, result, 1, 4, 0); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.READ_CALENDAR", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.WRITE_CALENDAR", 1, 0)); - - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(1, result.bundleRecords.size()); - CheckPermissionUsedResult(request, result, 4, 7, 0); -} - -/** - * @tc.name: GetPermissionUsedRecords004 - * @tc.desc: can GetPermissionUsedRecords with valid query time. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, GetPermissionUsedRecords004, TestSize.Level1) -{ - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.READ_CALENDAR", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_B, "ohos.permission.CAMERA", 1, 0)); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_B, "ohos.permission.READ_CALENDAR", 1, 0)); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(0, GetLocalDeviceUdid(), "", permissionList, request); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - if (result.bundleRecords.size() < 2) { - ASSERT_EQ(RET_NO_ERROR, RET_ERROR); - } -} - -/** - * @tc.name: GetPermissionUsedRecordsAsync001 - * @tc.desc: cannot GetPermissionUsedRecordsAsync with invalid query time. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, GetPermissionUsedRecordsAsync001, TestSize.Level1) -{ - std::string permission = "ohos.permission.CAMERA"; - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, permission, 1, 0)); - PermissionUsedRequest request; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), "", permissionList, request); - request.beginTimeMillis = -1; - request.endTimeMillis = -1; - OHOS::sptr callback(new TestCallBack()); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, callback)); -} - -/** - * @tc.name: GetPermissionUsedRecordsAsync002 - * @tc.desc: cannot GetPermissionUsedRecordsAsync with valid query time. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, GetPermissionUsedRecordsAsync002, TestSize.Level1) -{ - std::string permission = "ohos.permission.CAMERA"; - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, permission, 1, 0)); - PermissionUsedRequest request; - std::vector permissionList; - BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), "", permissionList, request); - OHOS::sptr callback(new TestCallBack()); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, callback)); -} - -/** - * @tc.name: DumpRecordInfo001 - * @tc.desc: cannot DumpRecordInfo with invalid params. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, DumpRecordInfo001, TestSize.Level1) -{ - std::string permission = "ohos.permission.CAMERA"; - - // invalid tokenId - std::string info = PrivacyKit::DumpRecordInfo(123, permission); - ASSERT_EQ(true, info.empty()); - - // invalid permission - info = PrivacyKit::DumpRecordInfo(g_TokenId_A, "invalid permission"); - ASSERT_EQ(true, info.empty()); -} - -/** - * @tc.name: DumpRecordInfo002 - * @tc.desc: cannot DumpRecordInfo with no record. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, DumpRecordInfo002, TestSize.Level1) -{ - std::string permission = "ohos.permission.CAMERA"; - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, permission, 1, 0)); - - std::string info = PrivacyKit::DumpRecordInfo(g_TokenId_A, ""); - ASSERT_EQ(false, info.empty()); - - info = PrivacyKit::DumpRecordInfo(0, permission); - ASSERT_EQ(false, info.empty()); - - info = PrivacyKit::DumpRecordInfo(0, ""); - ASSERT_EQ(false, info.empty()); -} - -/** - * @tc.name: DumpRecordInfo003 - * @tc.desc: cannot DumpRecordInfo with record. - * @tc.type: FUNC - * @tc.require:Issue Number - */ -HWTEST_F(PrivacyKitTest, DumpRecordInfo003, TestSize.Level1) -{ - std::string permission = "ohos.permission.CAMERA"; - - std::string info = PrivacyKit::DumpRecordInfo(g_TokenId_A, ""); - ASSERT_EQ(true, info.empty()); - - info = PrivacyKit::DumpRecordInfo(0, ""); - ASSERT_EQ(true, info.empty()); -} - -class CbCustomizeTest1 : public PermActiveStatusCustomizedCbk { -public: - explicit CbCustomizeTest1(const std::vector &permList) - : PermActiveStatusCustomizedCbk(permList) - { - GTEST_LOG_(INFO) << "CbCustomizeTest1 create"; - } - - ~CbCustomizeTest1() - {} - - virtual void ActiveStatusChangeCallback(ActiveChangeResponse& result) - { - type_ = result.type; - GTEST_LOG_(INFO) << "CbCustomizeTest1 ActiveChangeResponse"; - GTEST_LOG_(INFO) << "CbCustomizeTest1 tokenid " << result.tokenID; - GTEST_LOG_(INFO) << "CbCustomizeTest1 permissionName " << result.permissionName; - GTEST_LOG_(INFO) << "CbCustomizeTest1 deviceId " << result.deviceId; - GTEST_LOG_(INFO) << "CbCustomizeTest1 type " << result.type; - } - - ActiveChangeType type_ = PERM_INACTIVE; -}; - -class CbCustomizeTest2 : public PermActiveStatusCustomizedCbk { -public: - explicit CbCustomizeTest2(const std::vector &permList) - : PermActiveStatusCustomizedCbk(permList) - { - GTEST_LOG_(INFO) << "CbCustomizeTest2 create"; - } - - ~CbCustomizeTest2() - {} - - virtual void ActiveStatusChangeCallback(ActiveChangeResponse& result) - { - type_ = result.type; - GTEST_LOG_(INFO) << "CbCustomizeTest2 ActiveChangeResponse"; - GTEST_LOG_(INFO) << "CbCustomizeTest2 tokenid " << result.tokenID; - GTEST_LOG_(INFO) << "CbCustomizeTest2 permissionName " << result.permissionName; - GTEST_LOG_(INFO) << "CbCustomizeTest2 deviceId " << result.deviceId; - GTEST_LOG_(INFO) << "CbCustomizeTest2 type " << result.type; - } - - ActiveChangeType type_; -}; - -/** - * @tc.name: RegisterPermActiveStatusCallback001 - * @tc.desc: RegisterPermActiveStatusCallback with valid permission. - * @tc.type: FUNC - * @tc.require: issueI5NT1X - */ -HWTEST_F(PrivacyKitTest, RegisterPermActiveStatusCallback001, TestSize.Level1) -{ - std::vector permList = {"ohos.permission.CAMERA"}; - - auto callbackPtr = std::make_shared(permList); - callbackPtr->type_ = PERM_INACTIVE; - - int32_t res = PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr); - - res = PrivacyKit::StartUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); - ASSERT_EQ(RET_NO_ERROR, res); - - usleep(500000); // 500000us = 0.5s - ASSERT_EQ(PERM_ACTIVE_IN_FOREGROUND, callbackPtr->type_); - - res = PrivacyKit::StopUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); - ASSERT_EQ(RET_NO_ERROR, res); - - usleep(500000); // 500000us = 0.5s - ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); - - res = PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr); - ASSERT_EQ(RET_NO_ERROR, res); - callbackPtr->type_ = PERM_INACTIVE; - - res = PrivacyKit::StartUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); - ASSERT_EQ(RET_NO_ERROR, res); - ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); - - res = PrivacyKit::StopUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); - ASSERT_EQ(RET_NO_ERROR, res); - ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); -} - -/** - * @tc.name: RegisterPermActiveStatusCallback002 - * @tc.desc: RegisterPermActiveStatusCallback with valid permission. - * @tc.type: FUNC - * @tc.require: issueI5NT1X - */ - -HWTEST_F(PrivacyKitTest, RegisterPermActiveStatusCallback002, TestSize.Level1) -{ - std::vector permList1 = {"ohos.permission.CAMERA"}; - auto callbackPtr1 = std::make_shared(permList1); - callbackPtr1->type_ = PERM_INACTIVE; - - std::vector permList2 = {"ohos.permission.MICROPHONE"}; - auto callbackPtr2 = std::make_shared(permList2); - callbackPtr2->type_ = PERM_INACTIVE; - - int32_t res = PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr1); - res = PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr2); - - res = PrivacyKit::StartUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); - ASSERT_EQ(RET_NO_ERROR, res); - - usleep(500000); // 500000us = 0.5s - ASSERT_EQ(PERM_ACTIVE_IN_FOREGROUND, callbackPtr1->type_); - ASSERT_EQ(PERM_INACTIVE, callbackPtr2->type_); - - res = PrivacyKit::StopUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); - ASSERT_EQ(RET_NO_ERROR, res); - - usleep(500000); // 500000us = 0.5s - ASSERT_EQ(PERM_INACTIVE, callbackPtr1->type_); - - res = PrivacyKit::StartUsingPermission(g_TokenId_E, "ohos.permission.MICROPHONE"); - ASSERT_EQ(RET_NO_ERROR, res); - - usleep(500000); // 500000us = 0.5s - ASSERT_EQ(PERM_INACTIVE, callbackPtr1->type_); - ASSERT_EQ(PERM_ACTIVE_IN_FOREGROUND, callbackPtr2->type_); - - res = PrivacyKit::StopUsingPermission(g_TokenId_E, "ohos.permission.MICROPHONE"); - ASSERT_EQ(RET_NO_ERROR, res); - - usleep(500000); // 500000us = 0.5s - ASSERT_EQ(PERM_INACTIVE, callbackPtr2->type_); - - res = PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr1); - ASSERT_EQ(RET_NO_ERROR, res); - res = PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr2); - ASSERT_EQ(RET_NO_ERROR, res); -} - -/** - * @tc.name: StartUsingPermission001 - * @tc.desc: StartUsingPermission with invalid tokenId or permission. - * @tc.type: FUNC - * @tc.require: issueI5NT1X - */ -HWTEST_F(PrivacyKitTest, StartUsingPermission001, TestSize.Level1) -{ - std::string permissionName = "ohos.permission.CAMERA"; - int32_t ret = PrivacyKit::StartUsingPermission(0, permissionName); - ASSERT_EQ(RET_ERROR, ret); - - ret = PrivacyKit::StartUsingPermission(0, "permissionName"); - ASSERT_EQ(RET_ERROR, ret); -} - -/** - * @tc.name: StartUsingPermission002 - * @tc.desc: StartUsingPermission is called twice with same permission. - * @tc.type: FUNC - * @tc.require: issueI5NT1X - */ -HWTEST_F(PrivacyKitTest, StartUsingPermission002, TestSize.Level1) -{ - std::string permissionName = "ohos.permission.CAMERA"; - int32_t ret = PrivacyKit::StartUsingPermission(g_TokenId_E, permissionName); - ASSERT_EQ(RET_NO_ERROR, ret); - - ret = PrivacyKit::StartUsingPermission(g_TokenId_E, permissionName); - ASSERT_EQ(RET_ERROR, ret); - - ret = PrivacyKit::StopUsingPermission(g_TokenId_E, permissionName); - ASSERT_EQ(RET_NO_ERROR, ret); -} - - -/** - * @tc.name: StopUsingPermission003 - * @tc.desc: Add record when StopUsingPermission is called. - * @tc.type: FUNC - * @tc.require: issueI5NT1X - */ -HWTEST_F(PrivacyKitTest, StartUsingPermission003, TestSize.Level1) -{ - std::string permissionName = "ohos.permission.CAMERA"; - int32_t ret = PrivacyKit::StartUsingPermission(g_TokenId_E, permissionName); - ASSERT_EQ(RET_NO_ERROR, ret); - - usleep(500000); // 500000us = 0.5s - ret = PrivacyKit::StopUsingPermission(g_TokenId_E, permissionName); - ASSERT_EQ(RET_NO_ERROR, ret); - - PermissionUsedRequest request; - PermissionUsedResult result; - std::vector permissionList; - BuildQueryRequest(g_TokenId_E, GetLocalDeviceUdid(), g_InfoParmsE.bundleName, permissionList, request); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); - ASSERT_EQ(1, result.bundleRecords.size()); - ASSERT_EQ(g_TokenId_E, result.bundleRecords[0].tokenId); - ASSERT_EQ(g_InfoParmsE.bundleName, result.bundleRecords[0].bundleName); - ASSERT_EQ(1, result.bundleRecords[0].permissionRecords.size()); - ASSERT_EQ(1, result.bundleRecords[0].permissionRecords[0].accessCount); -} - -/** - * @tc.name: StopUsingPermission001 - * @tc.desc: StopUsingPermission with invalid tokenId or permission. - * @tc.type: FUNC - * @tc.require: issueI5NT1X - */ -HWTEST_F(PrivacyKitTest, StopUsingPermission001, TestSize.Level1) -{ - std::string permissionName = "ohos.permission.CAMERA"; - int32_t ret = PrivacyKit::StopUsingPermission(0, permissionName); - ASSERT_EQ(RET_ERROR, ret); - - ret = PrivacyKit::StopUsingPermission(0, "permissionName"); - ASSERT_EQ(RET_ERROR, ret); -} \ No newline at end of file +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "privacy_kit_test.h" + +#include "accesstoken_kit.h" +#include "nativetoken_kit.h" +#include "parameter.h" +#include "privacy_kit.h" +#include "token_setproc.h" + +using namespace testing::ext; +using namespace OHOS::Security::AccessToken; + +const static int32_t RET_NO_ERROR = 0; +const static int32_t RET_ERROR = -1; + +static HapPolicyParams g_PolicyPramsA = { + .apl = APL_NORMAL, + .domain = "test.domain.A", +}; + +static HapInfoParams g_InfoParmsA = { + .userID = 1, + .bundleName = "ohos.privacy_test.bundleA", + .instIndex = 0, + .appIDDesc = "privacy_test.bundleA" +}; + +static HapPolicyParams g_PolicyPramsB = { + .apl = APL_NORMAL, + .domain = "test.domain.B", +}; + +static HapInfoParams g_InfoParmsB = { + .userID = 1, + .bundleName = "ohos.privacy_test.bundleB", + .instIndex = 0, + .appIDDesc = "privacy_test.bundleB" +}; + +static PermissionStateFull g_infoManagerTestStateA = { + .permissionName = "ohos.permission.CAMERA", + .grantFlags = {1}, + .grantStatus = {PermissionState::PERMISSION_GRANTED}, + .isGeneral = true, + .resDeviceID = {"local"} +}; + +static PermissionStateFull g_infoManagerTestStateB = { + .permissionName = "ohos.permission.MICROPHONE", + .grantFlags = {1}, + .grantStatus = {PermissionState::PERMISSION_GRANTED}, + .isGeneral = true, + .resDeviceID = {"local"} +}; +static HapPolicyParams g_PolicyPramsE = { + .apl = APL_NORMAL, + .domain = "test.domain", + .permList = {}, + .permStateList = {g_infoManagerTestStateA, g_infoManagerTestStateB} +}; +static HapInfoParams g_InfoParmsE = { + .userID = 1, + .bundleName = "ohos.privacy_test.bundleE", + .instIndex = 0, + .appIDDesc = "privacy_test.bundleE" +}; + +static AccessTokenID g_selfTokenId = 0; +static AccessTokenID g_TokenId_A = 0; +static AccessTokenID g_TokenId_B = 0; +static AccessTokenID g_TokenId_E = 0; + +void PrivacyKitTest::SetUpTestCase() +{ + g_selfTokenId = GetSelfTokenID(); +} + +void PrivacyKitTest::TearDownTestCase() +{ +} + +void PrivacyKitTest::SetUp() +{ + AccessTokenKit::AllocHapToken(g_InfoParmsA, g_PolicyPramsA); + AccessTokenKit::AllocHapToken(g_InfoParmsB, g_PolicyPramsB); + AccessTokenKit::AllocHapToken(g_InfoParmsE, g_PolicyPramsE); + + g_TokenId_A = AccessTokenKit::GetHapTokenID(g_InfoParmsA.userID, + g_InfoParmsA.bundleName, + g_InfoParmsA.instIndex); + g_TokenId_B = AccessTokenKit::GetHapTokenID(g_InfoParmsB.userID, + g_InfoParmsB.bundleName, + g_InfoParmsB.instIndex); + g_TokenId_E = AccessTokenKit::GetHapTokenID(g_InfoParmsE.userID, + g_InfoParmsE.bundleName, + g_InfoParmsE.instIndex); + + AccessTokenID tokenId = AccessTokenKit::GetHapTokenID(100, "com.ohos.permissionmanager", 0); // 100 is userID + SetSelfTokenID(tokenId); +} + +void PrivacyKitTest::TearDown() +{ + SetSelfTokenID(g_selfTokenId); + AccessTokenID tokenId = AccessTokenKit::GetHapTokenID(g_InfoParmsA.userID, + g_InfoParmsA.bundleName, + g_InfoParmsA.instIndex); + AccessTokenKit::DeleteToken(tokenId); + + tokenId = AccessTokenKit::GetHapTokenID(g_InfoParmsB.userID, + g_InfoParmsB.bundleName, + g_InfoParmsB.instIndex); + AccessTokenKit::DeleteToken(tokenId); + + tokenId = AccessTokenKit::GetHapTokenID(g_InfoParmsE.userID, + g_InfoParmsE.bundleName, + g_InfoParmsE.instIndex); + AccessTokenKit::DeleteToken(tokenId); +} + +std::string PrivacyKitTest::GetLocalDeviceUdid() +{ + const int32_t DEVICE_UUID_LENGTH = 65; + char udid[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(udid, DEVICE_UUID_LENGTH); + return udid; +} + +void PrivacyKitTest::BuildQueryRequest(AccessTokenID tokenId, const std::string deviceId, const std::string& bundleName, + const std::vector permissionList, PermissionUsedRequest& request) +{ + request.tokenId = tokenId; + request.isRemote = false; + request.deviceId = deviceId; + request.bundleName = bundleName; + request.permissionList = permissionList; + request.beginTimeMillis = 0; + request.endTimeMillis = 0; + request.flag = FLAG_PERMISSION_USAGE_SUMMARY; +} + +void PrivacyKitTest::CheckPermissionUsedResult(const PermissionUsedRequest& request, const PermissionUsedResult& result, + int32_t permRecordSize, int32_t totalSuccessCount, int32_t totalFailCount) +{ + int32_t successCount = 0; + int32_t failCount = 0; + ASSERT_EQ(request.tokenId, result.bundleRecords[0].tokenId); + ASSERT_EQ(request.isRemote, result.bundleRecords[0].isRemote); + ASSERT_EQ(request.deviceId, result.bundleRecords[0].deviceId); + ASSERT_EQ(request.bundleName, result.bundleRecords[0].bundleName); + ASSERT_EQ(permRecordSize, result.bundleRecords[0].permissionRecords.size()); + for (int32_t i = 0; i < permRecordSize; i++) { + successCount += result.bundleRecords[0].permissionRecords[i].accessCount; + failCount += result.bundleRecords[0].permissionRecords[i].rejectCount; + } + ASSERT_EQ(totalSuccessCount, successCount); + ASSERT_EQ(totalFailCount, failCount); +} + +static void SetTokenID(std::vector& g_InfoParms_List, + std::vector& g_TokenId_List, int32_t number) +{ + SetSelfTokenID(g_selfTokenId); + for (int32_t i = 0; i < number; i++) { + HapInfoParams g_InfoParmsTmp = { + .userID = i, + .bundleName = "ohos.privacy_test.bundle" + std::to_string(i), + .instIndex = i, + .appIDDesc = "privacy_test.bundle" + std::to_string(i) + }; + g_InfoParms_List.push_back(g_InfoParmsTmp); + HapPolicyParams g_PolicyPramsTmp = { + .apl = APL_NORMAL, + .domain = "test.domain." + std::to_string(i) + }; + AccessTokenKit::AllocHapToken(g_InfoParmsTmp, g_PolicyPramsTmp); + AccessTokenID g_TokenId_Tmp = AccessTokenKit::GetHapTokenID(g_InfoParmsTmp.userID, + g_InfoParmsTmp.bundleName, + g_InfoParmsTmp.instIndex); + g_TokenId_List.push_back(g_TokenId_Tmp); + } + AccessTokenID tokenId = AccessTokenKit::GetHapTokenID(100, "com.ohos.permissionmanager", 0); + SetSelfTokenID(tokenId); +} + +static void DeleteTokenID(std::vector& g_InfoParms_List) +{ + SetSelfTokenID(g_selfTokenId); + for (size_t i = 0; i < g_InfoParms_List.size(); i++) { + AccessTokenID g_TokenId_Tmp = AccessTokenKit::GetHapTokenID(g_InfoParms_List[i].userID, + g_InfoParms_List[i].bundleName, + g_InfoParms_List[i].instIndex); + AccessTokenKit::DeleteToken(g_TokenId_Tmp); + } + AccessTokenID tokenId = AccessTokenKit::GetHapTokenID(100, "com.ohos.permissionmanager", 0); + SetSelfTokenID(tokenId); +} + +/** + * @tc.name: AddPermissionUsedRecord001 + * @tc.desc: cannot AddPermissionUsedRecord with illegal tokenId and permission. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord001, TestSize.Level1) +{ + ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord( + 0, "ohos.permission.READ_CONTACTS", 1, 0)); + ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "", 1, 0)); + ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord( + g_TokenId_A, "ohos.permission.READ_CONTACTS", -1, 0)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(0, result.bundleRecords.size()); +} + +/** + * @tc.name: AddPermissionUsedRecord002 + * @tc.desc: cannot AddPermissionUsedRecord with invalid tokenId and permission. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord002, TestSize.Level1) +{ + ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.test", 1, 0)); + ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord(123, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.READ_CONTACTS", 0, 0)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(123, "", "", permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(0, result.bundleRecords.size()); + + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(0, result.bundleRecords.size()); +} + +/** + * @tc.name: AddPermissionUsedRecord003 + * @tc.desc: cannot AddPermissionUsedRecord with native tokenId. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord003, TestSize.Level1) +{ + const char **dcaps = new const char *[2]; + dcaps[0] = "AT_CAP"; + dcaps[1] = "ST_CAP"; + uint64_t tokenId; + const char **acls = new const char *[2]; + acls[0] = "ohos.permission.test1"; + acls[1] = "ohos.permission.test2"; + const char **perms = new const char *[2]; + perms[0] = "ohos.permission.test1"; + perms[1] = "ohos.permission.test2"; + NativeTokenInfoParams infoInstance = { + .dcapsNum = 2, + .permsNum = 2, + .aclsNum = 2, + .dcaps = dcaps, + .perms = perms, + .acls = acls, + .processName = "GetAccessTokenId008", + .aplStr = "system_core", + }; + tokenId = GetAccessTokenId(&infoInstance); + ASSERT_NE(tokenId, 0); + + delete[] perms; + delete[] dcaps; + delete[] acls; + + ASSERT_EQ(RET_ERROR, PrivacyKit::AddPermissionUsedRecord( + tokenId, "ohos.permission.READ_CONTACTS", 1, 0)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(tokenId, "", "", permissionList, request); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(0, result.bundleRecords.size()); +} + +/** + * @tc.name: AddPermissionUsedRecord004 + * @tc.desc: AddPermissionUsedRecord user_grant permission. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord004, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.WRITE_CONTACTS", 0, 1)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.LOCATION", 1, 1)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + + ASSERT_EQ(1, result.bundleRecords.size()); + CheckPermissionUsedResult(request, result, 3, 2, 2); +} + +/** + * @tc.name: AddPermissionUsedRecord005 + * @tc.desc: AddPermissionUsedRecord user_grant permission. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord005, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.LOCATION", 0, 1)); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_B, "ohos.permission.CAMERA", 0, 1)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_B, "ohos.permission.LOCATION", 1, 0)); + + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + + ASSERT_EQ(1, result.bundleRecords.size()); + CheckPermissionUsedResult(request, result, 2, 1, 1); + + BuildQueryRequest(g_TokenId_B, GetLocalDeviceUdid(), g_InfoParmsB.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + + ASSERT_EQ(1, result.bundleRecords.size()); + CheckPermissionUsedResult(request, result, 2, 1, 1); +} + +/** + * @tc.name: AddPermissionUsedRecord006 + * @tc.desc: AddPermissionUsedRecord permission combine records. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord006, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + request.flag = FLAG_PERMISSION_USAGE_DETAIL; + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + + ASSERT_EQ(1, result.bundleRecords.size()); + ASSERT_EQ(1, result.bundleRecords[0].permissionRecords.size()); + ASSERT_EQ(1, result.bundleRecords[0].permissionRecords[0].accessRecords.size()); + CheckPermissionUsedResult(request, result, 1, 4, 0); + + sleep(61); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(1, result.bundleRecords.size()); + ASSERT_EQ(1, result.bundleRecords[0].permissionRecords.size()); + ASSERT_EQ(2, result.bundleRecords[0].permissionRecords[0].accessRecords.size()); + CheckPermissionUsedResult(request, result, 1, 5, 0); +} + +/** + * @tc.name: AddPermissionUsedRecord007 + * @tc.desc: AddPermissionUsedRecord user_grant permission. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, AddPermissionUsedRecord007, TestSize.Level1) +{ + std::vector g_InfoParms_List; + std::vector g_TokenId_List; + SetTokenID(g_InfoParms_List, g_TokenId_List, 100); + std::vector addPermissionList = { + "ohos.permission.ANSWER_CALL", + "ohos.permission.READ_CALENDAR", + }; + for (int32_t i = 0; i < 200; i++) { + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_List[i % 100], + addPermissionList[i % 2], 1, 0)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_List[i % 100], GetLocalDeviceUdid(), + g_InfoParms_List[i % 100].bundleName, permissionList, request); + request.flag = FLAG_PERMISSION_USAGE_DETAIL; + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + } + sleep(70); + for (int32_t i = 0; i < 100; i++) { + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_List[i], GetLocalDeviceUdid(), + g_InfoParms_List[i].bundleName, permissionList, request); + request.flag = FLAG_PERMISSION_USAGE_DETAIL; + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(1, result.bundleRecords.size()); + ASSERT_EQ(1, result.bundleRecords[0].permissionRecords.size()); + ASSERT_EQ(1, result.bundleRecords[0].permissionRecords[0].accessRecords.size()); + CheckPermissionUsedResult(request, result, 1, 2, 0); + } + DeleteTokenID(g_InfoParms_List); +} + +/** + * @tc.name: RemovePermissionUsedRecords001 + * @tc.desc: cannot RemovePermissionUsedRecords with illegal tokenId and deviceID. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, RemovePermissionUsedRecords001, TestSize.Level1) +{ + ASSERT_EQ(RET_ERROR, PrivacyKit::RemovePermissionUsedRecords(0, "")); +} + +/** + * @tc.name: RemovePermissionUsedRecords002 + * @tc.desc: RemovePermissionUsedRecords with invalid tokenId and deviceID. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, RemovePermissionUsedRecords002, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RemovePermissionUsedRecords(g_TokenId_A, "invalid_device")); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(1, result.bundleRecords.size()); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RemovePermissionUsedRecords(123, GetLocalDeviceUdid())); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(1, result.bundleRecords.size()); +} + +/** + * @tc.name: RemovePermissionUsedRecords003 + * @tc.desc: RemovePermissionUsedRecords with valid tokenId and deviceID. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, RemovePermissionUsedRecords003, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RemovePermissionUsedRecords(g_TokenId_A, "")); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(0, result.bundleRecords.size()); +} + +/** + * @tc.name: GetPermissionUsedRecords001 + * @tc.desc: cannot GetPermissionUsedRecords with invalid query time. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, GetPermissionUsedRecords001, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + request.beginTimeMillis = -1; + request.endTimeMillis = -1; + ASSERT_EQ(RET_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + + request.beginTimeMillis = 3; + request.endTimeMillis = 1; + ASSERT_EQ(RET_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + + request.flag = (PermissionUsageFlag)-1; + ASSERT_EQ(RET_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); +} + +/** + * @tc.name: GetPermissionUsedRecords002 + * @tc.desc: cannot GetPermissionUsedRecords with valid query time. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, GetPermissionUsedRecords002, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.READ_CALENDAR", 1, 0)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + // query by tokenId + BuildQueryRequest(g_TokenId_A, "", "", permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(1, result.bundleRecords.size()); + request.deviceId = GetLocalDeviceUdid(); + request.bundleName = g_InfoParmsA.bundleName; + CheckPermissionUsedResult(request, result, 3, 3, 0); + + // query by unmatched tokenId, deviceId and bundle Name + BuildQueryRequest(123, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(0, result.bundleRecords.size()); + + // query by invalid permission Name + permissionList.clear(); + permissionList.emplace_back("invalid permission"); + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(0, result.bundleRecords.size()); +} + +/** + * @tc.name: GetPermissionUsedRecords003 + * @tc.desc: can GetPermissionUsedRecords with valid query time. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, GetPermissionUsedRecords003, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.MICROPHONE", 1, 0)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(1, result.bundleRecords.size()); + CheckPermissionUsedResult(request, result, 1, 4, 0); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.READ_CALENDAR", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.WRITE_CALENDAR", 1, 0)); + + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), g_InfoParmsA.bundleName, permissionList, request); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + ASSERT_EQ(1, result.bundleRecords.size()); + CheckPermissionUsedResult(request, result, 4, 7, 0); +} + +/** + * @tc.name: GetPermissionUsedRecords004 + * @tc.desc: can GetPermissionUsedRecords with valid query time. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, GetPermissionUsedRecords004, TestSize.Level1) +{ + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, "ohos.permission.READ_CALENDAR", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_B, "ohos.permission.CAMERA", 1, 0)); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_B, "ohos.permission.READ_CALENDAR", 1, 0)); + + PermissionUsedRequest request; + PermissionUsedResult result; + std::vector permissionList; + BuildQueryRequest(0, GetLocalDeviceUdid(), "", permissionList, request); + + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, result)); + if (result.bundleRecords.size() < 2) { + ASSERT_EQ(RET_NO_ERROR, RET_ERROR); + } +} + +/** + * @tc.name: GetPermissionUsedRecordsAsync001 + * @tc.desc: cannot GetPermissionUsedRecordsAsync with invalid query time. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, GetPermissionUsedRecordsAsync001, TestSize.Level1) +{ + std::string permission = "ohos.permission.CAMERA"; + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, permission, 1, 0)); + PermissionUsedRequest request; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), "", permissionList, request); + request.beginTimeMillis = -1; + request.endTimeMillis = -1; + OHOS::sptr callback(new TestCallBack()); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, callback)); +} + +/** + * @tc.name: GetPermissionUsedRecordsAsync002 + * @tc.desc: cannot GetPermissionUsedRecordsAsync with valid query time. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, GetPermissionUsedRecordsAsync002, TestSize.Level1) +{ + std::string permission = "ohos.permission.CAMERA"; + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, permission, 1, 0)); + PermissionUsedRequest request; + std::vector permissionList; + BuildQueryRequest(g_TokenId_A, GetLocalDeviceUdid(), "", permissionList, request); + OHOS::sptr callback(new TestCallBack()); + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::GetPermissionUsedRecords(request, callback)); +} + +/** + * @tc.name: DumpRecordInfo001 + * @tc.desc: cannot DumpRecordInfo with invalid params. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, DumpRecordInfo001, TestSize.Level1) +{ + std::string permission = "ohos.permission.CAMERA"; + + // invalid tokenId + std::string info = PrivacyKit::DumpRecordInfo(123, permission); + ASSERT_EQ(true, info.empty()); + + // invalid permission + info = PrivacyKit::DumpRecordInfo(g_TokenId_A, "invalid permission"); + ASSERT_EQ(true, info.empty()); +} + +/** + * @tc.name: DumpRecordInfo002 + * @tc.desc: cannot DumpRecordInfo with no record. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, DumpRecordInfo002, TestSize.Level1) +{ + std::string permission = "ohos.permission.CAMERA"; + ASSERT_EQ(RET_NO_ERROR, PrivacyKit::AddPermissionUsedRecord(g_TokenId_A, permission, 1, 0)); + + std::string info = PrivacyKit::DumpRecordInfo(g_TokenId_A, ""); + ASSERT_EQ(false, info.empty()); + + info = PrivacyKit::DumpRecordInfo(0, permission); + ASSERT_EQ(false, info.empty()); + + info = PrivacyKit::DumpRecordInfo(0, ""); + ASSERT_EQ(false, info.empty()); +} + +/** + * @tc.name: DumpRecordInfo003 + * @tc.desc: cannot DumpRecordInfo with record. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, DumpRecordInfo003, TestSize.Level1) +{ + std::string permission = "ohos.permission.CAMERA"; + + std::string info = PrivacyKit::DumpRecordInfo(g_TokenId_A, ""); + ASSERT_EQ(true, info.empty()); + + info = PrivacyKit::DumpRecordInfo(0, ""); + ASSERT_EQ(true, info.empty()); +} + + +HWTEST_F(PrivacyKitTest, IsAllowUsingPermission001, TestSize.Level1) +{ + std::string permission = "ohos.permission.CAMERA"; + // invalid tokenId + bool info = PrivacyKit::IsAllowUsingPermission(123, "ohos.permission.CAMERA"); + ASSERT_EQ(false, info); + + // invalid permission + info = PrivacyKit::IsAllowUsingPermission(g_TokenId_A, "invalid permission"); + ASSERT_EQ(false, info); +} + + +class CbCustomizeTest1 : public PermActiveStatusCustomizedCbk { +public: + explicit CbCustomizeTest1(const std::vector &permList) + : PermActiveStatusCustomizedCbk(permList) + { + GTEST_LOG_(INFO) << "CbCustomizeTest1 create"; + } + + ~CbCustomizeTest1() + {} + + virtual void ActiveStatusChangeCallback(ActiveChangeResponse& result) + { + type_ = result.type; + GTEST_LOG_(INFO) << "CbCustomizeTest1 ActiveChangeResponse"; + GTEST_LOG_(INFO) << "CbCustomizeTest1 tokenid " << result.tokenID; + GTEST_LOG_(INFO) << "CbCustomizeTest1 permissionName " << result.permissionName; + GTEST_LOG_(INFO) << "CbCustomizeTest1 deviceId " << result.deviceId; + GTEST_LOG_(INFO) << "CbCustomizeTest1 type " << result.type; + } + + ActiveChangeType type_ = PERM_INACTIVE; +}; + +class CbCustomizeTest2 : public PermActiveStatusCustomizedCbk { +public: + explicit CbCustomizeTest2(const std::vector &permList) + : PermActiveStatusCustomizedCbk(permList) + { + GTEST_LOG_(INFO) << "CbCustomizeTest2 create"; + } + + ~CbCustomizeTest2() + {} + + virtual void ActiveStatusChangeCallback(ActiveChangeResponse& result) + { + type_ = result.type; + GTEST_LOG_(INFO) << "CbCustomizeTest2 ActiveChangeResponse"; + GTEST_LOG_(INFO) << "CbCustomizeTest2 tokenid " << result.tokenID; + GTEST_LOG_(INFO) << "CbCustomizeTest2 permissionName " << result.permissionName; + GTEST_LOG_(INFO) << "CbCustomizeTest2 deviceId " << result.deviceId; + GTEST_LOG_(INFO) << "CbCustomizeTest2 type " << result.type; + } + + ActiveChangeType type_; +}; + +/** + * @tc.name: RegisterPermActiveStatusCallback001 + * @tc.desc: RegisterPermActiveStatusCallback with valid permission. + * @tc.type: FUNC + * @tc.require:Issue Number + */ +HWTEST_F(PrivacyKitTest, RegisterPermActiveStatusCallback001, TestSize.Level1) +{ + std::vector permList = {"ohos.permission.CAMERA"}; + + auto callbackPtr = std::make_shared(permList); + callbackPtr->type_ = PERM_INACTIVE; + + int32_t res = PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr); + + res = PrivacyKit::StartUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); + ASSERT_EQ(RET_NO_ERROR, res); + + usleep(500000); // 500000us = 0.5s + ASSERT_EQ(PERM_ACTIVE_IN_FOREGROUND, callbackPtr->type_); + + res = PrivacyKit::StopUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); + ASSERT_EQ(RET_NO_ERROR, res); + + usleep(500000); // 500000us = 0.5s + ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); + + res = PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr); + ASSERT_EQ(RET_NO_ERROR, res); + callbackPtr->type_ = PERM_INACTIVE; + + res = PrivacyKit::StartUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); + ASSERT_EQ(RET_NO_ERROR, res); + ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); + + res = PrivacyKit::StopUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); + ASSERT_EQ(RET_NO_ERROR, res); + ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); +} + +/** + * @tc.name: RegisterPermActiveStatusCallback002 + * @tc.desc: RegisterPermActiveStatusCallback with valid permission. + * @tc.type: FUNC + * @tc.require:Issue Number + */ + +HWTEST_F(PrivacyKitTest, RegisterPermActiveStatusCallback002, TestSize.Level1) +{ + std::vector permList1 = {"ohos.permission.CAMERA"}; + auto callbackPtr1 = std::make_shared(permList1); + callbackPtr1->type_ = PERM_INACTIVE; + + std::vector permList2 = {"ohos.permission.MICROPHONE"}; + auto callbackPtr2 = std::make_shared(permList2); + callbackPtr2->type_ = PERM_INACTIVE; + + int32_t res = PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr1); + res = PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr2); + + res = PrivacyKit::StartUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); + ASSERT_EQ(RET_NO_ERROR, res); + + usleep(500000); // 500000us = 0.5s + ASSERT_EQ(PERM_ACTIVE_IN_FOREGROUND, callbackPtr1->type_); + ASSERT_EQ(PERM_INACTIVE, callbackPtr2->type_); + + res = PrivacyKit::StopUsingPermission(g_TokenId_E, "ohos.permission.CAMERA"); + ASSERT_EQ(RET_NO_ERROR, res); + + usleep(500000); // 500000us = 0.5s + ASSERT_EQ(PERM_INACTIVE, callbackPtr1->type_); + + res = PrivacyKit::StartUsingPermission(g_TokenId_E, "ohos.permission.MICROPHONE"); + ASSERT_EQ(RET_NO_ERROR, res); + + usleep(500000); // 500000us = 0.5s + ASSERT_EQ(PERM_INACTIVE, callbackPtr1->type_); + ASSERT_EQ(PERM_ACTIVE_IN_FOREGROUND, callbackPtr2->type_); + + res = PrivacyKit::StopUsingPermission(g_TokenId_E, "ohos.permission.MICROPHONE"); + ASSERT_EQ(RET_NO_ERROR, res); + + usleep(500000); // 500000us = 0.5s + ASSERT_EQ(PERM_INACTIVE, callbackPtr2->type_); + + res = PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr1); + ASSERT_EQ(RET_NO_ERROR, res); + res = PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr2); + ASSERT_EQ(RET_NO_ERROR, res); +} + +/** + * @tc.name: IsAllowUsingPermission001 + * @tc.desc: IsAllowUsingPermission with valid permission. + * @tc.type: FUNC + * @tc.require:Issue Number + */ + diff --git a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.h b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.h index 03729b70806778f17b3b573a97043b02ef7747a6..9e66e0176faa9d5ec3c9c1e64c4ebf2199a94fed 100644 --- a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.h +++ b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.h @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PRIVACY_KIT_TEST_H -#define PRIVACY_KIT_TEST_H - -#include -#include - -#include "on_permission_used_record_callback_stub.h" -#include "permission_used_request.h" -#include "permission_used_result.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyKitTest : public testing::Test { -public: - static void SetUpTestCase(); - - static void TearDownTestCase(); - - void SetUp(); - - void TearDown(); - - class TestCallBack : public OnPermissionUsedRecordCallbackStub { - public: - TestCallBack() = default; - virtual ~TestCallBack() = default; - - void OnQueried(ErrCode code, PermissionUsedResult& result) - { - GTEST_LOG_(INFO) << "TestCallBack, code :" << code << ", bundleSize :" << result.bundleRecords.size(); - } - }; - std::string GetLocalDeviceUdid(); - void BuildQueryRequest(AccessTokenID tokenId, const std::string deviceId, const std::string& bundleName, - const std::vector permissionList, PermissionUsedRequest& request); - void CheckPermissionUsedResult(const PermissionUsedRequest& request, const PermissionUsedResult& result, - int32_t permRecordSize, int32_t totalSuccessCount, int32_t totalFailCount); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PRIVACY_KIT_TEST_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PRIVACY_KIT_TEST_H +#define PRIVACY_KIT_TEST_H + +#include +#include + +#include "on_permission_used_record_callback_stub.h" +#include "permission_used_request.h" +#include "permission_used_result.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PrivacyKitTest : public testing::Test { +public: + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp(); + + void TearDown(); + + class TestCallBack : public OnPermissionUsedRecordCallbackStub { + public: + TestCallBack() = default; + virtual ~TestCallBack() = default; + + void OnQueried(ErrCode code, PermissionUsedResult& result) + { + GTEST_LOG_(INFO) << "TestCallBack, code :" << code << ", bundleSize :" << result.bundleRecords.size(); + } + }; + std::string GetLocalDeviceUdid(); + void BuildQueryRequest(AccessTokenID tokenId, const std::string deviceId, const std::string& bundleName, + const std::vector permissionList, PermissionUsedRequest& request); + void CheckPermissionUsedResult(const PermissionUsedRequest& request, const PermissionUsedResult& result, + int32_t permRecordSize, int32_t totalSuccessCount, int32_t totalFailCount); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PRIVACY_KIT_TEST_H diff --git a/services/privacymanager/BUILD.gn b/services/privacymanager/BUILD.gn index f2278527d971c6daf553263c30778f7709da143d..f7e6378a5d31adc24469ff1de03433306203d847 100644 --- a/services/privacymanager/BUILD.gn +++ b/services/privacymanager/BUILD.gn @@ -1,80 +1,82 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -ohos_prebuilt_etc("privacy.rc") { - source = "privacy.cfg" - relative_install_dir = "init" - subsystem_name = "security" - part_name = "access_token" -} - -if (is_standard_system) { - ohos_shared_library("privacy_manager_service") { - subsystem_name = "security" - part_name = "access_token" - - include_dirs = [ - "include/active", - "include/common", - "include/database", - "include/record", - "include/service", - "//base/security/access_token/frameworks/privacy/include", - "//base/security/access_token/frameworks/common/include", - "//base/security/access_token/interfaces/innerkits/accesstoken/include", - "//base/security/access_token/interfaces/innerkits/privacy/include", - "//base/security/access_token/services/common/database/include", - "//third_party/json/include", - "//third_party/sqlite/include/", - ] - - sources = [ - "src/active/active_status_callback_manager.cpp", - "src/active/perm_active_status_callback_death_recipient.cpp", - "src/active/perm_active_status_change_callback_proxy.cpp", - "src/common/constant.cpp", - "src/common/time_util.cpp", - "src/common/to_string.cpp", - "src/database/data_translator.cpp", - "src/database/permission_used_record_db.cpp", - "src/record/on_permission_used_record_callback_proxy.cpp", - "src/record/on_permission_used_record_callback_stub.cpp", - "src/record/permission_record.cpp", - "src/record/permission_record_manager.cpp", - "src/record/permission_record_repository.cpp", - "src/record/permission_used_record_cache.cpp", - "src/service/privacy_manager_service.cpp", - "src/service/privacy_manager_stub.cpp", - ] - - cflags_cc = [ "-DHILOG_ENABLE" ] - - deps = [ - "//base/security/access_token/frameworks/common:accesstoken_common_cxx", - "//base/security/access_token/frameworks/privacy:privacy_communication_adapter_cxx", - "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk", - "//base/security/access_token/services/common/database:accesstoken_database_cxx", - "//base/security/access_token/services/privacymanager:privacy.rc", - ] - - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] - } -} +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +ohos_prebuilt_etc("privacy.rc") { + source = "privacy.cfg" + relative_install_dir = "init" + subsystem_name = "security" + part_name = "access_token" +} + +if (is_standard_system) { + ohos_shared_library("privacy_manager_service") { + subsystem_name = "security" + part_name = "access_token" + + include_dirs = [ + "include/active", + "include/common", + "include/database", + "include/record", + "include/service", + "//base/security/access_token/frameworks/privacy/include", + "//base/security/access_token/frameworks/common/include", + "//base/security/access_token/interfaces/innerkits/accesstoken/include", + "//base/security/access_token/interfaces/innerkits/privacy/include", + "//base/security/access_token/services/common/database/include", + "//third_party/json/include", + ] + + sources = [ + "src/active/active_status_callback_manager.cpp", + "src/active/perm_active_status_callback_death_recipient.cpp", + "src/active/perm_active_status_change_callback_proxy.cpp", + "src/common/constant.cpp", + "src/common/time_util.cpp", + "src/common/to_string.cpp", + "src/database/data_translator.cpp", + "src/database/permission_used_record_db.cpp", + "src/record/on_permission_used_record_callback_proxy.cpp", + "src/record/on_permission_used_record_callback_stub.cpp", + "src/record/permission_record.cpp", + "src/record/permission_record_manager.cpp", + "src/record/permission_record_repository.cpp", + "src/record/permission_used_record_cache.cpp", + "src/service/privacy_manager_service.cpp", + "src/service/privacy_manager_stub.cpp", + ] + + cflags_cc = [ "-DHILOG_ENABLE" ] + + deps = [ + "//base/security/access_token/frameworks/common:accesstoken_common_cxx", + "//base/security/access_token/frameworks/privacy:privacy_communication_adapter_cxx", + "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk", + "//base/security/access_token/services/common/database:accesstoken_database_cxx", + "//base/security/access_token/services/privacymanager:privacy.rc", + "//third_party/sqlite:sqlite", + "//utils/native/base:utils", + ] + + external_deps = [ + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "init:libbegetutil", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + } +} diff --git a/services/privacymanager/include/active/active_status_callback_manager.h b/services/privacymanager/include/active/active_status_callback_manager.h index df6d801ae67a1b9e5c5f3488715a66fe9a9b06bd..fd7caa5a0fefd8c1470bb36b5428b2ff6735dd58 100644 --- a/services/privacymanager/include/active/active_status_callback_manager.h +++ b/services/privacymanager/include/active/active_status_callback_manager.h @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACTIVE_STATUS_CHANGE_CALLBACK_MANAGER_H -#define ACTIVE_STATUS_CHANGE_CALLBACK_MANAGER_H - -#include -#include - -#include "access_token.h" -#include "accesstoken_log.h" -#include "perm_active_status_callback_death_recipient.h" -#include "perm_active_status_change_callback_proxy.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct CallbackData { - CallbackData() : permList_(), callbackObject_(nullptr) - {} - CallbackData(const std::vector& permList, sptr callback) - : permList_(permList), callbackObject_(callback) - {} - - std::vector permList_; - sptr callbackObject_; -}; - -class ActiveStatusCallbackManager { -public: - virtual ~ActiveStatusCallbackManager(); - ActiveStatusCallbackManager(); - static ActiveStatusCallbackManager& GetInstance(); - - int32_t AddCallback( - const std::vector& permList, const sptr& callback); - int32_t RemoveCallback(const sptr& callback); - bool NeedCalled(const std::vector& permList, const std::string& permName); - void ExecuteCallbackAsync( - AccessTokenID tokenId, const std::string& permName, const std::string& deviceId, ActiveChangeType changeType); - -private: - std::mutex mutex_; - std::vector callbackDataList_; - sptr callbackDeathRecipient_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // ACTIVE_STATUS_CHANGE_CALLBACK_MANAGER_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ACTIVE_STATUS_CHANGE_CALLBACK_MANAGER_H +#define ACTIVE_STATUS_CHANGE_CALLBACK_MANAGER_H + +#include +#include + +#include "access_token.h" +#include "accesstoken_log.h" +#include "perm_active_status_callback_death_recipient.h" +#include "perm_active_status_change_callback_proxy.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct CallbackData { + CallbackData() : permList_(), callbackObject_(nullptr) + {} + CallbackData(const std::vector& permList, sptr callback) + : permList_(permList), callbackObject_(callback) + {} + + std::vector permList_; + sptr callbackObject_; +}; + +class ActiveStatusCallbackManager { +public: + virtual ~ActiveStatusCallbackManager(); + ActiveStatusCallbackManager(); + static ActiveStatusCallbackManager& GetInstance(); + + int32_t AddCallback( + const std::vector& permList, const sptr& callback); + int32_t RemoveCallback(const sptr& callback); + bool NeedCalled(const std::vector& permList, const std::string& permName); + void ExecuteCallbackAsync( + AccessTokenID tokenId, const std::string& permName, const std::string& deviceId, ActiveChangeType changeType); + +private: + std::mutex mutex_; + std::vector callbackDataList_; + sptr callbackDeathRecipient_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // ACTIVE_STATUS_CHANGE_CALLBACK_MANAGER_H diff --git a/services/privacymanager/include/active/perm_active_status_callback_death_recipient.h b/services/privacymanager/include/active/perm_active_status_callback_death_recipient.h index c69e05e3e5ecfab5a4f746c7bcb1567b40285abb..fb49b6ff02d69710870e76ac315adff877e55e04 100644 --- a/services/privacymanager/include/active/perm_active_status_callback_death_recipient.h +++ b/services/privacymanager/include/active/perm_active_status_callback_death_recipient.h @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERM_ACTIVE_STATUS_CALLBACK_DEATH_RECIPIENT_H -#define PERM_ACTIVE_STATUS_CALLBACK_DEATH_RECIPIENT_H - - -#include "iremote_object.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PermActiveStatusCallbackDeathRecipient : public IRemoteObject::DeathRecipient { -public: - PermActiveStatusCallbackDeathRecipient() = default; - virtual ~PermActiveStatusCallbackDeathRecipient() = default; - - virtual void OnRemoteDied(const wptr &remote); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERM_ACTIVE_STATUS_CALLBACK_DEATH_RECIPIENT_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERM_ACTIVE_STATUS_CALLBACK_DEATH_RECIPIENT_H +#define PERM_ACTIVE_STATUS_CALLBACK_DEATH_RECIPIENT_H + + +#include "iremote_object.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermActiveStatusCallbackDeathRecipient : public IRemoteObject::DeathRecipient { +public: + PermActiveStatusCallbackDeathRecipient() = default; + virtual ~PermActiveStatusCallbackDeathRecipient() = default; + + virtual void OnRemoteDied(const wptr &remote); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERM_ACTIVE_STATUS_CALLBACK_DEATH_RECIPIENT_H diff --git a/services/privacymanager/include/active/perm_active_status_change_callback_proxy.h b/services/privacymanager/include/active/perm_active_status_change_callback_proxy.h index db358c94be9367bd3cf740bfb01c501d861ce4d1..97a60376ad820ef8aedee4eba502cb2207c9aa51 100644 --- a/services/privacymanager/include/active/perm_active_status_change_callback_proxy.h +++ b/services/privacymanager/include/active/perm_active_status_change_callback_proxy.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H -#define PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H - - -#include "i_perm_active_status_callback.h" - -#include "iremote_proxy.h" -#include "nocopyable.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PermActiveStatusChangeCallbackProxy : public IRemoteProxy { -public: - explicit PermActiveStatusChangeCallbackProxy(const sptr& impl); - ~PermActiveStatusChangeCallbackProxy() override; - - virtual void ActiveStatusChangeCallback(ActiveChangeResponse& result) override; -private: - static inline BrokerDelegator delegator_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H +#define PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H + + +#include "i_perm_active_status_callback.h" + +#include "iremote_proxy.h" +#include "nocopyable.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermActiveStatusChangeCallbackProxy : public IRemoteProxy { +public: + explicit PermActiveStatusChangeCallbackProxy(const sptr& impl); + ~PermActiveStatusChangeCallbackProxy() override; + + virtual void ActiveStatusChangeCallback(ActiveChangeResponse& result) override; +private: + static inline BrokerDelegator delegator_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H diff --git a/services/privacymanager/include/common/constant.h b/services/privacymanager/include/common/constant.h index 6e3602ac6997e3bb12487543d7179de4991567ad..8b061eff5fc94eba971a5e4fbb1ce61a361f3f4e 100644 --- a/services/privacymanager/include/common/constant.h +++ b/services/privacymanager/include/common/constant.h @@ -1,75 +1,76 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CONSTANT_H -#define CONSTANT_H - -#include -#include - -namespace OHOS { -namespace Security { -namespace AccessToken { -class Constant { -public: - enum OpCode { - OP_INVALID = -1, - OP_ANSWER_CALL = 0, - OP_READ_CALENDAR = 1, - OP_WRITE_CALENDAR = 2, - OP_SEND_MESSAGES = 3, - OP_WRITE_CALL_LOG = 4, - OP_READ_CALL_LOG = 5, - OP_READ_CELL_MESSAGES = 6, - OP_MICROPHONE = 7, - OP_RECEIVE_WAP_MESSAGES = 8, - OP_RECEIVE_SMS = 9, - OP_RECEIVE_MMS = 10, - OP_READ_MESSAGES = 11, - OP_READ_CONTACTS = 12, - OP_WRITE_CONTACTS = 13, - OP_LOCATION_IN_BACKGROUND = 14, - OP_LOCATION = 15, - OP_MEDIA_LOCATION = 16, - OP_CAMERA = 17, - OP_READ_MEDIA = 18, - OP_WRITE_MEDIA = 19, - OP_ACTIVITY_MOTION = 20, - OP_READ_HEALTH_DATA = 21, - OP_MANAGE_VOICEMAIL = 22, - OP_DISTRIBUTED_DATASYNC = 23, - }; - - enum ErrorCode { - FAILURE = -1, - SUCCESS = 0, - }; - - const static int32_t MAX_TOTAL_RECORD = 10000; - const static int32_t MAX_DETAIL_RECORD = 10; - const static int32_t RECORD_DELETE_TIME = 30 * 86400; - const static int32_t PRECISE = 60; - const static int32_t LATEST_RECORD_TIME = 7 * 86400; - - const static std::map PERMISSION_OPCODE_MAP; -public: - static bool TransferPermissionToOpcode(const std::string& permissionName, int32_t& opCode); - static bool TransferOpcodeToPermission(int32_t opCode, std::string& permissionName); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // CONSTANT_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CONSTANT_H +#define CONSTANT_H + +#include +#include + +namespace OHOS { +namespace Security { +namespace AccessToken { +class Constant { +public: + enum OpCode { + OP_INVALID = -1, + OP_ANSWER_CALL = 0, + OP_READ_CALENDAR = 1, + OP_WRITE_CALENDAR = 2, + OP_SEND_MESSAGES = 3, + OP_WRITE_CALL_LOG = 4, + OP_READ_CALL_LOG = 5, + OP_READ_CELL_MESSAGES = 6, + OP_MICROPHONE = 7, + OP_RECEIVE_WAP_MESSAGES = 8, + OP_RECEIVE_SMS = 9, + OP_RECEIVE_MMS = 10, + OP_READ_MESSAGES = 11, + OP_READ_CONTACTS = 12, + OP_WRITE_CONTACTS = 13, + OP_LOCATION_IN_BACKGROUND = 14, + OP_LOCATION = 15, + OP_MEDIA_LOCATION = 16, + OP_CAMERA = 17, + OP_READ_MEDIA = 18, + OP_WRITE_MEDIA = 19, + OP_ACTIVITY_MOTION = 20, + OP_READ_HEALTH_DATA = 21, + OP_MANAGE_VOICEMAIL = 22, + OP_DISTRIBUTED_DATASYNC = 23, + }; + + enum ErrorCode { + FAILURE = -1, + SUCCESS = 0, + }; + + const static int32_t MAX_TOTAL_RECORD = 10000; + const static int32_t MAX_DETAIL_RECORD = 10; + const static int32_t RECORD_DELETE_TIME = 30 * 86400; + const static int32_t PRECISE = 60; + const static int32_t LATEST_RECORD_TIME = 7 * 86400; + const static std::string COUNT_CMD; + + const static std::map PERMISSION_OPCODE_MAP; +public: + static bool TransferPermissionToOpcode(const std::string& permissionName, int32_t& opCode); + static bool TransferOpcodeToPermission(int32_t opCode, std::string& permissionName); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // CONSTANT_H diff --git a/services/privacymanager/include/common/time_util.h b/services/privacymanager/include/common/time_util.h index 064e68486d9dd4cfcadc84affbe47c0f146daa6b..394be3a1c2bcc32849d0d3bfc0b886e23c59426a 100644 --- a/services/privacymanager/include/common/time_util.h +++ b/services/privacymanager/include/common/time_util.h @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TIME_UTIL_H -#define TIME_UTIL_H -#include -namespace OHOS { -namespace Security { -namespace AccessToken { -class TimeUtil { -public: - static int64_t GetCurrentTimestamp(); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // TIME_UTIL_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TIME_UTIL_H +#define TIME_UTIL_H +#include +namespace OHOS { +namespace Security { +namespace AccessToken { +class TimeUtil { +public: + static int64_t GetCurrentTimestamp(); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // TIME_UTIL_H diff --git a/services/privacymanager/include/common/to_string.h b/services/privacymanager/include/common/to_string.h index de6dd9290b58dfca38066e8edd51a9536061c198..a18ac75f151e427beb6b71625cce66947c59ec0c 100644 --- a/services/privacymanager/include/common/to_string.h +++ b/services/privacymanager/include/common/to_string.h @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TO_STRING_H -#define TO_STRING_H - -#include -#include "permission_used_request.h" -#include "permission_used_result.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class ToString { -public: - static void DetailUsedRecordToString( - bool isAccessDetail, const std::vector& detailRecord, std::string& infos); - static void PermissionUsedRecordToString( - const std::vector& permissionRecords, std::string& infos); - static void BundleUsedRecordToString(const BundleUsedRecord& bundleRecord, std::string& infos); - static void PermissionUsedResultToString(const PermissionUsedResult& result, std::string& infos); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // TO_STRING_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TO_STRING_H +#define TO_STRING_H + +#include +#include "permission_used_request.h" +#include "permission_used_result.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class ToString { +public: + static void DetailUsedRecordToString( + bool isAccessDetail, const std::vector& detailRecord, std::string& infos); + static void PermissionUsedRecordToString( + const std::vector& permissionRecords, std::string& infos); + static void BundleUsedRecordToString(const BundleUsedRecord& bundleRecord, std::string& infos); + static void PermissionUsedResultToString(const PermissionUsedResult& result, std::string& infos); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // TO_STRING_H diff --git a/services/privacymanager/include/database/data_translator.h b/services/privacymanager/include/database/data_translator.h index 488d887fff8c95759488ded9784fc850cb4939f5..6f2b02a34c50856bbf86468f043c947179b7cd6c 100644 --- a/services/privacymanager/include/database/data_translator.h +++ b/services/privacymanager/include/database/data_translator.h @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DATA_TRANSLATOR_H -#define DATA_TRANSLATOR_H - -#include - -#include "permission_used_request.h" -#include "permission_used_result.h" -#include "generic_values.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class DataTranslator final { -public: - static int32_t TranslationIntoGenericValues(const PermissionUsedRequest& request, - GenericValues& andGenericValues, GenericValues& orGenericValues); - static int32_t TranslationGenericValuesIntoPermissionUsedRecord( - const GenericValues& inGenericValues, PermissionUsedRecord& permissionRecord); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // DATA_TRANSLATOR_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DATA_TRANSLATOR_H +#define DATA_TRANSLATOR_H + +#include + +#include "permission_used_request.h" +#include "permission_used_result.h" +#include "generic_values.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class DataTranslator final { +public: + static int32_t TranslationIntoGenericValues(const PermissionUsedRequest& request, + GenericValues& andGenericValues, GenericValues& orGenericValues); + static int32_t TranslationGenericValuesIntoPermissionUsedRecord( + const GenericValues& inGenericValues, PermissionUsedRecord& permissionRecord); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // DATA_TRANSLATOR_H diff --git a/services/privacymanager/include/database/permission_used_record_db.h b/services/privacymanager/include/database/permission_used_record_db.h index 3ae7d5bb5db1838987d7717ac55b5a3cb56b3502..ef7126bd0b2ffb666809fb37bcc6ec411df215ba 100644 --- a/services/privacymanager/include/database/permission_used_record_db.h +++ b/services/privacymanager/include/database/permission_used_record_db.h @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_USED_RECORD_DB_H -#define PERMISSION_USED_RECORD_DB_H - -#include "generic_values.h" -#include "sqlite_helper.h" - -#include "nocopyable.h" -#include "rwlock.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct SqliteTable { -public: - std::string tableName_; - std::vector tableColumnNames_; -}; -class PermissionUsedRecordDb : public SqliteHelper { -public: - enum DataType { - PERMISSION_RECORD, - }; - enum ExecuteResult { FAILURE = -1, SUCCESS }; - static PermissionUsedRecordDb& GetInstance(); - - ~PermissionUsedRecordDb() override; - - int32_t Add(DataType type, const std::vector& values); - int32_t Remove(DataType type, const GenericValues& conditions); - int32_t FindByConditions(DataType type, const GenericValues& andConditions, - const GenericValues& orConditions, std::vector& results); - int32_t Modify(DataType type, const GenericValues& modifyValues, const GenericValues& conditions); - void Count(DataType type, GenericValues& result); - int32_t DeleteExpireRecords(DataType type, const GenericValues& andConditions); - int32_t DeleteExcessiveRecords(DataType type, uint32_t excessiveSize); - int32_t GetDistinctValue(DataType type, const std::string& condition, std::vector& results); - - void OnCreate() override; - void OnUpdate() override; - -private: - PermissionUsedRecordDb(); - DISALLOW_COPY_AND_MOVE(PermissionUsedRecordDb); - - std::map dataTypeToSqlTable_; - OHOS::Utils::RWLock rwLock_; - - int32_t CreatePermissionRecordTable() const; - - std::string CreateInsertPrepareSqlCmd(DataType type) const; - std::string CreateDeletePrepareSqlCmd( - DataType type, const std::vector& columnNames = std::vector()) const; - std::string CreateSelectByConditionPrepareSqlCmd(DataType type, - const std::vector& andColumns, const std::vector& orColumns) const; - std::string CreateUpdatePrepareSqlCmd(DataType type, const std::vector& modifyColumns, - const std::vector& conditionColumns) const; - std::string CreateCountPrepareSqlCmd(DataType type) const; - std::string CreateDeleteExpireRecordsPrepareSqlCmd(DataType type, - const std::vector& andColumns) const; - std::string CreateDeleteExcessiveRecordsPrepareSqlCmd(DataType type, uint32_t excessiveSize) const; - std::string CreateGetDistinctValue(DataType type, const std::string conditionColumns) const; - -private: - inline static const std::string PERMISSION_RECORD_TABLE = "permission_record_table"; - inline static const std::string DATABASE_NAME = "permission_used_record.db"; - inline static const std::string DATABASE_PATH = "/data/service/el1/public/access_token/"; - static const int32_t DATABASE_VERSION = 1; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - -#endif // PERMISSION_USED_RECORD_DB_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_USED_RECORD_DB_H +#define PERMISSION_USED_RECORD_DB_H + +#include "generic_values.h" +#include "sqlite_helper.h" + +#include "nocopyable.h" +#include "rwlock.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct SqliteTable { +public: + std::string tableName_; + std::vector tableColumnNames_; +}; +class PermissionUsedRecordDb : public SqliteHelper { +public: + enum DataType { + PERMISSION_RECORD, + }; + enum ExecuteResult { FAILURE = -1, SUCCESS }; + static PermissionUsedRecordDb& GetInstance(); + + ~PermissionUsedRecordDb() override; + + int32_t Add(DataType type, const std::vector& values); + int32_t Remove(DataType type, const GenericValues& conditions); + int32_t FindByConditions(DataType type, const GenericValues& andConditions, + const GenericValues& orConditions, std::vector& results); + int32_t Modify(DataType type, const GenericValues& modifyValues, const GenericValues& conditions); + int32_t Count(DataType type, GenericValues& result); + int32_t DeleteExpireRecords(DataType type, const GenericValues& andConditions); + int32_t DeleteExcessiveRecords(DataType type, unsigned excessiveSize); + int32_t GetDistinctValue(DataType type, const std::string& condition, std::vector& results); + + void OnCreate() override; + void OnUpdate() override; + +private: + PermissionUsedRecordDb(); + DISALLOW_COPY_AND_MOVE(PermissionUsedRecordDb); + + std::map dataTypeToSqlTable_; + OHOS::Utils::RWLock rwLock_; + + int32_t CreatePermissionRecordTable() const; + + std::string CreateInsertPrepareSqlCmd(DataType type) const; + std::string CreateDeletePrepareSqlCmd( + DataType type, const std::vector& columnNames = std::vector()) const; + std::string CreateSelectByConditionPrepareSqlCmd(DataType type, + const std::vector& andColumns, const std::vector& orColumns) const; + std::string CreateUpdatePrepareSqlCmd(DataType type, const std::vector& modifyColumns, + const std::vector& conditionColumns) const; + std::string CreateCountPrepareSqlCmd(DataType type) const; + std::string CreateDeleteExpireRecordsPrepareSqlCmd(DataType type, + const std::vector& andColumns) const; + std::string CreateDeleteExcessiveRecordsPrepareSqlCmd(DataType type, uint32_t excessiveSize) const; + std::string CreateGetDistinctValue(DataType type, const std::string conditionColumns) const; + +private: + inline static const std::string PERMISSION_RECORD_TABLE = "permission_record_table"; + inline static const std::string DATABASE_NAME = "permission_used_record.db"; + inline static const std::string DATABASE_PATH = "/data/service/el1/public/access_token/"; + static const int32_t DATABASE_VERSION = 1; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERMISSION_USED_RECORD_DB_H diff --git a/services/privacymanager/include/record/on_permission_used_record_callback_proxy.h b/services/privacymanager/include/record/on_permission_used_record_callback_proxy.h index 3a6975bd064b279622d4956ecad1a97f09e18bd9..0ec964bd151d75a1abf59e65e84f45cb4fe0c312 100644 --- a/services/privacymanager/include/record/on_permission_used_record_callback_proxy.h +++ b/services/privacymanager/include/record/on_permission_used_record_callback_proxy.h @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ON_PERMISSION_USED_RECORD_CALLBACK_PROXY_H -#define ON_PERMISSION_USED_RECORD_CALLBACK_PROXY_H - - -#include "on_permission_used_record_callback.h" - -#include "iremote_proxy.h" -#include "nocopyable.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class OnPermissionUsedRecordCallbackProxy : public IRemoteProxy { -public: - explicit OnPermissionUsedRecordCallbackProxy(const sptr& impl); - ~OnPermissionUsedRecordCallbackProxy() override; - - virtual void OnQueried(ErrCode code, PermissionUsedResult& result) override; -private: - static inline BrokerDelegator delegator_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // ON_PERMISSION_USED_RECORD_CALLBACK_PROXY_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ON_PERMISSION_USED_RECORD_CALLBACK_PROXY_H +#define ON_PERMISSION_USED_RECORD_CALLBACK_PROXY_H + + +#include "on_permission_used_record_callback.h" + +#include "iremote_proxy.h" +#include "nocopyable.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class OnPermissionUsedRecordCallbackProxy : public IRemoteProxy { +public: + explicit OnPermissionUsedRecordCallbackProxy(const sptr& impl); + ~OnPermissionUsedRecordCallbackProxy() override; + + virtual void OnQueried(ErrCode code, PermissionUsedResult& result) override; +private: + static inline BrokerDelegator delegator_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // ON_PERMISSION_USED_RECORD_CALLBACK_PROXY_H diff --git a/services/privacymanager/include/record/on_permission_used_record_callback_stub.h b/services/privacymanager/include/record/on_permission_used_record_callback_stub.h index b6120fe1b3a26bff9b674dde77fab0e3ff3caba2..5088ca032f84fc48de6f41b7ec6e83c1a292e694 100644 --- a/services/privacymanager/include/record/on_permission_used_record_callback_stub.h +++ b/services/privacymanager/include/record/on_permission_used_record_callback_stub.h @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ON_PERMISSION_USED_RECORD_CALLBACK_STUB_H -#define ON_PERMISSION_USED_RECORD_CALLBACK_STUB_H - - -#include "on_permission_used_record_callback.h" - -#include "iremote_stub.h" -#include "nocopyable.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class OnPermissionUsedRecordCallbackStub : public IRemoteStub { -public: - OnPermissionUsedRecordCallbackStub() = default; - virtual ~OnPermissionUsedRecordCallbackStub() = default; - - int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // ON_PERMISSION_USED_RECORD_CALLBACK_STUB_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ON_PERMISSION_USED_RECORD_CALLBACK_STUB_H +#define ON_PERMISSION_USED_RECORD_CALLBACK_STUB_H + + +#include "on_permission_used_record_callback.h" + +#include "iremote_stub.h" +#include "nocopyable.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class OnPermissionUsedRecordCallbackStub : public IRemoteStub { +public: + OnPermissionUsedRecordCallbackStub() = default; + virtual ~OnPermissionUsedRecordCallbackStub() = default; + + int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // ON_PERMISSION_USED_RECORD_CALLBACK_STUB_H diff --git a/services/privacymanager/include/record/permission_record.h b/services/privacymanager/include/record/permission_record.h index f2c0abb0731e3b70c4b03e8408a1eeb80ba12f3c..56148a79e0587da4de1dff6df7605802d6bfae1c 100644 --- a/services/privacymanager/include/record/permission_record.h +++ b/services/privacymanager/include/record/permission_record.h @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_RECORD_H -#define PERMISSION_RECORD_H - -#include "generic_values.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionRecord { - uint32_t tokenId = 0; - int32_t opCode = 0; - int32_t status = 0; - int64_t timestamp = 0L; - int64_t accessDuration = 0L; - int32_t accessCount = 0; - int32_t rejectCount = 0; - - PermissionRecord() = default; - - static void TranslationIntoGenericValues(const PermissionRecord& record, GenericValues& values); - static void TranslationIntoPermissionRecord(const GenericValues& values, PermissionRecord& record); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_RECORD_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_RECORD_H +#define PERMISSION_RECORD_H + +#include "generic_values.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionRecord { + uint32_t tokenId = 0; + int32_t opCode = 0; + int32_t status = 0; + int64_t timestamp = 0L; + int64_t accessDuration = 0L; + int32_t accessCount = 0; + int32_t rejectCount = 0; + + PermissionRecord() = default; + + static void TranslationIntoGenericValues(const PermissionRecord& record, GenericValues& values); + static void TranslationIntoPermissionRecord(const GenericValues& values, PermissionRecord& record); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERMISSION_RECORD_H diff --git a/services/privacymanager/include/record/permission_record_manager.h b/services/privacymanager/include/record/permission_record_manager.h index ae3c6706768fa26b4d2a7577b61ca28a88ed94a2..84bab127ffa9cea4a556976d973189e590a5c4e9 100644 --- a/services/privacymanager/include/record/permission_record_manager.h +++ b/services/privacymanager/include/record/permission_record_manager.h @@ -1,92 +1,80 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_RECORD_MANAGER_H -#define PERMISSION_RECORD_MANAGER_H - -#include -#include -#include - -#include "access_token.h" -#include "active_change_response_info.h" -#include "hap_token_info.h" -#include "nocopyable.h" -#include "on_permission_used_record_callback.h" -#include "permission_record.h" -#include "permission_used_request.h" -#include "permission_used_result.h" - -#include "rwlock.h" -#include "thread_pool.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PermissionRecordManager final { -public: - static PermissionRecordManager& GetInstance(); - virtual ~PermissionRecordManager(); - - void Init(); - int32_t AddPermissionUsedRecord( - AccessTokenID tokenId, const std::string& permissionName, int32_t successCount, int32_t failCount); - void RemovePermissionUsedRecords(AccessTokenID tokenId, const std::string& deviceID); - int32_t GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result); - int32_t GetPermissionUsedRecordsAsync( - const PermissionUsedRequest& request, const sptr& callback); - std::string DumpRecordInfo(AccessTokenID tokenId, const std::string& permissionName); - int32_t StartUsingPermission(AccessTokenID tokenId, const std::string& permissionName); - int32_t StopUsingPermission(AccessTokenID tokenId, const std::string& permissionName); - int32_t RegisterPermActiveStatusCallback( - std::vector& permList, const sptr& callback); - int32_t UnRegisterPermActiveStatusCallback(const sptr& callback); - - void CallbackExecute(AccessTokenID tokenId, const std::string& permissionName, int32_t status); - -private: - PermissionRecordManager(); - DISALLOW_COPY_AND_MOVE(PermissionRecordManager); - - bool GetLocalRecordTokenIdList(std::set& tokenIdList); - void AddRecord(const PermissionRecord& record); - bool GetPermissionRecord(AccessTokenID tokenId, const std::string& permissionName, - int32_t successCount, int32_t failCount, PermissionRecord& record); - bool CreateBundleUsedRecord(const AccessTokenID tokenId, BundleUsedRecord& bundleRecord); - void ExecuteDeletePermissionRecordTask(); - int32_t DeletePermissionRecord(int32_t days); - bool GetRecordsFromLocalDB(const PermissionUsedRequest& request, PermissionUsedResult& result); - bool GetRecords(int32_t flag, std::vector recordValues, - BundleUsedRecord& bundleRecord, PermissionUsedResult& result); - void UpdateRecords(int32_t flag, const PermissionUsedRecord& inBundleRecord, PermissionUsedRecord& outBundleRecord); - - void AddRecordToStartList(const PermissionRecord& record); - bool GetRecordFromStartList(uint32_t tokenId, int32_t opCode, PermissionRecord& record); - void ResetRecord(PermissionRecord& record, int32_t status); - bool HasStarted(const PermissionRecord& record); - std::vector GetRecordsAndReset(uint32_t tokenId, int32_t status); - - std::string GetDeviceId(AccessTokenID tokenId); - - OHOS::ThreadPool deleteTaskWorker_; - bool hasInited_; - OHOS::Utils::RWLock rwLock_; - OHOS::Utils::RWLock startRecordListRWLock_; - std::vector startRecordList_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_RECORD_MANAGER_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_RECORD_MANAGER_H +#define PERMISSION_RECORD_MANAGER_H + +#include +#include +#include + +#include "access_token.h" +#include "hap_token_info.h" +#include "nocopyable.h" +#include "on_permission_used_record_callback.h" +#include "permission_record.h" +#include "permission_used_request.h" +#include "permission_used_result.h" + +#include "rwlock.h" +#include "thread_pool.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermissionRecordManager final { +public: + static PermissionRecordManager& GetInstance(); + virtual ~PermissionRecordManager(); + + void Init(); + int32_t AddPermissionUsedRecord( + AccessTokenID tokenId, const std::string& permissionName, int32_t successCount, int32_t failCount); + void RemovePermissionUsedRecords(AccessTokenID tokenId, const std::string& deviceID); + int32_t GetPermissionUsedRecords(const PermissionUsedRequest& request, PermissionUsedResult& result); + int32_t GetPermissionUsedRecordsAsync( + const PermissionUsedRequest& request, const sptr& callback); + std::string DumpRecordInfo(AccessTokenID tokenId, const std::string& permissionName); + int32_t StartUsingPermission(AccessTokenID tokenId, const std::string& permissionName); + int32_t StopUsingPermission(AccessTokenID tokenId, const std::string& permissionName); + int32_t RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback); + int32_t UnRegisterPermActiveStatusCallback(const sptr& callback); +private: + PermissionRecordManager(); + DISALLOW_COPY_AND_MOVE(PermissionRecordManager); + + bool GetLocalRecordTokenIdList(std::set& tokenIdList); + int32_t AddRecord(const PermissionRecord& record); + bool GetPermissionsRecord(AccessTokenID tokenId, const std::string& permissionName, + int32_t successCount, int32_t failCount, PermissionRecord& record); + bool CreateBundleUsedRecord(const AccessTokenID tokenId, BundleUsedRecord& bundleRecord); + void ExecuteDeletePermissionRecordTask(); + int32_t DeletePermissionRecord(int32_t days); + bool GetRecordsFromLocalDB(const PermissionUsedRequest& request, PermissionUsedResult& result); + bool GetRecords(int32_t flag, std::vector recordValues, + BundleUsedRecord& bundleRecord, PermissionUsedResult& result); + void UpdateRecords(int32_t flag, const PermissionUsedRecord& inBundleRecord, PermissionUsedRecord& outBundleRecord); + + std::string GetDeviceId(AccessTokenID tokenId); + + OHOS::ThreadPool deleteTaskWorker_; + bool hasInited_; + OHOS::Utils::RWLock rwLock_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERMISSION_RECORD_MANAGER_H diff --git a/services/privacymanager/include/record/permission_record_node.h b/services/privacymanager/include/record/permission_record_node.h index d56b3d80083cd0c2f0b297aad08ef2a5b9cbe9e0..abd0af8ca16d069104a82aa3485f077a40aa38e6 100644 --- a/services/privacymanager/include/record/permission_record_node.h +++ b/services/privacymanager/include/record/permission_record_node.h @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_UESD_RECORD_NODE_H -#define PERMISSION_UESD_RECORD_NODE_H - -#include -#include "permission_record.h" -#include "rwlock.h" -namespace OHOS { -namespace Security { -namespace AccessToken { -struct PermissionUsedRecordNode { - std::weak_ptr pre; - std::shared_ptr next; - PermissionRecord record; - - PermissionUsedRecordNode() = default; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_UESD_RECORD_NODE_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_UESD_RECORD_NODE_H +#define PERMISSION_UESD_RECORD_NODE_H + +#include +#include "permission_record.h" +#include "rwlock.h" +namespace OHOS { +namespace Security { +namespace AccessToken { +struct PermissionUsedRecordNode { + std::weak_ptr pre; + std::shared_ptr next; + PermissionRecord record; + + PermissionUsedRecordNode() = default; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERMISSION_UESD_RECORD_NODE_H diff --git a/services/privacymanager/include/record/permission_record_repository.h b/services/privacymanager/include/record/permission_record_repository.h index 1ca8caee907aa98710b5b9b1e38da2516c8b2542..385f30fab93553daaa5e773c5cc9ea0f85b8d639 100644 --- a/services/privacymanager/include/record/permission_record_repository.h +++ b/services/privacymanager/include/record/permission_record_repository.h @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_RECORD_REPOSITORY_H -#define PERMISSION_RECORD_REPOSITORY_H - -#include -#include "generic_values.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PermissionRecordRepository final { -public: - virtual ~PermissionRecordRepository(); - PermissionRecordRepository(); - - static PermissionRecordRepository& GetInstance(); - - bool AddRecordValues(const std::vector& recordValues); - bool FindRecordValues(const GenericValues& andConditionValues, - const GenericValues& orConditionValues, std::vector& recordValues); - bool RemoveRecordValues(const GenericValues& conditionValues); - bool GetAllRecordValuesByKey(const std::string& condition, std::vector& resultValues); - void CountRecordValues(GenericValues& resultValues); - bool DeleteExpireRecordsValues(const GenericValues& andConditions); - bool DeleteExcessiveSizeRecordValues(uint32_t excessiveSize); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_RECORD_REPOSITORY_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_RECORD_REPOSITORY_H +#define PERMISSION_RECORD_REPOSITORY_H + +#include +#include "generic_values.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermissionRecordRepository final { +public: + virtual ~PermissionRecordRepository(); + PermissionRecordRepository(); + + static PermissionRecordRepository& GetInstance(); + + bool AddRecordValues(const std::vector& recordValues); + bool FindRecordValues(const GenericValues& andConditionValues, + const GenericValues& orConditionValues, std::vector& recordValues); + bool RemoveRecordValues(const GenericValues& conditionValues); + bool GetAllRecordValuesByKey(const std::string& condition, std::vector& resultValues); + int32_t CountRecordValues(GenericValues& resultValues); + bool DeleteExpireRecordsValues(const GenericValues& andConditions); + bool DeleteExcessiveSizeRecordValues(uint32_t excessiveSize); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERMISSION_RECORD_REPOSITORY_H diff --git a/services/privacymanager/include/record/permission_used_record_cache.h b/services/privacymanager/include/record/permission_used_record_cache.h index 272bef4716fc953a84c376292c4e21fbcf296d72..f4ec94aa4819bded61664466f77d9cdb24320edd 100644 --- a/services/privacymanager/include/record/permission_used_record_cache.h +++ b/services/privacymanager/include/record/permission_used_record_cache.h @@ -1,77 +1,78 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PERMISSION_USED_RECORD_CACHE_H -#define PERMISSION_USED_RECORD_CACHE_H - -#include -#include -#include -#include -#include -#include "accesstoken_kit.h" -#include "nocopyable.h" -#include "permission_record.h" -#include "permission_record_node.h" -#include "rwlock.h" -#include "thread_pool.h" -namespace OHOS { -namespace Security { -namespace AccessToken { -class PermissionUsedRecordCache { -public: - static PermissionUsedRecordCache& GetInstance(); - void AddRecordToBuffer(PermissionRecord& record); - void MergeRecord(PermissionRecord& record, std::shared_ptr curFindMergePos); - void AddToPersistQueue(const std::shared_ptr persistPendingBufferHead); - void ExecuteReadRecordBufferTask(); - int32_t PersistPendingRecords(); - void GetPersistPendingRecordsAndReset(); - int32_t RemoveRecords(const AccessTokenID tokenId); - void RemoveRecordsFromPersistPendingBufferQueue(const AccessTokenID tokenId, - std::shared_ptr persistPendingBufferHead, - std::shared_ptr persistPendingBufferEnd); - void GetRecords(const std::vector& permissionList, - const GenericValues& andConditionValues, const GenericValues& orConditionValues, - std::vector& findRecordsValues); - void GetRecordsFromPersistPendingBufferQueue(const std::set& opCodeList, - const GenericValues& andConditionValues, const GenericValues& orConditionValues, - std::vector& findRecordsValues); - bool RecordCompare(const AccessTokenID tokenId, const std::set& opCodeList, - const GenericValues& andConditionValues, const PermissionRecord& record); - void FindTokenIdList(std::set& tokenIdList); - void TransferToOpcode(std::set& opCodeList, - const std::vector& permissionList); - void ResetRecordBuffer(const int32_t remainCount, - std::shared_ptr& persistPendingBufferEnd); - void AddRecordNode(const PermissionRecord& record); - void DeleteRecordNode(std::shared_ptr deleteRecordNode); - -private: - int32_t readableSize_ = 0; - std::shared_ptr recordBufferHead_ = std::make_shared(); - std::shared_ptr curRecordBufferPos_ = recordBufferHead_; - std::vector> persistPendingBufferQueue_; - int64_t nextPersistTimestamp_ = 0L; - const static int32_t INTERVAL = 60 * 15; - const static int32_t MAX_PERSIST_SIZE = 100; - int32_t persistIsRunning_ = 0; - OHOS::Utils::RWLock cacheLock_; - OHOS::ThreadPool readRecordBufferTaskWorker_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_USED_RECORD_CACHE_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PERMISSION_USED_RECORD_CACHE_H +#define PERMISSION_USED_RECORD_CACHE_H + +#include +#include +#include +#include +#include +#include "accesstoken_kit.h" +#include "nocopyable.h" +#include "permission_record.h" +#include "permission_record_node.h" +#include "rwlock.h" +#include "thread_pool.h" +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermissionUsedRecordCache { +public: + static PermissionUsedRecordCache& GetInstance(); + int32_t AddRecordToBuffer(PermissionRecord& record); + void MergeRecord(PermissionRecord& record, std::shared_ptr curFindMergePos); + void AddToPersistQueue(const std::shared_ptr persistPendingBufferHead); + void ExecuteReadRecordBufferTask(); + int32_t PersistPendingRecords(); + void GetPersistPendingRecordsAndReset(); + int32_t RemoveRecords(const GenericValues &record); + void RemoveRecordsFromPersistPendingBufferQueue(const GenericValues &record, + std::shared_ptr persistPendingBufferHead, + std::shared_ptr persistPendingBufferEnd); + void GetRecords(const std::vector& permissionList, + const GenericValues &andConditionValues, const GenericValues& orConditionValues, + std::vector& findRecordsValues); + void GetAllRecords(const std::vector& permissionList, + const GenericValues &andConditionValues, const GenericValues& orConditionValues, + std::vector& findRecordsValues); + void GetRecordsFromPersistPendingBufferQueue(const std::vector& permissionList, + const GenericValues& andConditionValues, const GenericValues& orConditionValues, + std::vector& findRecordsValues, const std::set& opCodeList); + bool RecordCompare(const AccessTokenID tokenId, const std::set& opCodeList, + const GenericValues &andConditionValues, const PermissionRecord &record); + void FindTokenIdList(std::set& tokenIdList); + void TransferToOpcode(std::set& opCodeList, + const std::vector& permissionList); + void AddRecordNode(const PermissionRecord& record); + void DeleteRecordNode(std::shared_ptr deleteRecordNode); + +private: + int32_t readableSize_ = 0; + std::shared_ptr recordBufferHead_ = std::make_shared(); + std::shared_ptr curRecordBufferPos_ = recordBufferHead_; + std::vector> persistPendingBufferQueue_; + int64_t nextPersistTimestamp_ = 0L; + const static int32_t INTERVAL = 60 * 15; + const static int32_t MAX_PERSIST_SIZE = 100; + int32_t persistIsRunning_ = 0; + OHOS::Utils::RWLock cacheLock_; + OHOS::ThreadPool readRecordBufferTaskWorker_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERMISSION_USED_RECORD_CACHE_H diff --git a/services/privacymanager/include/service/privacy_manager_service.h b/services/privacymanager/include/service/privacy_manager_service.h index ce276d297ecefa5984f0e7b0cedd97a9d6908e6a..854a28365e29364302db6ee35fd11941116ffb4e 100644 --- a/services/privacymanager/include/service/privacy_manager_service.h +++ b/services/privacymanager/include/service/privacy_manager_service.h @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PRIVACY_MANAGER_SERVICE_H -#define PRIVACY_MANAGER_SERVICE_H - -#include - -#include "privacy_manager_stub.h" -#include "iremote_object.h" -#include "nocopyable.h" -#include "singleton.h" -#include "system_ability.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; -class PrivacyManagerService final : public SystemAbility, public PrivacyManagerStub { - DECLARE_DELAYED_SINGLETON(PrivacyManagerService); - DECLEAR_SYSTEM_ABILITY(PrivacyManagerService); - -public: - void OnStart() override; - void OnStop() override; - - int32_t AddPermissionUsedRecord( - AccessTokenID tokenId, const std::string& permissionName, int32_t successCount, int32_t failCount) override; - int32_t StartUsingPermission(AccessTokenID tokenId, const std::string& permissionName) override; - int32_t StopUsingPermission(AccessTokenID tokenId, const std::string& permissionName) override; - int32_t RemovePermissionUsedRecords(AccessTokenID tokenId, const std::string& deviceID) override; - int32_t GetPermissionUsedRecords( - const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) override; - int32_t GetPermissionUsedRecords( - const PermissionUsedRequestParcel& request, const sptr& callback) override; - std::string DumpRecordInfo(AccessTokenID tokenId, const std::string& permissionName) override; - int32_t RegisterPermActiveStatusCallback( - std::vector& permList, const sptr& callback) override; - int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) override; - -private: - bool Initialize() const; - - ServiceRunningState state_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PRIVACY_MANAGER_SERVICE_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PRIVACY_MANAGER_SERVICE_H +#define PRIVACY_MANAGER_SERVICE_H + +#include + +#include "privacy_manager_stub.h" +#include "iremote_object.h" +#include "nocopyable.h" +#include "singleton.h" +#include "system_ability.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; +class PrivacyManagerService final : public SystemAbility, public PrivacyManagerStub { + DECLARE_DELAYED_SINGLETON(PrivacyManagerService); + DECLEAR_SYSTEM_ABILITY(PrivacyManagerService); + +public: + void OnStart() override; + void OnStop() override; + + int32_t AddPermissionUsedRecord( + AccessTokenID tokenId, const std::string& permissionName, int32_t successCount, int32_t failCount) override; + int32_t StartUsingPermission(AccessTokenID tokenId, const std::string& permissionName) override; + int32_t StopUsingPermission(AccessTokenID tokenId, const std::string& permissionName) override; + int32_t RemovePermissionUsedRecords(AccessTokenID tokenId, const std::string& deviceID) override; + int32_t GetPermissionUsedRecords( + const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) override; + int32_t GetPermissionUsedRecords( + const PermissionUsedRequestParcel& request, const sptr& callback) override; + std::string DumpRecordInfo(AccessTokenID tokenId, const std::string& permissionName) override; + int32_t RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) override; + int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) override; + bool IsAllowUsingPermission(AccessTokenID tokenId, const std::string& permissionName) override; +private: + bool Initialize() const; + + ServiceRunningState state_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PRIVACY_MANAGER_SERVICE_H diff --git a/services/privacymanager/include/service/privacy_manager_stub.h b/services/privacymanager/include/service/privacy_manager_stub.h index 17f592436b386e52ffd31ebc9528acb30db5edb4..767cdbee5205621665f23145d1cd8e0bd68e0f2e 100644 --- a/services/privacymanager/include/service/privacy_manager_stub.h +++ b/services/privacymanager/include/service/privacy_manager_stub.h @@ -1,50 +1,51 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef PRIVACY_MANAGER_STUB_H -#define PRIVACY_MANAGER_STUB_H - -#include "i_privacy_manager.h" - -#include "iremote_stub.h" -#include "nocopyable.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyManagerStub : public IRemoteStub { -public: - PrivacyManagerStub() = default; - virtual ~PrivacyManagerStub() = default; - - int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - -private: - void AddPermissionUsedRecordInner(MessageParcel& data, MessageParcel& reply); - void StartUsingPermissionInner(MessageParcel& data, MessageParcel& reply); - void StopUsingPermissionInner(MessageParcel& data, MessageParcel& reply); - void RemovePermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply); - void GetPermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply); - void GetPermissionUsedRecordsAsyncInner(MessageParcel& data, MessageParcel& reply); - void DumpRecordInfoInner(MessageParcel& data, MessageParcel& reply); - void RegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply); - void UnRegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply); - bool IsAccessTokenCalling() const; - static const int32_t ACCESSTOKEN_UID = 3020; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PRIVACY_MANAGER_STUB_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PRIVACY_MANAGER_STUB_H +#define PRIVACY_MANAGER_STUB_H + +#include "i_privacy_manager.h" + +#include "iremote_stub.h" +#include "nocopyable.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PrivacyManagerStub : public IRemoteStub { +public: + PrivacyManagerStub() = default; + virtual ~PrivacyManagerStub() = default; + + int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; + +private: + void AddPermissionUsedRecordInner(MessageParcel& data, MessageParcel& reply); + void StartUsingPermissionInner(MessageParcel& data, MessageParcel& reply); + void StopUsingPermissionInner(MessageParcel& data, MessageParcel& reply); + void RemovePermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply); + void GetPermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply); + void GetPermissionUsedRecordsAsyncInner(MessageParcel& data, MessageParcel& reply); + void DumpRecordInfoInner(MessageParcel& data, MessageParcel& reply); + void RegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply); + void UnRegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply); + void IsAllowUsingPermissionInner(MessageParcel& data, MessageParcel& reply); + bool IsAccessTokenCalling() const; + static const int32_t ACCESSTOKEN_UID = 3020; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PRIVACY_MANAGER_STUB_H diff --git a/services/privacymanager/privacy.cfg b/services/privacymanager/privacy.cfg index 30d01427cab02273c043be171670f6ce81a61aa6..bb9d71e062521b38e4bfcf2c61ed3b29e4b15d03 100644 --- a/services/privacymanager/privacy.cfg +++ b/services/privacymanager/privacy.cfg @@ -1,11 +1,11 @@ -{ - "services" : [{ - "name" : "privacy_service", - "path" : ["/system/bin/sa_main", "/system/profile/privacy_service.xml"], - "importance" : -20, - "uid" : "access_token", - "gid" : ["access_token"], - "secon" : "u:r:privacy_service:s0" - } - ] -} +{ + "services" : [{ + "name" : "privacy_service", + "path" : ["/system/bin/sa_main", "/system/profile/privacy_service.xml"], + "importance" : -20, + "uid" : "access_token", + "gid" : ["access_token"], + "secon" : "u:r:privacy_service:s0" + } + ] +} diff --git a/services/privacymanager/privacy.rc b/services/privacymanager/privacy.rc index 9757637549b395e7ba088daf158e5a75af787ebc..40f5e6b8a3eb25199d8d11092ea43fc975124367 100644 --- a/services/privacymanager/privacy.rc +++ b/services/privacymanager/privacy.rc @@ -1,22 +1,22 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -on late-fs - start privacy_service - -service privacy_service /system/bin/sa_main /system/profile/privacy_service.xml - class privacy_service - priority -20 - user access_token - group access_token - seclabel u:r:privacy_service:s0 +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +on late-fs + start privacy_service + +service privacy_service /system/bin/sa_main /system/profile/privacy_service.xml + class privacy_service + priority -20 + user access_token + group access_token + seclabel u:r:privacy_service:s0 diff --git a/services/privacymanager/sa_profile/3505.xml b/services/privacymanager/sa_profile/3505.xml index 60b5eae50adee6518181101826cda8b7f4b6e8a3..16f0bc779c05fb4944de4ecf9da890cdec468df1 100644 --- a/services/privacymanager/sa_profile/3505.xml +++ b/services/privacymanager/sa_profile/3505.xml @@ -1,24 +1,24 @@ - - - - privacy_service - - 3505 - libprivacy_manager_service.z.so - true - true - 1 - - + + + + privacy_service + + 3505 + libprivacy_manager_service.z.so + true + true + 1 + + diff --git a/services/privacymanager/sa_profile/BUILD.gn b/services/privacymanager/sa_profile/BUILD.gn index 1bf6fc36a2b69832f8235d7267bedc68cc879f91..d44a4cd6132b57bb0799ede16819055106007261 100644 --- a/services/privacymanager/sa_profile/BUILD.gn +++ b/services/privacymanager/sa_profile/BUILD.gn @@ -1,23 +1,23 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//build/ohos/sa_profile/sa_profile.gni") - -if (is_standard_system) { - ohos_sa_profile("privacy_sa_profile_standard") { - part_name = "access_token" - - sources = [ "3505.xml" ] - } -} +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/sa_profile/sa_profile.gni") + +if (is_standard_system) { + ohos_sa_profile("privacy_sa_profile_standard") { + part_name = "access_token" + + sources = [ "3505.xml" ] + } +} diff --git a/services/privacymanager/src/active/active_status_callback_manager.cpp b/services/privacymanager/src/active/active_status_callback_manager.cpp index b14bcd6e249557823696e4d66e9926cdad95368d..9b7a68b4fe83fab65157aa71965ecd8830550e2f 100644 --- a/services/privacymanager/src/active/active_status_callback_manager.cpp +++ b/services/privacymanager/src/active/active_status_callback_manager.cpp @@ -1,154 +1,154 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "active_status_callback_manager.h" - -#include -#include -#include - -#include "accesstoken_log.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "ActiveStatusCallbackManager" -}; -static const time_t MAX_TIMEOUT_SEC = 30; -static const time_t MAX_CALLBACK_SIZE = 200; -} - -ActiveStatusCallbackManager& ActiveStatusCallbackManager::GetInstance() -{ - static ActiveStatusCallbackManager instance; - return instance; -} - -ActiveStatusCallbackManager::ActiveStatusCallbackManager() - : callbackDeathRecipient_(sptr( - new (std::nothrow) PermActiveStatusCallbackDeathRecipient())) -{ -} - -ActiveStatusCallbackManager::~ActiveStatusCallbackManager() -{ -} - -int32_t ActiveStatusCallbackManager::AddCallback( - const std::vector& permList, const sptr& callback) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "callback %{public}p ", (IRemoteObject *)callback); - if (callback == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "input is nullptr"); - return RET_FAILED; - } - - callback->AddDeathRecipient(callbackDeathRecipient_); - - CallbackData recordInstance; - recordInstance.callbackObject_ = callback; - recordInstance.permList_ = permList; - - std::lock_guard lock(mutex_); - if (callbackDataList_.size() > MAX_CALLBACK_SIZE) { - ACCESSTOKEN_LOG_ERROR(LABEL, "list size has reached max value"); - return RET_FAILED; - } - callbackDataList_.emplace_back(recordInstance); - - ACCESSTOKEN_LOG_INFO(LABEL, "recordInstance is added"); - return RET_SUCCESS; -} - -int32_t ActiveStatusCallbackManager::RemoveCallback(const sptr& callback) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "called"); - if (callback == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "callback is nullptr"); - return RET_FAILED; - } - - std::lock_guard lock(mutex_); - - for (auto it = callbackDataList_.begin(); it != callbackDataList_.end(); ++it) { - if (callback == (*it).callbackObject_) { - ACCESSTOKEN_LOG_INFO(LABEL, "find callback"); - if (callbackDeathRecipient_ != nullptr) { - callback->RemoveDeathRecipient(callbackDeathRecipient_); - } - (*it).callbackObject_ = nullptr; - callbackDataList_.erase(it); - break; - } - } - return RET_SUCCESS; -} - -bool ActiveStatusCallbackManager::NeedCalled(const std::vector& permList, const std::string& permName) -{ - if (permList.empty()) { - return true; - } - for (const auto& perm : permList) { - if (perm == permName) { - return true; - } - } - return false; -} - -void ActiveStatusCallbackManager::ExecuteCallbackAsync( - AccessTokenID tokenId, const std::string& permName, const std::string& deviceId, ActiveChangeType changeType) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "entry"); - - auto callbackFunc = [&]() { - ACCESSTOKEN_LOG_INFO(LABEL, "callbackStart"); - std::lock_guard lock(mutex_); - for (auto it = callbackDataList_.begin(); it != callbackDataList_.end(); ++it) { - std::vector permList = (*it).permList_; - if (!NeedCalled(permList, permName)) { - ACCESSTOKEN_LOG_INFO(LABEL, "tokenId %{public}u, permName %{public}s", tokenId, permName.c_str()); - continue; - } - auto callback = iface_cast((*it).callbackObject_); - if (callback != nullptr) { - ActiveChangeResponse resInfo; - resInfo.type = changeType; - resInfo.permissionName = permName; - resInfo.tokenID = tokenId; - resInfo.deviceId = deviceId; - ACCESSTOKEN_LOG_INFO(LABEL, "callback excute changeType %{public}d", changeType); - callback->ActiveStatusChangeCallback(resInfo); - } - } - }; - - std::packaged_task callbackTask(callbackFunc); - std::future fut = callbackTask.get_future(); - std::make_unique(std::move(callbackTask))->detach(); - - ACCESSTOKEN_LOG_INFO(LABEL, "Waiting for the callback execution complete..."); - std::future_status status = fut.wait_for(std::chrono::seconds(MAX_TIMEOUT_SEC)); - if (status == std::future_status::timeout) { - ACCESSTOKEN_LOG_WARN(LABEL, "callbackTask callback execution timeout"); - } - ACCESSTOKEN_LOG_INFO(LABEL, "The callback execution is complete"); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "active_status_callback_manager.h" + +#include +#include +#include + +#include "accesstoken_log.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "ActiveStatusCallbackManager" +}; +static const time_t MAX_TIMEOUT_SEC = 30; +static const time_t MAX_CALLBACK_SIZE = 200; +} + +ActiveStatusCallbackManager& ActiveStatusCallbackManager::GetInstance() +{ + static ActiveStatusCallbackManager instance; + return instance; +} + +ActiveStatusCallbackManager::ActiveStatusCallbackManager() + : callbackDeathRecipient_(sptr( + new (std::nothrow) PermActiveStatusCallbackDeathRecipient())) +{ +} + +ActiveStatusCallbackManager::~ActiveStatusCallbackManager() +{ +} + +int32_t ActiveStatusCallbackManager::AddCallback( + const std::vector& permList, const sptr& callback) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "callback %{public}p ", (IRemoteObject *)callback); + if (callback == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "input is nullptr"); + return RET_FAILED; + } + + callback->AddDeathRecipient(callbackDeathRecipient_); + + CallbackData recordInstance; + recordInstance.callbackObject_ = callback; + recordInstance.permList_ = permList; + + std::lock_guard lock(mutex_); + if (callbackDataList_.size() > MAX_CALLBACK_SIZE) { + ACCESSTOKEN_LOG_ERROR(LABEL, "list size has reached max value"); + return RET_FAILED; + } + callbackDataList_.emplace_back(recordInstance); + + ACCESSTOKEN_LOG_INFO(LABEL, "recordInstance is added"); + return RET_SUCCESS; +} + +int32_t ActiveStatusCallbackManager::RemoveCallback(const sptr& callback) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "called"); + if (callback == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "callback is nullptr"); + return RET_FAILED; + } + + std::lock_guard lock(mutex_); + + for (auto it = callbackDataList_.begin(); it != callbackDataList_.end(); ++it) { + if (callback == (*it).callbackObject_) { + ACCESSTOKEN_LOG_INFO(LABEL, "find callback"); + if (callbackDeathRecipient_ != nullptr) { + callback->RemoveDeathRecipient(callbackDeathRecipient_); + } + (*it).callbackObject_ = nullptr; + callbackDataList_.erase(it); + break; + } + } + return RET_SUCCESS; +} + +bool ActiveStatusCallbackManager::NeedCalled(const std::vector& permList, const std::string& permName) +{ + if (permList.empty()) { + return true; + } + for (const auto& perm : permList) { + if (perm == permName) { + return true; + } + } + return false; +} + +void ActiveStatusCallbackManager::ExecuteCallbackAsync( + AccessTokenID tokenId, const std::string& permName, const std::string& deviceId, ActiveChangeType changeType) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "entry"); + + auto callbackFunc = [&]() { + ACCESSTOKEN_LOG_INFO(LABEL, "callbackStart"); + std::lock_guard lock(mutex_); + for (auto it = callbackDataList_.begin(); it != callbackDataList_.end(); ++it) { + std::vector permList = (*it).permList_; + if (!NeedCalled(permList, permName)) { + ACCESSTOKEN_LOG_INFO(LABEL, "tokenId %{public}u, permName %{public}s", tokenId, permName.c_str()); + continue; + } + auto callback = iface_cast((*it).callbackObject_); + if (callback != nullptr) { + ActiveChangeResponse resInfo; + resInfo.type = changeType; + resInfo.permissionName = permName; + resInfo.tokenID = tokenId; + resInfo.deviceId = deviceId; + ACCESSTOKEN_LOG_INFO(LABEL, "callback excute changeType %{public}d", changeType); + callback->ActiveStatusChangeCallback(resInfo); + } + } + }; + + std::packaged_task callbackTask(callbackFunc); + std::future fut = callbackTask.get_future(); + std::make_unique(std::move(callbackTask))->detach(); + + ACCESSTOKEN_LOG_INFO(LABEL, "Waiting for the callback execution complete..."); + std::future_status status = fut.wait_for(std::chrono::seconds(MAX_TIMEOUT_SEC)); + if (status == std::future_status::timeout) { + ACCESSTOKEN_LOG_WARN(LABEL, "callbackTask callback execution timeout"); + } + ACCESSTOKEN_LOG_INFO(LABEL, "The callback execution is complete"); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/active/perm_active_status_callback_death_recipient.cpp b/services/privacymanager/src/active/perm_active_status_callback_death_recipient.cpp index 1acb1bdecfb11e5f76cd9f69f57d89139143080b..e0349ef54d65b4bf4461adca7815c77d666424e3 100644 --- a/services/privacymanager/src/active/perm_active_status_callback_death_recipient.cpp +++ b/services/privacymanager/src/active/perm_active_status_callback_death_recipient.cpp @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "perm_active_status_callback_death_recipient.h" - -#include "access_token.h" -#include "active_status_callback_manager.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "PermActiveStatusCallbackDeathRecipient" -}; -} -void PermActiveStatusCallbackDeathRecipient::OnRemoteDied(const wptr &remote) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "enter"); - if (remote == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "remote object is nullptr"); - return; - } - - sptr object = remote.promote(); - if (object == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "object is nullptr"); - return; - } - ActiveStatusCallbackManager::GetInstance().RemoveCallback(object); - ACCESSTOKEN_LOG_INFO(LABEL, "end"); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "perm_active_status_callback_death_recipient.h" + +#include "access_token.h" +#include "active_status_callback_manager.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "PermActiveStatusCallbackDeathRecipient" +}; +} +void PermActiveStatusCallbackDeathRecipient::OnRemoteDied(const wptr &remote) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "enter"); + if (remote == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "remote object is nullptr"); + return; + } + + sptr object = remote.promote(); + if (object == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "object is nullptr"); + return; + } + ActiveStatusCallbackManager::GetInstance().RemoveCallback(object); + ACCESSTOKEN_LOG_INFO(LABEL, "end"); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/active/perm_active_status_change_callback_proxy.cpp b/services/privacymanager/src/active/perm_active_status_change_callback_proxy.cpp index 5b41136ed949513551238a13d77eac81f9ecdd27..d1dc59a64b505385f2fe8c8274a843a1ebae81f3 100644 --- a/services/privacymanager/src/active/perm_active_status_change_callback_proxy.cpp +++ b/services/privacymanager/src/active/perm_active_status_change_callback_proxy.cpp @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "perm_active_status_change_callback_proxy.h" - -#include "accesstoken_log.h" -#include "perm_active_response_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermActiveStatusChangeCallbackProxy" -}; -} - -PermActiveStatusChangeCallbackProxy::PermActiveStatusChangeCallbackProxy(const sptr& impl) - : IRemoteProxy(impl) { -} - -PermActiveStatusChangeCallbackProxy::~PermActiveStatusChangeCallbackProxy() -{} - -void PermActiveStatusChangeCallbackProxy::ActiveStatusChangeCallback(ActiveChangeResponse& result) -{ - MessageParcel data; - data.WriteInterfaceToken(IPermActiveStatusCallback::GetDescriptor()); - - ActiveChangeResponseParcel resultParcel; - resultParcel.changeResponse = result; - if (!data.WriteParcelable(&resultParcel)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable"); - return; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); - return; - } - int32_t requestResult = remote->SendRequest( - static_cast(IPermActiveStatusCallback::PERM_ACTIVE_STATUS_CHANGE), data, reply, option); - if (requestResult != NO_ERROR) { - ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); - return; - } - - ACCESSTOKEN_LOG_INFO(LABEL, "SendRequest success"); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "perm_active_status_change_callback_proxy.h" + +#include "accesstoken_log.h" +#include "perm_active_response_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermActiveStatusChangeCallbackProxy" +}; +} + +PermActiveStatusChangeCallbackProxy::PermActiveStatusChangeCallbackProxy(const sptr& impl) + : IRemoteProxy(impl) { +} + +PermActiveStatusChangeCallbackProxy::~PermActiveStatusChangeCallbackProxy() +{} + +void PermActiveStatusChangeCallbackProxy::ActiveStatusChangeCallback(ActiveChangeResponse& result) +{ + MessageParcel data; + data.WriteInterfaceToken(IPermActiveStatusCallback::GetDescriptor()); + + ActiveChangeResponseParcel resultParcel; + resultParcel.changeResponse = result; + if (!data.WriteParcelable(&resultParcel)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable"); + return; + } + + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + sptr remote = Remote(); + if (remote == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); + return; + } + int32_t requestResult = remote->SendRequest( + static_cast(IPermActiveStatusCallback::PERM_ACTIVE_STATUS_CHANGE), data, reply, option); + if (requestResult != NO_ERROR) { + ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); + return; + } + + ACCESSTOKEN_LOG_INFO(LABEL, "SendRequest success"); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/common/constant.cpp b/services/privacymanager/src/common/constant.cpp index 34fda467f258b1d64a42f07a37f98c7203b51854..aef53ed82560de72b96be940c0c7f98297bd03e8 100644 --- a/services/privacymanager/src/common/constant.cpp +++ b/services/privacymanager/src/common/constant.cpp @@ -1,74 +1,75 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "constant.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -const std::map Constant::PERMISSION_OPCODE_MAP = { - std::map::value_type("ohos.permission.ANSWER_CALL", Constant::OP_ANSWER_CALL), - std::map::value_type("ohos.permission.READ_CALENDAR", Constant::OP_READ_CALENDAR), - std::map::value_type("ohos.permission.WRITE_CALENDAR", Constant::OP_WRITE_CALENDAR), - std::map::value_type("ohos.permission.SEND_MESSAGES", Constant::OP_SEND_MESSAGES), - std::map::value_type("ohos.permission.WRITE_CALL_LOG", Constant::OP_WRITE_CALL_LOG), - std::map::value_type("ohos.permission.READ_CALL_LOG", Constant::OP_READ_CALL_LOG), - std::map::value_type("ohos.permission.READ_CELL_MESSAGES", Constant::OP_READ_CELL_MESSAGES), - std::map::value_type("ohos.permission.MICROPHONE", Constant::OP_MICROPHONE), - std::map::value_type( - "ohos.permission.RECEIVE_WAP_MESSAGES", Constant::OP_RECEIVE_WAP_MESSAGES), - std::map::value_type("ohos.permission.RECEIVE_SMS", Constant::OP_RECEIVE_SMS), - std::map::value_type("ohos.permission.RECEIVE_MMS", Constant::OP_RECEIVE_MMS), - std::map::value_type("ohos.permission.READ_MESSAGES", Constant::OP_READ_MESSAGES), - std::map::value_type("ohos.permission.READ_CONTACTS", Constant::OP_READ_CONTACTS), - std::map::value_type("ohos.permission.WRITE_CONTACTS", Constant::OP_WRITE_CONTACTS), - std::map::value_type( - "ohos.permission.LOCATION_IN_BACKGROUND", Constant::OP_LOCATION_IN_BACKGROUND), - std::map::value_type("ohos.permission.LOCATION", Constant::OP_LOCATION), - std::map::value_type("ohos.permission.MEDIA_LOCATION", Constant::OP_MEDIA_LOCATION), - std::map::value_type("ohos.permission.CAMERA", Constant::OP_CAMERA), - std::map::value_type("ohos.permission.READ_MEDIA", Constant::OP_READ_MEDIA), - std::map::value_type("ohos.permission.WRITE_MEDIA", Constant::OP_WRITE_MEDIA), - std::map::value_type("ohos.permission.ACTIVITY_MOTION", Constant::OP_ACTIVITY_MOTION), - std::map::value_type("ohos.permission.READ_HEALTH_DATA", Constant::OP_READ_HEALTH_DATA), - std::map::value_type("ohos.permission.MANAGE_VOICEMAIL", Constant::OP_MANAGE_VOICEMAIL), - std::map::value_type( - "ohos.permission.DISTRIBUTED_DATASYNC", Constant::OP_DISTRIBUTED_DATASYNC), -}; - -bool Constant::TransferPermissionToOpcode(const std::string& permissionName, int32_t& opCode) -{ - if (PERMISSION_OPCODE_MAP.count(permissionName) == 0) { - return false; - } - opCode = PERMISSION_OPCODE_MAP.at(permissionName); - return true; -} - -bool Constant::TransferOpcodeToPermission(int32_t opCode, std::string& permissionName) -{ - auto iter = std::find_if(PERMISSION_OPCODE_MAP.begin(), PERMISSION_OPCODE_MAP.end(), - [opCode](const std::map::value_type item) { - return item.second == opCode; - }); - if (iter == PERMISSION_OPCODE_MAP.end()) { - return false; - } - permissionName = iter->first; - return true; -} -} // namespace AccessToken -} // namespace Security +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "constant.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +const std::string Constant::COUNT_CMD = "COUNT"; +const std::map Constant::PERMISSION_OPCODE_MAP = { + std::map::value_type("ohos.permission.ANSWER_CALL", Constant::OP_ANSWER_CALL), + std::map::value_type("ohos.permission.READ_CALENDAR", Constant::OP_READ_CALENDAR), + std::map::value_type("ohos.permission.WRITE_CALENDAR", Constant::OP_WRITE_CALENDAR), + std::map::value_type("ohos.permission.SEND_MESSAGES", Constant::OP_SEND_MESSAGES), + std::map::value_type("ohos.permission.WRITE_CALL_LOG", Constant::OP_WRITE_CALL_LOG), + std::map::value_type("ohos.permission.READ_CALL_LOG", Constant::OP_READ_CALL_LOG), + std::map::value_type("ohos.permission.READ_CELL_MESSAGES", Constant::OP_READ_CELL_MESSAGES), + std::map::value_type("ohos.permission.MICROPHONE", Constant::OP_MICROPHONE), + std::map::value_type( + "ohos.permission.RECEIVE_WAP_MESSAGES", Constant::OP_RECEIVE_WAP_MESSAGES), + std::map::value_type("ohos.permission.RECEIVE_SMS", Constant::OP_RECEIVE_SMS), + std::map::value_type("ohos.permission.RECEIVE_MMS", Constant::OP_RECEIVE_MMS), + std::map::value_type("ohos.permission.READ_MESSAGES", Constant::OP_READ_MESSAGES), + std::map::value_type("ohos.permission.READ_CONTACTS", Constant::OP_READ_CONTACTS), + std::map::value_type("ohos.permission.WRITE_CONTACTS", Constant::OP_WRITE_CONTACTS), + std::map::value_type( + "ohos.permission.LOCATION_IN_BACKGROUND", Constant::OP_LOCATION_IN_BACKGROUND), + std::map::value_type("ohos.permission.LOCATION", Constant::OP_LOCATION), + std::map::value_type("ohos.permission.MEDIA_LOCATION", Constant::OP_MEDIA_LOCATION), + std::map::value_type("ohos.permission.CAMERA", Constant::OP_CAMERA), + std::map::value_type("ohos.permission.READ_MEDIA", Constant::OP_READ_MEDIA), + std::map::value_type("ohos.permission.WRITE_MEDIA", Constant::OP_WRITE_MEDIA), + std::map::value_type("ohos.permission.ACTIVITY_MOTION", Constant::OP_ACTIVITY_MOTION), + std::map::value_type("ohos.permission.READ_HEALTH_DATA", Constant::OP_READ_HEALTH_DATA), + std::map::value_type("ohos.permission.MANAGE_VOICEMAIL", Constant::OP_MANAGE_VOICEMAIL), + std::map::value_type( + "ohos.permission.DISTRIBUTED_DATASYNC", Constant::OP_DISTRIBUTED_DATASYNC), +}; + +bool Constant::TransferPermissionToOpcode(const std::string& permissionName, int32_t& opCode) +{ + if (PERMISSION_OPCODE_MAP.count(permissionName) == 0) { + return false; + } + opCode = PERMISSION_OPCODE_MAP.at(permissionName); + return true; +} + +bool Constant::TransferOpcodeToPermission(int32_t opCode, std::string& permissionName) +{ + auto iter = std::find_if(PERMISSION_OPCODE_MAP.begin(), PERMISSION_OPCODE_MAP.end(), + [opCode](const std::map::value_type item) { + return item.second == opCode; + }); + if (iter == PERMISSION_OPCODE_MAP.end()) { + return false; + } + permissionName = iter->first; + return true; +} +} // namespace AccessToken +} // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/services/privacymanager/src/common/time_util.cpp b/services/privacymanager/src/common/time_util.cpp index eff098ca94f6de4a0c15b42164334a3f18944c75..c445c54c3b4289b1c89f3a53df83b99857e1e438 100644 --- a/services/privacymanager/src/common/time_util.cpp +++ b/services/privacymanager/src/common/time_util.cpp @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "time_util.h" -#include - -namespace OHOS { -namespace Security { -namespace AccessToken { -int64_t TimeUtil::GetCurrentTimestamp() -{ - const time_t timestamp = time(NULL); - return static_cast(timestamp); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "time_util.h" +#include + +namespace OHOS { +namespace Security { +namespace AccessToken { +int64_t TimeUtil::GetCurrentTimestamp() +{ + const time_t timestamp = time(NULL); + return static_cast(timestamp); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/common/to_string.cpp b/services/privacymanager/src/common/to_string.cpp index 91b893e974c8245d3607f922c35b20177fb935f4..a1840112f719a7e550656ea4469c4a7772a1aede 100644 --- a/services/privacymanager/src/common/to_string.cpp +++ b/services/privacymanager/src/common/to_string.cpp @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "to_string.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -void ToString::DetailUsedRecordToString( - bool isAccessDetail, const std::vector& detailRecord, std::string& infos) -{ - if (isAccessDetail) { - infos.append(R"( "accessRecords": [)"); - } else { - infos.append(R"( "rejectRecords": [)"); - } - infos.append("\n"); - for (const auto& detail : detailRecord) { - infos.append(" {"); - infos.append("\n"); - infos.append(R"( "status": ")" + std::to_string(detail.status) + R"(")" + ",\n"); - infos.append(R"( "timestamp": ")" + std::to_string(detail.timestamp) + R"(")" + ",\n"); - infos.append(R"( "duration": )" + std::to_string(detail.accessDuration) + ",\n"); - infos.append(" },"); - infos.append("\n"); - } - - infos.append(" ]"); - infos.append("\n"); -} - -void ToString::PermissionUsedRecordToString( - const std::vector& permissionRecords, std::string& infos) -{ - infos.append(R"( "permissionRecords": [)"); - infos.append("\n"); - - for (const auto& perm : permissionRecords) { - infos.append(" {"); - infos.append("\n"); - infos.append(R"( "permissionName": ")" + perm.permissionName + R"(")" + ",\n"); - infos.append(R"( "accessCount": ")" + std::to_string(perm.accessCount) + R"(")" + ",\n"); - infos.append(R"( "rejectCount": )" + std::to_string(perm.rejectCount) + ",\n"); - infos.append(R"( "lastAccessTime": )" + std::to_string(perm.lastAccessTime) + ",\n"); - infos.append(R"( "lastRejectTime": )" + std::to_string(perm.lastRejectTime) + ",\n"); - infos.append(R"( "lastAccessDuration": )" + std::to_string(perm.lastAccessDuration) + ",\n"); - ToString::DetailUsedRecordToString(true, perm.accessRecords, infos); - ToString::DetailUsedRecordToString(false, perm.rejectRecords, infos); - infos.append(" },"); - infos.append("\n"); - } - - infos.append(" ]"); - infos.append("\n"); -} - -void ToString::BundleUsedRecordToString(const BundleUsedRecord& bundleRecord, std::string& infos) -{ - infos.append("{"); - infos.append("\n"); - infos.append(R"( "tokenId": )" + std::to_string(bundleRecord.tokenId) + ",\n"); - infos.append(R"( "isRemote": )" + std::to_string(bundleRecord.isRemote) + ",\n"); - infos.append(R"( "bundleName": )" + bundleRecord.bundleName + ",\n"); - infos.append(R"( "deviceId": )" + bundleRecord.deviceId + ",\n"); - - ToString::PermissionUsedRecordToString(bundleRecord.permissionRecords, infos); - - infos.append("}"); - infos.append("\n"); -} - -void ToString::PermissionUsedResultToString(const PermissionUsedResult& result, std::string& infos) -{ - if (result.bundleRecords.empty()) { - return; - } - infos.append(R"("beginTime": )" + std::to_string(result.beginTimeMillis) + ",\n"); - infos.append(R"("endTime": )" + std::to_string(result.endTimeMillis) + ",\n"); - - for (const auto& res : result.bundleRecords) { - ToString::BundleUsedRecordToString(res, infos); - } -} -} // namespace AccessToken -} // namespace Security +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "to_string.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +void ToString::DetailUsedRecordToString( + bool isAccessDetail, const std::vector& detailRecord, std::string& infos) +{ + if (isAccessDetail) { + infos.append(R"( "accessRecords": [)"); + } else { + infos.append(R"( "rejectRecords": [)"); + } + infos.append("\n"); + for (const auto& detail : detailRecord) { + infos.append(" {"); + infos.append("\n"); + infos.append(R"( "status": ")" + std::to_string(detail.status) + R"(")" + ",\n"); + infos.append(R"( "timestamp": ")" + std::to_string(detail.timestamp) + R"(")" + ",\n"); + infos.append(R"( "duration": )" + std::to_string(detail.accessDuration) + ",\n"); + infos.append(" },"); + infos.append("\n"); + } + + infos.append(" ]"); + infos.append("\n"); +} + +void ToString::PermissionUsedRecordToString( + const std::vector& permissionRecords, std::string& infos) +{ + infos.append(R"( "permissionRecords": [)"); + infos.append("\n"); + + for (const auto& perm : permissionRecords) { + infos.append(" {"); + infos.append("\n"); + infos.append(R"( "permissionName": ")" + perm.permissionName + R"(")" + ",\n"); + infos.append(R"( "accessCount": ")" + std::to_string(perm.accessCount) + R"(")" + ",\n"); + infos.append(R"( "rejectCount": )" + std::to_string(perm.rejectCount) + ",\n"); + infos.append(R"( "lastAccessTime": )" + std::to_string(perm.lastAccessTime) + ",\n"); + infos.append(R"( "lastRejectTime": )" + std::to_string(perm.lastRejectTime) + ",\n"); + infos.append(R"( "lastAccessDuration": )" + std::to_string(perm.lastAccessDuration) + ",\n"); + ToString::DetailUsedRecordToString(true, perm.accessRecords, infos); + ToString::DetailUsedRecordToString(false, perm.rejectRecords, infos); + infos.append(" },"); + infos.append("\n"); + } + + infos.append(" ]"); + infos.append("\n"); +} + +void ToString::BundleUsedRecordToString(const BundleUsedRecord& bundleRecord, std::string& infos) +{ + infos.append("{"); + infos.append("\n"); + infos.append(R"( "tokenId": )" + std::to_string(bundleRecord.tokenId) + ",\n"); + infos.append(R"( "isRemote": )" + std::to_string(bundleRecord.isRemote) + ",\n"); + infos.append(R"( "bundleName": )" + bundleRecord.bundleName + ",\n"); + infos.append(R"( "deviceId": )" + bundleRecord.deviceId + ",\n"); + + ToString::PermissionUsedRecordToString(bundleRecord.permissionRecords, infos); + + infos.append("}"); + infos.append("\n"); +} + +void ToString::PermissionUsedResultToString(const PermissionUsedResult& result, std::string& infos) +{ + if (result.bundleRecords.empty()) { + return; + } + infos.append(R"("beginTime": )" + std::to_string(result.beginTimeMillis) + ",\n"); + infos.append(R"("endTime": )" + std::to_string(result.endTimeMillis) + ",\n"); + + for (const auto& res : result.bundleRecords) { + ToString::BundleUsedRecordToString(res, infos); + } +} +} // namespace AccessToken +} // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/services/privacymanager/src/database/data_translator.cpp b/services/privacymanager/src/database/data_translator.cpp index 27753200fbf65e5bedc50cfe939a1f340f8d5d21..90488ca86021863e86b02f49c7bf61c823ed6efd 100644 --- a/services/privacymanager/src/database/data_translator.cpp +++ b/services/privacymanager/src/database/data_translator.cpp @@ -1,104 +1,104 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "data_translator.h" - -#include "constant.h" -#include "field_const.h" -#include "time_util.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -int32_t DataTranslator::TranslationIntoGenericValues(const PermissionUsedRequest& request, - GenericValues& andGenericValues, GenericValues& orGenericValues) -{ - int64_t begin = request.beginTimeMillis; - int64_t end = request.endTimeMillis; - if ((begin < 0) || (end < 0) || (begin > end)) { - return Constant::FAILURE; - } - - if (request.flag != FLAG_PERMISSION_USAGE_SUMMARY && request.flag != FLAG_PERMISSION_USAGE_DETAIL) { - return Constant::FAILURE; - } - - if (begin == 0 && end == 0) { - int64_t beginTime = TimeUtil::GetCurrentTimestamp() - Constant::LATEST_RECORD_TIME; - begin = (beginTime < 0) ? 0 : beginTime; - end = TimeUtil::GetCurrentTimestamp(); - } - - if (begin != 0) { - andGenericValues.Put(FIELD_TIMESTAMP_BEGIN, begin); - } - if (end != 0) { - andGenericValues.Put(FIELD_TIMESTAMP_END, end); - } - - for (const auto& perm : request.permissionList) { - int32_t opCode; - if (Constant::TransferPermissionToOpcode(perm, opCode)) { - orGenericValues.Put(FIELD_OP_CODE, opCode); - } else { - orGenericValues.Put(FIELD_OP_CODE, Constant::OP_INVALID); - } - } - return Constant::SUCCESS; -} - -int32_t DataTranslator::TranslationGenericValuesIntoPermissionUsedRecord(const GenericValues& inGenericValues, - PermissionUsedRecord& permissionRecord) -{ - std::string permission; - int32_t opCode = inGenericValues.GetInt(FIELD_OP_CODE); - if (!Constant::TransferOpcodeToPermission(opCode, permission)) { - return Constant::FAILURE; - } - - int64_t timestamp = inGenericValues.GetInt64(FIELD_TIMESTAMP); - permissionRecord.permissionName = permission; - - if (inGenericValues.GetInt(FIELD_ACCESS_COUNT) != 0) { - permissionRecord.accessCount = inGenericValues.GetInt(FIELD_ACCESS_COUNT); - permissionRecord.lastAccessTime = timestamp; - permissionRecord.lastAccessDuration = inGenericValues.GetInt64(FIELD_ACCESS_DURATION); - } - - if (inGenericValues.GetInt(FIELD_REJECT_COUNT) != 0) { - permissionRecord.rejectCount = inGenericValues.GetInt(FIELD_REJECT_COUNT); - permissionRecord.lastRejectTime = timestamp; - } - - if (inGenericValues.GetInt(FIELD_FLAG) == 0) { - return Constant::SUCCESS; - } - - UsedRecordDetail detail; - detail.status = inGenericValues.GetInt(FIELD_STATUS); - if (permissionRecord.lastAccessTime > 0) { - detail.timestamp = permissionRecord.lastAccessTime; - detail.accessDuration = inGenericValues.GetInt64(FIELD_ACCESS_DURATION); - permissionRecord.accessRecords.emplace_back(detail); - } - if (permissionRecord.lastRejectTime > 0) { - detail.timestamp = permissionRecord.lastRejectTime; - permissionRecord.rejectRecords.emplace_back(detail); - } - return Constant::SUCCESS; -} -} // namespace AccessToken -} // namespace Security +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "data_translator.h" + +#include "constant.h" +#include "field_const.h" +#include "time_util.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +int32_t DataTranslator::TranslationIntoGenericValues(const PermissionUsedRequest& request, + GenericValues& andGenericValues, GenericValues& orGenericValues) +{ + int64_t begin = request.beginTimeMillis; + int64_t end = request.endTimeMillis; + if ((begin < 0) || (end < 0) || (begin > end)) { + return Constant::FAILURE; + } + + if (request.flag != FLAG_PERMISSION_USAGE_SUMMARY && request.flag != FLAG_PERMISSION_USAGE_DETAIL) { + return Constant::FAILURE; + } + + if (begin == 0 && end == 0) { + int64_t beginTime = TimeUtil::GetCurrentTimestamp() - Constant::LATEST_RECORD_TIME; + begin = (beginTime < 0) ? 0 : beginTime; + end = TimeUtil::GetCurrentTimestamp(); + } + + if (begin != 0) { + andGenericValues.Put(FIELD_TIMESTAMP_BEGIN, begin); + } + if (end != 0) { + andGenericValues.Put(FIELD_TIMESTAMP_END, end); + } + + for (const auto& perm : request.permissionList) { + int32_t opCode; + if (Constant::TransferPermissionToOpcode(perm, opCode)) { + orGenericValues.Put(FIELD_OP_CODE, opCode); + } else { + orGenericValues.Put(FIELD_OP_CODE, Constant::OP_INVALID); + } + } + return Constant::SUCCESS; +} + +int32_t DataTranslator::TranslationGenericValuesIntoPermissionUsedRecord(const GenericValues& inGenericValues, + PermissionUsedRecord& permissionRecord) +{ + std::string permission; + int32_t opCode = inGenericValues.GetInt(FIELD_OP_CODE); + if (!Constant::TransferOpcodeToPermission(opCode, permission)) { + return Constant::FAILURE; + } + + int64_t timestamp = inGenericValues.GetInt64(FIELD_TIMESTAMP); + permissionRecord.permissionName = permission; + + if (inGenericValues.GetInt(FIELD_ACCESS_COUNT) != 0) { + permissionRecord.accessCount = inGenericValues.GetInt(FIELD_ACCESS_COUNT); + permissionRecord.lastAccessTime = timestamp; + permissionRecord.lastAccessDuration = inGenericValues.GetInt64(FIELD_ACCESS_DURATION); + } + + if (inGenericValues.GetInt(FIELD_REJECT_COUNT) != 0) { + permissionRecord.rejectCount = inGenericValues.GetInt(FIELD_REJECT_COUNT); + permissionRecord.lastRejectTime = timestamp; + } + + if (inGenericValues.GetInt(FIELD_FLAG) == 0) { + return Constant::SUCCESS; + } + + UsedRecordDetail detail; + detail.status = inGenericValues.GetInt(FIELD_STATUS); + if (permissionRecord.lastAccessTime > 0) { + detail.timestamp = permissionRecord.lastAccessTime; + detail.accessDuration = inGenericValues.GetInt64(FIELD_ACCESS_DURATION); + permissionRecord.accessRecords.emplace_back(detail); + } + if (permissionRecord.lastRejectTime > 0) { + detail.timestamp = permissionRecord.lastRejectTime; + permissionRecord.rejectRecords.emplace_back(detail); + } + return Constant::SUCCESS; +} +} // namespace AccessToken +} // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/services/privacymanager/src/database/permission_used_record_db.cpp b/services/privacymanager/src/database/permission_used_record_db.cpp index 1e216b7a5f085f75af83268494ee0ede684bee33..04cda3e7fa7db3c92bdf9d868046901eba729ed7 100644 --- a/services/privacymanager/src/database/permission_used_record_db.cpp +++ b/services/privacymanager/src/database/permission_used_record_db.cpp @@ -1,413 +1,414 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_used_record_db.h" - -#include "accesstoken_log.h" -#include "constant.h" -#include "field_const.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermissionUsedRecordDb" -}; -static const std::string FIELD_COUNT_NUMBER = "count"; -} - -PermissionUsedRecordDb& PermissionUsedRecordDb::GetInstance() -{ - static PermissionUsedRecordDb instance; - return instance; -} - -PermissionUsedRecordDb::~PermissionUsedRecordDb() -{ - Close(); -} - -void PermissionUsedRecordDb::OnCreate() -{ - ACCESSTOKEN_LOG_INFO(LABEL, "Entry"); - CreatePermissionRecordTable(); -} - -void PermissionUsedRecordDb::OnUpdate() -{ - ACCESSTOKEN_LOG_INFO(LABEL, "Entry"); -} - -PermissionUsedRecordDb::PermissionUsedRecordDb() : SqliteHelper(DATABASE_NAME, DATABASE_PATH, DATABASE_VERSION) -{ - SqliteTable permissionRecordTable; - permissionRecordTable.tableName_ = PERMISSION_RECORD_TABLE; - permissionRecordTable.tableColumnNames_ = { - FIELD_TOKEN_ID, - FIELD_OP_CODE, - FIELD_STATUS, - FIELD_TIMESTAMP, - FIELD_ACCESS_DURATION, - FIELD_ACCESS_COUNT, - FIELD_REJECT_COUNT - }; - - dataTypeToSqlTable_ = { - {PERMISSION_RECORD, permissionRecordTable}, - }; - Open(); -} - -int32_t PermissionUsedRecordDb::Add(DataType type, const std::vector& values) -{ - OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); - std::string prepareSql = CreateInsertPrepareSqlCmd(type); - auto statement = Prepare(prepareSql); - BeginTransaction(); - bool isExecuteSuccessfully = true; - for (const auto& value : values) { - std::vector columnNames = value.GetAllKeys(); - for (const auto& columnName : columnNames) { - statement.Bind(columnName, value.Get(columnName)); - } - int32_t ret = statement.Step(); - if (ret != Statement::State::DONE) { - ACCESSTOKEN_LOG_ERROR(LABEL, "failed, errorMsg: %{public}s", SpitError().c_str()); - isExecuteSuccessfully = false; - } - statement.Reset(); - } - if (!isExecuteSuccessfully) { - ACCESSTOKEN_LOG_ERROR(LABEL, "rollback transaction."); - RollbackTransaction(); - return FAILURE; - } - ACCESSTOKEN_LOG_DEBUG(LABEL, "commit transaction."); - CommitTransaction(); - return SUCCESS; -} - -int32_t PermissionUsedRecordDb::Remove(DataType type, const GenericValues& conditions) -{ - OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); - std::vector columnNames = conditions.GetAllKeys(); - std::string prepareSql = CreateDeletePrepareSqlCmd(type, columnNames); - auto statement = Prepare(prepareSql); - for (const auto& columnName : columnNames) { - statement.Bind(columnName, conditions.Get(columnName)); - } - int32_t ret = statement.Step(); - return (ret == Statement::State::DONE) ? SUCCESS : FAILURE; -} - -int32_t PermissionUsedRecordDb::Modify( - DataType type, const GenericValues& modifyValues, const GenericValues& conditions) -{ - OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); - std::vector modifyColumns = modifyValues.GetAllKeys(); - std::vector conditionColumns = conditions.GetAllKeys(); - std::string prepareSql = CreateUpdatePrepareSqlCmd(type, modifyColumns, conditionColumns); - auto statement = Prepare(prepareSql); - for (const auto& columnName : modifyColumns) { - statement.Bind(columnName, modifyValues.Get(columnName)); - } - for (const auto& columnName : conditionColumns) { - statement.Bind(columnName, conditions.Get(columnName)); - } - int32_t ret = statement.Step(); - return (ret == Statement::State::DONE) ? SUCCESS : FAILURE; -} - -int32_t PermissionUsedRecordDb::FindByConditions(DataType type, const GenericValues& andConditions, - const GenericValues& orConditions, std::vector& results) -{ - OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); - std::vector andColumns = andConditions.GetAllKeys(); - std::vector orColumns = orConditions.GetAllKeys(); - std::string prepareSql = CreateSelectByConditionPrepareSqlCmd(type, andColumns, orColumns); - auto statement = Prepare(prepareSql); - - for (const auto& columnName : andColumns) { - statement.Bind(columnName, andConditions.Get(columnName)); - } - for (const auto& columnName : orColumns) { - statement.Bind(columnName, orConditions.Get(columnName)); - } - - while (statement.Step() == Statement::State::ROW) { - int32_t columnCount = statement.GetColumnCount(); - GenericValues value; - for (int32_t i = 0; i < columnCount; i++) { - if (statement.GetColumnName(i) == FIELD_TIMESTAMP || statement.GetColumnName(i) == FIELD_ACCESS_DURATION) { - value.Put(statement.GetColumnName(i), statement.GetValue(i, true)); - } else { - value.Put(statement.GetColumnName(i), statement.GetValue(i, false)); - } - } - results.emplace_back(value); - } - return SUCCESS; -} - -int32_t PermissionUsedRecordDb::GetDistinctValue(DataType type, - const std::string& condition, std::vector& results) -{ - OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); - std::string getDistinctValueSql = CreateGetDistinctValue(type, condition); - auto statement = Prepare(getDistinctValueSql); - while (statement.Step() == Statement::State::ROW) { - int32_t columnCount = statement.GetColumnCount(); - GenericValues value; - for (int32_t i = 0; i < columnCount; i++) { - if (statement.GetColumnName(i) == FIELD_TOKEN_ID) { - value.Put(statement.GetColumnName(i), statement.GetValue(i, false)); - } else if (statement.GetColumnName(i) == FIELD_DEVICE_ID) { - value.Put(statement.GetColumnName(i), statement.GetColumnString(i)); - } - } - results.emplace_back(value); - } - return SUCCESS; -} - -void PermissionUsedRecordDb::Count(DataType type, GenericValues& result) -{ - OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); - std::string countSql = CreateCountPrepareSqlCmd(type); - auto countStatement = Prepare(countSql); - if (countStatement.Step() == Statement::State::ROW) { - int32_t column = 0; - result.Put(FIELD_COUNT_NUMBER, countStatement.GetValue(column, true)); - } -} - -int32_t PermissionUsedRecordDb::DeleteExpireRecords(DataType type, - const GenericValues& andConditions) -{ - OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); - std::vector andColumns = andConditions.GetAllKeys(); - if (!andColumns.empty()) { - std::string deleteExpireSql = CreateDeleteExpireRecordsPrepareSqlCmd(type, andColumns); - auto deleteExpireStatement = Prepare(deleteExpireSql); - for (const auto& columnName : andColumns) { - deleteExpireStatement.Bind(columnName, andConditions.Get(columnName)); - } - if (deleteExpireStatement.Step() != Statement::State::DONE) { - return FAILURE; - } - } - return SUCCESS; -} - -int32_t PermissionUsedRecordDb::DeleteExcessiveRecords(DataType type, uint32_t excessiveSize) -{ - OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); - std::string deleteExcessiveSql = CreateDeleteExcessiveRecordsPrepareSqlCmd(type, excessiveSize); - auto deleteExcessiveStatement = Prepare(deleteExcessiveSql); - if (deleteExcessiveStatement.Step() != Statement::State::DONE) { - return FAILURE; - } - return SUCCESS; -} - -std::string PermissionUsedRecordDb::CreateInsertPrepareSqlCmd(DataType type) const -{ - auto it = dataTypeToSqlTable_.find(type); - if (it == dataTypeToSqlTable_.end()) { - return std::string(); - } - std::string sql = "insert into " + it->second.tableName_ + " values("; - int32_t i = 1; - for (const auto& columnName : it->second.tableColumnNames_) { - sql.append(":" + columnName); - if (i < (int32_t) it->second.tableColumnNames_.size()) { - sql.append(","); - } - i += 1; - } - sql.append(")"); - return sql; -} - -std::string PermissionUsedRecordDb::CreateDeletePrepareSqlCmd( - DataType type, const std::vector& columnNames) const -{ - auto it = dataTypeToSqlTable_.find(type); - if (it == dataTypeToSqlTable_.end()) { - return std::string(); - } - std::string sql = "delete from " + it->second.tableName_ + " where 1 = 1"; - for (const auto& columnName : columnNames) { - sql.append(" and "); - sql.append(columnName + "=:" + columnName); - } - return sql; -} - -std::string PermissionUsedRecordDb::CreateUpdatePrepareSqlCmd(DataType type, - const std::vector& modifyColumns, const std::vector& conditionColumns) const -{ - if (modifyColumns.empty()) { - return std::string(); - } - - auto it = dataTypeToSqlTable_.find(type); - if (it == dataTypeToSqlTable_.end()) { - return std::string(); - } - - std::string sql = "update " + it->second.tableName_ + " set "; - int32_t i = 1; - for (const auto& columnName : modifyColumns) { - sql.append(columnName + "=:" + columnName); - if (i < (int32_t) modifyColumns.size()) { - sql.append(","); - } - i += 1; - } - - if (!conditionColumns.empty()) { - sql.append(" where 1 = 1"); - for (const auto& columnName : conditionColumns) { - sql.append(" and "); - sql.append(columnName + "=:" + columnName); - } - } - return sql; -} - -std::string PermissionUsedRecordDb::CreateSelectByConditionPrepareSqlCmd(DataType type, - const std::vector& andColumns, const std::vector& orColumns) const -{ - auto it = dataTypeToSqlTable_.find(type); - if (it == dataTypeToSqlTable_.end()) { - return std::string(); - } - - std::string sql = "select * from " + it->second.tableName_ + " where 1 = 1"; - for (const auto& andColName : andColumns) { - if (andColName == FIELD_TIMESTAMP_BEGIN) { - sql.append(" and "); - sql.append(FIELD_TIMESTAMP + " >=:" + andColName); - } else if (andColName == FIELD_TIMESTAMP_END) { - sql.append(" and "); - sql.append(FIELD_TIMESTAMP + " <=:" + andColName); - } else { - sql.append(" and "); - sql.append(andColName + "=:" + andColName); - } - } - if (!orColumns.empty()) { - sql.append(" and ("); - for (const auto& orColName : orColumns) { - if (orColName.find(FIELD_OP_CODE) != std::string::npos) { - sql.append(FIELD_OP_CODE + " =:" + orColName); - sql.append(" or "); - } - } - sql.append("0)"); - } - return sql; -} - -std::string PermissionUsedRecordDb::CreateCountPrepareSqlCmd(DataType type) const -{ - auto it = dataTypeToSqlTable_.find(type); - if (it == dataTypeToSqlTable_.end()) { - return std::string(); - } - std::string sql = "select count(*) from " + it->second.tableName_; - return sql; -} - -std::string PermissionUsedRecordDb::CreateDeleteExpireRecordsPrepareSqlCmd(DataType type, - const std::vector& andColumns) const -{ - auto it = dataTypeToSqlTable_.find(type); - if (it == dataTypeToSqlTable_.end()) { - return std::string(); - } - std::string sql = "delete from " + it->second.tableName_ + " where "; - sql.append(FIELD_TIMESTAMP + " in (select "); - sql.append(FIELD_TIMESTAMP + " from " + it->second.tableName_ + " where 1 = 1"); - for (const auto& andColName : andColumns) { - if (andColName == FIELD_TIMESTAMP_BEGIN) { - sql.append(" and "); - sql.append(FIELD_TIMESTAMP + " >=:" + andColName); - } else if (andColName == FIELD_TIMESTAMP_END) { - sql.append(" and "); - sql.append(FIELD_TIMESTAMP + " <=:" + andColName); - } else { - sql.append(" and "); - sql.append(andColName + "=:" + andColName); - } - } - sql.append(" )"); - return sql; -} - -std::string PermissionUsedRecordDb::CreateDeleteExcessiveRecordsPrepareSqlCmd(DataType type, - uint32_t excessiveSize) const -{ - auto it = dataTypeToSqlTable_.find(type); - if (it == dataTypeToSqlTable_.end()) { - return std::string(); - } - std::string sql = "delete from " + it->second.tableName_ + " where "; - sql.append(FIELD_TIMESTAMP + " in (select "); - sql.append(FIELD_TIMESTAMP + " from " + it->second.tableName_ + " order by "); - sql.append(FIELD_TIMESTAMP + " limit "); - sql.append(std::to_string(excessiveSize) + " )"); - return sql; -} - -std::string PermissionUsedRecordDb::CreateGetDistinctValue(DataType type, - const std::string conditionColumns) const -{ - auto it = dataTypeToSqlTable_.find(type); - if (it == dataTypeToSqlTable_.end()) { - return std::string(); - } - std::string sql = "select distinct "; - sql.append(conditionColumns + " from "+ it->second.tableName_); - return sql; -} - -int32_t PermissionUsedRecordDb::CreatePermissionRecordTable() const -{ - auto it = dataTypeToSqlTable_.find(DataType::PERMISSION_RECORD); - if (it == dataTypeToSqlTable_.end()) { - return FAILURE; - } - std::string sql = "create table if not exists "; - sql.append(it->second.tableName_ + " (") - .append(FIELD_TOKEN_ID + " integer not null,") - .append(FIELD_OP_CODE + " integer not null,") - .append(FIELD_STATUS + " integer not null,") - .append(FIELD_TIMESTAMP + " integer not null,") - .append(FIELD_ACCESS_DURATION + " integer not null,") - .append(FIELD_ACCESS_COUNT + " integer not null,") - .append(FIELD_REJECT_COUNT + " integer not null,") - .append("primary key(" + FIELD_TOKEN_ID) - .append("," + FIELD_OP_CODE) - .append("," + FIELD_STATUS) - .append("," + FIELD_TIMESTAMP) - .append("))"); - return ExecuteSql(sql); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_used_record_db.h" + +#include "accesstoken_log.h" +#include "constant.h" +#include "field_const.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermissionUsedRecordDb" +}; +} + +PermissionUsedRecordDb& PermissionUsedRecordDb::GetInstance() +{ + static PermissionUsedRecordDb instance; + return instance; +} + +PermissionUsedRecordDb::~PermissionUsedRecordDb() +{ + Close(); +} + +void PermissionUsedRecordDb::OnCreate() +{ + ACCESSTOKEN_LOG_INFO(LABEL, "Entry"); + CreatePermissionRecordTable(); +} + +void PermissionUsedRecordDb::OnUpdate() +{ + ACCESSTOKEN_LOG_INFO(LABEL, "Entry"); +} + +PermissionUsedRecordDb::PermissionUsedRecordDb() : SqliteHelper(DATABASE_NAME, DATABASE_PATH, DATABASE_VERSION) +{ + SqliteTable permissionRecordTable; + permissionRecordTable.tableName_ = PERMISSION_RECORD_TABLE; + permissionRecordTable.tableColumnNames_ = { + FIELD_TOKEN_ID, + FIELD_OP_CODE, + FIELD_STATUS, + FIELD_TIMESTAMP, + FIELD_ACCESS_DURATION, + FIELD_ACCESS_COUNT, + FIELD_REJECT_COUNT + }; + + dataTypeToSqlTable_ = { + {PERMISSION_RECORD, permissionRecordTable}, + }; + Open(); +} + +int32_t PermissionUsedRecordDb::Add(DataType type, const std::vector& values) +{ + OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); + std::string prepareSql = CreateInsertPrepareSqlCmd(type); + auto statement = Prepare(prepareSql); + BeginTransaction(); + bool isExecuteSuccessfully = true; + for (const auto& value : values) { + std::vector columnNames = value.GetAllKeys(); + for (const auto& columnName : columnNames) { + statement.Bind(columnName, value.Get(columnName)); + } + int32_t ret = statement.Step(); + if (ret != Statement::State::DONE) { + ACCESSTOKEN_LOG_ERROR(LABEL, "failed, errorMsg: %{public}s", SpitError().c_str()); + isExecuteSuccessfully = false; + } + statement.Reset(); + } + if (!isExecuteSuccessfully) { + ACCESSTOKEN_LOG_ERROR(LABEL, "rollback transaction."); + RollbackTransaction(); + return FAILURE; + } + ACCESSTOKEN_LOG_DEBUG(LABEL, "commit transaction."); + CommitTransaction(); + return SUCCESS; +} + +int32_t PermissionUsedRecordDb::Remove(DataType type, const GenericValues& conditions) +{ + OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); + std::vector columnNames = conditions.GetAllKeys(); + std::string prepareSql = CreateDeletePrepareSqlCmd(type, columnNames); + auto statement = Prepare(prepareSql); + for (const auto& columnName : columnNames) { + statement.Bind(columnName, conditions.Get(columnName)); + } + int32_t ret = statement.Step(); + return (ret == Statement::State::DONE) ? SUCCESS : FAILURE; +} + +int32_t PermissionUsedRecordDb::Modify( + DataType type, const GenericValues& modifyValues, const GenericValues& conditions) +{ + OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); + std::vector modifyColumns = modifyValues.GetAllKeys(); + std::vector conditionColumns = conditions.GetAllKeys(); + std::string prepareSql = CreateUpdatePrepareSqlCmd(type, modifyColumns, conditionColumns); + auto statement = Prepare(prepareSql); + for (const auto& columnName : modifyColumns) { + statement.Bind(columnName, modifyValues.Get(columnName)); + } + for (const auto& columnName : conditionColumns) { + statement.Bind(columnName, conditions.Get(columnName)); + } + int32_t ret = statement.Step(); + return (ret == Statement::State::DONE) ? SUCCESS : FAILURE; +} + +int32_t PermissionUsedRecordDb::FindByConditions(DataType type, const GenericValues& andConditions, + const GenericValues& orConditions, std::vector& results) +{ + OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); + std::vector andColumns = andConditions.GetAllKeys(); + std::vector orColumns = orConditions.GetAllKeys(); + std::string prepareSql = CreateSelectByConditionPrepareSqlCmd(type, andColumns, orColumns); + auto statement = Prepare(prepareSql); + + for (const auto& columnName : andColumns) { + statement.Bind(columnName, andConditions.Get(columnName)); + } + for (const auto& columnName : orColumns) { + statement.Bind(columnName, orConditions.Get(columnName)); + } + + while (statement.Step() == Statement::State::ROW) { + int32_t columnCount = statement.GetColumnCount(); + GenericValues value; + for (int32_t i = 0; i < columnCount; i++) { + if (statement.GetColumnName(i) == FIELD_TIMESTAMP || statement.GetColumnName(i) == FIELD_ACCESS_DURATION) { + value.Put(statement.GetColumnName(i), statement.GetValue(i, true)); + } else { + value.Put(statement.GetColumnName(i), statement.GetValue(i, false)); + } + } + results.emplace_back(value); + } + return SUCCESS; +} + +int32_t PermissionUsedRecordDb::GetDistinctValue(DataType type, + const std::string& condition, std::vector& results) +{ + OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); + std::string getDistinctValueSql = CreateGetDistinctValue(type, condition); + auto statement = Prepare(getDistinctValueSql); + while (statement.Step() == Statement::State::ROW) { + int32_t columnCount = statement.GetColumnCount(); + GenericValues value; + for (int32_t i = 0; i < columnCount; i++) { + if (statement.GetColumnName(i) == FIELD_TOKEN_ID) { + value.Put(statement.GetColumnName(i), statement.GetValue(i, false)); + } else if (statement.GetColumnName(i) == FIELD_DEVICE_ID) { + value.Put(statement.GetColumnName(i), statement.GetColumnString(i)); + } + } + results.emplace_back(value); + } + return SUCCESS; +} + +int32_t PermissionUsedRecordDb::Count(DataType type, GenericValues& result) +{ + OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); + std::string countSql = CreateCountPrepareSqlCmd(type); + auto countStatement = Prepare(countSql); + if (countStatement.Step() == Statement::State::ROW) { + int32_t column = 0; + result.Put(Constant::COUNT_CMD, countStatement.GetValue(column, true)); + } + return SUCCESS; +} + +int32_t PermissionUsedRecordDb::DeleteExpireRecords(DataType type, + const GenericValues& andConditions) +{ + OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); + std::vector andColumns = andConditions.GetAllKeys(); + if (!andColumns.empty()) { + std::string deleteExpireSql = CreateDeleteExpireRecordsPrepareSqlCmd(type, andColumns); + auto deleteExpireStatement = Prepare(deleteExpireSql); + for (const auto& columnName : andColumns) { + deleteExpireStatement.Bind(columnName, andConditions.Get(columnName)); + } + int32_t ret = deleteExpireStatement.Step(); + if (ret != Statement::State::DONE) { + return FAILURE; + } + } + return SUCCESS; +} + +int32_t PermissionUsedRecordDb::DeleteExcessiveRecords(DataType type, unsigned excessiveSize) +{ + OHOS::Utils::UniqueWriteGuard lock(this->rwLock_); + std::string deleteExcessiveSql = CreateDeleteExcessiveRecordsPrepareSqlCmd(type, excessiveSize); + auto deleteExcessiveStatement = Prepare(deleteExcessiveSql); + if (deleteExcessiveStatement.Step() != Statement::State::DONE) { + return FAILURE; + } + return SUCCESS; +} + +std::string PermissionUsedRecordDb::CreateInsertPrepareSqlCmd(DataType type) const +{ + auto it = dataTypeToSqlTable_.find(type); + if (it == dataTypeToSqlTable_.end()) { + return std::string(); + } + std::string sql = "insert into " + it->second.tableName_ + " values("; + int32_t i = 1; + for (const auto& columnName : it->second.tableColumnNames_) { + sql.append(":" + columnName); + if (i < (int32_t) it->second.tableColumnNames_.size()) { + sql.append(","); + } + i += 1; + } + sql.append(")"); + return sql; +} + +std::string PermissionUsedRecordDb::CreateDeletePrepareSqlCmd( + DataType type, const std::vector& columnNames) const +{ + auto it = dataTypeToSqlTable_.find(type); + if (it == dataTypeToSqlTable_.end()) { + return std::string(); + } + std::string sql = "delete from " + it->second.tableName_ + " where 1 = 1"; + for (const auto& columnName : columnNames) { + sql.append(" and "); + sql.append(columnName + "=:" + columnName); + } + return sql; +} + +std::string PermissionUsedRecordDb::CreateUpdatePrepareSqlCmd(DataType type, + const std::vector& modifyColumns, const std::vector& conditionColumns) const +{ + if (modifyColumns.empty()) { + return std::string(); + } + + auto it = dataTypeToSqlTable_.find(type); + if (it == dataTypeToSqlTable_.end()) { + return std::string(); + } + + std::string sql = "update " + it->second.tableName_ + " set "; + int32_t i = 1; + for (const auto& columnName : modifyColumns) { + sql.append(columnName + "=:" + columnName); + if (i < (int32_t) modifyColumns.size()) { + sql.append(","); + } + i += 1; + } + + if (!conditionColumns.empty()) { + sql.append(" where 1 = 1"); + for (const auto& columnName : conditionColumns) { + sql.append(" and "); + sql.append(columnName + "=:" + columnName); + } + } + return sql; +} + +std::string PermissionUsedRecordDb::CreateSelectByConditionPrepareSqlCmd(DataType type, + const std::vector& andColumns, const std::vector& orColumns) const +{ + auto it = dataTypeToSqlTable_.find(type); + if (it == dataTypeToSqlTable_.end()) { + return std::string(); + } + + std::string sql = "select * from " + it->second.tableName_ + " where 1 = 1"; + for (const auto& andColName : andColumns) { + if (andColName == FIELD_TIMESTAMP_BEGIN) { + sql.append(" and "); + sql.append(FIELD_TIMESTAMP + " >=:" + andColName); + } else if (andColName == FIELD_TIMESTAMP_END) { + sql.append(" and "); + sql.append(FIELD_TIMESTAMP + " <=:" + andColName); + } else { + sql.append(" and "); + sql.append(andColName + "=:" + andColName); + } + } + if (!orColumns.empty()) { + sql.append(" and ("); + for (const auto& orColName : orColumns) { + if (orColName.find(FIELD_OP_CODE) != std::string::npos) { + sql.append(FIELD_OP_CODE + " =:" + orColName); + sql.append(" or "); + } + } + sql.append("0)"); + } + return sql; +} + +std::string PermissionUsedRecordDb::CreateCountPrepareSqlCmd(DataType type) const +{ + auto it = dataTypeToSqlTable_.find(type); + if (it == dataTypeToSqlTable_.end()) { + return std::string(); + } + std::string sql = "select count(*) from " + it->second.tableName_; + return sql; +} + +std::string PermissionUsedRecordDb::CreateDeleteExpireRecordsPrepareSqlCmd(DataType type, + const std::vector& andColumns) const +{ + auto it = dataTypeToSqlTable_.find(type); + if (it == dataTypeToSqlTable_.end()) { + return std::string(); + } + std::string sql = "delete from " + it->second.tableName_ + " where "; + sql.append(FIELD_TIMESTAMP + " in (select "); + sql.append(FIELD_TIMESTAMP + " from " + it->second.tableName_ + " where 1 = 1"); + for (const auto& andColName : andColumns) { + if (andColName == FIELD_TIMESTAMP_BEGIN) { + sql.append(" and "); + sql.append(FIELD_TIMESTAMP + " >=:" + andColName); + } else if (andColName == FIELD_TIMESTAMP_END) { + sql.append(" and "); + sql.append(FIELD_TIMESTAMP + " <=:" + andColName); + } else { + sql.append(" and "); + sql.append(andColName + "=:" + andColName); + } + } + sql.append(" )"); + return sql; +} + +std::string PermissionUsedRecordDb::CreateDeleteExcessiveRecordsPrepareSqlCmd(DataType type, + uint32_t excessiveSize) const +{ + auto it = dataTypeToSqlTable_.find(type); + if (it == dataTypeToSqlTable_.end()) { + return std::string(); + } + std::string sql = "delete from " + it->second.tableName_ + " where "; + sql.append(FIELD_TIMESTAMP + " in (select "); + sql.append(FIELD_TIMESTAMP + " from " + it->second.tableName_ + " order by "); + sql.append(FIELD_TIMESTAMP + " limit "); + sql.append(std::to_string(excessiveSize) + " )"); + return sql; +} + +std::string PermissionUsedRecordDb::CreateGetDistinctValue(DataType type, + const std::string conditionColumns) const +{ + auto it = dataTypeToSqlTable_.find(type); + if (it == dataTypeToSqlTable_.end()) { + return std::string(); + } + std::string sql = "select distinct "; + sql.append(conditionColumns + " from "+ it->second.tableName_); + return sql; +} + +int32_t PermissionUsedRecordDb::CreatePermissionRecordTable() const +{ + auto it = dataTypeToSqlTable_.find(DataType::PERMISSION_RECORD); + if (it == dataTypeToSqlTable_.end()) { + return FAILURE; + } + std::string sql = "create table if not exists "; + sql.append(it->second.tableName_ + " (") + .append(FIELD_TOKEN_ID + " integer not null,") + .append(FIELD_OP_CODE + " integer not null,") + .append(FIELD_STATUS + " integer not null,") + .append(FIELD_TIMESTAMP + " integer not null,") + .append(FIELD_ACCESS_DURATION + " integer not null,") + .append(FIELD_ACCESS_COUNT + " integer not null,") + .append(FIELD_REJECT_COUNT + " integer not null,") + .append("primary key(" + FIELD_TOKEN_ID) + .append("," + FIELD_OP_CODE) + .append("," + FIELD_STATUS) + .append("," + FIELD_TIMESTAMP) + .append("))"); + return ExecuteSql(sql); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/record/on_permission_used_record_callback_proxy.cpp b/services/privacymanager/src/record/on_permission_used_record_callback_proxy.cpp index 79ddc389df00b0f33994dea0f8610875bf64b197..f9b9e52fe4ad4e42e16314c5f0270f9ca50d631c 100644 --- a/services/privacymanager/src/record/on_permission_used_record_callback_proxy.cpp +++ b/services/privacymanager/src/record/on_permission_used_record_callback_proxy.cpp @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "on_permission_used_record_callback_proxy.h" - -#include "accesstoken_log.h" -#include "permission_used_result_parcel.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "OnPermissionUsedRecordCallbackProxy" -}; -} - -OnPermissionUsedRecordCallbackProxy::OnPermissionUsedRecordCallbackProxy(const sptr& impl) - : IRemoteProxy(impl) { -} - -OnPermissionUsedRecordCallbackProxy::~OnPermissionUsedRecordCallbackProxy() -{} - -void OnPermissionUsedRecordCallbackProxy::OnQueried(ErrCode code, PermissionUsedResult& result) -{ - MessageParcel data; - data.WriteInterfaceToken(OnPermissionUsedRecordCallback::GetDescriptor()); - if (!data.WriteInt32(code)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable(code)"); - return; - } - - PermissionUsedResultParcel resultParcel; - resultParcel.result = result; - if (!data.WriteParcelable(&resultParcel)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable(result)"); - return; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); - return; - } - int32_t requestResult = remote->SendRequest( - static_cast(OnPermissionUsedRecordCallback::ON_QUERIED), data, reply, option); - if (requestResult != NO_ERROR) { - ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); - return; - } - - ACCESSTOKEN_LOG_INFO(LABEL, "SendRequest success"); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "on_permission_used_record_callback_proxy.h" + +#include "accesstoken_log.h" +#include "permission_used_result_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "OnPermissionUsedRecordCallbackProxy" +}; +} + +OnPermissionUsedRecordCallbackProxy::OnPermissionUsedRecordCallbackProxy(const sptr& impl) + : IRemoteProxy(impl) { +} + +OnPermissionUsedRecordCallbackProxy::~OnPermissionUsedRecordCallbackProxy() +{} + +void OnPermissionUsedRecordCallbackProxy::OnQueried(ErrCode code, PermissionUsedResult& result) +{ + MessageParcel data; + data.WriteInterfaceToken(OnPermissionUsedRecordCallback::GetDescriptor()); + if (!data.WriteInt32(code)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable(code)"); + return; + } + + PermissionUsedResultParcel resultParcel; + resultParcel.result = result; + if (!data.WriteParcelable(&resultParcel)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable(result)"); + return; + } + + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + sptr remote = Remote(); + if (remote == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); + return; + } + int32_t requestResult = remote->SendRequest( + static_cast(OnPermissionUsedRecordCallback::ON_QUERIED), data, reply, option); + if (requestResult != NO_ERROR) { + ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); + return; + } + + ACCESSTOKEN_LOG_INFO(LABEL, "SendRequest success"); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/record/on_permission_used_record_callback_stub.cpp b/services/privacymanager/src/record/on_permission_used_record_callback_stub.cpp index d4b8215251c2bf436419ea0a9f26a5fa694eb07f..a5a53ee1fecf9de5d1660c4f105a99d7248a9ccd 100644 --- a/services/privacymanager/src/record/on_permission_used_record_callback_stub.cpp +++ b/services/privacymanager/src/record/on_permission_used_record_callback_stub.cpp @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "on_permission_used_record_callback_stub.h" - -#include "accesstoken_log.h" -#include "constant.h" -#include "permission_used_result_parcel.h" -#include "constant.h" -#include "string_ex.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "OnPermissionUsedRecordCallbackStub" -}; -} - -int32_t OnPermissionUsedRecordCallbackStub::OnRemoteRequest( - uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -{ - ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, code: 0x%{public}x", code); - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != OnPermissionUsedRecordCallback::GetDescriptor()) { - ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor: %{public}s", Str16ToStr8(descriptor).c_str()); - return Constant::FAILURE; - } - - int32_t msgCode = static_cast(code); - if (msgCode == OnPermissionUsedRecordCallback::ON_QUERIED) { - ErrCode errCode = data.ReadInt32(); - PermissionUsedResult result; - if (errCode != NO_ERROR) { - OnQueried(errCode, result); - return Constant::FAILURE; - } - sptr resultSptr = data.ReadParcelable(); - if (resultSptr == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable fail"); - return Constant::FAILURE; - } - ACCESSTOKEN_LOG_INFO(LABEL, "errCode: %{public}d", errCode); - OnQueried(errCode, resultSptr->result); - } else { - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - return NO_ERROR; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "on_permission_used_record_callback_stub.h" + +#include "accesstoken_log.h" +#include "constant.h" +#include "permission_used_result_parcel.h" +#include "constant.h" +#include "string_ex.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "OnPermissionUsedRecordCallbackStub" +}; +} + +int32_t OnPermissionUsedRecordCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, code: 0x%{public}x", code); + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != OnPermissionUsedRecordCallback::GetDescriptor()) { + ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor: %{public}s", Str16ToStr8(descriptor).c_str()); + return Constant::FAILURE; + } + + int32_t msgCode = static_cast(code); + if (msgCode == OnPermissionUsedRecordCallback::ON_QUERIED) { + ErrCode errCode = data.ReadInt32(); + PermissionUsedResult result; + if (errCode != NO_ERROR) { + OnQueried(errCode, result); + return Constant::FAILURE; + } + sptr resultSptr = data.ReadParcelable(); + if (resultSptr == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable fail"); + return Constant::FAILURE; + } + ACCESSTOKEN_LOG_INFO(LABEL, "errCode: %{public}d", errCode); + OnQueried(errCode, resultSptr->result); + } else { + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/record/permission_record.cpp b/services/privacymanager/src/record/permission_record.cpp index 643ec0f84f5bd7c8e4a511bf56158d821aa9a760..244879a796343d64a158d25714c353635d909b0e 100644 --- a/services/privacymanager/src/record/permission_record.cpp +++ b/services/privacymanager/src/record/permission_record.cpp @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_record.h" -#include "field_const.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -void PermissionRecord::TranslationIntoGenericValues(const PermissionRecord& record, GenericValues& values) -{ - values.Put(FIELD_TOKEN_ID, (int32_t)record.tokenId); - values.Put(FIELD_OP_CODE, record.opCode); - values.Put(FIELD_STATUS, record.status); - values.Put(FIELD_TIMESTAMP, record.timestamp); - values.Put(FIELD_ACCESS_DURATION, record.accessDuration); - values.Put(FIELD_ACCESS_COUNT, record.accessCount); - values.Put(FIELD_REJECT_COUNT, record.rejectCount); -} - -void PermissionRecord::TranslationIntoPermissionRecord(const GenericValues& values, PermissionRecord& record) -{ - record.tokenId = values.GetInt(FIELD_TOKEN_ID); - record.opCode = values.GetInt(FIELD_OP_CODE); - record.status = values.GetInt(FIELD_STATUS); - record.timestamp = values.GetInt64(FIELD_TIMESTAMP); - record.accessDuration = values.GetInt64(FIELD_ACCESS_DURATION); - record.accessCount = values.GetInt(FIELD_ACCESS_COUNT); - record.rejectCount = values.GetInt(FIELD_REJECT_COUNT); -} -} // namespace AccessToken -} // namespace Security +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_record.h" +#include "field_const.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +void PermissionRecord::TranslationIntoGenericValues(const PermissionRecord& record, GenericValues& values) +{ + values.Put(FIELD_TOKEN_ID, (int32_t)record.tokenId); + values.Put(FIELD_OP_CODE, record.opCode); + values.Put(FIELD_STATUS, record.status); + values.Put(FIELD_TIMESTAMP, record.timestamp); + values.Put(FIELD_ACCESS_DURATION, record.accessDuration); + values.Put(FIELD_ACCESS_COUNT, record.accessCount); + values.Put(FIELD_REJECT_COUNT, record.rejectCount); +} + +void PermissionRecord::TranslationIntoPermissionRecord(const GenericValues& values, PermissionRecord& record) +{ + record.tokenId = values.GetInt(FIELD_TOKEN_ID); + record.opCode = values.GetInt(FIELD_OP_CODE); + record.status = values.GetInt(FIELD_STATUS); + record.timestamp = values.GetInt64(FIELD_TIMESTAMP); + record.accessDuration = values.GetInt64(FIELD_ACCESS_DURATION); + record.accessCount = values.GetInt(FIELD_ACCESS_COUNT); + record.rejectCount = values.GetInt(FIELD_REJECT_COUNT); +} +} // namespace AccessToken +} // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/services/privacymanager/src/record/permission_record_manager.cpp b/services/privacymanager/src/record/permission_record_manager.cpp index 37514e9f5700b7eae12d3405ef18d2ddc47c53a2..0fd1b479abf61d5611ec9bd588a6824affbd100f 100644 --- a/services/privacymanager/src/record/permission_record_manager.cpp +++ b/services/privacymanager/src/record/permission_record_manager.cpp @@ -1,489 +1,389 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_record_manager.h" - -#include "accesstoken_kit.h" -#include "accesstoken_log.h" -#include "active_status_callback_manager.h" -#include "constant.h" -#include "constant_common.h" -#include "data_translator.h" -#include "field_const.h" -#include "permission_record_repository.h" -#include "permission_used_record_cache.h" -#include "time_util.h" -#include "to_string.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermissionRecordManager" -}; -static const std::string DEFAULT_DEVICEID = "0"; -static const std::string FIELD_COUNT_NUMBER = "count"; -} -PermissionRecordManager& PermissionRecordManager::GetInstance() -{ - static PermissionRecordManager instance; - return instance; -} - -PermissionRecordManager::PermissionRecordManager() : hasInited_(false) {} - -PermissionRecordManager::~PermissionRecordManager() -{ - if (!hasInited_) { - return; - } - deleteTaskWorker_.Stop(); - hasInited_ = false; -} - -void PermissionRecordManager::AddRecord(const PermissionRecord& record) -{ - Utils::UniqueWriteGuard lk(this->rwLock_); - PermissionUsedRecordCache::GetInstance().AddRecordToBuffer(const_cast(record)); -} - -bool PermissionRecordManager::GetPermissionRecord(AccessTokenID tokenId, const std::string& permissionName, - int32_t successCount, int32_t failCount, PermissionRecord& record) -{ - HapTokenInfo tokenInfo; - if (AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo) != Constant::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "invalid tokenId(%{public}d)", tokenId); - return false; - } - int32_t opCode; - if (!Constant::TransferPermissionToOpcode(permissionName, opCode)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "invalid permission(%{public}s)", permissionName.c_str()); - return false; - } - if (successCount == 0 && failCount == 0) { - record.status = PERM_INACTIVE; - } else { - record.status = PERM_ACTIVE_IN_FOREGROUND; - } - record.tokenId = tokenId; - record.accessCount = successCount; - record.rejectCount = failCount; - record.opCode = opCode; - record.timestamp = TimeUtil::GetCurrentTimestamp(); - record.accessDuration = 0; - ACCESSTOKEN_LOG_DEBUG(LABEL, "record status: %{public}d", record.status); - return true; -} - -int32_t PermissionRecordManager::AddPermissionUsedRecord(AccessTokenID tokenId, const std::string& permissionName, - int32_t successCount, int32_t failCount) -{ - ExecuteDeletePermissionRecordTask(); - - PermissionRecord record; - if (!GetPermissionRecord(tokenId, permissionName, successCount, failCount, record)) { - return Constant::FAILURE; - } - - if (record.status == PERM_INACTIVE) { - return Constant::FAILURE; - } - - AddRecord(record); - return Constant::SUCCESS; -} - -void PermissionRecordManager::RemovePermissionUsedRecords(AccessTokenID tokenId, const std::string& deviceID) -{ - if (tokenId == 0) { - ACCESSTOKEN_LOG_ERROR(LABEL, "tokenId is 0"); - return; - } - - // only support remove by tokenId(local) - std::string device = GetDeviceId(tokenId); - if (device.empty()) { - ACCESSTOKEN_LOG_ERROR(LABEL, "invalid tokenId = %{public}d", tokenId); - return; - } - - if (!deviceID.empty() && device != deviceID) { - ACCESSTOKEN_LOG_ERROR(LABEL, "deviceID mismatch"); - return; - } - - Utils::UniqueWriteGuard lk(this->rwLock_); - PermissionUsedRecordCache::GetInstance().RemoveRecords(tokenId); // remove from cache and database -} - -int32_t PermissionRecordManager::GetPermissionUsedRecords( - const PermissionUsedRequest& request, PermissionUsedResult& result) -{ - ExecuteDeletePermissionRecordTask(); - - if (!request.isRemote && !GetRecordsFromLocalDB(request, result)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to GetRecordsFromLocalDB"); - return Constant::FAILURE; - } - return Constant::SUCCESS; -} - -int32_t PermissionRecordManager::GetPermissionUsedRecordsAsync( - const PermissionUsedRequest& request, const sptr& callback) -{ - auto task = [request, callback]() { - ACCESSTOKEN_LOG_INFO(LABEL, "GetPermissionUsedRecordsAsync task called"); - PermissionUsedResult result; - int32_t ret = PermissionRecordManager::GetInstance().GetPermissionUsedRecords(request, result); - callback->OnQueried(ret, result); - }; - std::thread recordThread(task); - recordThread.detach(); - return Constant::SUCCESS; -} - -bool PermissionRecordManager::GetLocalRecordTokenIdList(std::set& tokenIdList) -{ - std::vector results; - { - Utils::UniqueWriteGuard lk(this->rwLock_); - // find tokenId from cache - PermissionUsedRecordCache::GetInstance().FindTokenIdList(tokenIdList); - // find tokenId from database - PermissionRecordRepository::GetInstance().GetAllRecordValuesByKey(FIELD_TOKEN_ID, results); - } - for (const auto& res : results) { - tokenIdList.emplace(res.GetInt(FIELD_TOKEN_ID)); - } - return true; -} - -bool PermissionRecordManager::GetRecordsFromLocalDB(const PermissionUsedRequest& request, PermissionUsedResult& result) -{ - GenericValues andConditionValues; - GenericValues orConditionValues; - if (DataTranslator::TranslationIntoGenericValues(request, andConditionValues, orConditionValues) - != Constant::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "query time or flag is invalid"); - return false; - } - - std::set tokenIdList; - if (request.tokenId == 0) { - GetLocalRecordTokenIdList(tokenIdList); - } else { - tokenIdList.emplace(request.tokenId); - } - ACCESSTOKEN_LOG_DEBUG(LABEL, "GetLocalRecordTokenIdList.size = %{public}zu", tokenIdList.size()); - Utils::UniqueWriteGuard lk(this->rwLock_); - for (const auto& tokenId : tokenIdList) { - andConditionValues.Put(FIELD_TOKEN_ID, (int32_t)tokenId); - std::vector findRecordsValues; - PermissionUsedRecordCache::GetInstance().GetRecords(request.permissionList, - andConditionValues, orConditionValues, findRecordsValues); // find records from cache and database - andConditionValues.Remove(FIELD_TOKEN_ID); - BundleUsedRecord bundleRecord; - CreateBundleUsedRecord(tokenId, bundleRecord); - if (!findRecordsValues.empty()) { - if (!GetRecords(request.flag, findRecordsValues, bundleRecord, result)) { - return false; - } - } - - if (!bundleRecord.permissionRecords.empty()) { - result.bundleRecords.emplace_back(bundleRecord); - } - } - return true; -} - -bool PermissionRecordManager::CreateBundleUsedRecord(const AccessTokenID tokenId, BundleUsedRecord& bundleRecord) -{ - HapTokenInfo tokenInfo; - if (AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo) != Constant::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "GetHapTokenInfo failed"); - return false; - } - bundleRecord.tokenId = tokenId; - bundleRecord.isRemote = false; - bundleRecord.deviceId = GetDeviceId(tokenId); - bundleRecord.bundleName = tokenInfo.bundleName; - return true; -} - -bool PermissionRecordManager::GetRecords( - int32_t flag, std::vector recordValues, BundleUsedRecord& bundleRecord, PermissionUsedResult& result) -{ - std::vector permissionRecords; - for (auto it = recordValues.rbegin(); it != recordValues.rend(); ++it) { - GenericValues record = *it; - PermissionUsedRecord tmpPermissionRecord; - int64_t timestamp = record.GetInt64(FIELD_TIMESTAMP); - result.beginTimeMillis = ((result.beginTimeMillis == 0) || (timestamp < result.beginTimeMillis)) ? - timestamp : result.beginTimeMillis; - result.endTimeMillis = (timestamp > result.endTimeMillis) ? timestamp : result.endTimeMillis; - - record.Put(FIELD_FLAG, flag); - if (DataTranslator::TranslationGenericValuesIntoPermissionUsedRecord(record, tmpPermissionRecord) - != Constant::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to transform opcode(%{public}d) into permission", - record.GetInt(FIELD_OP_CODE)); - continue; - } - - auto iter = std::find_if(permissionRecords.begin(), permissionRecords.end(), - [tmpPermissionRecord](const PermissionUsedRecord& rec) { - return tmpPermissionRecord.permissionName == rec.permissionName; - }); - if (iter != permissionRecords.end()) { - UpdateRecords(flag, tmpPermissionRecord, *iter); - } else { - permissionRecords.emplace_back(tmpPermissionRecord); - } - } - bundleRecord.permissionRecords = permissionRecords; - return true; -} - -void PermissionRecordManager::UpdateRecords( - int32_t flag, const PermissionUsedRecord& inBundleRecord, PermissionUsedRecord& outBundleRecord) -{ - outBundleRecord.accessCount += inBundleRecord.accessCount; - outBundleRecord.rejectCount += inBundleRecord.rejectCount; - if (inBundleRecord.lastAccessTime > outBundleRecord.lastAccessTime) { - outBundleRecord.lastAccessTime = inBundleRecord.lastAccessTime; - outBundleRecord.lastAccessDuration = inBundleRecord.lastAccessDuration; - } - outBundleRecord.lastRejectTime = (inBundleRecord.lastRejectTime > outBundleRecord.lastRejectTime) ? - inBundleRecord.lastRejectTime : outBundleRecord.lastRejectTime; - - if (flag == 0) { - return; - } - if (inBundleRecord.lastAccessTime > 0 && outBundleRecord.accessRecords.size() < Constant::MAX_DETAIL_RECORD) { - outBundleRecord.accessRecords.emplace_back(inBundleRecord.accessRecords[0]); - } - if (inBundleRecord.lastRejectTime > 0 && outBundleRecord.rejectRecords.size() < Constant::MAX_DETAIL_RECORD) { - outBundleRecord.rejectRecords.emplace_back(inBundleRecord.rejectRecords[0]); - } -} - -void PermissionRecordManager::ExecuteDeletePermissionRecordTask() -{ - if (deleteTaskWorker_.GetCurTaskNum() > 1) { - ACCESSTOKEN_LOG_INFO(LABEL, "Already has delete task!"); - return; - } - - auto deleteRecordsTask = [this]() { - ACCESSTOKEN_LOG_DEBUG(LABEL, "DeletePermissionRecord task called"); - DeletePermissionRecord(Constant::RECORD_DELETE_TIME); - }; - deleteTaskWorker_.AddTask(deleteRecordsTask); -} - -int32_t PermissionRecordManager::DeletePermissionRecord(int32_t days) -{ - Utils::UniqueWriteGuard lk(this->rwLock_); - GenericValues countValue; - PermissionRecordRepository::GetInstance().CountRecordValues(countValue); - int64_t total = countValue.GetInt64(FIELD_COUNT_NUMBER); - if (total > Constant::MAX_TOTAL_RECORD) { - uint32_t excessiveSize = total - Constant::MAX_TOTAL_RECORD; - if (!PermissionRecordRepository::GetInstance().DeleteExcessiveSizeRecordValues(excessiveSize)) { - return Constant::FAILURE; - } - } - GenericValues andConditionValues; - int64_t deleteTimestamp = TimeUtil::GetCurrentTimestamp() - days; - andConditionValues.Put(FIELD_TIMESTAMP_END, deleteTimestamp); - if (!PermissionRecordRepository::GetInstance().DeleteExpireRecordsValues(andConditionValues)) { - return Constant::FAILURE; - } - return Constant::SUCCESS; -} - -std::string PermissionRecordManager::DumpRecordInfo(AccessTokenID tokenId, const std::string& permissionName) -{ - PermissionUsedRequest request; - request.tokenId = tokenId; - request.flag = FLAG_PERMISSION_USAGE_DETAIL; - if (!permissionName.empty()) { - request.permissionList.emplace_back(permissionName); - } - - PermissionUsedResult result; - if (!GetRecordsFromLocalDB(request, result)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "failed to GetRecordsFromLocalDB"); - return ""; - } - - if (result.bundleRecords.empty()) { - ACCESSTOKEN_LOG_DEBUG(LABEL, "no record"); - return ""; - } - std::string dumpInfo; - ToString::PermissionUsedResultToString(result, dumpInfo); - return dumpInfo; -} - -bool PermissionRecordManager::HasStarted(const PermissionRecord& record) -{ - Utils::UniqueWriteGuard lk(this->startRecordListRWLock_); - for (const auto& rec : startRecordList_) { - if ((rec.opCode == record.opCode) && (rec.tokenId == record.tokenId)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "tokenId(%{public}d), opCode(%{public}d) has been started.", - record.tokenId, record.opCode); - return true; - } - } - return false; -} - -void PermissionRecordManager::AddRecordToStartList(const PermissionRecord& record) -{ - Utils::UniqueWriteGuard lk(this->startRecordListRWLock_); - startRecordList_.emplace_back(record); -} - -bool PermissionRecordManager::GetRecordFromStartList(uint32_t tokenId, int32_t opCode, PermissionRecord& record) -{ - Utils::UniqueWriteGuard lk(this->startRecordListRWLock_); - for (auto it = startRecordList_.begin(); it != startRecordList_.end(); ++it) { - if ((it->opCode == opCode) && (tokenId == (it->tokenId))) { - record = *it; - record.accessDuration = TimeUtil::GetCurrentTimestamp() - record.timestamp; - startRecordList_.erase(it); - return true; - } - } - return false; -} - -void PermissionRecordManager::ResetRecord(PermissionRecord& record, int32_t status) -{ - record.status = status; - record.accessDuration = 0; - record.timestamp = TimeUtil::GetCurrentTimestamp(); -} - -std::vector PermissionRecordManager::GetRecordsAndReset(uint32_t tokenId, int32_t status) -{ - std::vector recordList; - Utils::UniqueWriteGuard lk(this->startRecordListRWLock_); - for (auto it = startRecordList_.begin(); it != startRecordList_.end(); ++it) { - if ((it->tokenId == tokenId) && status != (it->status)) { - PermissionRecord record = *it; - record.accessDuration = TimeUtil::GetCurrentTimestamp() - record.timestamp; - recordList.emplace_back(record); - ResetRecord(*it, status); - } - } - return recordList; -} - -void PermissionRecordManager::CallbackExecute( - AccessTokenID tokenId, const std::string& permissionName, int32_t status) -{ - ActiveStatusCallbackManager::GetInstance().ExecuteCallbackAsync( - tokenId, permissionName, GetDeviceId(tokenId), (ActiveChangeType)status); -} - -int32_t PermissionRecordManager::StartUsingPermission(AccessTokenID tokenId, const std::string& permissionName) -{ - int32_t accessCount = 1; - int32_t failCount = 0; - - PermissionRecord record = { 0 }; - if (!GetPermissionRecord(tokenId, permissionName, accessCount, failCount, record)) { - return Constant::FAILURE; - } - - if (HasStarted(record)) { - return Constant::FAILURE; - } - - AddRecordToStartList(record); - if (record.status != PERM_INACTIVE) { - CallbackExecute(tokenId, permissionName, record.status); - } - return Constant::SUCCESS; -} - -int32_t PermissionRecordManager::StopUsingPermission(AccessTokenID tokenId, const std::string& permissionName) -{ - ExecuteDeletePermissionRecordTask(); - - if (AccessTokenKit::GetTokenTypeFlag(tokenId) != TOKEN_HAP) { - ACCESSTOKEN_LOG_ERROR(LABEL, "invalid tokenId(%{public}d)", tokenId); - return Constant::FAILURE; - } - - int32_t opCode; - if (!Constant::TransferPermissionToOpcode(permissionName, opCode)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "invalid permission(%{public}s)", permissionName.c_str()); - return Constant::FAILURE; - } - - PermissionRecord record; - if (!GetRecordFromStartList(tokenId, opCode, record)) { - return Constant::FAILURE; - } - - if (record.status != PERM_INACTIVE) { - ACCESSTOKEN_LOG_INFO(LABEL, "AddRecord(tokenId: %{public}d, opCode: %{public}d, status: %{public}d)", - record.tokenId, record.opCode, record.status); - AddRecord(record); - CallbackExecute(tokenId, permissionName, PERM_INACTIVE); - } - return Constant::SUCCESS; -} - -int32_t PermissionRecordManager::RegisterPermActiveStatusCallback( - std::vector& permList, const sptr& callback) -{ - return ActiveStatusCallbackManager::GetInstance().AddCallback(permList, callback); -} - -int32_t PermissionRecordManager::UnRegisterPermActiveStatusCallback(const sptr& callback) -{ - return ActiveStatusCallbackManager::GetInstance().RemoveCallback(callback); -} - -std::string PermissionRecordManager::GetDeviceId(AccessTokenID tokenId) -{ - HapTokenInfo tokenInfo; - if (AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo) != Constant::SUCCESS) { - return ""; - } - if (tokenInfo.deviceID == DEFAULT_DEVICEID) { // local - return ConstantCommon::GetLocalDeviceId(); - } - return tokenInfo.deviceID; -} - -void PermissionRecordManager::Init() -{ - if (hasInited_) { - return; - } - ACCESSTOKEN_LOG_INFO(LABEL, "init"); - deleteTaskWorker_.Start(1); - hasInited_ = true; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_record_manager.h" + +#include "accesstoken_kit.h" +#include "accesstoken_log.h" +#include "constant.h" +#include "constant_common.h" +#include "data_translator.h" +#include "field_const.h" +#include "permission_record_repository.h" +#include "permission_used_record_cache.h" +#include "active_status_callback_manager.h" +#include "time_util.h" +#include "to_string.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermissionRecordManager" +}; +static const std::string DEFAULT_DEVICEID = "0"; +} +PermissionRecordManager& PermissionRecordManager::GetInstance() +{ + static PermissionRecordManager instance; + return instance; +} + +PermissionRecordManager::PermissionRecordManager() : hasInited_(false) {} + +PermissionRecordManager::~PermissionRecordManager() +{ + if (!hasInited_) { + return; + } + deleteTaskWorker_.Stop(); + hasInited_ = false; +} + +int32_t PermissionRecordManager::AddRecord(const PermissionRecord& record) +{ + Utils::UniqueWriteGuard lk(this->rwLock_); + return PermissionUsedRecordCache::GetInstance().AddRecordToBuffer(const_cast(record)); +} + +bool PermissionRecordManager::GetPermissionsRecord(AccessTokenID tokenId, const std::string& permissionName, + int32_t successCount, int32_t failCount, PermissionRecord& record) +{ + HapTokenInfo tokenInfo; + if (AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo) != Constant::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "invalid tokenId(%{public}d)", tokenId); + return false; + } + int32_t opCode; + if (!Constant::TransferPermissionToOpcode(permissionName, opCode)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "invalid permission(%{public}s)", permissionName.c_str()); + return false; + } + if (successCount == 0 && failCount == 0) { + ACCESSTOKEN_LOG_ERROR(LABEL, "successCount and failCount are both zero"); + return false; + } + record.tokenId = tokenId; + record.accessCount = successCount; + record.rejectCount = failCount; + record.opCode = opCode; + record.status = 0; + record.timestamp = TimeUtil::GetCurrentTimestamp(); + record.accessDuration = 0; + return true; +} + +int32_t PermissionRecordManager::AddPermissionUsedRecord(AccessTokenID tokenId, const std::string& permissionName, + int32_t successCount, int32_t failCount) +{ + ExecuteDeletePermissionRecordTask(); + + PermissionRecord record; + if (!GetPermissionsRecord(tokenId, permissionName, successCount, failCount, record)) { + return Constant::FAILURE; + } + + return AddRecord(record); +} + +void PermissionRecordManager::RemovePermissionUsedRecords(AccessTokenID tokenId, const std::string& deviceID) +{ + if (tokenId == 0) { + ACCESSTOKEN_LOG_ERROR(LABEL, "tokenId is 0"); + return; + } + + // only support remove by tokenId(local) + std::string device = GetDeviceId(tokenId); + if (device.empty()) { + ACCESSTOKEN_LOG_ERROR(LABEL, "invalid tokenId = %{public}d", tokenId); + return; + } + + if (!deviceID.empty() && device != deviceID) { + ACCESSTOKEN_LOG_ERROR(LABEL, "deviceID mismatch"); + return; + } + + Utils::UniqueWriteGuard lk(this->rwLock_); + GenericValues record; + record.Put(FIELD_TOKEN_ID, (int32_t)tokenId); + PermissionUsedRecordCache::GetInstance().RemoveRecords(record); // remove from cache and database +} + +int32_t PermissionRecordManager::GetPermissionUsedRecords( + const PermissionUsedRequest& request, PermissionUsedResult& result) +{ + ExecuteDeletePermissionRecordTask(); + + if (!request.isRemote && !GetRecordsFromLocalDB(request, result)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to GetRecordsFromLocalDB"); + return Constant::FAILURE; + } + return Constant::SUCCESS; +} + +int32_t PermissionRecordManager::GetPermissionUsedRecordsAsync( + const PermissionUsedRequest& request, const sptr& callback) +{ + auto task = [request, callback]() { + ACCESSTOKEN_LOG_INFO(LABEL, "GetPermissionUsedRecordsAsync task called"); + PermissionUsedResult result; + int32_t ret = PermissionRecordManager::GetInstance().GetPermissionUsedRecords(request, result); + callback->OnQueried(ret, result); + }; + std::thread recordThread(task); + recordThread.detach(); + return Constant::SUCCESS; +} + +bool PermissionRecordManager::GetLocalRecordTokenIdList(std::set& tokenIdList) +{ + std::vector results; + { + Utils::UniqueWriteGuard lk(this->rwLock_); + // find tokenId from cache + PermissionUsedRecordCache::GetInstance().FindTokenIdList(tokenIdList); + // find tokenId from database + PermissionRecordRepository::GetInstance().GetAllRecordValuesByKey(FIELD_TOKEN_ID, results); + } + for (const auto& res : results) { + tokenIdList.emplace(res.GetInt(FIELD_TOKEN_ID)); + } + return true; +} + +bool PermissionRecordManager::GetRecordsFromLocalDB(const PermissionUsedRequest& request, PermissionUsedResult& result) +{ + GenericValues andConditionValues; + GenericValues orConditionValues; + if (DataTranslator::TranslationIntoGenericValues(request, andConditionValues, orConditionValues) + != Constant::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "query time or flag is invalid"); + return false; + } + + std::set tokenIdList; + if (request.tokenId == 0) { + GetLocalRecordTokenIdList(tokenIdList); + } else { + tokenIdList.emplace(request.tokenId); + } + ACCESSTOKEN_LOG_DEBUG(LABEL, "GetLocalRecordTokenIdList.size = %{public}zu", tokenIdList.size()); + Utils::UniqueWriteGuard lk(this->rwLock_); + for (const auto& tokenId : tokenIdList) { + andConditionValues.Put(FIELD_TOKEN_ID, (int32_t)tokenId); + std::vector findRecordsValues; + PermissionUsedRecordCache::GetInstance().GetRecords(request.permissionList, + andConditionValues, orConditionValues, findRecordsValues); // find records from cache and database + andConditionValues.Remove(FIELD_TOKEN_ID); + BundleUsedRecord bundleRecord; + CreateBundleUsedRecord(tokenId, bundleRecord); + if (!findRecordsValues.empty()) { + if (!GetRecords(request.flag, findRecordsValues, bundleRecord, result)) { + return false; + } + } + + if (!bundleRecord.permissionRecords.empty()) { + result.bundleRecords.emplace_back(bundleRecord); + } + } + return true; +} + +bool PermissionRecordManager::CreateBundleUsedRecord(const AccessTokenID tokenId, BundleUsedRecord& bundleRecord) +{ + HapTokenInfo tokenInfo; + if (AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo) != Constant::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "GetHapTokenInfo failed"); + return false; + } + bundleRecord.tokenId = tokenId; + bundleRecord.isRemote = false; + bundleRecord.deviceId = ConstantCommon::GetLocalDeviceId(); + bundleRecord.bundleName = tokenInfo.bundleName; + return true; +} + +bool PermissionRecordManager::GetRecords( + int32_t flag, std::vector recordValues, BundleUsedRecord& bundleRecord, PermissionUsedResult& result) +{ + std::vector permissionRecords; + for (auto it = recordValues.rbegin(); it != recordValues.rend(); ++it) { + GenericValues record = *it; + PermissionUsedRecord tmpPermissionRecord; + int64_t timestamp = record.GetInt64(FIELD_TIMESTAMP); + result.beginTimeMillis = ((result.beginTimeMillis == 0) || (timestamp < result.beginTimeMillis)) ? + timestamp : result.beginTimeMillis; + result.endTimeMillis = (timestamp > result.endTimeMillis) ? timestamp : result.endTimeMillis; + + record.Put(FIELD_FLAG, flag); + if (DataTranslator::TranslationGenericValuesIntoPermissionUsedRecord(record, tmpPermissionRecord) + != Constant::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to transform opcode(%{public}d) into permission", + record.GetInt(FIELD_OP_CODE)); + continue; + } + + auto iter = std::find_if(permissionRecords.begin(), permissionRecords.end(), + [tmpPermissionRecord](const PermissionUsedRecord& rec) { + return tmpPermissionRecord.permissionName == rec.permissionName; + }); + if (iter != permissionRecords.end()) { + UpdateRecords(flag, tmpPermissionRecord, *iter); + } else { + permissionRecords.emplace_back(tmpPermissionRecord); + } + } + bundleRecord.permissionRecords = permissionRecords; + return true; +} + +void PermissionRecordManager::UpdateRecords( + int32_t flag, const PermissionUsedRecord& inBundleRecord, PermissionUsedRecord& outBundleRecord) +{ + outBundleRecord.accessCount += inBundleRecord.accessCount; + outBundleRecord.rejectCount += inBundleRecord.rejectCount; + if (inBundleRecord.lastAccessTime > outBundleRecord.lastAccessTime) { + outBundleRecord.lastAccessTime = inBundleRecord.lastAccessTime; + outBundleRecord.lastAccessDuration = inBundleRecord.lastAccessDuration; + } + outBundleRecord.lastRejectTime = (inBundleRecord.lastRejectTime > outBundleRecord.lastRejectTime) ? + inBundleRecord.lastRejectTime : outBundleRecord.lastRejectTime; + + if (flag == 0) { + return; + } + if (inBundleRecord.lastAccessTime > 0 && outBundleRecord.accessRecords.size() < Constant::MAX_DETAIL_RECORD) { + outBundleRecord.accessRecords.emplace_back(inBundleRecord.accessRecords[0]); + } + if (inBundleRecord.lastRejectTime > 0 && outBundleRecord.rejectRecords.size() < Constant::MAX_DETAIL_RECORD) { + outBundleRecord.rejectRecords.emplace_back(inBundleRecord.rejectRecords[0]); + } +} + +void PermissionRecordManager::ExecuteDeletePermissionRecordTask() +{ + if (deleteTaskWorker_.GetCurTaskNum() > 1) { + ACCESSTOKEN_LOG_INFO(LABEL, "Already has delete task!"); + return; + } + + auto deleteRecordsTask = [this]() { + ACCESSTOKEN_LOG_DEBUG(LABEL, "DeletePermissionRecord task called"); + DeletePermissionRecord(Constant::RECORD_DELETE_TIME); + }; + deleteTaskWorker_.AddTask(deleteRecordsTask); +} + +int32_t PermissionRecordManager::DeletePermissionRecord(int32_t days) +{ + Utils::UniqueWriteGuard lk(this->rwLock_); + GenericValues countValue; + if (!PermissionRecordRepository::GetInstance().CountRecordValues(countValue)) { + return Constant::FAILURE; + } + int64_t total = countValue.GetInt64(Constant::COUNT_CMD); + if (total > Constant::MAX_TOTAL_RECORD) { + uint32_t excessiveSize = total - Constant::MAX_TOTAL_RECORD; + if (!PermissionRecordRepository::GetInstance().DeleteExcessiveSizeRecordValues(excessiveSize)) { + return Constant::FAILURE; + } + } + GenericValues andConditionValues; + int64_t deleteTimestamp = TimeUtil::GetCurrentTimestamp() - days; + andConditionValues.Put(FIELD_TIMESTAMP_END, deleteTimestamp); + if (!PermissionRecordRepository::GetInstance().DeleteExpireRecordsValues(andConditionValues)) { + return Constant::FAILURE; + } + return Constant::SUCCESS; +} + +std::string PermissionRecordManager::DumpRecordInfo(AccessTokenID tokenId, const std::string& permissionName) +{ + PermissionUsedRequest request; + request.tokenId = tokenId; + request.flag = FLAG_PERMISSION_USAGE_DETAIL; + if (!permissionName.empty()) { + request.permissionList.emplace_back(permissionName); + } + + PermissionUsedResult result; + if (!GetRecordsFromLocalDB(request, result)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "failed to GetRecordsFromLocalDB"); + return ""; + } + + if (result.bundleRecords.empty()) { + ACCESSTOKEN_LOG_DEBUG(LABEL, "no record"); + return ""; + } + std::string dumpInfo; + ToString::PermissionUsedResultToString(result, dumpInfo); + return dumpInfo; +} + +int32_t PermissionRecordManager::StartUsingPermission(AccessTokenID tokenId, const std::string& permissionName) +{ + ActiveStatusCallbackManager::GetInstance().ExecuteCallbackAsync( + tokenId, permissionName, ConstantCommon::GetLocalDeviceId(), PERM_ACTIVE_IN_FOREGROUND); + return Constant::SUCCESS; +} + +int32_t PermissionRecordManager::StopUsingPermission(AccessTokenID tokenId, const std::string& permissionName) +{ + ActiveStatusCallbackManager::GetInstance().ExecuteCallbackAsync( + tokenId, permissionName, ConstantCommon::GetLocalDeviceId(), PERM_INACTIVE); + return Constant::SUCCESS; +} + +int32_t PermissionRecordManager::RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) +{ + return ActiveStatusCallbackManager::GetInstance().AddCallback(permList, callback); +} + +int32_t PermissionRecordManager::UnRegisterPermActiveStatusCallback(const sptr& callback) +{ + return ActiveStatusCallbackManager::GetInstance().RemoveCallback(callback); +} + +std::string PermissionRecordManager::GetDeviceId(AccessTokenID tokenId) +{ + HapTokenInfo tokenInfo; + if (AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo) != Constant::SUCCESS) { + return ""; + } + if (tokenInfo.deviceID == DEFAULT_DEVICEID) { // local + return ConstantCommon::GetLocalDeviceId(); + } + return tokenInfo.deviceID; +} + + +void PermissionRecordManager::Init() +{ + if (hasInited_) { + return; + } + ACCESSTOKEN_LOG_INFO(LABEL, "init"); + deleteTaskWorker_.Start(1); + hasInited_ = true; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/record/permission_record_repository.cpp b/services/privacymanager/src/record/permission_record_repository.cpp index 4d2e7d08aeed75836da24c65c09b50dd838453e6..5e1eca1f7c5ea75ac012a7b9d5f698119c304145 100644 --- a/services/privacymanager/src/record/permission_record_repository.cpp +++ b/services/privacymanager/src/record/permission_record_repository.cpp @@ -1,112 +1,117 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_record_repository.h" - -#include "accesstoken_log.h" -#include "permission_used_record_db.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermissionRecordRepository" -}; -} - -PermissionRecordRepository& PermissionRecordRepository::GetInstance() -{ - static PermissionRecordRepository instance; - return instance; -} - -PermissionRecordRepository::PermissionRecordRepository() -{ -} - -PermissionRecordRepository::~PermissionRecordRepository() -{ -} - -bool PermissionRecordRepository::AddRecordValues(const std::vector& recordValues) -{ - if (PermissionUsedRecordDb::GetInstance().Add(PermissionUsedRecordDb::PERMISSION_RECORD, recordValues) - != PermissionUsedRecordDb::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD table add fail"); - return false; - } - return true; -} - -bool PermissionRecordRepository::FindRecordValues(const GenericValues& andConditionValues, - const GenericValues& orConditionValues, std::vector& recordValues) -{ - if (PermissionUsedRecordDb::GetInstance().FindByConditions(PermissionUsedRecordDb::PERMISSION_RECORD, - andConditionValues, orConditionValues, recordValues) != PermissionUsedRecordDb::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD table find fail"); - return false; - } - return true; -} - -bool PermissionRecordRepository::RemoveRecordValues(const GenericValues& conditionValues) -{ - if (PermissionUsedRecordDb::GetInstance().Remove(PermissionUsedRecordDb::PERMISSION_RECORD, conditionValues) - != PermissionUsedRecordDb::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD table add fail"); - return false; - } - return true; -} - -bool PermissionRecordRepository::GetAllRecordValuesByKey( - const std::string& condition, std::vector& resultValues) -{ - if (PermissionUsedRecordDb::GetInstance().GetDistinctValue(PermissionUsedRecordDb::PERMISSION_RECORD, - condition, resultValues) != PermissionUsedRecordDb::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD table add fail"); - return false; - } - return true; -} - -void PermissionRecordRepository::CountRecordValues(GenericValues& resultValues) -{ - PermissionUsedRecordDb::GetInstance().Count(PermissionUsedRecordDb::PERMISSION_RECORD, resultValues); -} - -bool PermissionRecordRepository::DeleteExpireRecordsValues(const GenericValues& andConditions) -{ - if (PermissionUsedRecordDb::GetInstance().DeleteExpireRecords(PermissionUsedRecordDb::PERMISSION_RECORD, - andConditions) != PermissionUsedRecordDb::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD delete fail"); - return false; - } - return true; -} - -bool PermissionRecordRepository::DeleteExcessiveSizeRecordValues(uint32_t excessiveSize) -{ - if (PermissionUsedRecordDb::GetInstance().DeleteExcessiveRecords(PermissionUsedRecordDb::PERMISSION_RECORD, - excessiveSize) != PermissionUsedRecordDb::SUCCESS) { - ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD delete fail"); - return false; - } - return true; -} -} // namespace AccessToken -} // namespace Security +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_record_repository.h" + +#include "accesstoken_log.h" +#include "permission_used_record_db.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermissionRecordRepository" +}; +} + +PermissionRecordRepository& PermissionRecordRepository::GetInstance() +{ + static PermissionRecordRepository instance; + return instance; +} + +PermissionRecordRepository::PermissionRecordRepository() +{ +} + +PermissionRecordRepository::~PermissionRecordRepository() +{ +} + +bool PermissionRecordRepository::AddRecordValues(const std::vector& recordValues) +{ + if (PermissionUsedRecordDb::GetInstance().Add(PermissionUsedRecordDb::PERMISSION_RECORD, recordValues) + != PermissionUsedRecordDb::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD table add fail"); + return false; + } + return true; +} + +bool PermissionRecordRepository::FindRecordValues(const GenericValues& andConditionValues, + const GenericValues& orConditionValues, std::vector& recordValues) +{ + if (PermissionUsedRecordDb::GetInstance().FindByConditions(PermissionUsedRecordDb::PERMISSION_RECORD, + andConditionValues, orConditionValues, recordValues) != PermissionUsedRecordDb::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD table find fail"); + return false; + } + return true; +} + +bool PermissionRecordRepository::RemoveRecordValues(const GenericValues& conditionValues) +{ + if (PermissionUsedRecordDb::GetInstance().Remove(PermissionUsedRecordDb::PERMISSION_RECORD, conditionValues) + != PermissionUsedRecordDb::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD table add fail"); + return false; + } + return true; +} + +bool PermissionRecordRepository::GetAllRecordValuesByKey( + const std::string& condition, std::vector& resultValues) +{ + if (PermissionUsedRecordDb::GetInstance().GetDistinctValue(PermissionUsedRecordDb::PERMISSION_RECORD, + condition, resultValues) != PermissionUsedRecordDb::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD table add fail"); + return false; + } + return true; +} + +int32_t PermissionRecordRepository::CountRecordValues(GenericValues& resultValues) +{ + if (PermissionUsedRecordDb::GetInstance().Count(PermissionUsedRecordDb::PERMISSION_RECORD, resultValues) + != PermissionUsedRecordDb::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Cannot count PERMISSION_RECORD"); + return false; + } + return true; +} + +bool PermissionRecordRepository::DeleteExpireRecordsValues(const GenericValues& andConditions) +{ + if (PermissionUsedRecordDb::GetInstance().DeleteExpireRecords(PermissionUsedRecordDb::PERMISSION_RECORD, + andConditions) != PermissionUsedRecordDb::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD delete fail"); + return false; + } + return true; +} + +bool PermissionRecordRepository::DeleteExcessiveSizeRecordValues(uint32_t excessiveSize) +{ + if (PermissionUsedRecordDb::GetInstance().DeleteExcessiveRecords(PermissionUsedRecordDb::PERMISSION_RECORD, + excessiveSize) != PermissionUsedRecordDb::SUCCESS) { + ACCESSTOKEN_LOG_ERROR(LABEL, "PERMISSION_RECORD delete fail"); + return false; + } + return true; +} +} // namespace AccessToken +} // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/services/privacymanager/src/record/permission_used_record_cache.cpp b/services/privacymanager/src/record/permission_used_record_cache.cpp index 038595fc592171fa11737f450703516e4776ad1e..0dba804cd6925dd94780a11ea5ca2f67c74fdb24 100644 --- a/services/privacymanager/src/record/permission_used_record_cache.cpp +++ b/services/privacymanager/src/record/permission_used_record_cache.cpp @@ -1,415 +1,425 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "permission_used_record_cache.h" -#include "accesstoken_log.h" -#include "constant.h" -#include "field_const.h" -#include "generic_values.h" -#include "permission_record.h" -#include "permission_record_manager.h" -#include "permission_record_node.h" -#include "permission_record_repository.h" -#include "permission_used_record_db.h" -#include "time_util.h" -#include "to_string.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermissionUsedRecordCache" -}; -} - -PermissionUsedRecordCache& PermissionUsedRecordCache::GetInstance() -{ - static PermissionUsedRecordCache instance; - return instance; -} - -void PermissionUsedRecordCache::AddRecordToBuffer(PermissionRecord& record) -{ - if (nextPersistTimestamp_ == 0) { - nextPersistTimestamp_ = record.timestamp + INTERVAL; - } - std::shared_ptr curFindMergePos; - std::shared_ptr persistPendingBufferHead; - std::shared_ptr persistPendingBufferEnd = nullptr; - { - Utils::UniqueWriteGuard lock1(this->cacheLock_); - curFindMergePos = curRecordBufferPos_; - persistPendingBufferHead = recordBufferHead_; - int32_t remainCount = 0; - while (curFindMergePos != recordBufferHead_) { - auto pre = curFindMergePos->pre.lock(); - if ((record.timestamp - curFindMergePos->record.timestamp) >= INTERVAL) { - persistPendingBufferEnd = curFindMergePos; - break; - } else if (curFindMergePos->record.tokenId == record.tokenId && - record.opCode == curFindMergePos->record.opCode && - record.status == curFindMergePos->record.status && - (record.timestamp - curFindMergePos->record.timestamp) <= Constant::PRECISE) { - MergeRecord(record, curFindMergePos); - } else { - remainCount++; - } - curFindMergePos = pre; - } - AddRecordNode(record); // refresh curRecordBUfferPos and readableSize - remainCount++; - if (persistPendingBufferEnd != nullptr) { - ResetRecordBuffer(remainCount, persistPendingBufferEnd); - } - } - if (persistPendingBufferEnd != nullptr) { - AddToPersistQueue(persistPendingBufferHead); - } -} - -void PermissionUsedRecordCache::MergeRecord(PermissionRecord& record, - std::shared_ptr curFindMergePos) -{ - record.accessDuration += curFindMergePos->record.accessDuration; - record.accessCount += curFindMergePos->record.accessCount; - record.rejectCount += curFindMergePos->record.rejectCount; - if (curRecordBufferPos_ == curFindMergePos) { - curRecordBufferPos_ = curRecordBufferPos_->pre.lock(); - } - DeleteRecordNode(curFindMergePos); // delete old same node - readableSize_--; -} - -void PermissionUsedRecordCache::AddToPersistQueue( - const std::shared_ptr persistPendingBufferHead) -{ - bool startPersist = false; - { - Utils::UniqueWriteGuard lock2(this->cacheLock_); - persistPendingBufferQueue_.emplace_back(persistPendingBufferHead); - if ((TimeUtil::GetCurrentTimestamp() >= nextPersistTimestamp_ || - readableSize_ >= MAX_PERSIST_SIZE) && persistIsRunning_ == 0) { - startPersist = true; - } - } - if (startPersist) { - ExecuteReadRecordBufferTask(); - } -} - -void PermissionUsedRecordCache::ExecuteReadRecordBufferTask() -{ - if (readRecordBufferTaskWorker_.GetCurTaskNum() > 1) { - ACCESSTOKEN_LOG_INFO(LABEL, "Already has read record buffer task!"); - return; - } - auto readRecordBufferTask = [this]() { - ACCESSTOKEN_LOG_INFO(LABEL, "ReadRecordBuffer task called"); - PersistPendingRecords(); - }; - readRecordBufferTaskWorker_.AddTask(readRecordBufferTask); -} - -int32_t PermissionUsedRecordCache::PersistPendingRecords() -{ - std::shared_ptr persistPendingBufferHead; - bool isEmpty; - std::vector insertValues; - { - Utils::UniqueReadGuard lock2(this->cacheLock_); - isEmpty = persistPendingBufferQueue_.empty(); - persistIsRunning_ = 1; - nextPersistTimestamp_ = 0; - } - while (!isEmpty) { - { - Utils::UniqueWriteGuard lock2(this->cacheLock_); - persistPendingBufferHead = persistPendingBufferQueue_[0]; - persistPendingBufferQueue_.erase(persistPendingBufferQueue_.begin()); - } - std::shared_ptr curPendingRecordNode = - persistPendingBufferHead->next; - while (curPendingRecordNode != nullptr) { - auto next = curPendingRecordNode->next; - GenericValues tmpRecordValues; - PermissionRecord tmpRecord = curPendingRecordNode->record; - PermissionRecord::TranslationIntoGenericValues(tmpRecord, tmpRecordValues); - insertValues.emplace_back(tmpRecordValues); - DeleteRecordNode(curPendingRecordNode); - curPendingRecordNode = next; - } - if (!insertValues.empty() && !PermissionRecordRepository::GetInstance().AddRecordValues(insertValues)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to persist pending records"); - } - ACCESSTOKEN_LOG_DEBUG(LABEL, "Persist pending records successful"); - { - Utils::UniqueReadGuard lock2(this->cacheLock_); - isEmpty = persistPendingBufferQueue_.empty(); - } - } - { - Utils::UniqueReadGuard lock2(this->cacheLock_); - if (isEmpty) { // free persistPendingBufferQueue - std::vector> tmpPersistPendingBufferQueue; - std::swap(tmpPersistPendingBufferQueue, persistPendingBufferQueue_); - } - persistIsRunning_ = 0; - } - return true; -} - -int32_t PermissionUsedRecordCache::RemoveRecords(const AccessTokenID tokenId) -{ - std::shared_ptr curFindDeletePos; - std::shared_ptr persistPendingBufferHead; - std::shared_ptr persistPendingBufferEnd = nullptr; - int32_t countPersistPendingNode = 0; - { - Utils::UniqueWriteGuard lock1(this->cacheLock_); - curFindDeletePos = recordBufferHead_->next; - persistPendingBufferHead = recordBufferHead_; - while (curFindDeletePos != nullptr) { - auto next = curFindDeletePos->next; - if (curFindDeletePos->record.tokenId == tokenId) { - if (curRecordBufferPos_ == curFindDeletePos) { - curRecordBufferPos_ = curFindDeletePos->pre.lock(); - } - DeleteRecordNode(curFindDeletePos); - readableSize_--; - } else if (TimeUtil::GetCurrentTimestamp() - - curFindDeletePos->record.timestamp >= INTERVAL) { - persistPendingBufferEnd = curFindDeletePos; - countPersistPendingNode++; - } - curFindDeletePos = next; - } - if (countPersistPendingNode != 0) { // refresh recordBufferHead - int32_t remainCount = readableSize_ - countPersistPendingNode; - ResetRecordBuffer(remainCount, persistPendingBufferEnd); - } - } - RemoveRecordsFromPersistPendingBufferQueue(tokenId, persistPendingBufferHead, persistPendingBufferEnd); - return Constant::SUCCESS; -} - -void PermissionUsedRecordCache::RemoveRecordsFromPersistPendingBufferQueue(const AccessTokenID tokenId, - std::shared_ptr persistPendingBufferHead, - std::shared_ptr persistPendingBufferEnd) -{ - { - std::shared_ptr curFindDeletePos; - Utils::UniqueWriteGuard lock2(this->cacheLock_); - if (!persistPendingBufferQueue_.empty()) { - for (auto& persistHead : persistPendingBufferQueue_) { - curFindDeletePos = persistHead->next; - while (curFindDeletePos != nullptr) { - auto next = curFindDeletePos->next; - if (curFindDeletePos->record.tokenId == tokenId) { - DeleteRecordNode(curFindDeletePos); - } - curFindDeletePos = next; - } - } - } - } - GenericValues record; - record.Put(FIELD_TOKEN_ID, (int32_t)tokenId); - PermissionRecordRepository::GetInstance().RemoveRecordValues(record); // remove from database - if (persistPendingBufferEnd != nullptr) { // add to queue - AddToPersistQueue(persistPendingBufferHead); - } -} - -void PermissionUsedRecordCache::GetRecords(const std::vector& permissionList, - const GenericValues& andConditionValues, const GenericValues& orConditionValues, - std::vector& findRecordsValues) -{ - std::set opCodeList; - std::shared_ptr curFindPos; - std::shared_ptr persistPendingBufferHead; - std::shared_ptr persistPendingBufferEnd = nullptr; - int32_t countPersistPendingNode = 0; - AccessTokenID tokenId = andConditionValues.GetInt(FIELD_TOKEN_ID); - TransferToOpcode(opCodeList, permissionList); - { - Utils::UniqueWriteGuard lock1(this->cacheLock_); - curFindPos = recordBufferHead_->next; - persistPendingBufferHead = recordBufferHead_; - while (curFindPos != nullptr) { - auto next = curFindPos->next; - if (RecordCompare(tokenId, opCodeList, andConditionValues, curFindPos->record)) { - GenericValues recordValues; - PermissionRecord::TranslationIntoGenericValues(curFindPos->record, recordValues); - findRecordsValues.emplace_back(recordValues); - } - if (TimeUtil::GetCurrentTimestamp() - curFindPos->record.timestamp >= INTERVAL) { - persistPendingBufferEnd = curFindPos; - countPersistPendingNode++; - } - curFindPos = next; - } - if (countPersistPendingNode != 0) { // refresh recordBufferHead - int32_t remainCount = readableSize_ - countPersistPendingNode; - ResetRecordBuffer(remainCount, persistPendingBufferEnd); - } - } - GetRecordsFromPersistPendingBufferQueue(opCodeList, andConditionValues, - orConditionValues, findRecordsValues); - if (countPersistPendingNode != 0) { - AddToPersistQueue(persistPendingBufferHead); - } -} - -void PermissionUsedRecordCache::GetRecordsFromPersistPendingBufferQueue(const std::set& opCodeList, - const GenericValues& andConditionValues, const GenericValues& orConditionValues, - std::vector& findRecordsValues) -{ - AccessTokenID tokenId = andConditionValues.GetInt(FIELD_TOKEN_ID); - std::shared_ptr curFindPos; - Utils::UniqueWriteGuard lock2(this->cacheLock_); - if (!persistPendingBufferQueue_.empty()) { - for (auto& persistHead : persistPendingBufferQueue_) { - curFindPos = persistHead->next; - while (curFindPos != nullptr) { - auto next = curFindPos->next; - if (RecordCompare(tokenId, opCodeList, andConditionValues, curFindPos->record)) { - GenericValues recordValues; - PermissionRecord::TranslationIntoGenericValues(curFindPos->record, recordValues); - findRecordsValues.emplace_back(recordValues); - } - curFindPos = next; - } - } - } - if (!PermissionRecordRepository::GetInstance().FindRecordValues( - andConditionValues, orConditionValues, findRecordsValues)) { // find records from database - ACCESSTOKEN_LOG_ERROR(LABEL, "find records from database failed"); - } -} - -void PermissionUsedRecordCache::ResetRecordBuffer(const int32_t remainCount, - std::shared_ptr& persistPendingBufferEnd) -{ - readableSize_ = remainCount; - // refresh recordBufferHead - std::shared_ptr tmpRecordBufferHead = - std::make_shared(); - tmpRecordBufferHead->next = persistPendingBufferEnd->next; - persistPendingBufferEnd->next.reset(); - recordBufferHead_ = tmpRecordBufferHead; - - if (persistPendingBufferEnd == curRecordBufferPos_) { - // persistPendingBufferEnd == curRecordBufferPos, reset curRecordBufferPos - curRecordBufferPos_ = recordBufferHead_; - } else { - // recordBufferHead_->next->pre = persistPendingBufferEnd, reset recordBufferHead_->next->pre - recordBufferHead_->next->pre = recordBufferHead_; - } -} - -void PermissionUsedRecordCache::TransferToOpcode(std::set& opCodeList, - const std::vector& permissionList) -{ - for (const auto& permission : permissionList) { - int32_t opCode = Constant::OP_INVALID; - Constant::TransferPermissionToOpcode(permission, opCode); - opCodeList.insert(opCode); - } -} - -bool PermissionUsedRecordCache::RecordCompare(const AccessTokenID tokenId, const std::set& opCodeList, - const GenericValues& andConditionValues, const PermissionRecord& record) -{ - // compare tokenId - if (record.tokenId != tokenId) { - return false; - } - // compare opCode - if (!opCodeList.empty() && opCodeList.find(record.opCode) == opCodeList.end()) { - return false; - } - // compare timestamp - std::vector andColumns = andConditionValues.GetAllKeys(); - if (!andColumns.empty()) { - for (auto andColumn : andColumns) { - if (andColumn == FIELD_TIMESTAMP_BEGIN && - record.timestamp < andConditionValues.GetInt64(andColumn)) { - return false; - } else if (andColumn == FIELD_TIMESTAMP_END && - record.timestamp > andConditionValues.GetInt64(andColumn)) { - return false; - } else if (andColumn == FIELD_TIMESTAMP && - record.timestamp != andConditionValues.GetInt64(andColumn)) { - return false; - } - } - } - return true; -} - -void PermissionUsedRecordCache::FindTokenIdList(std::set& tokenIdList) -{ - std::shared_ptr curFindPos; - { - // find tokenIdList from recordBuffer - Utils::UniqueWriteGuard lock1(this->cacheLock_); - curFindPos = recordBufferHead_->next; - while (curFindPos != nullptr) { - auto next = curFindPos->next; - tokenIdList.emplace((AccessTokenID)curFindPos->record.tokenId); - curFindPos = next; - } - } - { - // find tokenIdList from BufferQueue - Utils::UniqueWriteGuard lock2(this->cacheLock_); - if (!persistPendingBufferQueue_.empty()) { - for (auto persistHead : persistPendingBufferQueue_) { - curFindPos = persistHead->next; - while (curFindPos != nullptr) { - auto next = curFindPos->next; - tokenIdList.emplace((AccessTokenID)curFindPos->record.tokenId); - curFindPos = next; - } - } - } - } -} - -void PermissionUsedRecordCache::AddRecordNode(const PermissionRecord& record) -{ - std::shared_ptr tmpRecordNode = std::make_shared(); - tmpRecordNode->record = record; - tmpRecordNode->pre = curRecordBufferPos_; - curRecordBufferPos_->next = tmpRecordNode; - curRecordBufferPos_ = curRecordBufferPos_->next; - readableSize_++; -} - -void PermissionUsedRecordCache::DeleteRecordNode(std::shared_ptr deleteRecordNode) -{ - std::shared_ptr pre = deleteRecordNode->pre.lock(); - if (deleteRecordNode->next == nullptr) { // End of the linked list - pre->next = nullptr; - } else { - std::shared_ptr next = deleteRecordNode->next; - pre->next = next; - next->pre = pre; - } -} -} // namespace AccessToken -} // namespace Security +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_used_record_cache.h" +#include "accesstoken_log.h" +#include "constant.h" +#include "field_const.h" +#include "generic_values.h" +#include "permission_record.h" +#include "permission_record_manager.h" +#include "permission_record_node.h" +#include "permission_record_repository.h" +#include "permission_used_record_db.h" +#include "time_util.h" +#include "to_string.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermissionUsedRecordCache" +}; +} + +PermissionUsedRecordCache& PermissionUsedRecordCache::GetInstance() +{ + static PermissionUsedRecordCache instance; + return instance; +} + +int32_t PermissionUsedRecordCache::AddRecordToBuffer(PermissionRecord& record) +{ + if (nextPersistTimestamp_ == 0) { + nextPersistTimestamp_ = record.timestamp + INTERVAL; + } + std::shared_ptr curFindMergePos; + std::shared_ptr persistPendingBufferHead; + std::shared_ptr persistPendingBufferEnd = nullptr; + { + Utils::UniqueWriteGuard lock1(this->cacheLock_); + curFindMergePos = curRecordBufferPos_; + persistPendingBufferHead = recordBufferHead_; + int32_t remainCount = 0; + while (curFindMergePos != recordBufferHead_) { + auto pre = curFindMergePos->pre.lock(); + if ((record.timestamp - curFindMergePos->record.timestamp) >= INTERVAL) { + persistPendingBufferEnd = curFindMergePos; + break; + } else if (curFindMergePos->record.tokenId == record.tokenId && + record.opCode == curFindMergePos->record.opCode && + (record.timestamp - curFindMergePos->record.timestamp) <= Constant::PRECISE) { + MergeRecord(record, curFindMergePos); + } else { + remainCount++; + } + curFindMergePos = pre; + } + AddRecordNode(record); // refresh curRecordBUfferPos and readableSize + remainCount++; + if (persistPendingBufferEnd != nullptr) { + readableSize_ = remainCount; + std::shared_ptr tmpRecordBufferHead = + std::make_shared(); + tmpRecordBufferHead->next = persistPendingBufferEnd->next; + persistPendingBufferEnd->next.reset(); + recordBufferHead_ = tmpRecordBufferHead; + if (persistPendingBufferEnd == curRecordBufferPos_) { // persistPendingBufferEnd == curRecordBufferPos + curRecordBufferPos_ = recordBufferHead_; + } else { // remainCount !=0 ==> recordBufferHead->next != nullptr + recordBufferHead_->next->pre = recordBufferHead_; + } + } + } + if (persistPendingBufferEnd != nullptr) { + AddToPersistQueue(persistPendingBufferHead); + } + return Constant::SUCCESS; +} + +void PermissionUsedRecordCache::MergeRecord(PermissionRecord& record, + std::shared_ptr curFindMergePos) +{ + record.accessDuration += curFindMergePos->record.accessDuration; + record.accessCount += curFindMergePos->record.accessCount; + record.rejectCount += curFindMergePos->record.rejectCount; + if (curRecordBufferPos_ == curFindMergePos) { + curRecordBufferPos_ = curRecordBufferPos_->pre.lock(); + } + DeleteRecordNode(curFindMergePos); // delete old same node + readableSize_--; +} + +void PermissionUsedRecordCache::AddToPersistQueue( + const std::shared_ptr persistPendingBufferHead) +{ + bool startPersist = false; + { + Utils::UniqueWriteGuard lock2(this->cacheLock_); + persistPendingBufferQueue_.emplace_back(persistPendingBufferHead); + if ((TimeUtil::GetCurrentTimestamp() >= nextPersistTimestamp_ || + readableSize_ >= MAX_PERSIST_SIZE) && persistIsRunning_ == 0) { + startPersist = true; + } + } + if (startPersist) { + ExecuteReadRecordBufferTask(); + } +} + +void PermissionUsedRecordCache::ExecuteReadRecordBufferTask() +{ + if (readRecordBufferTaskWorker_.GetCurTaskNum() > 1) { + ACCESSTOKEN_LOG_INFO(LABEL, "Already has read record buffer task!"); + return; + } + auto readRecordBufferTask = [this]() { + ACCESSTOKEN_LOG_INFO(LABEL, "ReadRecordBuffer task called"); + PersistPendingRecords(); + }; + readRecordBufferTaskWorker_.AddTask(readRecordBufferTask); +} + +int32_t PermissionUsedRecordCache::PersistPendingRecords() +{ + std::shared_ptr persistPendingBufferHead; + bool isEmpty; + std::vector insertValues; + { + Utils::UniqueReadGuard lock2(this->cacheLock_); + isEmpty = persistPendingBufferQueue_.empty(); + persistIsRunning_ = 1; + nextPersistTimestamp_ = 0; + } + while (!isEmpty) { + { + Utils::UniqueWriteGuard lock2(this->cacheLock_); + persistPendingBufferHead = persistPendingBufferQueue_[0]; + persistPendingBufferQueue_.erase(persistPendingBufferQueue_.begin()); + } + std::shared_ptr curPendingRecordNode = + persistPendingBufferHead->next; + while (curPendingRecordNode != nullptr) { + auto next = curPendingRecordNode->next; + GenericValues tmpRecordValues; + PermissionRecord tmpRecord = curPendingRecordNode->record; + PermissionRecord::TranslationIntoGenericValues(tmpRecord, tmpRecordValues); + insertValues.emplace_back(tmpRecordValues); + DeleteRecordNode(curPendingRecordNode); + curPendingRecordNode = next; + } + if (!insertValues.empty() && !PermissionRecordRepository::GetInstance().AddRecordValues(insertValues)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to persist pending records"); + } + ACCESSTOKEN_LOG_DEBUG(LABEL, "Persist pending records successful"); + { + Utils::UniqueReadGuard lock2(this->cacheLock_); + isEmpty = persistPendingBufferQueue_.empty(); + } + } + { + Utils::UniqueReadGuard lock2(this->cacheLock_); + if (isEmpty) { // free persistPendingBufferQueue + std::vector> tmpPersistPendingBufferQueue; + std::swap(tmpPersistPendingBufferQueue, persistPendingBufferQueue_); + } + persistIsRunning_ = 0; + } + return true; +} + +int32_t PermissionUsedRecordCache::RemoveRecords(const GenericValues& record) +{ + AccessTokenID tokenId = record.GetInt(FIELD_TOKEN_ID); + std::shared_ptr curFindDeletePos; + std::shared_ptr persistPendingBufferHead; + std::shared_ptr persistPendingBufferEnd = nullptr; + int32_t countPersistPendingNode = 0; + { + Utils::UniqueWriteGuard lock1(this->cacheLock_); + curFindDeletePos = recordBufferHead_->next; + persistPendingBufferHead = recordBufferHead_; + while (curFindDeletePos != nullptr) { + auto next = curFindDeletePos->next; + if (curFindDeletePos->record.tokenId == tokenId) { + if (curRecordBufferPos_ == curFindDeletePos) { + curRecordBufferPos_ = curFindDeletePos->pre.lock(); + } + DeleteRecordNode(curFindDeletePos); + readableSize_--; + } else if (TimeUtil::GetCurrentTimestamp() - + curFindDeletePos->record.timestamp >= INTERVAL) { + persistPendingBufferEnd = curFindDeletePos; + countPersistPendingNode++; + } + curFindDeletePos = next; + } + if (countPersistPendingNode != 0) { // refresh recordBufferHead + readableSize_ -= countPersistPendingNode; + std::shared_ptr tmpRecordBufferHead = + std::make_shared(); + tmpRecordBufferHead->next = persistPendingBufferEnd->next; + persistPendingBufferEnd->next.reset(); + recordBufferHead_ = tmpRecordBufferHead; + recordBufferHead_->pre.reset(); + if (persistPendingBufferEnd == curRecordBufferPos_) { + curRecordBufferPos_ = recordBufferHead_; + } else { // remainCount !=0 ==> recordBufferHead->next != nullptr + recordBufferHead_->next->pre = recordBufferHead_; + } + } + } + RemoveRecordsFromPersistPendingBufferQueue(record, persistPendingBufferHead, persistPendingBufferEnd); + return Constant::SUCCESS; +} + +void PermissionUsedRecordCache::RemoveRecordsFromPersistPendingBufferQueue(const GenericValues& record, + std::shared_ptr persistPendingBufferHead, + std::shared_ptr persistPendingBufferEnd) +{ + AccessTokenID tokenId = record.GetInt(FIELD_TOKEN_ID); + { + std::shared_ptr curFindDeletePos; + Utils::UniqueWriteGuard lock2(this->cacheLock_); + if (!persistPendingBufferQueue_.empty()) { + for (auto persistHead : persistPendingBufferQueue_) { + curFindDeletePos = persistHead->next; + while (curFindDeletePos != nullptr) { + auto next = curFindDeletePos->next; + if (curFindDeletePos->record.tokenId == tokenId) { + DeleteRecordNode(curFindDeletePos); + } + curFindDeletePos = next; + } + } + } + PermissionRecordRepository::GetInstance().RemoveRecordValues(record); // remove from database + } + if (persistPendingBufferEnd != nullptr) { // add to queue + AddToPersistQueue(persistPendingBufferHead); + } +} + +void PermissionUsedRecordCache::GetRecords(const std::vector& permissionList, + const GenericValues& andConditionValues, const GenericValues& orConditionValues, + std::vector& findRecordsValues) +{ + std::set opCodeList; + std::shared_ptr curFindPos; + std::shared_ptr persistPendingBufferHead; + std::shared_ptr persistPendingBufferEnd = nullptr; + int32_t countPersistPendingNode = 0; + AccessTokenID tokenId = andConditionValues.GetInt(FIELD_TOKEN_ID); + TransferToOpcode(opCodeList, permissionList); + { + Utils::UniqueWriteGuard lock1(this->cacheLock_); + curFindPos = recordBufferHead_->next; + persistPendingBufferHead = recordBufferHead_; + while (curFindPos != nullptr) { + auto next = curFindPos->next; + if (RecordCompare(tokenId, opCodeList, andConditionValues, curFindPos->record)) { + GenericValues recordValues; + PermissionRecord::TranslationIntoGenericValues(curFindPos->record, recordValues); + findRecordsValues.emplace_back(recordValues); + } + if (TimeUtil::GetCurrentTimestamp() - curFindPos->record.timestamp >= INTERVAL) { + persistPendingBufferEnd = curFindPos; + countPersistPendingNode++; + } + curFindPos = next; + } + if (countPersistPendingNode != 0) { // refresh recordBufferHead + readableSize_ -= countPersistPendingNode; + std::shared_ptr tmpRecordBufferHead = + std::make_shared(); + tmpRecordBufferHead->next = persistPendingBufferEnd->next; + persistPendingBufferEnd->next.reset(); + recordBufferHead_ = tmpRecordBufferHead; + if (persistPendingBufferEnd == curRecordBufferPos_) { + curRecordBufferPos_ = recordBufferHead_; + } else { // remainCount !=0 ==> recordBufferHead->next != nullptr + recordBufferHead_->next->pre = recordBufferHead_; + } + } + } + GetRecordsFromPersistPendingBufferQueue(permissionList, andConditionValues, + orConditionValues, findRecordsValues, opCodeList); + if (countPersistPendingNode != 0) { + AddToPersistQueue(persistPendingBufferHead); + } +} + +void PermissionUsedRecordCache::GetRecordsFromPersistPendingBufferQueue( + const std::vector& permissionList, const GenericValues& andConditionValues, + const GenericValues& orConditionValues, std::vector& findRecordsValues, + const std::set& opCodeList) +{ + AccessTokenID tokenId = andConditionValues.GetInt(FIELD_TOKEN_ID); + std::shared_ptr curFindPos; + Utils::UniqueWriteGuard lock2(this->cacheLock_); + if (!persistPendingBufferQueue_.empty()) { + for (auto persistHead : persistPendingBufferQueue_) { + curFindPos = persistHead->next; + while (curFindPos != nullptr) { + auto next = curFindPos->next; + if (RecordCompare(tokenId, opCodeList, andConditionValues, curFindPos->record)) { + GenericValues recordValues; + PermissionRecord::TranslationIntoGenericValues(curFindPos->record, recordValues); + findRecordsValues.emplace_back(recordValues); + } + curFindPos = next; + } + } + } + if (tokenId != INVALID_TOKENID && !PermissionRecordRepository::GetInstance().FindRecordValues( + andConditionValues, orConditionValues, findRecordsValues)) { // find records from database + ACCESSTOKEN_LOG_ERROR(LABEL, "find records from database failed"); + } +} + +void PermissionUsedRecordCache::TransferToOpcode(std::set& opCodeList, + const std::vector& permissionList) +{ + for (const auto& permission : permissionList) { + int32_t opCode = Constant::OP_INVALID; + Constant::TransferPermissionToOpcode(permission, opCode); + opCodeList.insert(opCode); + } +} + +bool PermissionUsedRecordCache::RecordCompare(const AccessTokenID tokenId, const std::set& opCodeList, + const GenericValues& andConditionValues, const PermissionRecord& record) +{ + // compare tokenId + if (record.tokenId != (int32_t)tokenId) { + return false; + } + // compare opCode + if (!opCodeList.empty() && opCodeList.find(record.opCode) == opCodeList.end()) { + return false; + } + // compare timestamp + std::vector andColumns = andConditionValues.GetAllKeys(); + if (!andColumns.empty()) { + for (auto andColumn : andColumns) { + if (andColumn == FIELD_TIMESTAMP_BEGIN && + record.timestamp < andConditionValues.GetInt64(andColumn)) { + return false; + } else if (andColumn == FIELD_TIMESTAMP_END && + record.timestamp > andConditionValues.GetInt64(andColumn)) { + return false; + } else if (andColumn == FIELD_TIMESTAMP && + record.timestamp != andConditionValues.GetInt64(andColumn)) { + return false; + } + } + } + return true; +} + +void PermissionUsedRecordCache::FindTokenIdList(std::set& tokenIdList) +{ + std::shared_ptr curFindPos; + { + // find tokenIdList from recordBuffer + Utils::UniqueWriteGuard lock1(this->cacheLock_); + curFindPos = recordBufferHead_->next; + while (curFindPos != nullptr) { + auto next = curFindPos->next; + tokenIdList.emplace((AccessTokenID)curFindPos->record.tokenId); + curFindPos = next; + } + } + { + // find tokenIdList from BufferQueue + Utils::UniqueWriteGuard lock2(this->cacheLock_); + if (!persistPendingBufferQueue_.empty()) { + for (auto persistHead : persistPendingBufferQueue_) { + curFindPos = persistHead->next; + while (curFindPos != nullptr) { + auto next = curFindPos->next; + tokenIdList.emplace((AccessTokenID)curFindPos->record.tokenId); + curFindPos = next; + } + } + } + } +} + +void PermissionUsedRecordCache::AddRecordNode(const PermissionRecord& record) +{ + std::shared_ptr tmpRecordNode = std::make_shared(); + tmpRecordNode->record = record; + tmpRecordNode->pre = curRecordBufferPos_; + curRecordBufferPos_->next = tmpRecordNode; + curRecordBufferPos_ = curRecordBufferPos_->next; + readableSize_++; +} + +void PermissionUsedRecordCache::DeleteRecordNode(std::shared_ptr deleteRecordNode) +{ + std::shared_ptr pre = deleteRecordNode->pre.lock(); + if (deleteRecordNode->next == nullptr) { // End of the linked list + pre->next = nullptr; + } else { + std::shared_ptr next = deleteRecordNode->next; + pre->next = next; + next->pre = pre; + } +} +} // namespace AccessToken +} // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/services/privacymanager/src/service/privacy_manager_service.cpp b/services/privacymanager/src/service/privacy_manager_service.cpp index 41e1087e1458ec3d3c26dbbd9bd694b996245052..9651bf413493694e893c889f2349de7aa44a92a1 100644 --- a/services/privacymanager/src/service/privacy_manager_service.cpp +++ b/services/privacymanager/src/service/privacy_manager_service.cpp @@ -1,133 +1,138 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "privacy_manager_service.h" - -#include "accesstoken_log.h" -#include "constant_common.h" -#include "constant.h" -#include "ipc_skeleton.h" -#include "permission_record_manager.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyManagerService" -}; -} - -const bool REGISTER_RESULT = - SystemAbility::MakeAndRegisterAbility(DelayedSingleton::GetInstance().get()); - -PrivacyManagerService::PrivacyManagerService() - : SystemAbility(SA_ID_PRIVACY_MANAGER_SERVICE, true), state_(ServiceRunningState::STATE_NOT_START) -{ - ACCESSTOKEN_LOG_INFO(LABEL, "PrivacyManagerService()"); -} - -PrivacyManagerService::~PrivacyManagerService() -{ - ACCESSTOKEN_LOG_INFO(LABEL, "~PrivacyManagerService()"); -} - -void PrivacyManagerService::OnStart() -{ - if (state_ == ServiceRunningState::STATE_RUNNING) { - ACCESSTOKEN_LOG_INFO(LABEL, "PrivacyManagerService has already started!"); - return; - } - if (!Initialize()) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to initialize"); - return; - } - state_ = ServiceRunningState::STATE_RUNNING; - bool ret = Publish(DelayedSingleton::GetInstance().get()); - if (!ret) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to publish service!"); - return; - } - ACCESSTOKEN_LOG_INFO(LABEL, "Congratulations, PrivacyManagerService start successfully!"); -} - -void PrivacyManagerService::OnStop() -{ - ACCESSTOKEN_LOG_INFO(LABEL, "stop service"); - state_ = ServiceRunningState::STATE_NOT_START; -} - -int32_t PrivacyManagerService::AddPermissionUsedRecord( - AccessTokenID tokenId, const std::string& permissionName, int32_t successCount, int32_t failCount) -{ - return PermissionRecordManager::GetInstance().AddPermissionUsedRecord( - tokenId, permissionName, successCount, failCount); -} - -int32_t PrivacyManagerService::StartUsingPermission(AccessTokenID tokenId, const std::string& permissionName) -{ - return PermissionRecordManager::GetInstance().StartUsingPermission(tokenId, permissionName); -} - -int32_t PrivacyManagerService::StopUsingPermission(AccessTokenID tokenId, const std::string& permissionName) -{ - return PermissionRecordManager::GetInstance().StopUsingPermission(tokenId, permissionName); -} - -int32_t PrivacyManagerService::RemovePermissionUsedRecords(AccessTokenID tokenId, const std::string& deviceID) -{ - PermissionRecordManager::GetInstance().RemovePermissionUsedRecords(tokenId, deviceID); - return Constant::SUCCESS; -} - -int32_t PrivacyManagerService::GetPermissionUsedRecords( - const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) -{ - PermissionUsedResult permissionRecord; - int32_t ret = PermissionRecordManager::GetInstance().GetPermissionUsedRecords(request.request, permissionRecord); - result.result = permissionRecord; - return ret; -} - -int32_t PrivacyManagerService::GetPermissionUsedRecords( - const PermissionUsedRequestParcel& request, const sptr& callback) -{ - return PermissionRecordManager::GetInstance().GetPermissionUsedRecordsAsync(request.request, callback); -} - -std::string PrivacyManagerService::DumpRecordInfo(AccessTokenID tokenId, const std::string& permissionName) -{ - return PermissionRecordManager::GetInstance().DumpRecordInfo(tokenId, permissionName); -} - -int32_t PrivacyManagerService::RegisterPermActiveStatusCallback( - std::vector& permList, const sptr& callback) -{ - return PermissionRecordManager::GetInstance().RegisterPermActiveStatusCallback(permList, callback); -} - -int32_t PrivacyManagerService::UnRegisterPermActiveStatusCallback(const sptr& callback) -{ - return PermissionRecordManager::GetInstance().UnRegisterPermActiveStatusCallback(callback); -} - -bool PrivacyManagerService::Initialize() const -{ - PermissionRecordManager::GetInstance().Init(); - return true; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "privacy_manager_service.h" + +#include "accesstoken_log.h" +#include "constant_common.h" +#include "constant.h" +#include "ipc_skeleton.h" +#include "permission_record_manager.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyManagerService" +}; +} + +const bool REGISTER_RESULT = + SystemAbility::MakeAndRegisterAbility(DelayedSingleton::GetInstance().get()); + +PrivacyManagerService::PrivacyManagerService() + : SystemAbility(SA_ID_PRIVACY_MANAGER_SERVICE, true), state_(ServiceRunningState::STATE_NOT_START) +{ + ACCESSTOKEN_LOG_INFO(LABEL, "PrivacyManagerService()"); +} + +PrivacyManagerService::~PrivacyManagerService() +{ + ACCESSTOKEN_LOG_INFO(LABEL, "~PrivacyManagerService()"); +} + +void PrivacyManagerService::OnStart() +{ + if (state_ == ServiceRunningState::STATE_RUNNING) { + ACCESSTOKEN_LOG_INFO(LABEL, "PrivacyManagerService has already started!"); + return; + } + if (!Initialize()) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to initialize"); + return; + } + state_ = ServiceRunningState::STATE_RUNNING; + bool ret = Publish(DelayedSingleton::GetInstance().get()); + if (!ret) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to publish service!"); + return; + } + ACCESSTOKEN_LOG_INFO(LABEL, "Congratulations, PrivacyManagerService start successfully!"); +} + +void PrivacyManagerService::OnStop() +{ + ACCESSTOKEN_LOG_INFO(LABEL, "stop service"); + state_ = ServiceRunningState::STATE_NOT_START; +} + +int32_t PrivacyManagerService::AddPermissionUsedRecord( + AccessTokenID tokenId, const std::string& permissionName, int32_t successCount, int32_t failCount) +{ + return PermissionRecordManager::GetInstance().AddPermissionUsedRecord( + tokenId, permissionName, successCount, failCount); +} + +int32_t PrivacyManagerService::StartUsingPermission(AccessTokenID tokenId, const std::string& permissionName) +{ + return PermissionRecordManager::GetInstance().StartUsingPermission(tokenId, permissionName); +} + +int32_t PrivacyManagerService::StopUsingPermission(AccessTokenID tokenId, const std::string& permissionName) +{ + return PermissionRecordManager::GetInstance().StopUsingPermission(tokenId, permissionName); +} + +int32_t PrivacyManagerService::RemovePermissionUsedRecords(AccessTokenID tokenId, const std::string& deviceID) +{ + PermissionRecordManager::GetInstance().RemovePermissionUsedRecords(tokenId, deviceID); + return Constant::SUCCESS; +} + +int32_t PrivacyManagerService::GetPermissionUsedRecords( + const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) +{ + PermissionUsedResult permissionRecord; + int32_t ret = PermissionRecordManager::GetInstance().GetPermissionUsedRecords(request.request, permissionRecord); + result.result = permissionRecord; + return ret; +} + +int32_t PrivacyManagerService::GetPermissionUsedRecords( + const PermissionUsedRequestParcel& request, const sptr& callback) +{ + return PermissionRecordManager::GetInstance().GetPermissionUsedRecordsAsync(request.request, callback); +} + +std::string PrivacyManagerService::DumpRecordInfo(AccessTokenID tokenId, const std::string& permissionName) +{ + return PermissionRecordManager::GetInstance().DumpRecordInfo(tokenId, permissionName); +} + +int32_t PrivacyManagerService::RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) +{ + return PermissionRecordManager::GetInstance().RegisterPermActiveStatusCallback(permList, callback); +} + +int32_t PrivacyManagerService::UnRegisterPermActiveStatusCallback(const sptr& callback) +{ + return PermissionRecordManager::GetInstance().UnRegisterPermActiveStatusCallback(callback); +} + +bool PrivacyManagerService::IsAllowUsingPermission(AccessTokenID tokenId, const std::string& permissionName) +{ + return false; +} + +bool PrivacyManagerService::Initialize() const +{ + PermissionRecordManager::GetInstance().Init(); + return true; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/service/privacy_manager_stub.cpp b/services/privacymanager/src/service/privacy_manager_stub.cpp index 743cd11b595da3882498a7de7ab982255fa3e278..618d291fa6da18487c40a642f114eb328b7cd459 100644 --- a/services/privacymanager/src/service/privacy_manager_stub.cpp +++ b/services/privacymanager/src/service/privacy_manager_stub.cpp @@ -1,211 +1,223 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "privacy_manager_stub.h" - -#include "accesstoken_kit.h" -#include "accesstoken_log.h" - -#include "ipc_skeleton.h" -#include "string_ex.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyManagerStub" -}; -static const uint32_t PERM_LIST_SIZE_MAX = 1024; -} - -int32_t PrivacyManagerStub::OnRemoteRequest( - uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -{ - std::u16string descriptor = data.ReadInterfaceToken(); - if (descriptor != IPrivacyManager::GetDescriptor()) { - ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor: %{public}s", Str16ToStr8(descriptor).c_str()); - return -1; - } - switch (code) { - case static_cast(IPrivacyManager::InterfaceCode::ADD_PERMISSION_USED_RECORD): - AddPermissionUsedRecordInner(data, reply); - break; - case static_cast(IPrivacyManager::InterfaceCode::START_USING_PERMISSION): - StartUsingPermissionInner(data, reply); - break; - case static_cast(IPrivacyManager::InterfaceCode::STOP_USING_PERMISSION): - StopUsingPermissionInner(data, reply); - break; - case static_cast(IPrivacyManager::InterfaceCode::DELETE_PERMISSION_USED_RECORDS): - RemovePermissionUsedRecordsInner(data, reply); - break; - case static_cast(IPrivacyManager::InterfaceCode::GET_PERMISSION_USED_RECORDS): - GetPermissionUsedRecordsInner(data, reply); - break; - case static_cast(IPrivacyManager::InterfaceCode::GET_PERMISSION_USED_RECORDS_ASYNC): - GetPermissionUsedRecordsAsyncInner(data, reply); - break; - case static_cast(IPrivacyManager::InterfaceCode::DUMP_RECORD_INFO): - DumpRecordInfoInner(data, reply); - break; - case static_cast(IPrivacyManager::InterfaceCode::REGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK): - RegisterPermActiveStatusCallbackInner(data, reply); - break; - case static_cast(IPrivacyManager::InterfaceCode::UNREGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK): - UnRegisterPermActiveStatusCallbackInner(data, reply); - break; - default: - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - return NO_ERROR; -} - -void PrivacyManagerStub::AddPermissionUsedRecordInner(MessageParcel& data, MessageParcel& reply) -{ - uint32_t callingTokenID = IPCSkeleton::GetCallingTokenID(); - if (AccessTokenKit::VerifyAccessToken( - callingTokenID, "ohos.permission.PERMISSION_USED_STATS") == PERMISSION_DENIED) { - ACCESSTOKEN_LOG_INFO(LABEL, "permission denied"); - reply.WriteInt32(RET_FAILED); - return; - } - AccessTokenID tokenId = data.ReadUint32(); - std::string permissionName = data.ReadString(); - int32_t successCount = data.ReadInt32(); - int32_t failCount = data.ReadInt32(); - int32_t result = this->AddPermissionUsedRecord(tokenId, permissionName, successCount, failCount); - reply.WriteInt32(result); -} - -void PrivacyManagerStub::StartUsingPermissionInner(MessageParcel& data, MessageParcel& reply) -{ - AccessTokenID tokenId = data.ReadUint32(); - std::string permissionName = data.ReadString(); - int32_t result = this->StartUsingPermission(tokenId, permissionName); - reply.WriteInt32(result); -} - -void PrivacyManagerStub::StopUsingPermissionInner(MessageParcel& data, MessageParcel& reply) -{ - AccessTokenID tokenId = data.ReadUint32(); - std::string permissionName = data.ReadString(); - int32_t result = this->StopUsingPermission(tokenId, permissionName); - reply.WriteInt32(result); -} - -void PrivacyManagerStub::RemovePermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply) -{ - uint32_t callingTokenID = IPCSkeleton::GetCallingTokenID(); - if (!IsAccessTokenCalling() && AccessTokenKit::VerifyAccessToken( - callingTokenID, "ohos.permission.PERMISSION_USED_STATS") == PERMISSION_DENIED) { - ACCESSTOKEN_LOG_INFO(LABEL, "permission denied"); - reply.WriteInt32(RET_FAILED); - return; - } - AccessTokenID tokenId = data.ReadUint32(); - std::string deviceID = data.ReadString(); - int32_t result = this->RemovePermissionUsedRecords(tokenId, deviceID); - reply.WriteInt32(result); -} - -void PrivacyManagerStub::GetPermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply) -{ - PermissionUsedResultParcel responseParcel; - uint32_t callingTokenID = IPCSkeleton::GetCallingTokenID(); - if (AccessTokenKit::VerifyAccessToken( - callingTokenID, "ohos.permission.PERMISSION_USED_STATS") == PERMISSION_DENIED) { - ACCESSTOKEN_LOG_INFO(LABEL, "permission denied"); - reply.WriteParcelable(&responseParcel); - reply.WriteInt32(RET_FAILED); - return; - } - sptr requestParcel = data.ReadParcelable(); - if (requestParcel == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable faild"); - reply.WriteParcelable(&responseParcel); - reply.WriteInt32(RET_FAILED); - return; - } - int32_t result = this->GetPermissionUsedRecords(*requestParcel, responseParcel); - reply.WriteParcelable(&responseParcel); - reply.WriteInt32(result); -} - -void PrivacyManagerStub::GetPermissionUsedRecordsAsyncInner(MessageParcel& data, MessageParcel& reply) -{ - sptr requestParcel = data.ReadParcelable(); - if (requestParcel == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable faild"); - reply.WriteInt32(RET_FAILED); - return; - } - sptr callback = iface_cast(data.ReadRemoteObject()); - int32_t result = this->GetPermissionUsedRecords(*requestParcel, callback); - reply.WriteInt32(result); -} - -void PrivacyManagerStub::DumpRecordInfoInner(MessageParcel& data, MessageParcel& reply) -{ - AccessTokenID tokenId = data.ReadUint32(); - std::string permissionName = data.ReadString(); - std::string dumpInfo = this->DumpRecordInfo(tokenId, permissionName); - reply.WriteString(dumpInfo); -} - -void PrivacyManagerStub::RegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply) -{ - uint32_t permListSize = data.ReadUint32(); - if (permListSize > PERM_LIST_SIZE_MAX) { - ACCESSTOKEN_LOG_ERROR(LABEL, "read permListSize fail"); - reply.WriteInt32(RET_FAILED); - return; - } - std::vector permList; - for (uint32_t i = 0; i < permListSize; i++) { - std::string perm = data.ReadString(); - permList.emplace_back(perm); - } - sptr callback = data.ReadRemoteObject(); - if (callback == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "read ReadRemoteObject fail"); - reply.WriteInt32(RET_FAILED); - return; - } - int32_t result = this->RegisterPermActiveStatusCallback(permList, callback); - reply.WriteInt32(result); -} - -void PrivacyManagerStub::UnRegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply) -{ - sptr callback = data.ReadRemoteObject(); - if (callback == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "read scopeParcel fail"); - reply.WriteInt32(RET_FAILED); - return; - } - - int32_t result = this->UnRegisterPermActiveStatusCallback(callback); - reply.WriteInt32(result); -} - -bool PrivacyManagerStub::IsAccessTokenCalling() const -{ - int32_t callingUid = IPCSkeleton::GetCallingUid(); - return callingUid == ACCESSTOKEN_UID; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "privacy_manager_stub.h" + +#include "accesstoken_kit.h" +#include "accesstoken_log.h" + +#include "ipc_skeleton.h" +#include "string_ex.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PrivacyManagerStub" +}; +static const uint32_t PERM_LIST_SIZE_MAX = 1024; +} + +int32_t PrivacyManagerStub::OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IPrivacyManager::GetDescriptor()) { + ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor: %{public}s", Str16ToStr8(descriptor).c_str()); + return -1; + } + switch (code) { + case static_cast(IPrivacyManager::InterfaceCode::ADD_PERMISSION_USED_RECORD): + AddPermissionUsedRecordInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::START_USING_PERMISSION): + StartUsingPermissionInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::STOP_USING_PERMISSION): + StopUsingPermissionInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::DELETE_PERMISSION_USED_RECORDS): + RemovePermissionUsedRecordsInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::GET_PERMISSION_USED_RECORDS): + GetPermissionUsedRecordsInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::GET_PERMISSION_USED_RECORDS_ASYNC): + GetPermissionUsedRecordsAsyncInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::DUMP_RECORD_INFO): + DumpRecordInfoInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::REGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK): + RegisterPermActiveStatusCallbackInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::UNREGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK): + UnRegisterPermActiveStatusCallbackInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::IS_ALLOW_USING_PERMISSION): + IsAllowUsingPermissionInner(data, reply); + break; + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} + +void PrivacyManagerStub::AddPermissionUsedRecordInner(MessageParcel& data, MessageParcel& reply) +{ + uint32_t callingTokenID = IPCSkeleton::GetCallingTokenID(); + if (AccessTokenKit::VerifyAccessToken( + callingTokenID, "ohos.permission.PERMISSION_USED_STATS") == PERMISSION_DENIED) { + ACCESSTOKEN_LOG_INFO(LABEL, "permission denied"); + reply.WriteInt32(RET_FAILED); + return; + } + AccessTokenID tokenId = data.ReadUint32(); + std::string permissionName = data.ReadString(); + int32_t successCount = data.ReadInt32(); + int32_t failCount = data.ReadInt32(); + int32_t result = this->AddPermissionUsedRecord(tokenId, permissionName, successCount, failCount); + reply.WriteInt32(result); +} + +void PrivacyManagerStub::StartUsingPermissionInner(MessageParcel& data, MessageParcel& reply) +{ + AccessTokenID tokenId = data.ReadUint32(); + std::string permissionName = data.ReadString(); + int32_t result = this->StartUsingPermission(tokenId, permissionName); + reply.WriteInt32(result); +} + +void PrivacyManagerStub::StopUsingPermissionInner(MessageParcel& data, MessageParcel& reply) +{ + AccessTokenID tokenId = data.ReadUint32(); + std::string permissionName = data.ReadString(); + int32_t result = this->StopUsingPermission(tokenId, permissionName); + reply.WriteInt32(result); +} + +void PrivacyManagerStub::RemovePermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply) +{ + uint32_t callingTokenID = IPCSkeleton::GetCallingTokenID(); + if (!IsAccessTokenCalling() && AccessTokenKit::VerifyAccessToken( + callingTokenID, "ohos.permission.PERMISSION_USED_STATS") == PERMISSION_DENIED) { + ACCESSTOKEN_LOG_INFO(LABEL, "permission denied"); + reply.WriteInt32(RET_FAILED); + return; + } + AccessTokenID tokenId = data.ReadUint32(); + std::string deviceID = data.ReadString(); + int32_t result = this->RemovePermissionUsedRecords(tokenId, deviceID); + reply.WriteInt32(result); +} + +void PrivacyManagerStub::GetPermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply) +{ + PermissionUsedResultParcel responseParcel; + uint32_t callingTokenID = IPCSkeleton::GetCallingTokenID(); + if (AccessTokenKit::VerifyAccessToken( + callingTokenID, "ohos.permission.PERMISSION_USED_STATS") == PERMISSION_DENIED) { + ACCESSTOKEN_LOG_INFO(LABEL, "permission denied"); + reply.WriteParcelable(&responseParcel); + reply.WriteInt32(RET_FAILED); + return; + } + sptr requestParcel = data.ReadParcelable(); + if (requestParcel == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable faild"); + reply.WriteParcelable(&responseParcel); + reply.WriteInt32(RET_FAILED); + return; + } + int32_t result = this->GetPermissionUsedRecords(*requestParcel, responseParcel); + reply.WriteParcelable(&responseParcel); + reply.WriteInt32(result); +} + +void PrivacyManagerStub::GetPermissionUsedRecordsAsyncInner(MessageParcel& data, MessageParcel& reply) +{ + sptr requestParcel = data.ReadParcelable(); + if (requestParcel == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable faild"); + reply.WriteInt32(RET_FAILED); + return; + } + sptr callback = iface_cast(data.ReadRemoteObject()); + int32_t result = this->GetPermissionUsedRecords(*requestParcel, callback); + reply.WriteInt32(result); +} + +void PrivacyManagerStub::DumpRecordInfoInner(MessageParcel& data, MessageParcel& reply) +{ + AccessTokenID tokenId = data.ReadUint32(); + std::string permissionName = data.ReadString(); + std::string dumpInfo = this->DumpRecordInfo(tokenId, permissionName); + reply.WriteString(dumpInfo); +} + +void PrivacyManagerStub::RegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply) +{ + uint32_t permListSize = data.ReadUint32(); + if (permListSize > PERM_LIST_SIZE_MAX) { + ACCESSTOKEN_LOG_ERROR(LABEL, "read permListSize fail"); + reply.WriteInt32(RET_FAILED); + return; + } + std::vector permList; + for (uint32_t i = 0; i < permListSize; i++) { + std::string perm = data.ReadString(); + permList.emplace_back(perm); + } + sptr callback = data.ReadRemoteObject(); + if (callback == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "read ReadRemoteObject fail"); + reply.WriteInt32(RET_FAILED); + return; + } + int32_t result = this->RegisterPermActiveStatusCallback(permList, callback); + reply.WriteInt32(result); +} + +void PrivacyManagerStub::UnRegisterPermActiveStatusCallbackInner(MessageParcel& data, MessageParcel& reply) +{ + sptr callback = data.ReadRemoteObject(); + if (callback == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "read scopeParcel fail"); + reply.WriteInt32(RET_FAILED); + return; + } + + int32_t result = this->UnRegisterPermActiveStatusCallback(callback); + reply.WriteInt32(result); +} + +void PrivacyManagerStub::IsAllowUsingPermissionInner(MessageParcel& data, MessageParcel& reply) +{ + AccessTokenID tokenId = data.ReadUint32(); + std::string permissionName = data.ReadString(); + bool allowperInfo = this->IsAllowUsingPermission(tokenId, permissionName); + reply.WriteBool(allowperInfo); +} + + +bool PrivacyManagerStub::IsAccessTokenCalling() const +{ + int32_t callingUid = IPCSkeleton::GetCallingUid(); + return callingUid == ACCESSTOKEN_UID; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/test/add_permission_used_record_test/add_permission_used_record_test.cpp b/services/privacymanager/test/add_permission_used_record_test/add_permission_used_record_test.cpp index c139fe2ab0b812c572b4d82ed44d9f84a68c0956..41c953308e77afe1f0c90e0b76b63e677dda4af3 100644 --- a/services/privacymanager/test/add_permission_used_record_test/add_permission_used_record_test.cpp +++ b/services/privacymanager/test/add_permission_used_record_test/add_permission_used_record_test.cpp @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "add_permission_used_record_test.h" - -using namespace testing::ext; -using namespace OHOS::Security::AccessToken; - -void AddPermissionUsedRecordTest::SetUpTestCase() -{} - -void AddPermissionUsedRecordTest::TearDownTestCase() -{ -} - -void AddPermissionUsedRecordTest::SetUp() -{ -} - -void AddPermissionUsedRecordTest::TearDown() -{ -} - -/** - * @tc.name: AddPermissionUsedRecord_001 - * @tc.desc: cannot AddPermissionUsedRecord with invalid tokenID and permission. - * @tc.type: FUNC - * @tc.require:AR000GK6TD===== - */ -HWTEST_F(AddPermissionUsedRecordTest, AddPermissionUsedRecord_001, TestSize.Level1) -{ - int32_t successCount = 1; - int32_t fasilCount = 0; - std::string permission = "ohon.permission.READ_CONTACTS"; - AccessTokenID tokenID = AccessTokenKit::GetHapTokenID(g_InfoParmsA.userID, - g_InfoParmsA.bundleName, - g_InfoParmsA.instIndex); - int32_t ret = PrivacyKit::AddPermissionUsedRecord(0, permission, successCount, fasilCount); - ASSERT_EQ(RET_FAILED, ret); - - ret = PrivacyKit::AddPermissionUsedRecord(tokenID, "", successCount, fasilCount); - ASSERT_EQ(RET_FAILED, ret); -} +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "add_permission_used_record_test.h" + +using namespace testing::ext; +using namespace OHOS::Security::AccessToken; + +void AddPermissionUsedRecordTest::SetUpTestCase() +{} + +void AddPermissionUsedRecordTest::TearDownTestCase() +{ +} + +void AddPermissionUsedRecordTest::SetUp() +{ +} + +void AddPermissionUsedRecordTest::TearDown() +{ +} + +/** + * @tc.name: AddPermissionUsedRecord_001 + * @tc.desc: cannot AddPermissionUsedRecord with invalid tokenID and permission. + * @tc.type: FUNC + * @tc.require:AR000GK6TD===== + */ +HWTEST_F(AddPermissionUsedRecordTest, AddPermissionUsedRecord_001, TestSize.Level1) +{ + int32_t successCount = 1; + int32_t fasilCount = 0; + std::string permission = "ohon.permission.READ_CONTACTS"; + AccessTokenID tokenID = AccessTokenKit::GetHapTokenID(g_InfoParmsA.userID, + g_InfoParmsA.bundleName, + g_InfoParmsA.instIndex); + int32_t ret = PrivacyKit::AddPermissionUsedRecord(0, permission, successCount, fasilCount); + ASSERT_EQ(RET_FAILED, ret); + + ret = PrivacyKit::AddPermissionUsedRecord(tokenID, "", successCount, fasilCount); + ASSERT_EQ(RET_FAILED, ret); +} diff --git a/services/privacymanager/test/add_permission_used_record_test/add_permission_used_record_test.h b/services/privacymanager/test/add_permission_used_record_test/add_permission_used_record_test.h index 8f6f83d318ffc07700083e1b442c73945c12461d..ad18b7d11d10c3cd2b5186faab6eb32e3a098438 100644 --- a/services/privacymanager/test/add_permission_used_record_test/add_permission_used_record_test.h +++ b/services/privacymanager/test/add_permission_used_record_test/add_permission_used_record_test.h @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ADD_PERMISSION_USED_RECORD_TEST_H -#define ADD_PERMISSION_USED_RECORD_TEST_H - -#include - -namespace OHOS { -namespace Security { -namespace AccessToken { -class AddPermissionUsedRecordTest : public testing::Test { -public: - static void SetUpTestCase(); - - static void TearDownTestCase(); - - void SetUp(); - - void TearDown(); -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // ADD_PERMISSION_USED_RECORD_TEST_H +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ADD_PERMISSION_USED_RECORD_TEST_H +#define ADD_PERMISSION_USED_RECORD_TEST_H + +#include + +namespace OHOS { +namespace Security { +namespace AccessToken { +class AddPermissionUsedRecordTest : public testing::Test { +public: + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp(); + + void TearDown(); +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // ADD_PERMISSION_USED_RECORD_TEST_H