From c3c4795094738fe59e97bc369497f4b36d0fa883 Mon Sep 17 00:00:00 2001 From: caochuan Date: Fri, 19 Apr 2024 04:57:40 -0400 Subject: [PATCH] add ringtone_data_extension Signed-off-by: caochuan --- LICENSE | 177 ++ OAT.xml | 38 +- frameworks/ringtone_extension_hap/BUILD.gn | 46 + .../RingtoneLibraryExt/.gitignore | 4 + .../RingtoneLibraryExt/AppScope/app.json | 17 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes .../RingtoneLibraryExt/build-profile.json5 | 26 + .../RingtoneLibraryExt/entry/.gitignore | 3 + .../entry/build-profile.json5 | 13 + .../RingtoneLibraryExt/entry/hvigorfile.js | 2 + .../entry/package-lock.json | 5 + .../RingtoneLibraryExt/entry/package.json | 14 + .../src/main/ets/Application/AbilityStage.ts | 22 + .../DataShareExtAbility.ts | 60 + .../src/main/ets/MainAbility/MainAbility.ts | 48 + .../entry/src/main/ets/pages/index.ets | 17 + .../entry/src/main/module.json | 73 + .../main/resources/base/element/string.json | 28 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 5 + .../ohosTest/ets/TestAbility/TestAbility.ts | 54 + .../ohosTest/ets/TestAbility/pages/index.ets | 34 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 73 + .../src/ohosTest/ets/test/Ability.test.ets | 13 + .../entry/src/ohosTest/ets/test/List.test.ets | 5 + .../entry/src/ohosTest/module.json5 | 38 + .../resources/base/element/string.json | 16 + .../ohosTest/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/test_pages.json | 5 + .../RingtoneLibraryExt/hvigorfile.js | 2 + .../RingtoneLibraryExt/package-lock.json | 1652 +++++++++++++++++ .../RingtoneLibraryExt/package.json | 18 + .../signature/ringtonelibrary.p7b | Bin 0 -> 3688 bytes hisysevent.yaml | 45 + .../include/ringtone_bundle_manager.h | 46 + .../include/ringtone_data_command.h | 76 + .../include/ringtone_data_manager.h | 64 + .../include/ringtone_datashare_extension.h | 138 ++ .../include/ringtone_datashare_stub_impl.h | 74 + .../include/ringtone_rdbstore.h | 67 + .../include/ringtone_subscriber.h | 38 + .../include/ringtone_unistore.h | 58 + .../src/ringtone_bundle_manager.cpp | 82 + .../src/ringtone_data_command.cpp | 127 ++ .../src/ringtone_data_manager.cpp | 359 ++++ .../src/ringtone_datashare_extension.cpp | 337 ++++ .../src/ringtone_datashare_stub_impl.cpp | 242 +++ .../src/ringtone_rdbstore.cpp | 327 ++++ .../src/ringtone_subscriber.cpp | 62 + services/ringtone_helper/BUILD.gn | 80 + .../ringtone_helper/include/ringtone_asset.h | 107 ++ .../include/ringtone_fetch_result.h | 71 + .../ringtone_helper/src/ringtone_asset.cpp | 280 +++ .../src/ringtone_fetch_result.cpp | 309 +++ 55 files changed, 5503 insertions(+), 2 deletions(-) create mode 100644 LICENSE create mode 100644 frameworks/ringtone_extension_hap/BUILD.gn create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/.gitignore create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/app.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/resources/base/element/string.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/resources/base/media/app_icon.png create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/build-profile.json5 create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/.gitignore create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/build-profile.json5 create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/hvigorfile.js create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/package-lock.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/package.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/Application/AbilityStage.ts create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/MainAbility/MainAbility.ts create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/pages/index.ets create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/module.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/resources/base/element/string.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/resources/base/media/icon.png create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/resources/base/profile/main_pages.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/TestAbility/TestAbility.ts create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/TestAbility/pages/index.ets create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/test/Ability.test.ets create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/test/List.test.ets create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/module.json5 create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/resources/base/element/string.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/resources/base/media/icon.png create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/resources/base/profile/test_pages.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/hvigorfile.js create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/package-lock.json create mode 100644 frameworks/ringtone_extension_hap/RingtoneLibraryExt/package.json create mode 100644 frameworks/ringtone_extension_hap/signature/ringtonelibrary.p7b create mode 100644 hisysevent.yaml create mode 100644 services/ringtone_data_extension/include/ringtone_bundle_manager.h create mode 100644 services/ringtone_data_extension/include/ringtone_data_command.h create mode 100644 services/ringtone_data_extension/include/ringtone_data_manager.h create mode 100644 services/ringtone_data_extension/include/ringtone_datashare_extension.h create mode 100644 services/ringtone_data_extension/include/ringtone_datashare_stub_impl.h create mode 100644 services/ringtone_data_extension/include/ringtone_rdbstore.h create mode 100644 services/ringtone_data_extension/include/ringtone_subscriber.h create mode 100644 services/ringtone_data_extension/include/ringtone_unistore.h create mode 100644 services/ringtone_data_extension/src/ringtone_bundle_manager.cpp create mode 100644 services/ringtone_data_extension/src/ringtone_data_command.cpp create mode 100644 services/ringtone_data_extension/src/ringtone_data_manager.cpp create mode 100644 services/ringtone_data_extension/src/ringtone_datashare_extension.cpp create mode 100644 services/ringtone_data_extension/src/ringtone_datashare_stub_impl.cpp create mode 100644 services/ringtone_data_extension/src/ringtone_rdbstore.cpp create mode 100644 services/ringtone_data_extension/src/ringtone_subscriber.cpp create mode 100644 services/ringtone_helper/BUILD.gn create mode 100644 services/ringtone_helper/include/ringtone_asset.h create mode 100644 services/ringtone_helper/include/ringtone_fetch_result.h create mode 100644 services/ringtone_helper/src/ringtone_asset.cpp create mode 100644 services/ringtone_helper/src/ringtone_fetch_result.cpp diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4947287 --- /dev/null +++ b/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/OAT.xml b/OAT.xml index ff5a7d1..f90efce 100644 --- a/OAT.xml +++ b/OAT.xml @@ -67,10 +67,44 @@ - + + + + + + + + + + + + + + + + + + diff --git a/frameworks/ringtone_extension_hap/BUILD.gn b/frameworks/ringtone_extension_hap/BUILD.gn new file mode 100644 index 0000000..c560cd8 --- /dev/null +++ b/frameworks/ringtone_extension_hap/BUILD.gn @@ -0,0 +1,46 @@ +# Copyright (C) 2024 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("//foundation/multimedia/ringtone_library/ringtone_library.gni") + +ohos_hap("ringtone_extension_hap") { + hap_profile = "RingtoneLibraryExt/entry/src/main/module.json" + deps = [ + ":RingtoneLibStage_js_assets", + ":RingtoneLibStage_resources", + ] + certificate_profile = "${RINGTONE_EXT_HAP_PATH}/signature/ringtonelibrary.p7b" + shared_libraries = [ "${RINGTONE_SERVICES_PATH}:ringtone_data_extension" ] + hap_name = "Ringtone_Library_Ext" + part_name = "prebuilt_hap" + subsystem_name = "applications" + module_install_dir = "app/com.ohos.ringtonelibrary.RingtoneLibraryData" +} + +ohos_js_assets("RingtoneLibStage_js_assets") { + hap_profile = "RingtoneLibraryExt/entry/src/main/module.json" + ets2abc = true + source_dir = "RingtoneLibraryExt/entry/src/main/ets" +} + +ohos_app_scope("RingtoneLibStage_app_profile") { + app_profile = "RingtoneLibraryExt/AppScope/app.json" + sources = [ "RingtoneLibraryExt/AppScope/resources" ] +} + +ohos_resources("RingtoneLibStage_resources") { + hap_profile = "RingtoneLibraryExt/entry/src/main/module.json" + deps = [ ":RingtoneLibStage_app_profile" ] + sources = [ "RingtoneLibraryExt/entry/src/main/resources" ] +} diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/.gitignore b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/.gitignore new file mode 100644 index 0000000..39187eb --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/local.properties +/.idea +**/build \ No newline at end of file diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/app.json b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/app.json new file mode 100644 index 0000000..799a8d8 --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/app.json @@ -0,0 +1,17 @@ +{ + "app": { + "bundleName": "com.ohos.ringtonelibrary.ringtonelibrarydata", + "vendor": "huawei", + "versionCode": 10000000, + "versionName": "1.0.0.0", + "minAPIVersion": 12, + "targetAPIVersion": 12, + "KeepAlive": false, + "removable": false, + "singleton": false, + "icon": "$media:app_icon", + "label": "$string:app_name", + "generateBuildHash": true, + "distributedNotificationEnabled": true + } +} diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/resources/base/element/string.json b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/resources/base/element/string.json new file mode 100644 index 0000000..d504011 --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "RingtoneLibraryExt" + } + ] +} diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/resources/base/media/app_icon.png b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O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4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y> DataShareExtAbility onCreate, want:' + want.abilityName); + } + + getFileTypes(uri: string, mimeTypeFilter: string): void { + console.info('[RingtoneDataShare] <> [getFileTypes] enter'); + } + + insert(uri, value, callback): void { + console.info('[RingtoneDataShare] <> [insert] enter'); + } + + update(uri, value, predicates, callback): void { + console.info('[RingtoneDataShare] <> [update] enter'); + } + + delete(uri, predicates, callback): void { + console.info('[RingtoneDataShare] <> [delete] enter'); + } + + query(uri, columns, predicates, callback): void { + console.info('[RingtoneDataShare] <> [query] enter'); + } + + getType(uri: string): void { + console.info('[RingtoneDataShare] <> [getType] enter'); + } + + batchInsert(uri: string, valueBuckets, callback): void { + console.info('[RingtoneDataShare] <> [batchInsert] enter'); + } + + normalizeUri(uri: string): void { + console.info('[RingtoneDataShare] <> [normalizeUri] enter'); + } + + denormalizeUri(uri: string): void { + console.info('[RingtoneDataShare] <> [denormalizeUri] enter'); + } +}; diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/MainAbility/MainAbility.ts b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000..1d5bf9e --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2024 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.app.ability.UIAbility'; + +export default class MainAbility extends Ability { + onCreate(want, launchParam): void { + console.log('[Ringtone] MainAbility onCreate'); + globalThis.abilityWant = want; + } + + onDestroy(): void { + console.log('[Ringtone] MainAbility onDestroy'); + } + + onWindowStageCreate(windowStage): void { + // Main window is created, set main page for this ability + console.log('[Ringtone] MainAbility onWindowStageCreate'); + windowStage.setUIContent(this.context, 'pages/index', null); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + console.log('[Ringtone] MainAbility onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + console.log('[Ringtone] MainAbility onForeground'); + } + + onBackground(): void { + // Ability has back to background + console.log('[Ringtone] MainAbility onBackground'); + } +}; diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/pages/index.ets b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000..d6ca48c --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/ets/pages/index.ets @@ -0,0 +1,17 @@ +@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/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/module.json b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/module.json new file mode 100644 index 0000000..8a34811 --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/module.json @@ -0,0 +1,73 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "phone", + "tablet", + "2in1" + ], + "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:app_name", + "visible": false + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/DataShareExtAbility/DataShareExtAbility.ts", + "name": "DataShareExtAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:DataShareExtAbility_desc", + "type": "dataShare", + "uri": "datashare://ringtone", + "visible": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.PERMISSION_USED_STATS", + "reason": "$string:permission_used_stats", + "usedScene": { + "abilities": [ + "DataShareExtAbility" + ], + "when": "inuse" + } + }, + { + "name": "ohos.permission.PROXY_AUTHORIZATION_URI", + "reason": "$string:permission_proxy_authorization_uri", + "usedScene": { + "abilities": [ + "DataShareExtAbility" + ], + "when": "inuse" + } + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "$string:permission_get_bundle_info_privileged", + "usedScene": { + "abilities": [ + "DataShareExtAbility" + ], + "when": "inuse" + } + } + ] + } +} diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/resources/base/element/string.json b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000..332be58 --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "DataShareExtAbility_desc", + "value": "description" + }, + { + "name": "permission_used_stats", + "value": "Allow the application to access the permission usage records" + }, + { + "name": "permission_proxy_authorization_uri", + "value": "Allow the application proxy to grant URIs" + }, + { + "name": "permission_get_bundle_info_privileged", + "value": "Allows querying of the app's basic information and other sensitive information" + } + ] +} \ No newline at end of file diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/resources/base/media/icon.png b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+Y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Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000..0eee5e0 --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 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 TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; + +let abilityDelegator = undefined; +let abilityDelegatorArguments = undefined; + +function translateParamsToString(parameters): string { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}`; + } + } + return targetParams.trim(); +} + +async function onAbilityCreateCallback(): Promise { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err): Promise { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare(): void { + console.info('OpenHarmonyTestRunner OnPrepare '); + } + + async onRun(): Promise { + console.log('OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters); + console.info('cmd : ' + cmd); + abilityDelegator.executeShellCommand(cmd, + (err, d) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }); + console.info('OpenHarmonyTestRunner onRun end'); + } +}; \ No newline at end of file diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/test/Ability.test.ets b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..679d23a --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,13 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' + +export default function abilityTest() { + describe('ActsAbilityTest', function () { + it('assertContain',0, function () { + console.info("it begin") + let a = 'abc' + let b = 'b' + expect(a).assertContain(b) + expect(a).assertEqual(a) + }) + }) +} \ No newline at end of file diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/test/List.test.ets b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..d766fe2 --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/module.json5 b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000..a1a754e --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/module.json5 @@ -0,0 +1,38 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "description": "$string:entry_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/resources/base/element/string.json b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000..8407800 --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_test_desc", + "value": "i am an entry for tv" + }, + { + "name": "TestAbility_desc", + "value": "the tv entry test ability" + }, + { + "name": "TestAbility_label", + "value": "tvBase" + } + ] +} \ No newline at end of file diff --git a/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/resources/base/media/icon.png b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obw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e2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y= 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.9.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", + "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.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/streamroller/-/streamroller-3.0.7.tgz", + "integrity": "sha512-kh68kwiDGuIPiPDWwRbEC5us+kfARP1e9AsQiaLaSqGrctOvMn0mtL8iNY3r4/o5nIoYi3gPI1jexguZsXDlxw==", + "requires": { + "date-format": "^4.0.7", + "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/ringtone_extension_hap/RingtoneLibraryExt/package.json b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/package.json new file mode 100644 index 0000000..63c7ca3 --- /dev/null +++ b/frameworks/ringtone_extension_hap/RingtoneLibraryExt/package.json @@ -0,0 +1,18 @@ +{ + "license":"ISC", + "devDependencies":{}, + "name":"ringtonelibrarydata", + "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" + } +} diff --git a/frameworks/ringtone_extension_hap/signature/ringtonelibrary.p7b b/frameworks/ringtone_extension_hap/signature/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null +++ b/hisysevent.yaml @@ -0,0 +1,45 @@ +# Copyright (c) 2024 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. + +##################################################### +# below is the format of defining event # +##################################################### +#domain: domain name. [Only one domain name can be defined at the top] +# +#author: the author name who defined this event. +#date: the date when this event was defined, format is YYYY-MM-DD. +#logged: source file which refer to this event. +#usage: the usage of this event. +#//Define event name and event properties. +#@EVENT_NAME: the event definition part begin. +# // __BASE is used for defining the basic info of the event. +# // "type" optional values are: FAULT, STATISTICS, SECURITY, BEHAVIOR. +# // "level" optional values are: CRITICAL, MINOR. +# // "tag" set tags with may used by subscriber of this event, multiple tags divided by space. +# // "desc" full description of this event. +# @PARAMETER: {type: parameter type, arrsize: array length(optional), desc: parameter description}. +# // follow the __BASE block, each line defines a parameter of this event. +# // "type" optional values are: INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT, DOUBLE, STRING. +# // "arrsize" of the parameter is an array, set a non-zero value. +# // "desc" full description of this parameter. + +# DESCRIPTION contains userid,request type. +# REASON contains errno num, and failed interface. + +domain: RINGTONELIBRARY + +RINGTONELIB_DFX_MESSAGE: + __BASE: { type: STATISTIC, level: MINOR, desc: preset and custom ringtone number } + DATE: { type: STRING, desc: report date } + PRESET_NUM: { type: INT32, desc: preset ringtone number } + CUSTOM_NUM: { type: INT32, desc: custom ringtone number } diff --git a/services/ringtone_data_extension/include/ringtone_bundle_manager.h b/services/ringtone_data_extension/include/ringtone_bundle_manager.h new file mode 100644 index 0000000..fd196ee --- /dev/null +++ b/services/ringtone_data_extension/include/ringtone_bundle_manager.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 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 OHOS_RINGTONE_BUNDLE_MANAGER_H +#define OHOS_RINGTONE_BUNDLE_MANAGER_H + +#include +#include +#include + +namespace OHOS { +namespace Media { +class RingtoneBundleManager { +public: + RingtoneBundleManager() = default; + ~RingtoneBundleManager() = default; + static std::shared_ptr GetInstance(); + std::string GetClientBundleName(); + void Clear(); + +private: + void GetBundleNameByUid(const int32_t uid, std::string &bundleName); + + // BundleMessage is the pair of bundleName and whether bundle is system app + std::list> cacheList_; + std::unordered_map>::iterator> cacheMap_; + std::mutex uninstallMutex_; + + static std::mutex mutex_; + static std::shared_ptr instance_; +}; +} // RingtoneBundleManager +} // OHOS +#endif // OHOS_RINGTONE_BUNDLE_MANAGER_H diff --git a/services/ringtone_data_extension/include/ringtone_data_command.h b/services/ringtone_data_extension/include/ringtone_data_command.h new file mode 100644 index 0000000..e58d09d --- /dev/null +++ b/services/ringtone_data_extension/include/ringtone_data_command.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2024 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 RINGTONE_COLUMN_DATA_COMMAND_H +#define RINGTONE_COLUMN_DATA_COMMAND_H + +#include "abs_rdb_predicates.h" +#include "datashare_predicates.h" +#include "ringtone_db_const.h" +#include "uri.h" +#include "values_bucket.h" + +namespace OHOS { +namespace Media { +#define EXPORT __attribute__ ((visibility ("default"))) +enum class EXPORT RingtoneOperationType : uint32_t { + UNKNOWN_TYPE = 0, + OPEN, + INSERT, + DELETE, + UPDATE, + QUERY, + SCAN, +}; + +class RingtoneDataCommand { +public: + EXPORT explicit RingtoneDataCommand(const Uri &uri, const std::string &table, const RingtoneOperationType type); + EXPORT RingtoneDataCommand() = delete; + EXPORT ~RingtoneDataCommand(); + EXPORT RingtoneDataCommand(const RingtoneDataCommand &) = delete; + EXPORT RingtoneDataCommand &operator=(const RingtoneDataCommand &) = delete; + EXPORT RingtoneDataCommand(RingtoneDataCommand &&) = delete; + EXPORT RingtoneDataCommand &operator=(RingtoneDataCommand &&) = delete; + + const Uri &GetUri() const; + const std::string &GetTableName(); + NativeRdb::ValuesBucket &GetValueBucket(); + EXPORT NativeRdb::AbsRdbPredicates *GetAbsRdbPredicates(); + const std::string &GetBundleName(); + const std::string &GetResult(); + + EXPORT void SetDataSharePred(const DataShare::DataSharePredicates &pred); + EXPORT void SetValueBucket(const NativeRdb::ValuesBucket &value); + void SetBundleName(const std::string &bundleName); + void SetResult(const std::string &result); + RingtoneOperationType GetOprnType() const; +private: + static int32_t GetToneIdFromUri(Uri &uri); + + Uri uri_ {""}; + std::string tableName_; + RingtoneOperationType oprnType_ {RingtoneOperationType::UNKNOWN_TYPE}; + int32_t toneId_; + NativeRdb::ValuesBucket insertValue_; + std::unique_ptr absRdbPredicates_; + std::unique_ptr datasharePred_; + std::string bundleName_; + std::string result_; +}; +} // namespace Media +} // namespace OHOS + +#endif // RINGTONE_COLUMN_DATA_COMMAND_H diff --git a/services/ringtone_data_extension/include/ringtone_data_manager.h b/services/ringtone_data_extension/include/ringtone_data_manager.h new file mode 100644 index 0000000..cfbee16 --- /dev/null +++ b/services/ringtone_data_extension/include/ringtone_data_manager.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2024 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 RINGTONE_COLUMN_DATA_MANAGER_H +#define RINGTONE_COLUMN_DATA_MANAGER_H + +#include "datashare_values_bucket.h" +#include "rdb_utils.h" +#include "ringtone_asset.h" +#include "ringtone_data_command.h" +#include "ringtone_datashare_extension.h" + +#define EXPORT __attribute__ ((visibility ("default"))) + +namespace OHOS { +namespace AbilityRuntime { +class RingtoneDataShareExtension; +} +namespace Media { +using OHOS::AbilityRuntime::RingtoneDataShareExtension; +class RingtoneDataManager { +public: + EXPORT RingtoneDataManager(); + EXPORT ~RingtoneDataManager(); + EXPORT static std::shared_ptr GetInstance(); + + EXPORT int32_t Insert(RingtoneDataCommand &cmd, const DataShare::DataShareValuesBucket &value); + EXPORT int32_t Delete(RingtoneDataCommand &cmd, const DataShare::DataSharePredicates &predicates); + EXPORT int32_t Update(RingtoneDataCommand &cmd, const DataShare::DataShareValuesBucket &value, + const DataShare::DataSharePredicates &predicates); + EXPORT std::shared_ptr Query(RingtoneDataCommand &cmd, + const std::vector &columns, const DataShare::DataSharePredicates &predicates, int &errCode); + EXPORT int32_t OpenFile(RingtoneDataCommand &cmd, const std::string &mode); + + EXPORT int32_t Init(const std::shared_ptr &context); + EXPORT void ClearRingtoneDataMgr(); + EXPORT void SetOwner(const std::shared_ptr &datashareExtension); + EXPORT std::shared_ptr GetOwner(); +private: + std::string GetIdFromUri(Uri &uri); + std::shared_ptr GetRingtoneAssetFromId(const std::string &id); + int32_t DeleteFileFromResultSet(std::shared_ptr &resultSet); + std::shared_mutex mgrSharedMutex_; + std::shared_ptr context_ = nullptr; + static std::mutex mutex_; + static std::shared_ptr instance_; + std::atomic refCnt_ {0}; + std::shared_ptr extension_ = nullptr; +}; +} // namespace Media +} // namespace OHOS +#endif // RINGTONE_COLUMN_DATA_MANAGER_H diff --git a/services/ringtone_data_extension/include/ringtone_datashare_extension.h b/services/ringtone_data_extension/include/ringtone_datashare_extension.h new file mode 100644 index 0000000..8827d4e --- /dev/null +++ b/services/ringtone_data_extension/include/ringtone_datashare_extension.h @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2024 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 FOUNDATION_ABILITYRUNTIME_OHOS_RINGTONE_COLUMN_DATASHARE_EXT_ABILITY_H +#define FOUNDATION_ABILITYRUNTIME_OHOS_RINGTONE_COLUMN_DATASHARE_EXT_ABILITY_H + +#include "datashare_ext_ability.h" + +namespace OHOS { +namespace AbilityRuntime { +using namespace DataShare; +/** + * @brief Basic datashare extension ability components. + */ +#define EXPORT __attribute__ ((visibility ("default"))) +class RingtoneDataShareExtension : public DataShareExtAbility { +public: + EXPORT RingtoneDataShareExtension(Runtime &runtime); + EXPORT virtual ~RingtoneDataShareExtension() override; + + /** + * @brief Create RingtoneDataShareExtension. + * + * @param runtime The runtime. + * @return The RingtoneDataShareExtension instance. + */ + EXPORT static RingtoneDataShareExtension *Create(const std::unique_ptr &runtime); + + /** + * @brief Init the extension. + * + * @param record the extension record. + * @param application the application info. + * @param handler the extension handler. + * @param token the remote token. + */ + EXPORT void Init(const std::shared_ptr &record, + const std::shared_ptr &application, + std::shared_ptr &handler, + const sptr &token) override; + + /** + * @brief Called when this datashare extension ability is started. You must override this function if you want to + * perform some initialization operations during extension startup. + * + * This function can be called only once in the entire lifecycle of an extension. + * @param Want Indicates the {@link Want} structure containing startup information about the extension. + */ + EXPORT void OnStart(const AAFwk::Want &want) override; + + EXPORT void OnStop() override; + + /** + * @brief Called when this datashare extension ability is connected for the first time. + * + * You can override this function to implement your own processing logic. + * + * @param want Indicates the {@link Want} structure containing connection information about the datashare + * extension. + * @return Returns a pointer to the sid of the connected datashare extension ability. + */ + EXPORT sptr OnConnect(const AAFwk::Want &want) override; + /** + * @brief Inserts a single data record into the database. + * + * @param uri Indicates the path of the data to operate. + * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. + * + * @return Returns the index of the inserted data record. + */ + EXPORT int Insert(const Uri &uri, const DataShareValuesBucket &value) override; + + /** + * @brief Deletes one or more data records from the database. + * + * @param uri Indicates the path of the data to operate. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * + * @return Returns the number of data records deleted. + */ + EXPORT int Delete(const Uri &uri, const DataSharePredicates &predicates) override; + + /** + * @brief Updates data records in the database. + * + * @param uri Indicates the path of data to update. + * @param value Indicates the data to update. This parameter can be null. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * + * @return Returns the number of data records updated. + */ + EXPORT int Update(const Uri &uri, const DataSharePredicates &predicates, + const DataShareValuesBucket &value) override; + + /** + * @brief query one or more data records from the database. + * + * @param uri Indicates the path of data to query. + * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. + * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. + * @param businessError Indicates errorcode and message. + + * @return Returns the query result. + */ + EXPORT std::shared_ptr Query(const Uri &uri, const DataSharePredicates &predicates, + std::vector &columns, DatashareBusinessError &businessError) override; + + /** + * @brief Opens a file in a specified remote path. + * + * @param uri Indicates the path of the file to open. + * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access + * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, + * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing data, + * or "rwt" for read and write access that truncates any existing file. + * + * @return Returns the file descriptor. + */ + EXPORT int OpenFile(const Uri &uri, const std::string &mode) override; +private: + static void DumpDataShareValueBucket(const std::vector &tabFields, const DataShareValuesBucket &value); + Runtime &runtime_; +}; +} // namespace AbilityRuntime +} // namespace OHOS +#endif // FOUNDATION_ABILITYRUNTIME_OHOS_RINGTONE_COLUMN_DATASHARE_EXT_ABILITY_H diff --git a/services/ringtone_data_extension/include/ringtone_datashare_stub_impl.h b/services/ringtone_data_extension/include/ringtone_datashare_stub_impl.h new file mode 100644 index 0000000..9f7af04 --- /dev/null +++ b/services/ringtone_data_extension/include/ringtone_datashare_stub_impl.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 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 RINGTONE_COLUMN_DATASHARE_STUB_IMPL_H +#define RINGTONE_COLUMN_DATASHARE_STUB_IMPL_H + +#include "datashare_stub.h" +#include "ringtone_datashare_extension.h" + +namespace OHOS { +namespace DataShare { +using DataShare::RingtoneDataShareExtension; +#define EXPORT __attribute__ ((visibility ("default"))) +class EXPORT RingtoneDataShareStubImpl : public DataShareStub { +public: + EXPORT explicit RingtoneDataShareStubImpl(const std::shared_ptr& extension, + napi_env env) : extension_(extension) {} + + EXPORT virtual ~RingtoneDataShareStubImpl() {} + + EXPORT std::vector GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override; + + EXPORT int OpenFile(const Uri &uri, const std::string &mode) override; + + EXPORT int Insert(const Uri &uri, const DataShareValuesBucket &value) override; + + EXPORT int InsertExt(const Uri &uri, const DataShareValuesBucket &value, std::string &result) override; + + EXPORT int Update(const Uri &uri, const DataSharePredicates &predicates, + const DataShareValuesBucket &value) override; + + EXPORT int Delete(const Uri &uri, const DataSharePredicates &predicates) override; + + EXPORT std::shared_ptr Query(const Uri &uri, const DataSharePredicates &predicates, + std::vector &columns, DatashareBusinessError &businessError) override; + + EXPORT int OpenRawFile(const Uri &uri, const std::string &mode) override; + + EXPORT std::string GetType(const Uri &uri) override; + + EXPORT int BatchInsert(const Uri &uri, const std::vector &values) override; + + EXPORT bool RegisterObserver(const Uri &uri, const sptr &dataObserver) override; + + EXPORT bool UnregisterObserver(const Uri &uri, const sptr &dataObserver) override; + + EXPORT bool NotifyChange(const Uri &uri) override; + + EXPORT Uri NormalizeUri(const Uri &uri) override; + + EXPORT Uri DenormalizeUri(const Uri &uri) override; + +private: + EXPORT std::shared_ptr GetOwner(); + +private: + std::shared_ptr extension_; +}; +} // namespace Media_DataShare +} // namespace OHOS +#endif // RINGTONE_COLUMN_DATASHARE_STUB_IMPL_H + diff --git a/services/ringtone_data_extension/include/ringtone_rdbstore.h b/services/ringtone_data_extension/include/ringtone_rdbstore.h new file mode 100644 index 0000000..dd3288f --- /dev/null +++ b/services/ringtone_data_extension/include/ringtone_rdbstore.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2024 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 RINGTONE_RDBSTORE_H +#define RINGTONE_RDBSTORE_H + +#include "ringtone_unistore.h" + +namespace OHOS { +namespace Media { +#define EXPORT __attribute__ ((visibility ("default"))) + +class RingtoneDataCallBack; + +class RingtoneRdbStore final : public RingtoneUnistore { +public: + EXPORT static RingtoneUnistore *GetInstance(const std::shared_ptr &context = + nullptr); + EXPORT virtual ~RingtoneRdbStore(); + + EXPORT virtual int32_t Init() override; + EXPORT virtual void Stop() override; + + EXPORT virtual int32_t Insert(RingtoneDataCommand &cmd, int64_t &rowId) override; + EXPORT virtual int32_t Delete(RingtoneDataCommand &cmd, int32_t &deletedRows) override; + EXPORT virtual int32_t Update(RingtoneDataCommand &cmd, int32_t &changedRows) override; + EXPORT std::shared_ptr Query(RingtoneDataCommand &cmd, + const std::vector &columns) override; + + EXPORT int32_t ExecuteSql(const std::string &sql) override; + EXPORT std::shared_ptr QuerySql(const std::string &sql, + const std::vector &selectionArgs = std::vector()) override; + EXPORT std::shared_ptr GetRaw() override; +private: + explicit RingtoneRdbStore(const std::shared_ptr &context); + + std::string bundleName_ {BUNDLE_NAME}; + NativeRdb::RdbStoreConfig config_ {""}; + static std::shared_ptr rdbStore_; +}; + +class RingtoneDataCallBack : public NativeRdb::RdbOpenCallback { +public: + int32_t OnCreate(NativeRdb::RdbStore &rdbStore) override; + int32_t OnUpgrade(NativeRdb::RdbStore &rdbStore, int32_t oldVersion, int32_t newVersion) override; +private: + static int32_t InitSql(NativeRdb::RdbStore &store); + static int32_t PrepareDir(); + static int32_t CreatePreloadFolder(const std::string &path); + static int32_t MkdirRecursive(const std::string &path, size_t start); +}; +} // namespace Media +} // namespace OHOS + +#endif // RINGTONE_RDBSTORE_H diff --git a/services/ringtone_data_extension/include/ringtone_subscriber.h b/services/ringtone_data_extension/include/ringtone_subscriber.h new file mode 100644 index 0000000..640e125 --- /dev/null +++ b/services/ringtone_data_extension/include/ringtone_subscriber.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 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 RINGTONE_SUBSCRIBER_H +#define RINGTONE_SUBSCRIBER_H + +#include "common_event_manager.h" + +namespace OHOS { +namespace Media { +#define EXPORT __attribute__ ((visibility ("default"))) +class EXPORT RingtoneSubscriber : public EventFwk::CommonEventSubscriber { +public: + EXPORT RingtoneSubscriber() = default; + EXPORT explicit RingtoneSubscriber(const EventFwk::CommonEventSubscribeInfo &subscriberInfo); + EXPORT static bool Subscribe(void); + EXPORT virtual ~RingtoneSubscriber() = default; + + EXPORT virtual void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override; + +private: + static const std::vector events_; +}; +} // namespace Media +} // namespace OHOS + +#endif // RINGTONE_SUBSCRIBER_H diff --git a/services/ringtone_data_extension/include/ringtone_unistore.h b/services/ringtone_data_extension/include/ringtone_unistore.h new file mode 100644 index 0000000..ea53108 --- /dev/null +++ b/services/ringtone_data_extension/include/ringtone_unistore.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2024 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 RINGTONE_UNISTORE_H +#define RINGTONE_UNISTORE_H + +#include "ability_context.h" +#include "rdb_helper.h" +#include "ringtone_data_command.h" + +namespace OHOS { +namespace Media { +#define EXPORT __attribute__ ((visibility ("default"))) +class RingtoneUnistore { +public: + EXPORT RingtoneUnistore() = default; + EXPORT virtual ~RingtoneUnistore() = default; + + EXPORT virtual int32_t Init() = 0; + EXPORT virtual void Stop() = 0; + + EXPORT virtual int32_t Insert(RingtoneDataCommand &cmd, int64_t &rowId) = 0; + EXPORT virtual int32_t Delete(RingtoneDataCommand &cmd, int32_t &rowId) = 0; + EXPORT virtual int32_t Update(RingtoneDataCommand &cmd, int32_t &rowId) = 0; + EXPORT virtual std::shared_ptr Query(RingtoneDataCommand &cmd, + const std::vector &columns) + { + return nullptr; + } + + EXPORT virtual int32_t ExecuteSql(const std::string &sql) + { + return NativeRdb::E_NOT_SUPPORT; + } + + EXPORT virtual std::shared_ptr QuerySql(const std::string &sql, + const std::vector &selectionArgs = std::vector()) + { + return nullptr; + } + EXPORT virtual std::shared_ptr GetRaw() = 0; +}; +} // namespace Media +} // namespace OHOS + +#endif // RINGTONE_UNISTORE_H diff --git a/services/ringtone_data_extension/src/ringtone_bundle_manager.cpp b/services/ringtone_data_extension/src/ringtone_bundle_manager.cpp new file mode 100644 index 0000000..962f729 --- /dev/null +++ b/services/ringtone_data_extension/src/ringtone_bundle_manager.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 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. + */ + +#define MLOG_TAG "RingtoneBundleManager" + +#include "ringtone_bundle_manager.h" + +#include "ipc_skeleton.h" +#include "permission_utils.h" + +using namespace std; + +namespace OHOS { +namespace Media { +const int CAPACITY = 50; +shared_ptr RingtoneBundleManager::instance_ = nullptr; +mutex RingtoneBundleManager::mutex_; +shared_ptr RingtoneBundleManager::GetInstance() +{ + if (instance_ == nullptr) { + lock_guard lock(mutex_); + if (instance_ == nullptr) { + instance_ = make_shared(); + } + } + return instance_; +} + +void RingtoneBundleManager::GetBundleNameByUid(const int32_t uid, string &bundleName) +{ + RingtonePermissionUtils::GetClientBundle(uid, bundleName); + if (bundleName.empty()) { + return; + } + + auto it = cacheMap_.find(uid); + if (it != cacheMap_.end()) { + cacheList_.erase(it->second); + } + cacheList_.push_front(make_pair(uid, bundleName)); + cacheMap_[uid] = cacheList_.begin(); + if (cacheMap_.size() > CAPACITY) { + int32_t deleteKey = cacheList_.back().first; + cacheMap_.erase(deleteKey); + cacheList_.pop_back(); + } +} + +string RingtoneBundleManager::GetClientBundleName() +{ + lock_guard lock(uninstallMutex_); + int32_t uid = IPCSkeleton::GetCallingUid(); + auto iter = cacheMap_.find(uid); + if (iter == cacheMap_.end()) { + string bundleName; + GetBundleNameByUid(uid, bundleName); + return bundleName; + } + cacheList_.splice(cacheList_.begin(), cacheList_, iter->second); + return iter->second->second; +} + +void RingtoneBundleManager::Clear() +{ + lock_guard lock(uninstallMutex_); + cacheList_.clear(); + cacheMap_.clear(); +} +} // Ringtone +} // OHOS diff --git a/services/ringtone_data_extension/src/ringtone_data_command.cpp b/services/ringtone_data_extension/src/ringtone_data_command.cpp new file mode 100644 index 0000000..6192eb7 --- /dev/null +++ b/services/ringtone_data_extension/src/ringtone_data_command.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2024 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 "ringtone_data_command.h" + +#include "ringtone_errno.h" +#include "ringtone_log.h" + +using namespace std; +using namespace OHOS::NativeRdb; +using namespace OHOS::DataShare; + +namespace OHOS { +namespace Media { + +RingtoneDataCommand::RingtoneDataCommand(const Uri &uri, const string &table, const RingtoneOperationType type) + : uri_(uri), tableName_(table), oprnType_(type), toneId_(-1) +{ + toneId_ = GetToneIdFromUri(uri_); +} + +RingtoneDataCommand::~RingtoneDataCommand() {} + +// set functions +void RingtoneDataCommand::SetDataSharePred(const DataShare::DataSharePredicates &pred) +{ + datasharePred_ = make_unique(pred); +} + +void RingtoneDataCommand::SetValueBucket(const NativeRdb::ValuesBucket &value) +{ + insertValue_ = value; +} + +void RingtoneDataCommand::SetBundleName(const string &bundleName) +{ + bundleName_ = bundleName; +} + +void RingtoneDataCommand::SetResult(const string &result) +{ + result_ = result; +} + +// get functions +ValuesBucket &RingtoneDataCommand::GetValueBucket() +{ + return insertValue_; +} + +AbsRdbPredicates *RingtoneDataCommand::GetAbsRdbPredicates() +{ + if (absRdbPredicates_ == nullptr) { + absRdbPredicates_ = make_unique(tableName_); + } + return absRdbPredicates_.get(); +} + +const string &RingtoneDataCommand::GetTableName() +{ + return tableName_; +} + +const Uri &RingtoneDataCommand::GetUri() const +{ + return uri_; +} + +const string &RingtoneDataCommand::GetBundleName() +{ + return bundleName_; +} + +const string &RingtoneDataCommand::GetResult() +{ + return result_; +} + +static bool IsNumber(const string &str) +{ + if (str.empty()) { + RINGTONE_ERR_LOG("IsNumber input is empty "); + return false; + } + + for (char const &c : str) { + if (isdigit(c) == 0) { + return false; + } + } + return true; +} + +int32_t RingtoneDataCommand::GetToneIdFromUri(Uri &uri) +{ + string uriStr = uri.ToString(); + if (uriStr.empty()) { + return E_INVALID_URI; + } + + auto toneId = uriStr.substr(RINGTONE_PATH_URI.size(), uriStr.size()); + if (IsNumber(toneId)) { + RINGTONE_INFO_LOG("Get toneId=%{public}s from Uri", toneId.c_str()); + return stoi(toneId); + } + + return E_INVALID_URI; +} + +RingtoneOperationType RingtoneDataCommand::GetOprnType() const +{ + return oprnType_; +} +} // namespace Media +} // namespace OHOS diff --git a/services/ringtone_data_extension/src/ringtone_data_manager.cpp b/services/ringtone_data_extension/src/ringtone_data_manager.cpp new file mode 100644 index 0000000..501a0f8 --- /dev/null +++ b/services/ringtone_data_extension/src/ringtone_data_manager.cpp @@ -0,0 +1,359 @@ +/* + * Copyright (C) 2024 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. + */ + +#define MLOG_TAG "DataManager" + +#include "ringtone_data_manager.h" + +#include "directory_ex.h" +#include "rdb_utils.h" +#include "ringtone_fetch_result.h" +#include "ringtone_file_utils.h" +#include "ringtone_log.h" +#include "ringtone_mimetype_utils.h" +#include "ringtone_rdbstore.h" +#include "ringtone_scanner_manager.h" +#include "ringtone_tracer.h" + + +using namespace std; +using namespace OHOS::AppExecFwk; +using namespace OHOS::AbilityRuntime; +using namespace OHOS::NativeRdb; +using namespace OHOS::DataShare; +using namespace OHOS::RdbDataShareAdapter; + +namespace OHOS { +namespace Media { +shared_ptr RingtoneDataManager::instance_ = nullptr; +mutex RingtoneDataManager::mutex_; +RingtoneUnistore *g_uniStore_ = nullptr; + +RingtoneDataManager::RingtoneDataManager(void) +{ +} + +RingtoneDataManager::~RingtoneDataManager(void) +{ +} + +shared_ptr RingtoneDataManager::GetInstance() +{ + if (instance_ == nullptr) { + lock_guard lock(mutex_); + + if (instance_ == nullptr) { + instance_ = make_shared(); + } + } + return instance_; +} + +int32_t RingtoneDataManager::Init(const shared_ptr &context) +{ + RINGTONE_DEBUG_LOG("start"); + lock_guard lock(mgrSharedMutex_); + + if (refCnt_.load() > 0) { + RINGTONE_DEBUG_LOG("already initialized"); + refCnt_++; + return E_OK; + } + context_ = context; + if (g_uniStore_ == nullptr) { + g_uniStore_ = RingtoneRdbStore::GetInstance(context_); + if (g_uniStore_ == nullptr) { + RINGTONE_ERR_LOG("RingtoneDataManager is not initialized"); + return E_DB_FAIL; + } + } + RingtoneMimeTypeUtils::InitMimeTypeMap(); + refCnt_++; + + RINGTONE_DEBUG_LOG("end"); + return E_OK; +} + +int32_t RingtoneDataManager::Insert(RingtoneDataCommand &cmd, const DataShareValuesBucket &dataShareValue) +{ + RINGTONE_DEBUG_LOG("start"); + shared_lock sharedLock(mgrSharedMutex_); + if (refCnt_.load() <= 0) { + RINGTONE_ERR_LOG("RingtoneDataManager is not initialized"); + return E_FAIL; + } + if (g_uniStore_ == nullptr) { + RINGTONE_ERR_LOG("rdb store is not initialized"); + return E_DB_FAIL; + } + + ValuesBucket value = RdbUtils::ToValuesBucket(dataShareValue); + if (value.IsEmpty()) { + RINGTONE_ERR_LOG("RingtoneDataManager Insert: Input parameter is invalid"); + return E_INVALID_VALUES; + } + cmd.SetValueBucket(value); + + int64_t outRowId = E_HAS_DB_ERROR; + auto retRdb = g_uniStore_->Insert(cmd, outRowId); + if (retRdb != NativeRdb::E_OK) { + RINGTONE_ERR_LOG("Insert operation failed. Result %{public}d.", retRdb); + return E_HAS_DB_ERROR; + } + + auto asset = GetRingtoneAssetFromId(to_string(outRowId)); + if (asset == nullptr) { + RINGTONE_ERR_LOG("Failed to get RingtoneAsset"); + return E_INVALID_VALUES; + } + + auto ret = RingtoneFileUtils::CreateFile(asset->GetPath()); + if (ret != E_SUCCESS) { + return ret; + } + + RINGTONE_DEBUG_LOG("end"); + return static_cast(outRowId); +} + +int32_t RingtoneDataManager::DeleteFileFromResultSet(std::shared_ptr &resultSet) +{ + auto count = 0; + auto ret = resultSet->GetRowCount(count); + if (ret != NativeRdb::E_OK) { + RINGTONE_ERR_LOG("get rdbstore failed"); + return E_HAS_DB_ERROR; + } + if (count == 0) { + RINGTONE_ERR_LOG("have no files to delete"); + return E_SUCCESS; + } + + shared_ptr> fetchResult = make_shared>(); + if (fetchResult == nullptr) { + RINGTONE_ERR_LOG("Failed to obtain fetch file result"); + return E_ERR; + } + + for (auto i = 0; i < count; i++) { + auto asset = fetchResult->GetObjectFromRdb(resultSet, i); + RingtoneFileUtils::DeleteFile(asset->GetPath()); + } + + return E_SUCCESS; +} + +int32_t RingtoneDataManager::Delete(RingtoneDataCommand &cmd, const DataSharePredicates &predicates) +{ + RINGTONE_DEBUG_LOG("start"); + shared_lock sharedLock(mgrSharedMutex_); + if (refCnt_.load() <= 0) { + RINGTONE_DEBUG_LOG("RingtoneDataManager is not initialized"); + return E_FAIL; + } + if (g_uniStore_ == nullptr) { + RINGTONE_ERR_LOG("rdb store is not initialized"); + return E_DB_FAIL; + } + + string uriString = cmd.GetUri().ToString(); + if (uriString.find(RINGTONE_URI) == string::npos) { + RINGTONE_ERR_LOG("Not Data ability Uri"); + return E_INVALID_URI; + } + + NativeRdb::RdbPredicates rdbPredicate = RdbUtils::ToPredicates(predicates, cmd.GetTableName()); + cmd.GetAbsRdbPredicates()->SetWhereClause(rdbPredicate.GetWhereClause()); + cmd.GetAbsRdbPredicates()->SetWhereArgs(rdbPredicate.GetWhereArgs()); + + vector columns = {RINGTONE_COLUMN_TONE_ID, RINGTONE_COLUMN_DATA}; + auto absResultSet = g_uniStore_->Query(cmd, columns); + + DeleteFileFromResultSet(absResultSet); + + int32_t deletedRows = E_HAS_DB_ERROR; + int32_t ret = g_uniStore_->Delete(cmd, deletedRows); + if (ret != NativeRdb::E_OK || deletedRows <= 0) { + RINGTONE_ERR_LOG("Delete operation failed. Result %{public}d.", ret); + deletedRows = E_HAS_DB_ERROR; + } + + RINGTONE_DEBUG_LOG("end"); + return deletedRows; +} + +int32_t RingtoneDataManager::Update(RingtoneDataCommand &cmd, const DataShareValuesBucket &dataShareValue, + const DataSharePredicates &predicates) +{ + RINGTONE_DEBUG_LOG("start"); + shared_lock sharedLock(mgrSharedMutex_); + if (refCnt_.load() <= 0) { + RINGTONE_DEBUG_LOG("RingtoneDataManager is not initialized"); + return E_FAIL; + } + if (g_uniStore_ == nullptr) { + RINGTONE_ERR_LOG("rdb store is not initialized"); + return E_DB_FAIL; + } + + ValuesBucket value = RdbUtils::ToValuesBucket(dataShareValue); + if (value.IsEmpty()) { + RINGTONE_ERR_LOG("RingtoneDataManager Update:Input parameter is invalid"); + return E_INVALID_VALUES; + } + + cmd.SetValueBucket(value); + cmd.SetDataSharePred(predicates); + NativeRdb::RdbPredicates rdbPredicate = RdbUtils::ToPredicates(predicates, cmd.GetTableName()); + cmd.GetAbsRdbPredicates()->SetWhereClause(rdbPredicate.GetWhereClause()); + cmd.GetAbsRdbPredicates()->SetWhereArgs(rdbPredicate.GetWhereArgs()); + + int32_t updatedRows = E_HAS_DB_ERROR; + int32_t result = g_uniStore_->Update(cmd, updatedRows); + if (result != NativeRdb::E_OK || updatedRows <= 0) { + RINGTONE_ERR_LOG("Update operation failed. Result %{public}d. Updated %{public}d", result, updatedRows); + updatedRows = E_HAS_DB_ERROR; + } + + RINGTONE_DEBUG_LOG("end"); + return updatedRows; +} + +shared_ptr RingtoneDataManager::Query(RingtoneDataCommand &cmd, + const vector &columns, const DataSharePredicates &predicates, int &errCode) +{ + RINGTONE_DEBUG_LOG("start"); + shared_lock sharedLock(mgrSharedMutex_); + if (refCnt_.load() <= 0) { + RINGTONE_DEBUG_LOG("RingtoneDataManager is not initialized"); + return nullptr; + } + if (g_uniStore_ == nullptr) { + RINGTONE_ERR_LOG("rdb store is not initialized"); + return nullptr; + } + + RingtoneTracer tracer; + tracer.Start("RingtoneDataManager::Query"); + cmd.SetDataSharePred(predicates); + NativeRdb::RdbPredicates rdbPredicate = RdbUtils::ToPredicates(predicates, cmd.GetTableName()); + cmd.GetAbsRdbPredicates()->SetWhereClause(rdbPredicate.GetWhereClause()); + cmd.GetAbsRdbPredicates()->SetWhereArgs(rdbPredicate.GetWhereArgs()); + cmd.GetAbsRdbPredicates()->SetOrder(rdbPredicate.GetOrder()); + + auto absResultSet = g_uniStore_->Query(cmd, columns); + + RINGTONE_DEBUG_LOG("end"); + return RdbUtils::ToResultSetBridge(absResultSet); +} + +static bool IsNumber(const string &str) +{ + if (str.empty()) { + RINGTONE_ERR_LOG("IsNumber input is empty "); + return false; + } + + for (char const &c : str) { + if (isdigit(c) == 0) { + return false; + } + } + return true; +} + +int32_t RingtoneDataManager::OpenFile(RingtoneDataCommand &cmd, const string &mode) +{ + RINGTONE_DEBUG_LOG("start"); + RingtoneTracer tracer; + tracer.Start("RingtoneDataManager::OpenFile"); + string toneId = GetIdFromUri(const_cast(cmd.GetUri())); + auto asset = GetRingtoneAssetFromId(toneId); + if (asset == nullptr) { + RINGTONE_ERR_LOG("Failed to get RingtoneAsset"); + return E_INVALID_VALUES; + } + + string absFilePath; + if (!PathToRealPath(asset->GetPath(), absFilePath)) { + RINGTONE_ERR_LOG("Failed to get real path: %{private}s", asset->GetPath().c_str()); + return E_ERR; + } + + RINGTONE_DEBUG_LOG("end"); + return RingtoneFileUtils::OpenFile(absFilePath, mode); +} + +void RingtoneDataManager::SetOwner(const shared_ptr &datashareExternsion) +{ + extension_ = datashareExternsion; +} + +shared_ptr RingtoneDataManager::GetOwner() +{ + return extension_; +} + +string RingtoneDataManager::GetIdFromUri(Uri &uri) +{ + vector segments; + uri.GetPathSegments(segments); + const int uriSegmentsCount = 3; + const int toneIdSegmentNumber = 2; + if (segments.size() != uriSegmentsCount || segments[1] != RINGTONE_URI_PATH || + !IsNumber(segments[toneIdSegmentNumber])) { + return {}; + } + return segments[toneIdSegmentNumber]; +} + +shared_ptr RingtoneDataManager::GetRingtoneAssetFromId(const string &id) +{ + if ((id.empty()) || (!IsNumber(id)) || (stoi(id) == -1)) { + RINGTONE_ERR_LOG("Id for the path is incorrect: %{private}s", id.c_str()); + return nullptr; + } + Uri uri(""); + RingtoneDataCommand cmd(uri, RINGTONE_TABLE, RingtoneOperationType::QUERY); + cmd.GetAbsRdbPredicates()->EqualTo(RINGTONE_COLUMN_TONE_ID, id); + + auto resultSet = g_uniStore_->Query(cmd, {RINGTONE_COLUMN_TONE_ID, RINGTONE_COLUMN_DATA}); + if (resultSet == nullptr) { + RINGTONE_ERR_LOG("Failed to obtain file asset from database"); + return nullptr; + } + + shared_ptr> fetchResult = make_shared>(); + if (fetchResult == nullptr) { + RINGTONE_ERR_LOG("Failed to obtain fetch file result"); + return nullptr; + } + return fetchResult->GetObjectFromRdb(resultSet, 0); +} + +void RingtoneDataManager::ClearRingtoneDataMgr() +{ + lock_guard lock(mgrSharedMutex_); + + refCnt_--; + if (refCnt_.load() > 0) { + RINGTONE_DEBUG_LOG("still other extension exist"); + return; + } + + extension_ = nullptr; +} +} // namespace Media +} // namespace OHOS diff --git a/services/ringtone_data_extension/src/ringtone_datashare_extension.cpp b/services/ringtone_data_extension/src/ringtone_datashare_extension.cpp new file mode 100644 index 0000000..940396b --- /dev/null +++ b/services/ringtone_data_extension/src/ringtone_datashare_extension.cpp @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2024 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. + */ +#define MLOG_TAG "ringtone_Extension" + +#include "ringtone_datashare_extension.h" + +#include "app_mgr_client.h" +#include "datashare_ext_ability_context.h" +#include "dfx_manager.h" +#include "parameter.h" +#include "permission_utils.h" +#include "ringtone_data_manager.h" +#include "ringtone_datashare_stub_impl.h" +#include "ringtone_log.h" +#include "ringtone_scanner_manager.h" +#include "runtime.h" +#include "singleton.h" + + +using namespace std; +using namespace OHOS::AppExecFwk; +using namespace OHOS::NativeRdb; +using namespace OHOS::Media; +using namespace OHOS::DataShare; + +namespace OHOS { +namespace AbilityRuntime { +using namespace OHOS::AppExecFwk; +const char RINGTONE_PARAMETER_SCANNER_COMPLETED_KEY[] = "ringtone.scanner.completed"; +const char RINGTONE_PARAMETER_SCANNER_COMPLETED_TRUE[] = "1"; +const char RINGTONE_PARAMETER_SCANNER_COMPLETED_FALSE[] = "0"; +const int32_t SYSPARA_SIZE = 64; + +RingtoneDataShareExtension *RingtoneDataShareExtension::Create(const unique_ptr &runtime) +{ + return new RingtoneDataShareExtension(static_cast(*runtime)); +} + +RingtoneDataShareExtension::RingtoneDataShareExtension(Runtime &runtime) : DataShareExtAbility(), runtime_(runtime) {} + +RingtoneDataShareExtension::~RingtoneDataShareExtension() +{ +} + +void RingtoneDataShareExtension::Init(const shared_ptr &record, + const shared_ptr &application, shared_ptr &handler, + const sptr &token) +{ + if ((record == nullptr) || (application == nullptr) || (handler == nullptr) || (token == nullptr)) { + RINGTONE_ERR_LOG("RingtoneDataShareExtension::init failed, some object is nullptr"); + DelayedSingleton::GetInstance()->KillApplicationSelf(); + return; + } + DataShareExtAbility::Init(record, application, handler, token); +} + +void RingtoneDataShareExtension::OnStart(const AAFwk::Want &want) +{ + RINGTONE_INFO_LOG("begin."); + Extension::OnStart(want); + auto context = AbilityRuntime::Context::GetApplicationContext(); + if (context == nullptr) { + RINGTONE_ERR_LOG("Failed to get context"); + DelayedSingleton::GetInstance()->KillApplicationSelf(); + return; + } + RINGTONE_INFO_LOG("runtime language %{public}d", runtime_.GetLanguage()); + auto dataManager = RingtoneDataManager::GetInstance(); + if (dataManager == nullptr) { + RINGTONE_ERR_LOG("Failed to get dataManager"); + DelayedSingleton::GetInstance()->KillApplicationSelf(); + return; + } + int32_t ret = dataManager->Init(context); + if (ret != E_OK) { + RINGTONE_ERR_LOG("Failed to init RingtoneData Mgr"); + DelayedSingleton::GetInstance()->KillApplicationSelf(); + return; + } + dataManager->SetOwner(static_pointer_cast(shared_from_this())); + auto dfxMgr = DfxManager::GetInstance(); + dfxMgr->Init(context); + + // ringtone scan + char scanCompletedValue[SYSPARA_SIZE] = {0}; + GetParameter(RINGTONE_PARAMETER_SCANNER_COMPLETED_KEY, RINGTONE_PARAMETER_SCANNER_COMPLETED_FALSE, + scanCompletedValue, SYSPARA_SIZE); + int isCompleted = atoi(scanCompletedValue); + if (!isCompleted) { + RingtoneScannerManager::GetInstance()->Start(false); + SetParameter(RINGTONE_PARAMETER_SCANNER_COMPLETED_KEY, RINGTONE_PARAMETER_SCANNER_COMPLETED_TRUE); + } + RINGTONE_INFO_LOG("end."); +} + +void RingtoneDataShareExtension::OnStop() +{ + RINGTONE_INFO_LOG("begin."); + auto scannerManager = RingtoneScannerManager::GetInstance(); + if (scannerManager != nullptr) { + scannerManager->Stop(); + } + RingtoneDataManager::GetInstance()->ClearRingtoneDataMgr(); + RINGTONE_INFO_LOG("end."); +} + +sptr RingtoneDataShareExtension::OnConnect(const AAFwk::Want &want) +{ + RINGTONE_INFO_LOG("begin."); + Extension::OnConnect(want); + sptr remoteObject = new (nothrow) RingtoneDataShareStubImpl( + static_pointer_cast(shared_from_this()), + nullptr); + if (remoteObject == nullptr) { + RINGTONE_ERR_LOG("No memory allocated for DataShareStubImpl"); + return nullptr; + } + RINGTONE_INFO_LOG("end."); + return remoteObject->AsObject(); +} + +static int32_t CheckRingtonePerm(RingtoneDataCommand &cmd, bool isWrite) +{ + auto err = E_SUCCESS; + if (isWrite) { + err = (RingtonePermissionUtils::CheckCallerPermission(PERM_WRITE_RINGTONE) ? E_SUCCESS : E_PERMISSION_DENIED); + } + + return err; +} + +static int32_t UriValidCheck(const Uri &uri) +{ + string uriStr = uri.ToString(); + if (uriStr.compare(0, RINGTONE_PATH_URI.size(), RINGTONE_PATH_URI)) { + RINGTONE_ERR_LOG("error: invalid uri!"); + return E_INVALID_URI; + } + return E_OK; +} + +static const std::vector g_ringToneTableFields = { + { RINGTONE_COLUMN_TONE_ID }, + { RINGTONE_COLUMN_DATA }, + { RINGTONE_COLUMN_SIZE }, + { RINGTONE_COLUMN_DISPLAY_NAME }, + { RINGTONE_COLUMN_TITLE }, + { RINGTONE_COLUMN_MEDIA_TYPE }, + { RINGTONE_COLUMN_TONE_TYPE }, + { RINGTONE_COLUMN_MIME_TYPE }, + { RINGTONE_COLUMN_SOURCE_TYPE }, + { RINGTONE_COLUMN_DATE_ADDED }, + { RINGTONE_COLUMN_DATE_MODIFIED }, + { RINGTONE_COLUMN_DATE_TAKEN }, + { RINGTONE_COLUMN_DURATION }, + { RINGTONE_COLUMN_SHOT_TONE_TYPE }, + { RINGTONE_COLUMN_SHOT_TONE_SOURCE_TYPE }, + { RINGTONE_COLUMN_NOTIFICATION_TONE_TYPE }, + { RINGTONE_COLUMN_NOTIFICATION_TONE_SOURCE_TYPE }, + { RINGTONE_COLUMN_RING_TONE_TYPE }, + { RINGTONE_COLUMN_RING_TONE_SOURCE_TYPE }, + { RINGTONE_COLUMN_ALARM_TONE_TYPE }, + { RINGTONE_COLUMN_ALARM_TONE_SOURCE_TYPE }, +}; + +void RingtoneDataShareExtension::DumpDataShareValueBucket(const std::vector &tabFields, + const DataShareValuesBucket &value) +{ + bool isValid = false; + for (auto tab : tabFields) { + auto valueObject = value.Get(tab, isValid); + if (!isValid) { + RINGTONE_INFO_LOG("not set field: %{public}s", tab.c_str()); + continue; + } + + if (std::get_if>(&(valueObject.value))) { + auto value = static_cast>(valueObject); + RINGTONE_INFO_LOG("field: %{public}s, value=%{public}s", + tab.c_str(), value.data()); + } else if (std::get_if(&(valueObject.value))) { + auto value = static_cast(valueObject); + RINGTONE_INFO_LOG("field: %{public}s, value=%{public}lld", + tab.c_str(), value); + } else if (std::get_if(&(valueObject.value))) { + auto value = static_cast(valueObject); + RINGTONE_INFO_LOG("field: %{public}s, value=%{public}s", + tab.c_str(), value.c_str()); + } else if (std::get_if(&(valueObject.value))) { + auto value = static_cast(valueObject); + RINGTONE_INFO_LOG("field: %{public}s, value=%{public}d", + tab.c_str(), value); + } else if (std::get_if(&(valueObject.value))) { + auto value = static_cast(valueObject); + RINGTONE_INFO_LOG("field: %{public}s, value=%{public}lf", + tab.c_str(), value); + } else { + RINGTONE_INFO_LOG("unkown field: %{public}s type", tab.c_str()); + } + } +} + +int RingtoneDataShareExtension::Insert(const Uri &uri, const DataShareValuesBucket &value) +{ + RINGTONE_DEBUG_LOG("entry, uri=%{public}s", uri.ToString().c_str()); + + DumpDataShareValueBucket(g_ringToneTableFields, value); + + int err = UriValidCheck(uri); + if (err != E_OK) { + return err; + } + RingtoneDataCommand cmd(uri, RINGTONE_TABLE, RingtoneOperationType::INSERT); + err = CheckRingtonePerm(cmd, true); + if (err < 0) { + RINGTONE_ERR_LOG("Check Insert-permission failed, errCode: %{public}d", err); + return err; + } + + auto ret = RingtoneDataManager::GetInstance()->Insert(cmd, value); + return ret; +} + +int RingtoneDataShareExtension::Update(const Uri &uri, const DataSharePredicates &predicates, + const DataShareValuesBucket &value) +{ + RINGTONE_DEBUG_LOG("entry, uri=%{public}s", uri.ToString().c_str()); + RINGTONE_DEBUG_LOG("WhereClause=%{public}s", predicates.GetWhereClause().c_str()); + + int err = UriValidCheck(uri); + if (err != E_OK) { + return err; + } + RingtoneDataCommand cmd(uri, RINGTONE_TABLE, RingtoneOperationType::UPDATE); + err = CheckRingtonePerm(cmd, false); + if (err < 0) { + RINGTONE_ERR_LOG("Check Update-permission failed, errCode: %{public}d", err); + return err; + } + + return RingtoneDataManager::GetInstance()->Update(cmd, value, predicates); +} + +int RingtoneDataShareExtension::Delete(const Uri &uri, const DataSharePredicates &predicates) +{ + RINGTONE_DEBUG_LOG("entry, uri=%{public}s", uri.ToString().c_str()); + + int err = UriValidCheck(uri); + if (err != E_OK) { + return err; + } + RingtoneDataCommand cmd(uri, RINGTONE_TABLE, RingtoneOperationType::DELETE); + err = CheckRingtonePerm(cmd, true); + if (err < 0) { + RINGTONE_ERR_LOG("Check Delete-permission failed, errCode: %{public}d", err); + return err; + } + + return RingtoneDataManager::GetInstance()->Delete(cmd, predicates); +} + +shared_ptr RingtoneDataShareExtension::Query(const Uri &uri, + const DataSharePredicates &predicates, vector &columns, DatashareBusinessError &businessError) +{ + RINGTONE_DEBUG_LOG("entry, uri=%{public}s", uri.ToString().c_str()); + int err = UriValidCheck(uri); + if (err != E_OK) { + return nullptr; + } + RingtoneDataCommand cmd(uri, RINGTONE_TABLE, RingtoneOperationType::QUERY); + err = CheckRingtonePerm(cmd, false); + if (err < 0) { + businessError.SetCode(err); + RINGTONE_ERR_LOG("Check Query-permission failed, errCode: %{public}d", err); + return nullptr; + } + + int errCode = businessError.GetCode(); + auto queryResultSet = RingtoneDataManager::GetInstance()->Query(cmd, columns, predicates, errCode); + businessError.SetCode(to_string(errCode)); + if (queryResultSet == nullptr) { + RINGTONE_ERR_LOG("queryResultSet is nullptr! errCode: %{public}d", errCode); + return nullptr; + } + shared_ptr resultSet = make_shared(queryResultSet); + return resultSet; +} + +int RingtoneDataShareExtension::OpenFile(const Uri &uri, const string &mode) +{ + RINGTONE_DEBUG_LOG("entry, uri=%{public}s, mode=%{public}s", + uri.ToString().c_str(), mode.c_str()); + + int err = UriValidCheck(uri); + if (err != E_OK) { + return err; + } + RingtoneDataCommand cmd(uri, RINGTONE_TABLE, RingtoneOperationType::OPEN); + + string unifyMode = mode; + transform(unifyMode.begin(), unifyMode.end(), unifyMode.begin(), ::tolower); + + err = CheckRingtonePerm(cmd, true); + if (err == E_PERMISSION_DENIED) { + RINGTONE_ERR_LOG("OpenFile denied, errCode: %{public}d", err); + return err; + } + return RingtoneDataManager::GetInstance()->OpenFile(cmd, unifyMode); +} + +static DataShare::DataShareExtAbility *RingtoneDataShareCreator(const unique_ptr &runtime) +{ + RINGTONE_DEBUG_LOG("entry"); + return RingtoneDataShareExtension::Create(runtime); +} + +__attribute__((constructor)) void RegisterDataShareCreator() +{ + RINGTONE_ERR_LOG("entry"); + DataShare::DataShareExtAbility::SetCreator(RingtoneDataShareCreator); + + RINGTONE_ERR_LOG("End"); +} +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/services/ringtone_data_extension/src/ringtone_datashare_stub_impl.cpp b/services/ringtone_data_extension/src/ringtone_datashare_stub_impl.cpp new file mode 100644 index 0000000..800115a --- /dev/null +++ b/services/ringtone_data_extension/src/ringtone_datashare_stub_impl.cpp @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2024 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. + */ +#define MLOG_TAG "Extension" + +#include "ringtone_datashare_stub_impl.h" + +#include "ringtone_log.h" + +namespace OHOS { +namespace DataShare { +std::shared_ptr RingtoneDataShareStubImpl::GetOwner() +{ + return extension_; +} + +std::vector RingtoneDataShareStubImpl::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) +{ + RINGTONE_INFO_LOG("begin."); + std::vector ret; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->GetFileTypes(uri, mimeTypeFilter); + RINGTONE_INFO_LOG("end successfully."); + return ret; +} + +int RingtoneDataShareStubImpl::OpenFile(const Uri &uri, const std::string &mode) +{ + int ret = -1; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->OpenFile(uri, mode); + return ret; +} + +int RingtoneDataShareStubImpl::OpenRawFile(const Uri &uri, const std::string &mode) +{ + RINGTONE_INFO_LOG("begin."); + int ret = -1; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->OpenRawFile(uri, mode); + RINGTONE_INFO_LOG("end successfully. ret: %{public}d", ret); + return ret; +} + +int RingtoneDataShareStubImpl::Insert(const Uri &uri, const DataShareValuesBucket &value) +{ + int ret = 0; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->Insert(uri, value); + return ret; +} + +int RingtoneDataShareStubImpl::InsertExt(const Uri &uri, const DataShareValuesBucket &value, std::string &result) +{ + int ret = 0; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->InsertExt(uri, value, result); + return ret; +} + +int RingtoneDataShareStubImpl::Update(const Uri &uri, const DataSharePredicates &predicates, + const DataShareValuesBucket &value) +{ + int ret = 0; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->Update(uri, predicates, value); + return ret; +} + +int RingtoneDataShareStubImpl::Delete(const Uri &uri, const DataSharePredicates &predicates) +{ + int ret = 0; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->Delete(uri, predicates); + return ret; +} + +std::shared_ptr RingtoneDataShareStubImpl::Query(const Uri &uri, + const DataSharePredicates &predicates, std::vector &columns, DatashareBusinessError &businessError) +{ + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return nullptr; + } + return extension->Query(uri, predicates, columns, businessError); +} + +std::string RingtoneDataShareStubImpl::GetType(const Uri &uri) +{ + RINGTONE_INFO_LOG("begin."); + std::string ret = ""; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->GetType(uri); + RINGTONE_INFO_LOG("end successfully."); + return ret; +} + +int RingtoneDataShareStubImpl::BatchInsert(const Uri &uri, const std::vector &values) +{ + RINGTONE_INFO_LOG("begin."); + int ret = 0; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->BatchInsert(uri, values); + RINGTONE_INFO_LOG("end successfully."); + return ret; +} + +bool RingtoneDataShareStubImpl::RegisterObserver(const Uri &uri, const sptr &dataObserver) +{ + RINGTONE_INFO_LOG("begin."); + bool ret = false; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->RegisterObserver(uri, dataObserver); + RINGTONE_INFO_LOG("end successfully. ret: %{public}d", ret); + return ret; +} + +bool RingtoneDataShareStubImpl::UnregisterObserver(const Uri &uri, + const sptr &dataObserver) +{ + RINGTONE_INFO_LOG("begin."); + bool ret = false; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->UnregisterObserver(uri, dataObserver); + RINGTONE_INFO_LOG("end successfully. ret: %{public}d", ret); + return ret; +} + +bool RingtoneDataShareStubImpl::NotifyChange(const Uri &uri) +{ + RINGTONE_INFO_LOG("begin."); + bool ret = false; + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return ret; + } + ret = extension->NotifyChange(uri); + RINGTONE_INFO_LOG("end successfully. ret: %{public}d", ret); + return ret; +} + +Uri RingtoneDataShareStubImpl::NormalizeUri(const Uri &uri) +{ + RINGTONE_INFO_LOG("begin."); + Uri urivalue(""); + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return urivalue; + } + urivalue = extension->NormalizeUri(uri); + RINGTONE_INFO_LOG("end successfully."); + return urivalue; +} + +Uri RingtoneDataShareStubImpl::DenormalizeUri(const Uri &uri) +{ + RINGTONE_INFO_LOG("begin."); + Uri urivalue(""); + auto client = sptr(this); + auto extension = client->GetOwner(); + if (extension == nullptr) { + RINGTONE_ERR_LOG("end failed."); + return urivalue; + } + urivalue = extension->DenormalizeUri(uri); + RINGTONE_INFO_LOG("end successfully."); + return urivalue; +} +} // namespace DataShare +} // namespace OHOS diff --git a/services/ringtone_data_extension/src/ringtone_rdbstore.cpp b/services/ringtone_data_extension/src/ringtone_rdbstore.cpp new file mode 100644 index 0000000..1fa1195 --- /dev/null +++ b/services/ringtone_data_extension/src/ringtone_rdbstore.cpp @@ -0,0 +1,327 @@ +/* + * Copyright (C) 2024 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. + */ +#define MLOG_TAG "RdbStore" + +#include "ringtone_rdbstore.h" + +#include + +#include "rdb_sql_utils.h" +#include "ringtone_errno.h" +#include "ringtone_log.h" +#include "ringtone_tracer.h" + +using namespace std; +using namespace OHOS::NativeRdb; +namespace OHOS::Media { +static const mode_t MODE_RWX_USR_GRP = 02771; +const std::string CREATE_RINGTONE_TABLE = "CREATE TABLE IF NOT EXISTS " + RINGTONE_TABLE + "(" + + RINGTONE_COLUMN_TONE_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + RINGTONE_COLUMN_DATA + " TEXT , " + + RINGTONE_COLUMN_SIZE + " BIGINT DEFAULT 0, " + + RINGTONE_COLUMN_DISPLAY_NAME + " TEXT , " + + RINGTONE_COLUMN_TITLE + " TEXT , " + + RINGTONE_COLUMN_MEDIA_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_TONE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_MIME_TYPE + " TEXT , " + + RINGTONE_COLUMN_SOURCE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_DATE_ADDED + " BIGINT DEFAULT 0, " + + RINGTONE_COLUMN_DATE_MODIFIED + " BIGINT DEFAULT 0, " + + RINGTONE_COLUMN_DATE_TAKEN + " BIGINT DEFAULT 0, " + + RINGTONE_COLUMN_DURATION + " INT DEFAULT 0, " + + RINGTONE_COLUMN_SHOT_TONE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_SHOT_TONE_SOURCE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_NOTIFICATION_TONE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_NOTIFICATION_TONE_SOURCE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_RING_TONE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_RING_TONE_SOURCE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_ALARM_TONE_TYPE + " INT DEFAULT 0, " + + RINGTONE_COLUMN_ALARM_TONE_SOURCE_TYPE + " INT DEFAULT 0 " + ")"; + +shared_ptr RingtoneRdbStore::rdbStore_; + +static const vector g_initSqls = { + CREATE_RINGTONE_TABLE, +}; + +int32_t RingtoneDataCallBack::MkdirRecursive(const string &path, size_t start) +{ + RINGTONE_DEBUG_LOG("start pos %{public}zu", start); + size_t end = path.find("/", start + 1); + + string subDir = ""; + if (end == std::string::npos) { + if (start + 1 == path.size()) { + RINGTONE_DEBUG_LOG("path size=%d", path.size()); + } else { + subDir = path.substr(start + 1, path.size() - start - 1); + } + } else { + subDir = path.substr(start + 1, end - start - 1); + } + + if (subDir.size() == 0) { + return NativeRdb::E_OK; + } else { + string real = path.substr(0, start + subDir.size() + 1); + mode_t mask = umask(0); + int result = mkdir(real.c_str(), MODE_RWX_USR_GRP); + if (result == 0) { + RINGTONE_INFO_LOG("mkdir %{public}s successfully", real.c_str()); + } else { + RINGTONE_INFO_LOG("mkdir %{public}s failed, errno is %{public}d", real.c_str(), errno); + } + umask(mask); + } + if (end == std::string::npos) { + return NativeRdb::E_OK; + } + + return MkdirRecursive(path, end); +} + +int32_t RingtoneDataCallBack::CreatePreloadFolder(const string &path) +{ + RINGTONE_DEBUG_LOG("start"); + if (access(path.c_str(), F_OK) == 0) { + RINGTONE_INFO_LOG("dir is existing"); + return NativeRdb::E_OK; + } + + auto start = path.find(RINGTONE_CUSTOMIZED_BASE_PATH); + if (start == string::npos) { + RINGTONE_ERR_LOG("base dir is wrong"); + return NativeRdb::E_ERROR; + } + + return MkdirRecursive(path, start + RINGTONE_CUSTOMIZED_BASE_PATH.size()); +} + +int32_t RingtoneDataCallBack::PrepareDir() +{ + static const vector userPreloadDirs = { + { RINGTONE_CUSTOMIZED_ALARM }, { RINGTONE_CUSTOMIZED_RINGTONE }, { RINGTONE_CUSTOMIZED_NOTIFICATIONS } + }; + + for (const auto &dir: userPreloadDirs) { + if (CreatePreloadFolder(dir) != NativeRdb::E_OK) { + RINGTONE_INFO_LOG("scan failed on dir %{public}s", dir.c_str()); + continue; + } + } + return NativeRdb::E_OK; +} + +int32_t RingtoneDataCallBack::InitSql(RdbStore &store) +{ + for (const string &sqlStr : g_initSqls) { + if (store.ExecuteSql(sqlStr) != NativeRdb::E_OK) { + RINGTONE_ERR_LOG("Failed to execute sql"); + return NativeRdb::E_ERROR; + } + } + return NativeRdb::E_OK; +} + +int32_t RingtoneDataCallBack::OnCreate(RdbStore &store) +{ + if (InitSql(store) != NativeRdb::E_OK) { + RINGTONE_DEBUG_LOG("error"); + return NativeRdb::E_ERROR; + } + + if (PrepareDir() != NativeRdb::E_OK) { + RINGTONE_DEBUG_LOG("Prepare dir error"); + return NativeRdb::E_ERROR; + } + return NativeRdb::E_OK; +} + +int32_t RingtoneDataCallBack::OnUpgrade(RdbStore &store, int32_t oldVersion, int32_t newVersion) +{ + RINGTONE_DEBUG_LOG("OnUpgrade old:%d, new:%d", oldVersion, newVersion); + + return NativeRdb::E_OK; +} +RingtoneUnistore *RingtoneRdbStore::GetInstance(const std::shared_ptr &context) +{ + static RingtoneRdbStore *instance = nullptr; + if (instance == nullptr && context == nullptr) { + RINGTONE_ERR_LOG("RingtoneRdbStore is not initialized"); + return nullptr; + } + if (instance == nullptr) { + instance = new RingtoneRdbStore(context); + if (instance->Init() != 0) { + RINGTONE_ERR_LOG("init RingtoneRdbStore failed"); + delete instance; + instance = nullptr; + return nullptr; + } + } + return instance; +} + +RingtoneRdbStore::RingtoneRdbStore(const shared_ptr &context) +{ + if (context == nullptr) { + RINGTONE_ERR_LOG("Failed to get context"); + return; + } + string databaseDir = context->GetDatabaseDir(); + string name = RINGTONE_COLUMN_DATA_ABILITY_DB_NAME; + int32_t errCode = 0; + string realPath = RdbSqlUtils::GetDefaultDatabasePath(databaseDir, name, errCode); + config_.SetName(move(name)); + config_.SetPath(move(realPath)); + config_.SetBundleName(context->GetBundleName()); + config_.SetArea(context->GetArea()); + config_.SetSecurityLevel(SecurityLevel::S3); +} + +int32_t RingtoneRdbStore::Init() +{ + RINGTONE_INFO_LOG("Init rdb store"); + if (rdbStore_ != nullptr) { + return E_OK; + } + + int32_t errCode = 0; + RingtoneDataCallBack rdbDataCallBack; + rdbStore_ = RdbHelper::GetRdbStore(config_, RINGTONE_RDB_VERSION, rdbDataCallBack, errCode); + if (rdbStore_ == nullptr) { + RINGTONE_ERR_LOG("GetRdbStore is failed , errCode=%{public}d", errCode); + return E_ERR; + } + RINGTONE_INFO_LOG("SUCCESS"); + return E_OK; +} + +RingtoneRdbStore::~RingtoneRdbStore() = default; + +void RingtoneRdbStore::Stop() +{ + if (rdbStore_ == nullptr) { + return; + } + + rdbStore_ = nullptr; +} + +int32_t RingtoneRdbStore::Insert(RingtoneDataCommand &cmd, int64_t &rowId) +{ + RingtoneTracer tracer; + tracer.Start("RingtoneRdbStore::Insert"); + if (rdbStore_ == nullptr) { + RINGTONE_ERR_LOG("Pointer rdbStore_ is nullptr. Maybe it didn't init successfully."); + return E_HAS_DB_ERROR; + } + + int32_t ret = rdbStore_->Insert(rowId, cmd.GetTableName(), cmd.GetValueBucket()); + if (ret != NativeRdb::E_OK) { + RINGTONE_ERR_LOG("rdbStore_->Insert failed, ret = %{public}d", ret); + return E_HAS_DB_ERROR; + } + + RINGTONE_DEBUG_LOG("rdbStore_->Insert end, rowId = %d, ret = %{public}d", (int)rowId, ret); + return ret; +} + +int32_t RingtoneRdbStore::Delete(RingtoneDataCommand &cmd, int32_t &deletedRows) +{ + if (rdbStore_ == nullptr) { + RINGTONE_ERR_LOG("Pointer rdbStore_ is nullptr. Maybe it didn't init successfully."); + return E_HAS_DB_ERROR; + } + RingtoneTracer tracer; + tracer.Start("RdbStore->DeleteByCmd"); + + auto predicates = cmd.GetAbsRdbPredicates(); + int32_t ret = rdbStore_->Delete(deletedRows, cmd.GetTableName(), predicates->GetWhereClause(), + predicates->GetWhereArgs()); + if (ret != NativeRdb::E_OK) { + RINGTONE_ERR_LOG("rdbStore_->Delete failed, ret = %{public}d", ret); + return E_HAS_DB_ERROR; + } + return ret; +} + +int32_t RingtoneRdbStore::Update(RingtoneDataCommand &cmd, int32_t &changedRows) +{ + if (rdbStore_ == nullptr) { + RINGTONE_ERR_LOG("rdbStore_ is nullptr"); + return E_HAS_DB_ERROR; + } + + RingtoneTracer tracer; + tracer.Start("RdbStore->UpdateByCmd"); + int32_t ret = rdbStore_->Update(changedRows, cmd.GetTableName(), cmd.GetValueBucket(), + cmd.GetAbsRdbPredicates()->GetWhereClause(), cmd.GetAbsRdbPredicates()->GetWhereArgs()); + if (ret != NativeRdb::E_OK) { + RINGTONE_ERR_LOG("rdbStore_->Update failed, ret = %{public}d", ret); + return E_HAS_DB_ERROR; + } + return ret; +} + +shared_ptr RingtoneRdbStore::Query(RingtoneDataCommand &cmd, + const vector &columns) +{ + if (rdbStore_ == nullptr) { + RINGTONE_ERR_LOG("rdbStore_ is nullptr"); + return nullptr; + } + + RingtoneTracer tracer; + tracer.Start("RdbStore->QueryByCmd"); + + auto resultSet = rdbStore_->Query(*cmd.GetAbsRdbPredicates(), columns); + return resultSet; +} + +int32_t RingtoneRdbStore::ExecuteSql(const string &sql) +{ + if (rdbStore_ == nullptr) { + RINGTONE_ERR_LOG("Pointer rdbStore_ is nullptr. Maybe it didn't init successfully."); + return E_HAS_DB_ERROR; + } + RingtoneTracer tracer; + tracer.Start("RdbStore->ExecuteSql"); + int32_t ret = rdbStore_->ExecuteSql(sql); + if (ret != NativeRdb::E_OK) { + RINGTONE_ERR_LOG("rdbStore_->ExecuteSql failed, ret = %{public}d", ret); + return E_HAS_DB_ERROR; + } + return ret; +} + +shared_ptr RingtoneRdbStore::QuerySql(const string &sql, const vector &selectionArgs) +{ + if (rdbStore_ == nullptr) { + RINGTONE_ERR_LOG("Pointer rdbStore_ is nullptr. Maybe it didn't init successfully."); + return nullptr; + } + + RingtoneTracer tracer; + tracer.Start("RdbStore->QuerySql"); + auto resultSet = rdbStore_->QuerySql(sql, selectionArgs); + return resultSet; +} + +shared_ptr RingtoneRdbStore::GetRaw() +{ + return rdbStore_; +} +} // namespace OHOS::Media diff --git a/services/ringtone_data_extension/src/ringtone_subscriber.cpp b/services/ringtone_data_extension/src/ringtone_subscriber.cpp new file mode 100644 index 0000000..f57e8d2 --- /dev/null +++ b/services/ringtone_data_extension/src/ringtone_subscriber.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 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. + */ +#define MLOG_TAG "Subscribe" + +#include "ringtone_subscriber.h" + +#include "common_event_support.h" +#include "ringtone_log.h" + +using namespace OHOS::AAFwk; + +namespace OHOS { +namespace Media { +const std::vector RingtoneSubscriber::events_ = { + EventFwk::CommonEventSupport::COMMON_EVENT_CHARGING, + EventFwk::CommonEventSupport::COMMON_EVENT_DISCHARGING, + EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF, + EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_ON, + EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED, + EventFwk::CommonEventSupport::COMMON_EVENT_BOOT_COMPLETED +}; + +RingtoneSubscriber::RingtoneSubscriber(const EventFwk::CommonEventSubscribeInfo &subscriberInfo) + : EventFwk::CommonEventSubscriber(subscriberInfo) +{ +} + +bool RingtoneSubscriber::Subscribe(void) +{ + EventFwk::MatchingSkills matchingSkills; + for (auto event : events_) { + matchingSkills.AddEvent(event); + } + EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills); + + std::shared_ptr subscriber = std::make_shared(subscribeInfo); + return EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber); +} + +void RingtoneSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &eventData) +{ + const AAFwk::Want &want = eventData.GetWant(); + std::string action = want.GetAction(); + RINGTONE_INFO_LOG("OnReceiveEvent action:%{public}s.", action.c_str()); + if (action.compare(EventFwk::CommonEventSupport::COMMON_EVENT_BOOT_COMPLETED) == 0) { + RINGTONE_INFO_LOG("recieve boot complete event."); + } +} +} // namespace Media +} // namespace OHOS diff --git a/services/ringtone_helper/BUILD.gn b/services/ringtone_helper/BUILD.gn new file mode 100644 index 0000000..942ab51 --- /dev/null +++ b/services/ringtone_helper/BUILD.gn @@ -0,0 +1,80 @@ +# Copyright (C) 2024 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("//foundation/multimedia/ringtone_library/ringtone_library.gni") + +config("ringtone_helper_public_config") { + visibility = [ ":*" ] +} + +ohos_shared_library("ringtone_data_helper") { + install_enable = true + + include_dirs = [ + "${RINGTONE_SCANNER_PATH}/include", + "${RINGTONE_BACKUP_PATH}/include", + "${RINGTONE_EXTENSION_PATH}/include", + "${RINGTONE_DFX_PATH}/include", + "${RINGTONE_SERVICES_PATH}/utils/include", + "${RINGTONE_INTERFACES_PATH}/inner_api/native", + "${RINGTONE_HELPER_PATH}/include", + ] + + sources = [ + "src/ringtone_asset.cpp", + "src/ringtone_fetch_result.cpp", + ] + + public_configs = [ ":ringtone_helper_public_config" ] + + cflags = [ + "-Wall", + "-Werror", + "-Wno-unused-but-set-variable", + "-fdata-sections", + "-ffunction-sections", + "-Os", + ] + + cflags_cc = [ "-Os" ] + + external_deps = [ + "ability_base:zuri", + "ability_runtime:abilitykit_native", + "app_file_service:sandbox_helper_native", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "data_share:datashare_common", + "data_share:datashare_consumer", + "hilog:libhilog", + "hitrace:hitrace_meter", + "kv_store:distributeddata_inner", + "relational_store:native_rdb", + ] + + if (!ringtone_link_opt) { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + boundary_sanitize = true + stack_protector_ret = true + } + } + + subsystem_name = "multimedia" + part_name = "ringtone_library" +} diff --git a/services/ringtone_helper/include/ringtone_asset.h b/services/ringtone_helper/include/ringtone_asset.h new file mode 100644 index 0000000..48359b2 --- /dev/null +++ b/services/ringtone_helper/include/ringtone_asset.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2024 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 RINGTONE_ASSET_H +#define RINGTONE_ASSET_H + +#include +#include + +namespace OHOS { +namespace Media { +#define EXPORT __attribute__ ((visibility ("default"))) + +class RingtoneAsset { +public: + EXPORT RingtoneAsset(); + EXPORT virtual ~RingtoneAsset() = default; + + EXPORT int32_t GetId() const; + EXPORT void SetId(int32_t id); + + EXPORT int64_t GetSize() const; + EXPORT void SetSize(int64_t size); + + EXPORT const std::string &GetPath() const; + EXPORT void SetPath(const std::string &path); + + EXPORT const std::string &GetDisplayName() const; + EXPORT void SetDisplayName(const std::string &displayName); + + EXPORT const std::string &GetTitle() const; + EXPORT void SetTitle(const std::string &title); + + EXPORT const std::string &GetMimeType() const; + EXPORT void SetMimeType(const std::string &mimeType); + + EXPORT int32_t GetSourceType() const; + EXPORT void SetSourceType(int32_t type); + + EXPORT int64_t GetDateAdded() const; + EXPORT void SetDateAdded(int64_t dateAdded); + + EXPORT int64_t GetDateModified() const; + EXPORT void SetDateModified(int64_t dateModified); + + EXPORT int64_t GetDateTaken() const; + EXPORT void SetDateTaken(int64_t dateTaken); + + EXPORT int32_t GetDuration() const; + EXPORT void SetDuration(int32_t duration); + + EXPORT int32_t GetShottoneType() const; + EXPORT void SetShottoneType(int32_t type); + + EXPORT int32_t GetShottoneSourceType() const; + EXPORT void SetShottoneSourceType(int32_t type); + + EXPORT int32_t GetNotificationtoneType() const; + EXPORT void SetNotificationtoneType(int32_t type); + + EXPORT int32_t GetNotificationtoneSourceType() const; + EXPORT void SetNotificationtoneSourceType(int32_t type); + + EXPORT int32_t GetRingtoneType() const; + EXPORT void SetRingtoneType(int32_t type); + + EXPORT int32_t GetRingtoneSourceType() const; + EXPORT void SetRingtoneSourceType(int32_t type); + + EXPORT int32_t GetAlarmtoneType() const; + EXPORT void SetAlarmtoneType(int32_t type); + + EXPORT int32_t GetAlarmtoneSourceType() const; + EXPORT void SetAlarmtoneSourceType(int32_t type); + + EXPORT void SetOpenStatus(int32_t fd, int32_t openStatus); + EXPORT void RemoveOpenStatus(int32_t fd); + EXPORT int32_t GetOpenStatus(int32_t fd); + + EXPORT std::unordered_map> &GetMemberMap(); + EXPORT std::variant &GetMemberValue(const std::string &name); + +private: + const std::string &GetStrMember(const std::string &name) const; + int32_t GetInt32Member(const std::string &name) const; + int64_t GetInt64Member(const std::string &name) const; + + std::unordered_map> member_; + std::mutex openStatusMapMutex_; + std::shared_ptr> openStatusMap_; +}; +} // namespace Media +} // namespace OHOS + +#endif // RINGTONE_ASSET_H diff --git a/services/ringtone_helper/include/ringtone_fetch_result.h b/services/ringtone_helper/include/ringtone_fetch_result.h new file mode 100644 index 0000000..10018fb --- /dev/null +++ b/services/ringtone_helper/include/ringtone_fetch_result.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2024 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 RINGTONE_FETCH_RESULT_H +#define RINGTONE_FETCH_RESULT_H + +#include "abs_shared_result_set.h" +#include "datashare_result_set.h" +#include "rdb_errno.h" +#include "ringtone_asset.h" +#include "ringtone_db_const.h" +#include "ringtone_type.h" + +namespace OHOS { +namespace Media { +#define EXPORT __attribute__ ((visibility ("default"))) +/** + * @brief Class for returning the data cursor to application. + * + * @since 1.0 + * @version 1.0 + */ +template +class RingtoneFetchResult { +public: + EXPORT explicit RingtoneFetchResult(const std::shared_ptr &resultset); + EXPORT RingtoneFetchResult(); + EXPORT virtual ~RingtoneFetchResult(); + + EXPORT void Close(); + EXPORT int32_t GetCount(); + EXPORT bool IsAtLastRow(); + + EXPORT std::shared_ptr &GetDataShareResultSet(); + + EXPORT std::unique_ptr GetObjectAtPosition(int32_t index); + EXPORT std::unique_ptr GetFirstObject(); + EXPORT std::unique_ptr GetObjectFromRdb(std::shared_ptr &resultSet, int idx); + EXPORT std::unique_ptr GetNextObject(); + EXPORT std::unique_ptr GetLastObject(); + EXPORT std::unique_ptr GetObject(); + +private: + EXPORT std::unique_ptr GetObject(std::shared_ptr &resultSet); + EXPORT std::variant GetRowValFromColumn(std::string columnName, + ResultSetDataType dataType, std::shared_ptr &resultSet); + std::variant GetValByIndex(int32_t index, ResultSetDataType dataType, + std::shared_ptr &resultSet); + + void SetRingtoneAsset(RingtoneAsset *asset, std::shared_ptr &resultSet); + + void GetObjectFromResultSet(RingtoneAsset *asset, std::shared_ptr &resultSet); + + std::shared_ptr resultset_ = nullptr; +}; +} // namespace Media +} // namespace OHOS + +#endif // INTERFACES_INNERKITS_NATIVE_INCLUDE_FETCH_RESULT_H diff --git a/services/ringtone_helper/src/ringtone_asset.cpp b/services/ringtone_helper/src/ringtone_asset.cpp new file mode 100644 index 0000000..c267050 --- /dev/null +++ b/services/ringtone_helper/src/ringtone_asset.cpp @@ -0,0 +1,280 @@ +/* + * Copyright (C) 2024 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. + */ +#define MLOG_TAG "RingtoneAsset" + +#include "ringtone_asset.h" + +#include "ringtone_db_const.h" +#include "ringtone_errno.h" +#include "ringtone_log.h" +#include "ringtone_type.h" + +using namespace std; + +namespace OHOS { +namespace Media { +RingtoneAsset::RingtoneAsset() +{ +} + +int32_t RingtoneAsset::GetId() const +{ + return GetInt32Member(RINGTONE_COLUMN_TONE_ID); +} + +void RingtoneAsset::SetId(int32_t id) +{ + member_[RINGTONE_COLUMN_TONE_ID] = id; +} + +int64_t RingtoneAsset::GetSize() const +{ + return GetInt64Member(RINGTONE_COLUMN_SIZE); +} + +void RingtoneAsset::SetSize(int64_t size) +{ + member_[RINGTONE_COLUMN_SIZE] = size; +} + +const string &RingtoneAsset::GetPath() const +{ + return GetStrMember(RINGTONE_COLUMN_DATA); +} + +void RingtoneAsset::SetPath(const string &path) +{ + member_[RINGTONE_COLUMN_DATA] = path; +} + +const string &RingtoneAsset::GetDisplayName() const +{ + return GetStrMember(RINGTONE_COLUMN_DISPLAY_NAME); +} + +void RingtoneAsset::SetDisplayName(const string &displayName) +{ + member_[RINGTONE_COLUMN_DISPLAY_NAME] = displayName; +} + +const string &RingtoneAsset::GetTitle() const +{ + return GetStrMember(RINGTONE_COLUMN_TITLE); +} + +void RingtoneAsset::SetTitle(const string &title) +{ + member_[RINGTONE_COLUMN_TITLE] = title; +} + +const string &RingtoneAsset::GetMimeType() const +{ + return GetStrMember(RINGTONE_COLUMN_MIME_TYPE); +} + +void RingtoneAsset::SetMimeType(const string &mimeType) +{ + member_[RINGTONE_COLUMN_MIME_TYPE] = mimeType; +} + +int32_t RingtoneAsset::GetSourceType() const +{ + return GetInt32Member(RINGTONE_COLUMN_SOURCE_TYPE); +} + +void RingtoneAsset::SetSourceType(int32_t type) +{ + member_[RINGTONE_COLUMN_SOURCE_TYPE] = type; +} + +int64_t RingtoneAsset::GetDateAdded() const +{ + return GetInt64Member(RINGTONE_COLUMN_DATE_ADDED); +} + +void RingtoneAsset::SetDateAdded(int64_t dateAdded) +{ + member_[RINGTONE_COLUMN_DATE_ADDED] = dateAdded; +} + +int64_t RingtoneAsset::GetDateModified() const +{ + return GetInt64Member(RINGTONE_COLUMN_DATE_MODIFIED); +} + +void RingtoneAsset::SetDateModified(int64_t dateModified) +{ + member_[RINGTONE_COLUMN_DATE_MODIFIED] = dateModified; +} + + +int64_t RingtoneAsset::GetDateTaken() const +{ + return GetInt64Member(RINGTONE_COLUMN_DATE_TAKEN); +} + +void RingtoneAsset::SetDateTaken(int64_t dataTaken) +{ + member_[RINGTONE_COLUMN_DATE_TAKEN] = dataTaken; +} + +int32_t RingtoneAsset::GetDuration() const +{ + return GetInt32Member(RINGTONE_COLUMN_DURATION); +} + +void RingtoneAsset::SetDuration(int32_t duration) +{ + member_[RINGTONE_COLUMN_DURATION] = duration; +} + +int32_t RingtoneAsset::GetShottoneType() const +{ + return GetInt32Member(RINGTONE_COLUMN_SHOT_TONE_TYPE); +} + +void RingtoneAsset::SetShottoneType(int32_t type) +{ + member_[RINGTONE_COLUMN_SHOT_TONE_TYPE] = type; +} + +int32_t RingtoneAsset::GetShottoneSourceType() const +{ + return GetInt32Member(RINGTONE_COLUMN_SHOT_TONE_SOURCE_TYPE); +} + +void RingtoneAsset::SetShottoneSourceType(int32_t type) +{ + member_[RINGTONE_COLUMN_SHOT_TONE_SOURCE_TYPE] = type; +} + +int32_t RingtoneAsset::GetNotificationtoneType() const +{ + return GetInt32Member(RINGTONE_COLUMN_NOTIFICATION_TONE_TYPE); +} + +void RingtoneAsset::SetNotificationtoneType(int32_t type) +{ + member_[RINGTONE_COLUMN_NOTIFICATION_TONE_TYPE] = type; +} + +int32_t RingtoneAsset::GetNotificationtoneSourceType() const +{ + return GetInt32Member(RINGTONE_COLUMN_NOTIFICATION_TONE_SOURCE_TYPE); +} + +void RingtoneAsset::SetNotificationtoneSourceType(int32_t type) +{ + member_[RINGTONE_COLUMN_NOTIFICATION_TONE_SOURCE_TYPE] = type; +} + +int32_t RingtoneAsset::GetRingtoneType() const +{ + return GetInt32Member(RINGTONE_COLUMN_RING_TONE_TYPE); +} + +void RingtoneAsset::SetRingtoneType(int32_t type) +{ + member_[RINGTONE_COLUMN_RING_TONE_TYPE] = type; +} + +int32_t RingtoneAsset::GetRingtoneSourceType() const +{ + return GetInt32Member(RINGTONE_COLUMN_RING_TONE_SOURCE_TYPE); +} + +void RingtoneAsset::SetRingtoneSourceType(int32_t type) +{ + member_[RINGTONE_COLUMN_RING_TONE_SOURCE_TYPE] = type; +} + +int32_t RingtoneAsset::GetAlarmtoneType() const +{ + return GetInt32Member(RINGTONE_COLUMN_ALARM_TONE_TYPE); +} + +void RingtoneAsset::SetAlarmtoneType(int32_t type) +{ + member_[RINGTONE_COLUMN_ALARM_TONE_TYPE] = type; +} + +int32_t RingtoneAsset::GetAlarmtoneSourceType() const +{ + return GetInt32Member(RINGTONE_COLUMN_ALARM_TONE_SOURCE_TYPE); +} + +void RingtoneAsset::SetAlarmtoneSourceType(int32_t type) +{ + member_[RINGTONE_COLUMN_ALARM_TONE_SOURCE_TYPE] = type; +} + +void RingtoneAsset::SetOpenStatus(int32_t fd, int32_t openStatus) +{ + lock_guard lock(openStatusMapMutex_); + if (openStatusMap_ == nullptr) { + openStatusMap_ = make_shared>(); + } + openStatusMap_->insert({fd, openStatus}); +} + +void RingtoneAsset::RemoveOpenStatus(int32_t fd) +{ + lock_guard lock(openStatusMapMutex_); + if (openStatusMap_ == nullptr) { + return; + } + openStatusMap_->erase(fd); +} + +int32_t RingtoneAsset::GetOpenStatus(int32_t fd) +{ + lock_guard lock(openStatusMapMutex_); + if (openStatusMap_ == nullptr) { + return E_INVALID_VALUES; + } + if (openStatusMap_->find(fd) != openStatusMap_->end()) { + return openStatusMap_->at(fd); + } else { + RINGTONE_ERR_LOG("can not find this fd: [%{public}d]", fd); + return E_INVALID_VALUES; + } +} + +unordered_map> &RingtoneAsset::GetMemberMap() +{ + return member_; +} + +variant &RingtoneAsset::GetMemberValue(const string &name) +{ + return member_[name]; +} + +const string &RingtoneAsset::GetStrMember(const string &name) const +{ + return (member_.count(name) > 0) ? get(member_.at(name)) : DEFAULT_STR; +} + +int32_t RingtoneAsset::GetInt32Member(const string &name) const +{ + return (member_.count(name) > 0) ? get(member_.at(name)) : DEFAULT_INT32; +} + +int64_t RingtoneAsset::GetInt64Member(const string &name) const +{ + return (member_.count(name) > 0) ? get(member_.at(name)) : DEFAULT_INT64; +} +} // namespace Media +} // namespace OHOS diff --git a/services/ringtone_helper/src/ringtone_fetch_result.cpp b/services/ringtone_helper/src/ringtone_fetch_result.cpp new file mode 100644 index 0000000..75d3537 --- /dev/null +++ b/services/ringtone_helper/src/ringtone_fetch_result.cpp @@ -0,0 +1,309 @@ +/* + * Copyright (C) 2024 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. + */ +#define MLOG_TAG "RingtoneFetchResult" + +#include "ringtone_fetch_result.h" + +#include "ringtone_log.h" + +using namespace std; + +namespace OHOS { +namespace Media { +using ResultTypeMap = unordered_map; + +static const ResultTypeMap &GetResultTypeMap() +{ + static const ResultTypeMap RESULT_TYPE_MAP = { + { RINGTONE_COLUMN_TONE_ID, TYPE_INT32 }, + { RINGTONE_COLUMN_DATA, TYPE_STRING }, + { RINGTONE_COLUMN_SIZE, TYPE_INT64 }, + { RINGTONE_COLUMN_DISPLAY_NAME, TYPE_STRING }, + { RINGTONE_COLUMN_TITLE, TYPE_STRING }, + { RINGTONE_COLUMN_MEDIA_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_TONE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_MIME_TYPE, TYPE_STRING }, + { RINGTONE_COLUMN_SOURCE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_DATE_ADDED, TYPE_INT64 }, + { RINGTONE_COLUMN_DATE_MODIFIED, TYPE_INT64 }, + { RINGTONE_COLUMN_DATE_TAKEN, TYPE_INT64 }, + { RINGTONE_COLUMN_DURATION, TYPE_INT32 }, + { RINGTONE_COLUMN_SHOT_TONE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_SHOT_TONE_SOURCE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_NOTIFICATION_TONE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_NOTIFICATION_TONE_SOURCE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_RING_TONE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_RING_TONE_SOURCE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_ALARM_TONE_TYPE, TYPE_INT32 }, + { RINGTONE_COLUMN_ALARM_TONE_SOURCE_TYPE, TYPE_INT32 }, + }; + return RESULT_TYPE_MAP; +} + +template +RingtoneFetchResult::RingtoneFetchResult(const shared_ptr &resultset) +{ + resultset_ = resultset; + GetCount(); +} + +template +// empty constructor napi +RingtoneFetchResult::RingtoneFetchResult() : resultset_(nullptr) +{ +} + +template +RingtoneFetchResult::~RingtoneFetchResult() +{ + resultset_.reset(); +} + +template +void RingtoneFetchResult::Close() +{ + if (resultset_ != nullptr) { + resultset_->Close(); + resultset_ = nullptr; + } +} + +template +int32_t RingtoneFetchResult::GetCount() +{ + int32_t count = 0; + if (resultset_ == nullptr || resultset_->GetRowCount(count) != NativeRdb::E_OK) { + return 0; + } + return count < 0 ? 0 : count; +} + +template +shared_ptr &RingtoneFetchResult::GetDataShareResultSet() +{ + return resultset_; +} + +template +unique_ptr RingtoneFetchResult::GetObjectAtPosition(int32_t index) +{ + if (resultset_ == nullptr) { + RINGTONE_ERR_LOG("rs is null"); + return nullptr; + } + + int32_t count = GetCount(); + if ((index < 0) || (index > (count - 1))) { + RINGTONE_ERR_LOG("index not proper"); + return nullptr; + } + + if (resultset_->GoToRow(index) != 0) { + RINGTONE_ERR_LOG("failed to go to row at index pos"); + return nullptr; + } + + return GetObject(); +} + +template +unique_ptr RingtoneFetchResult::GetFirstObject() +{ + if ((resultset_ == nullptr) || (resultset_->GoToFirstRow() != 0)) { + RINGTONE_DEBUG_LOG("resultset is null|first row failed"); + return nullptr; + } + + return GetObject(); +} + +template +unique_ptr RingtoneFetchResult::GetNextObject() +{ + if ((resultset_ == nullptr) || (resultset_->GoToNextRow() != 0)) { + RINGTONE_DEBUG_LOG("resultset is null|go to next row failed"); + return nullptr; + } + + return GetObject(); +} + +template +unique_ptr RingtoneFetchResult::GetLastObject() +{ + if ((resultset_ == nullptr) || (resultset_->GoToLastRow() != 0)) { + RINGTONE_ERR_LOG("resultset is null|go to last row failed"); + return nullptr; + } + + return GetObject(); +} + +template +bool RingtoneFetchResult::IsAtLastRow() +{ + if (resultset_ == nullptr) { + RINGTONE_ERR_LOG("resultset null"); + return false; + } + + bool retVal = false; + resultset_->IsAtLastRow(retVal); + return retVal; +} + +variant ReturnDefaultOnError(string errMsg, ResultSetDataType dataType) +{ + if (dataType == TYPE_STRING) { + return ""; + } else if (dataType == TYPE_INT64) { + return static_cast(0); + } else { + return 0; + } +} + +template +variant RingtoneFetchResult::GetRowValFromColumn(string columnName, + ResultSetDataType dataType, shared_ptr &resultSet) +{ + if ((resultset_ == nullptr) && (resultSet == nullptr)) { + return ReturnDefaultOnError("Resultset is null", dataType); + } + int index; + int status; + if (resultSet) { + status = resultSet->GetColumnIndex(columnName, index); + } else { + status = resultset_->GetColumnIndex(columnName, index); + } + if (status != NativeRdb::E_OK) { + return ReturnDefaultOnError("failed to obtain the index", dataType); + } + return GetValByIndex(index, dataType, resultSet); +} + +template +variant RingtoneFetchResult::GetValByIndex(int32_t index, + ResultSetDataType dataType, shared_ptr &resultSet) +{ + if ((resultset_ == nullptr) && (resultSet == nullptr)) { + return ReturnDefaultOnError("Resultset is null", dataType); + } + variant cellValue; + int integerVal = 0; + string stringVal = ""; + int64_t longVal = 0; + int status; + double doubleVal = 0.0; + switch (dataType) { + case TYPE_STRING: + if (resultSet) { + status = resultSet->GetString(index, stringVal); + } else { + status = resultset_->GetString(index, stringVal); + } + cellValue = move(stringVal); + break; + case TYPE_INT32: + if (resultSet) { + status = resultSet->GetInt(index, integerVal); + } else { + status = resultset_->GetInt(index, integerVal); + } + cellValue = integerVal; + break; + case TYPE_INT64: + if (resultSet) { + status = resultSet->GetLong(index, longVal); + } else { + status = resultset_->GetLong(index, longVal); + } + cellValue = longVal; + break; + case TYPE_DOUBLE: + if (resultSet) { + status = resultSet->GetDouble(index, doubleVal); + } else { + status = resultset_->GetDouble(index, doubleVal); + } + cellValue = doubleVal; + break; + default: + break; + } + return cellValue; +} + +template +void RingtoneFetchResult::SetRingtoneAsset(RingtoneAsset *asset, shared_ptr &resultSet) +{ + if ((resultset_ == nullptr) && (resultSet == nullptr)) { + RINGTONE_ERR_LOG("SetRingtoneAsset fail, result is nullptr"); + return; + } + vector columnNames; + if (resultSet != nullptr) { + resultSet->GetAllColumnNames(columnNames); + } else { + resultset_->GetAllColumnNames(columnNames); + } + int32_t index = -1; + auto &map = asset->GetMemberMap(); + for (const auto &name : columnNames) { + index++; + if (GetResultTypeMap().count(name) == 0) { + continue; + } + auto memberType = GetResultTypeMap().at(name); + map.emplace(move(name), move(GetValByIndex(index, memberType, resultSet))); + } +} + +template +void RingtoneFetchResult::GetObjectFromResultSet(RingtoneAsset *asset, shared_ptr &resultSet) +{ + SetRingtoneAsset(asset, resultSet); +} + +template +unique_ptr RingtoneFetchResult::GetObject(shared_ptr &resultSet) +{ + unique_ptr asset = make_unique(); + GetObjectFromResultSet(asset.get(), resultSet); + return asset; +} + +template +unique_ptr RingtoneFetchResult::GetObject() +{ + shared_ptr resultSet = nullptr; + return GetObject(resultSet); +} + +template +unique_ptr RingtoneFetchResult::GetObjectFromRdb(shared_ptr &resultSet, int idx) +{ + if ((resultSet == nullptr) || (resultSet->GoToFirstRow() != 0) || (resultSet->GoTo(idx))) { + RINGTONE_ERR_LOG("resultset is null|first row failed"); + return nullptr; + } + + return GetObject(resultSet); +} + +template class RingtoneFetchResult; +} // namespace Media +} // namespace OHOS