From 3939d59ed9aa1f4b567cd023e6db456e73310114 Mon Sep 17 00:00:00 2001 From: houdisheng Date: Mon, 10 Jan 2022 14:57:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- BUILD.gn | 97 +++++++++ LICENSE.txt | 201 ++++++++++++++++++ adapter/.gitkeep | 0 frameworks/.gitkeep | 0 frameworks/JS/.gitkeep | 0 frameworks/native/.gitkeep | 0 init/bundleactive_service.cfg | 16 ++ init/bundleactive_service.rc | 8 + interfaces/.gitkeep | 0 interfaces/innerkits/.gitkeep | 0 .../innerkits/include/bundle_active_client.h | 26 +++ .../innerkits/include/bundle_active_proxy.h | 27 +++ .../innerkits/src/bundle_active_client.cpp | 53 +++++ .../innerkits/src/bundle_active_proxy.cpp | 50 +++++ interfaces/kits/JS/.gitkeep | 0 interfaces/kits/native/.gitkeep | 0 ohos.build | 31 +++ sa_profile/1906.xml | 11 + services/.gitkeep | 0 services/common/include/bundle_active_event.h | 55 +++++ .../common/include/bundle_active_event_list.h | 23 ++ .../include/bundle_active_event_stats.h | 30 +++ .../include/bundle_active_event_tracker.h | 24 +++ .../include/bundle_active_interval_stats.h | 58 +++++ .../include/bundle_active_usage_stats.h | 51 +++++ .../include/bundle_active_user_service.h | 38 ++++ services/common/src/bundle_active_event.cpp | 45 ++++ .../common/src/bundle_active_event_list.cpp | 48 +++++ .../common/src/bundle_active_event_stats.cpp | 48 +++++ .../src/bundle_active_event_tracker.cpp | 33 +++ .../src/bundle_active_interval_stats.cpp | 89 ++++++++ .../common/src/bundle_active_usage_stats.cpp | 172 +++++++++++++++ .../common/src/bundle_active_user_service.cpp | 55 +++++ services/include/bundle_active_iservice.h | 42 ++++ services/include/bundle_active_log.h | 21 ++ services/include/bundle_active_service.h | 33 +++ services/include/bundle_active_stub.h | 20 ++ services/src/bundle_active_service.cpp | 39 ++++ services/src/bundle_active_stub.cpp | 41 ++++ test/.gitkeep | 0 40 files changed, 1485 insertions(+) create mode 100644 BUILD.gn create mode 100644 LICENSE.txt create mode 100644 adapter/.gitkeep create mode 100644 frameworks/.gitkeep create mode 100644 frameworks/JS/.gitkeep create mode 100644 frameworks/native/.gitkeep create mode 100644 init/bundleactive_service.cfg create mode 100644 init/bundleactive_service.rc create mode 100644 interfaces/.gitkeep create mode 100644 interfaces/innerkits/.gitkeep create mode 100644 interfaces/innerkits/include/bundle_active_client.h create mode 100644 interfaces/innerkits/include/bundle_active_proxy.h create mode 100644 interfaces/innerkits/src/bundle_active_client.cpp create mode 100644 interfaces/innerkits/src/bundle_active_proxy.cpp create mode 100644 interfaces/kits/JS/.gitkeep create mode 100644 interfaces/kits/native/.gitkeep create mode 100644 ohos.build create mode 100644 sa_profile/1906.xml create mode 100644 services/.gitkeep create mode 100644 services/common/include/bundle_active_event.h create mode 100644 services/common/include/bundle_active_event_list.h create mode 100644 services/common/include/bundle_active_event_stats.h create mode 100644 services/common/include/bundle_active_event_tracker.h create mode 100644 services/common/include/bundle_active_interval_stats.h create mode 100644 services/common/include/bundle_active_usage_stats.h create mode 100644 services/common/include/bundle_active_user_service.h create mode 100644 services/common/src/bundle_active_event.cpp create mode 100644 services/common/src/bundle_active_event_list.cpp create mode 100644 services/common/src/bundle_active_event_stats.cpp create mode 100644 services/common/src/bundle_active_event_tracker.cpp create mode 100644 services/common/src/bundle_active_interval_stats.cpp create mode 100644 services/common/src/bundle_active_usage_stats.cpp create mode 100644 services/common/src/bundle_active_user_service.cpp create mode 100644 services/include/bundle_active_iservice.h create mode 100644 services/include/bundle_active_log.h create mode 100644 services/include/bundle_active_service.h create mode 100644 services/include/bundle_active_stub.h create mode 100644 services/src/bundle_active_service.cpp create mode 100644 services/src/bundle_active_stub.cpp create mode 100644 test/.gitkeep diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..37f9b52 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,97 @@ +import("//build/ohos.gni") +import("//build/ohos/sa_profile/sa_profile.gni") + +################################################## +ohos_sa_profile("bundleactive_sa_profile") { + sources = [ + "sa_profile/1906.xml" + ] + part_name = "bundleactive" +} +################################################## + +################################################## bundleactiveinner begin +ohos_shared_library("bundleactiveinner") { + sources = [ + "interfaces/innerkits/src/bundle_active_proxy.cpp", + "interfaces/innerkits/src/bundle_active_client.cpp" + ] + include_dirs = [ + "services/include", + "interfaces/innerkits/include" + ] + + deps = [ + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//utils/native/base:utils", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy" + ] + part_name = "bundleactive" + subsystem_name = "resourceschedule" +} +################################################## bundleactiveinner end + +################################################## +ohos_prebuilt_etc("bundleactive_service_init") { + if (use_musl) { + source = "init/bundleactive_service.cfg" + } else { + source = "init/bundleactive_service.rc" + } + relative_install_dir = "init" + part_name = "bundleactive" + subsystem_name = "resourceschedule" +} +################################################## + +################################################## bundleactivekit begin +#ohos_shared_library("bundleactivekit") { +# sources = [ + #"interfaces/kits/xxx.cpp" + #"frameworks/xxx.cpp" +# ] +# include_dirs = [ +# ] + +# deps = [ +# "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", +# "//utils/native/base:utils", +# "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", +# "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", +# "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy" +# ] +# part_name = "bundleactive" +# subsystem_name = "resourceschedule" +#} +################################################## bundleactivekit end + +################################################## bundleactiveservice begin +ohos_shared_library("bundleactiveservice") { + sources = [ + "services/src/bundle_active_stub.cpp", + "services/src/bundle_active_service.cpp", + "services/common/src/bundle_active_event.cpp", + "services/common/src/bundle_active_event_list.cpp", + "services/common/src/bundle_active_event_stats.cpp", + "services/common/src/bundle_active_event_tracker.cpp", + "services/common/src/bundle_active_usage_stats.cpp", + "services/common/src/bundle_active_interval_stats.cpp", + "services/common/src/bundle_active_user_service.cpp" + ] + include_dirs = [ + "services/include", + "services/common/include" + ] + deps = [ + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//utils/native/base:utils", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy" + ] + part_name = "bundleactive" + subsystem_name = "resourceschedule" +} +################################################## bundleactiveservice end diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..29f81d8 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,201 @@ + 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 + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/adapter/.gitkeep b/adapter/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/frameworks/.gitkeep b/frameworks/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/frameworks/JS/.gitkeep b/frameworks/JS/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/frameworks/native/.gitkeep b/frameworks/native/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/init/bundleactive_service.cfg b/init/bundleactive_service.cfg new file mode 100644 index 0000000..6f53109 --- /dev/null +++ b/init/bundleactive_service.cfg @@ -0,0 +1,16 @@ +{ + "jobs" : [{ + "name" : "post-fs-data", + "cmds" : [ + "start bundleactive_service" + ] + } + ], + "services" : [{ + "name" : "bundleactive_service", + "path" : ["/system/bin/sa_main", "/system/profile/bundleactive_service.xml"], + "uid" : "root", + "gid" : ["root", "shell"] + } + ] +} \ No newline at end of file diff --git a/init/bundleactive_service.rc b/init/bundleactive_service.rc new file mode 100644 index 0000000..5982831 --- /dev/null +++ b/init/bundleactive_service.rc @@ -0,0 +1,8 @@ +on post-fs-data + start bundleactive_service + +service bundleactive_service /system/bin/sa_main /system/profile/bundleactive_service.xml + class z_core + user root + group root shell + seclabel u:r:bundleactive_service:s0 \ No newline at end of file diff --git a/interfaces/.gitkeep b/interfaces/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/interfaces/innerkits/.gitkeep b/interfaces/innerkits/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/interfaces/innerkits/include/bundle_active_client.h b/interfaces/innerkits/include/bundle_active_client.h new file mode 100644 index 0000000..135145f --- /dev/null +++ b/interfaces/innerkits/include/bundle_active_client.h @@ -0,0 +1,26 @@ +#ifndef BUNDLE_ACTIVE_CLIENT_H +#define BUNDLE_ACTIVE_CLIENT_H + +#include "bundle_active_iservice.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveClient { +public: + int ReportEvent(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId, const int& eventId); + int IsBundleIdle(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId); + int Query(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId); + static BundleActiveClient& GetInstance(); +public: + BundleActiveClient() {} + ~BundleActiveClient() {}; + +private: + bool GetBundleActiveProxy(); + sptr bundleActiveProxy; +}; + +} +} +#endif \ No newline at end of file diff --git a/interfaces/innerkits/include/bundle_active_proxy.h b/interfaces/innerkits/include/bundle_active_proxy.h new file mode 100644 index 0000000..fdebc38 --- /dev/null +++ b/interfaces/innerkits/include/bundle_active_proxy.h @@ -0,0 +1,27 @@ +#ifndef BUNDLE_ACTIVE_PROXY_H +#define BUNDLE_ACTIVE_PROXY_H + +#include "bundle_active_iservice.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveProxy : public IRemoteProxy { +public: + int ReportEvent(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId, const int& eventId) override; + int IsBundleIdle(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) override; + int Query(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) override; + +public: + explicit BundleActiveProxy(const sptr& impl) + : IRemoteProxy(impl) {} + virtual ~BundleActiveProxy() {} + +private: + static inline BrokerDelegator delegator_; +}; + +} +} + +#endif diff --git a/interfaces/innerkits/src/bundle_active_client.cpp b/interfaces/innerkits/src/bundle_active_client.cpp new file mode 100644 index 0000000..c69240e --- /dev/null +++ b/interfaces/innerkits/src/bundle_active_client.cpp @@ -0,0 +1,53 @@ +#include "bundle_active_client.h" + +namespace OHOS { +namespace BundleActive { + +BundleActiveClient& BundleActiveClient::GetInstance() { + static BundleActiveClient instance; + return instance; +} + +bool BundleActiveClient::GetBundleActiveProxy() { + sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + BUNDLE_ACTIVE_LOGE("Failed to get SystemAbilityManager."); + return false; + } + + sptr object = samgr->GetSystemAbility(BUNDLE_ACTIVE_SYS_ABILITY_ID); + if (object == nullptr) { + BUNDLE_ACTIVE_LOGE("Failed to get SystemAbility[1910] ."); + return false; + } + + bundleActiveProxy = iface_cast(object); + if (bundleActiveProxy == nullptr) { + BUNDLE_ACTIVE_LOGE("Failed to get BundleActiveClient."); + return false; + } + return true; +} +int BundleActiveClient::ReportEvent(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId, const int& eventId) { + if (!GetBundleActiveProxy()) { + return -1; + } + return bundleActiveProxy->ReportEvent(bundleName, abilityName, abilityId, userId, eventId); +} + +int BundleActiveClient::IsBundleIdle(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) { + if (!GetBundleActiveProxy()) { + return -1; + } + return bundleActiveProxy->IsBundleIdle(bundleName, abilityName, abilityId, userId); +} + +int BundleActiveClient::Query(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) { + if (!GetBundleActiveProxy()) { + return -1; + } + return bundleActiveProxy->Query(bundleName, abilityName, abilityId, userId); +} + +} +} \ No newline at end of file diff --git a/interfaces/innerkits/src/bundle_active_proxy.cpp b/interfaces/innerkits/src/bundle_active_proxy.cpp new file mode 100644 index 0000000..feb8204 --- /dev/null +++ b/interfaces/innerkits/src/bundle_active_proxy.cpp @@ -0,0 +1,50 @@ +#include "bundle_active_proxy.h" + +namespace OHOS{ +namespace BundleActive { + +int BundleActiveProxy::ReportEvent(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId, const int& eventId) { + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteString(bundleName); + data.WriteString(abilityName); + data.WriteInt32(abilityId); + data.WriteInt32(userId); + data.WriteInt32(eventId); + Remote() -> SendRequest(REPORT_EVENT, data, reply, option); + + int32_t result = reply.ReadInt32(); + return result; +} + +int BundleActiveProxy::IsBundleIdle(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) { + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteString(bundleName); + data.WriteString(abilityName); + data.WriteInt32(abilityId); + data.WriteInt32(userId); + Remote() -> SendRequest(IS_BUNDLE_IDLE, data, reply, option); + + int32_t result = reply.ReadInt32(); + return result; +} + +int BundleActiveProxy::Query(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) { + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteString(bundleName); + data.WriteString(abilityName); + data.WriteInt32(abilityId); + data.WriteInt32(userId); + Remote() -> SendRequest(QUERY, data, reply, option); + + int32_t result = reply.ReadInt32(); + return result; +} + +} +} \ No newline at end of file diff --git a/interfaces/kits/JS/.gitkeep b/interfaces/kits/JS/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/interfaces/kits/native/.gitkeep b/interfaces/kits/native/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/ohos.build b/ohos.build new file mode 100644 index 0000000..6435cac --- /dev/null +++ b/ohos.build @@ -0,0 +1,31 @@ +{ + "subsystem": "resourceschedule", + "parts": { + "bundleactive": { + "variants": [ + ], + "module_list": [ + "//foundation/resourceschedule/bundleactive:bundleactiveinner", + "//foundation/resourceschedule/bundleactive:bundleactiveservice", + "//foundation/resourceschedule/bundleactive:bundleactive_sa_profile", + "//foundation/resourceschedule/bundleactive:bundleactive_service_init" + ], + "inner_kits": [ + { + "header": { + "header_base": "//foundation/resourceschedule/bundleactive/interfaces/innerkits/include", + "header_files": [ + "bundle_active_proxy.h", + "bundle_active_client.h" + ] + }, + "name": "//foundation/resourceschedule/bundleactive:bundleactiveinner" + } + ], + "system_kits": [ + ], + "test_list":[ + ] + } + } +} diff --git a/sa_profile/1906.xml b/sa_profile/1906.xml new file mode 100644 index 0000000..070b556 --- /dev/null +++ b/sa_profile/1906.xml @@ -0,0 +1,11 @@ + + + bundleactive_service + + 1906 + libbundleactiveservice.z.so + true + false + 1 + + diff --git a/services/.gitkeep b/services/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/services/common/include/bundle_active_event.h b/services/common/include/bundle_active_event.h new file mode 100644 index 0000000..6588e75 --- /dev/null +++ b/services/common/include/bundle_active_event.h @@ -0,0 +1,55 @@ +#ifndef BUNDLE_ACTIVE_EVENT_H +#define BUNDLE_ACTIVE_EVENT_H + +#include "bundle_active_iservice.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveEvent { +public: + //external events + //static const int ABILITY_START = 1;//onStart() called, ability is not in front, but still visible + static const int ABILITY_FOREGROUND = 2;//onForeground() called, ability is in front. + static const int ABILITY_BACKGROUND = 3;//onBackground() called, ability is in background. + static const int ABILITY_STOP = 4;//onStop() called, ability is destroyed. + static const int FRONT_SERVICE_STARTTED = 5; + //static const int FRONT_SERVICE_CONTINUED = 11; + static const int FRONT_SERVICE_STOPPED = 6; + static const int SYSTEM_INTERACTIVE = 7; + static const int USER_INTERACTIVE = 8; + + //internal events + static const int END_OF_THE_DAY = 9; + //static const int CONTINUE_PREVIOUS_DAY = 21; + static const int DEVICE_SHUTDOWN = 10; + static const int DEVICE_STARTUP = 11; + static const int FLUSH_TO_DISK = 12; + static const int SCREEN_INTERACTIVE = 13; + static const int SCREEN_NON_INTERACTIVE = 14; + static const int KEYGUARD_SHOWN = 15; + static const int KEYGUARD_HIDDEN = 16; + inline static const std::string DEVICE_EVENT_PACKAGE_NAME = "openharmony"; + std::string m_bundleName; + std::string m_serviceName; + std::string m_abilityName; + int m_abilityId; + long m_timeStamp; + int m_eventId; + bool m_isIdle; + +public: + BundleActiveEvent() {}; + BundleActiveEvent(const BundleActiveEvent& orig); + BundleActiveEvent(int eventId, long timeStamp); + std::string GetBundleName(); + std::string GetAbilityName(); + int GetAbilityId(); + long GetTimeStamp(); + int GetEventId(); + bool GetIsIdle(); +}; + +} +} +#endif \ No newline at end of file diff --git a/services/common/include/bundle_active_event_list.h b/services/common/include/bundle_active_event_list.h new file mode 100644 index 0000000..6b3ec12 --- /dev/null +++ b/services/common/include/bundle_active_event_list.h @@ -0,0 +1,23 @@ +#ifndef BUNDLE_ACTIVE_EVENT_LIST_H +#define BUNDLE_ACTIVE_EVENT_LIST_H + +#include "bundle_active_iservice.h" +#include "bundle_active_event.h" + +namespace OHOS { +namespace BundleActive { +class BundleActiveEventList { +public: + BundleActiveEventList(); + int Size(); + void Clear(); + void Insert(BundleActiveEvent event); + int FirstIndexOnOrAfter(long timeStamp); + void Merge(const BundleActiveEventList& right); +private: + std::vector m_events; +}; + +} +} +#endif \ No newline at end of file diff --git a/services/common/include/bundle_active_event_stats.h b/services/common/include/bundle_active_event_stats.h new file mode 100644 index 0000000..9d0de8c --- /dev/null +++ b/services/common/include/bundle_active_event_stats.h @@ -0,0 +1,30 @@ +#ifndef BUNDLE_ACTIVE_EVENT_STATS_H +#define BUNDLE_ACTIVE_EVENT_STATS_H + +#include "bundle_active_iservice.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveEventStats { +public: + int m_eventId; + long m_beginTimeStamp; + long m_endTimeStamp; + long m_lastEventTime; + long m_totalTime; + int m_count; + BundleActiveEventStats() {}; + BundleActiveEventStats(const BundleActiveEventStats& orig); + int GetEventId(); + int GetFirstTimeStamp(); + int GetLastTimeStamp(); + int GetLastEventTime(); + int GetTotalTime(); + int GetCount(); + void add(const BundleActiveEventStats& right); +}; + +} +} +#endif \ No newline at end of file diff --git a/services/common/include/bundle_active_event_tracker.h b/services/common/include/bundle_active_event_tracker.h new file mode 100644 index 0000000..80ef511 --- /dev/null +++ b/services/common/include/bundle_active_event_tracker.h @@ -0,0 +1,24 @@ +#ifndef BUNDLE_ACTIVE_EVENT_TRACKER_H +#define BUNDLE_ACTIVE_EVENT_TRACKER_H + +#include "bundle_active_iservice.h" +#include "bundle_active_event_stats.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveEventTracker { +public: + long m_curStartTime; + long m_lastEventTime; + long m_duration; + long m_count; + void CommitTime(long timeStamp); + void Update(long timeStamp); + void AddToEventStats(std::vector& eventStatsList, int eventId, long beginTime, long endTime); + BundleActiveEventTracker() {}; +}; + +} +} +#endif \ No newline at end of file diff --git a/services/common/include/bundle_active_interval_stats.h b/services/common/include/bundle_active_interval_stats.h new file mode 100644 index 0000000..ba0ac38 --- /dev/null +++ b/services/common/include/bundle_active_interval_stats.h @@ -0,0 +1,58 @@ +#ifndef BUNDLE_ACTIVE_INTERVAL_STATS_H +#define BUNDLE_ACTIVE_INTERVAL_STATS_H + +#include "bundle_active_iservice.h" +#include "bundle_active_event.h" +#include "bundle_active_usage_stats.h" +#include "bundle_active_event_list.h" +#include "bundle_active_event_tracker.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveIntervalStats { +public: + static const int CURRENT_MAJOR_VERSION = 1; + static const int CURRENT_MINOR_VERSION = 1; + static const int INTERVAL_DAILY = 0; + static const int INTERVAL_WEEKLY = 1; + static const int INTERVAL_MONTHLY = 2; + static const int INTERVAL_YEARLY = 3; + static const int INTERVAL_BEST = 4; + static const int INTERVAL_COUNT = 4; + static const long long DAY_IN_MILLIS = (long long)24 * 60 * 60 * 1000; + static const long long WEEK_IN_MILLIS = (long long)7 * 24 * 60 * 60 * 1000; + static const long long MONTH_IN_MILLIS = (long long)30 * 24 * 60 * 60 * 1000; + static const long long YEAR_IN_MILLIS = (long long)365 * 24 * 60 * 60 * 1000; + int majorVersion = CURRENT_MAJOR_VERSION; + int minorVersion = CURRENT_MINOR_VERSION; + long m_beginTime; + long m_endTime; + long m_lastTimeSaved; + std::map m_bundleStats; + BundleActiveEventList m_events; + std::set m_packetNamesCache; + BundleActiveEventTracker m_interactiveTracker; + BundleActiveEventTracker m_noninteractiveTracker; + BundleActiveEventTracker m_keyguardShownTracker; + BundleActiveEventTracker m_keyguardHiddenTracker; + + BundleActiveUsageStats& GetOrCreateUsageStats(std::string bundleName); + BundleActiveEvent BuildEvent(std::string bundleName, std::string serviceName); + void Update(std::string bundleName, std::string serviceName, long timeStamp, int eventId, int abilityId); + void AddEvent(BundleActiveEvent event); + void UpdateScreenInteractive(long timeStamp); + void UpdateScreenNonInteractive(long timeStamp); + void UpdateKeyguardShown(long timeStamp); + void UpdateKeyguardHidden(long timeStamp); + +private: + void CommitTime(long timeStamp); + void AddEventStatsTo(std::vector& eventStatsList); + std::string GetCachedString(std::string str); + +}; + +} +} +#endif \ No newline at end of file diff --git a/services/common/include/bundle_active_usage_stats.h b/services/common/include/bundle_active_usage_stats.h new file mode 100644 index 0000000..e01a8a7 --- /dev/null +++ b/services/common/include/bundle_active_usage_stats.h @@ -0,0 +1,51 @@ +#ifndef BUNDLE_ACTIVE_USAGE_STATS_H +#define BUNDLE_ACTIVE_USAGE_STATS_H + +#include "bundle_active_iservice.h" +#include "bundle_active_event.h" + +namespace OHOS { +namespace BundleActive { + +//bundles statistics, including activities and frontservices. +class BundleActiveUsageStats { +public: + std::string m_bundleName; + long m_beginTimeStamp; //start time of counting + long m_endTimeStamp; //stop time of counting + long m_lastTimeUsed; //the timestamp of last launch + long m_totalTimeInFront; // the total time of using the bundle + long m_lastTimeFrontServiceUsed; + long m_totalTimeFrontServiceUsed; + int m_launchedCount; + int m_bundleLaunchedCount; + int m_lastEvent; + std::map m_abilities; // key is abilityId, value is the last event of this ability. Restore all abilities' last event of bundle. + std::map m_frontServices; // restore the frontservices' names using by bundle. + BundleActiveUsageStats() {}; + BundleActiveUsageStats(const BundleActiveUsageStats& orig); + std::string GetBundleName(); + long GetBeginTimeStamp(); + long GetEntTimeStamp(); + long GetLastTimeUsed(); + long GetTotalTimeInFront(); + long GetLastTimeFrontServiceUsed(); + long GetTotalTimeFrontServiceUsed(); + int GetLaunchedCount(); + int GetBundleLaunchedCount(); + void Update(std::string frontServiceName, long timeStamp, int eventId, int abilityId); + void IncrementTimeUsed(long timeStamp); + void IncrementServiceTimeUsed(long timeStamp); + void IncrementBundleLaunchedCount(); +private: + bool HasFrontAbility(); + bool AnyFrontServiceStarted(); + void UpdateActivity(long timeStamp, int eventId, int abilityId); + void UpdateFrontService(std::string frontServiceName, long timeStamp, int eventId); + + +}; + +} +} +#endif diff --git a/services/common/include/bundle_active_user_service.h b/services/common/include/bundle_active_user_service.h new file mode 100644 index 0000000..fc92466 --- /dev/null +++ b/services/common/include/bundle_active_user_service.h @@ -0,0 +1,38 @@ +#ifndef BUNDLE_ACTIVE_USER_SERVICE_H +#define BUNDLE_ACTIVE_USER_SERVICE_H + +#include "bundle_active_iservice.h" +#include "bundle_active_event.h" +#include "bundle_active_usage_stats.h" +#include "bundle_active_interval_stats.h" +#include "bundle_active_event_stats.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveUserService { +public: + + BundleActiveUserService(int userId);//,/*database定义待补充*/ BundleActiveService listener/*刷数据库监听器接口实现类*/); + virtual void onStatsUpdated() = 0; + virtual void onstatsReloaded() = 0; + virtual void onNewUpdate(int userId) = 0; +private: + //BundleActiveUsageDatabase m_dataBase; + int m_incrementBundleLaunch; + int m_userId; + std::vector m_currentStats; + bool m_statsChanged; + std::string m_lastBackgroundBundle; + //BundleActiveService m_listener; + inline static const std::vector INTERVAL_LENGTH = {BundleActiveIntervalStats::DAY_IN_MILLIS, BundleActiveIntervalStats::WEEK_IN_MILLIS, + BundleActiveIntervalStats::MONTH_IN_MILLIS, BundleActiveIntervalStats::YEAR_IN_MILLIS}; + void NotifyStatsChanged(); + void ReportEvent(BundleActiveEvent event); + + +}; + +} +} +#endif \ No newline at end of file diff --git a/services/common/src/bundle_active_event.cpp b/services/common/src/bundle_active_event.cpp new file mode 100644 index 0000000..bc1db12 --- /dev/null +++ b/services/common/src/bundle_active_event.cpp @@ -0,0 +1,45 @@ +#include "bundle_active_event.h" + +namespace OHOS { +namespace BundleActive { + +BundleActiveEvent::BundleActiveEvent (const BundleActiveEvent& orig) { + m_bundleName = orig.m_bundleName; + m_abilityName = orig.m_abilityName; + m_abilityId = orig.m_abilityId; + m_timeStamp = orig.m_timeStamp; + m_eventId = orig.m_eventId; + m_isIdle = orig.m_isIdle; +} + +BundleActiveEvent::BundleActiveEvent(int eventId, long timeStamp) { + m_eventId = eventId; + m_timeStamp = timeStamp; +} + +std::string BundleActiveEvent::GetBundleName() { + return m_bundleName; +} + +std::string BundleActiveEvent::GetAbilityName() { + return m_abilityName; +} + +int BundleActiveEvent::GetAbilityId() { + return m_abilityId; +} + +long BundleActiveEvent::GetTimeStamp() { + return m_timeStamp; +} + +int BundleActiveEvent::GetEventId() { + return m_eventId; +} + +bool BundleActiveEvent::GetIsIdle() { + return m_isIdle; +} + +} +} diff --git a/services/common/src/bundle_active_event_list.cpp b/services/common/src/bundle_active_event_list.cpp new file mode 100644 index 0000000..0db705c --- /dev/null +++ b/services/common/src/bundle_active_event_list.cpp @@ -0,0 +1,48 @@ +#include "bundle_active_event_list.h" + +namespace OHOS { +namespace BundleActive { +BundleActiveEventList::BundleActiveEventList() { + +} +int BundleActiveEventList::Size() { + return m_events.size(); +} +void BundleActiveEventList::Clear() { + m_events.clear(); +} +void BundleActiveEventList::Insert(BundleActiveEvent event) { + int size = m_events.size(); + if (size == 0 || event.m_timeStamp >= m_events.back().m_timeStamp) { + m_events.push_back(event); + return; + } + int insertIdx = FirstIndexOnOrAfter(event.m_timeStamp); + m_events.insert(m_events.begin() + insertIdx, event); +} +int BundleActiveEventList::FirstIndexOnOrAfter(long timeStamp) { + int size = m_events.size(); + int result = size; + int lo = 0; + int hi = size - 1; + while (lo <= hi) { + int mid = (hi - lo) / 2 + lo; + long midTimeStamp = m_events[mid].m_timeStamp; + if (midTimeStamp >= timeStamp) { + hi = mid - 1; + result = mid; + } else { + lo = mid + 1; + } + } + return result; +} +void BundleActiveEventList::Merge(const BundleActiveEventList& right) { + int size = right.m_events.size(); + for (int i = 0; i < size; i++) { + Insert(right.m_events[i]); + } +} + +} +} \ No newline at end of file diff --git a/services/common/src/bundle_active_event_stats.cpp b/services/common/src/bundle_active_event_stats.cpp new file mode 100644 index 0000000..062c7e4 --- /dev/null +++ b/services/common/src/bundle_active_event_stats.cpp @@ -0,0 +1,48 @@ +#include "bundle_active_event_stats.h" + +namespace OHOS { +namespace BundleActive { + +BundleActiveEventStats::BundleActiveEventStats(const BundleActiveEventStats& orig) { + m_eventId = orig.m_eventId; + m_beginTimeStamp = orig.m_beginTimeStamp; + m_endTimeStamp = orig.m_endTimeStamp; + m_lastEventTime = orig.m_lastEventTime; + m_totalTime = orig.m_totalTime; + m_count = orig.m_count; +} + +int BundleActiveEventStats::GetEventId() { + return m_eventId; +} +int BundleActiveEventStats::GetFirstTimeStamp() { + return m_beginTimeStamp; +} +int BundleActiveEventStats::GetLastTimeStamp() { + return m_endTimeStamp; +} +int BundleActiveEventStats::GetLastEventTime() { + return m_lastEventTime; +} +int BundleActiveEventStats::GetTotalTime() { + return m_totalTime; +} +int BundleActiveEventStats::GetCount() { + return m_count; +} +void BundleActiveEventStats::add(const BundleActiveEventStats& right) { + if (m_eventId != right.m_eventId) { + return; + } + + if (right.m_beginTimeStamp > m_beginTimeStamp) { + m_lastEventTime = std::max(m_lastEventTime, right.m_lastEventTime); + } + m_beginTimeStamp = std::min(m_beginTimeStamp, right.m_beginTimeStamp); + m_endTimeStamp = std::max(m_endTimeStamp, right.m_endTimeStamp); + m_totalTime += right.m_totalTime; + m_count += right.m_count; +} + +} +} \ No newline at end of file diff --git a/services/common/src/bundle_active_event_tracker.cpp b/services/common/src/bundle_active_event_tracker.cpp new file mode 100644 index 0000000..0d9e5b3 --- /dev/null +++ b/services/common/src/bundle_active_event_tracker.cpp @@ -0,0 +1,33 @@ +#include "bundle_active_event_tracker.h" + +namespace OHOS { +namespace BundleActive { +void BundleActiveEventTracker::CommitTime(long timeStamp) { + if (m_curStartTime != 0) { + m_duration += timeStamp - m_curStartTime; + m_curStartTime = 0; + } +} +void BundleActiveEventTracker::Update(long timeStamp) { + if (m_curStartTime == 0) { + m_count++; + } + CommitTime(timeStamp); + m_curStartTime = timeStamp; + m_lastEventTime = timeStamp; +} +void BundleActiveEventTracker::AddToEventStats(std::vector& eventStatsList, int eventId, long beginTime, long endTime) { + if (m_count != 0 || m_duration != 0) { + BundleActiveEventStats newEvent; + newEvent.m_eventId = eventId; + newEvent.m_count = m_count; + newEvent.m_totalTime = m_duration; + newEvent.m_lastEventTime = m_lastEventTime; + newEvent.m_beginTimeStamp = beginTime; + newEvent.m_endTimeStamp = endTime; + eventStatsList.emplace_back(newEvent); + } +} + +} +} \ No newline at end of file diff --git a/services/common/src/bundle_active_interval_stats.cpp b/services/common/src/bundle_active_interval_stats.cpp new file mode 100644 index 0000000..c3e4da0 --- /dev/null +++ b/services/common/src/bundle_active_interval_stats.cpp @@ -0,0 +1,89 @@ +#include "bundle_active_interval_stats.h" +#include "bundle_active_event.h" + +namespace OHOS { +namespace BundleActive { + +BundleActiveUsageStats& BundleActiveIntervalStats::GetOrCreateUsageStats(std::string bundleName) { + std::map::iterator it; + it = m_bundleStats.find(bundleName); + if (it == m_bundleStats.end()) { + BundleActiveUsageStats newStats; + newStats.m_beginTimeStamp = m_beginTime; + newStats.m_endTimeStamp = m_endTime; + newStats.m_bundleName = GetCachedString(bundleName); + m_bundleStats[newStats.m_bundleName] = newStats; + } + return m_bundleStats[bundleName]; +} +BundleActiveEvent BundleActiveIntervalStats::BuildEvent(std::string bundleName, std::string serviceName) { + BundleActiveEvent newEvent; + newEvent.m_bundleName = bundleName; + if (!serviceName.empty()) { + newEvent.m_serviceName = serviceName; + } + return newEvent; +} +void BundleActiveIntervalStats::Update(std::string bundleName, std::string serviceName, long timeStamp, int eventId, int abilityId) { + if (eventId == BundleActiveEvent::DEVICE_SHUTDOWN || eventId == BundleActiveEvent::FLUSH_TO_DISK) { + for (auto usageStatsPair : m_bundleStats) { + usageStatsPair.second.Update("", timeStamp, eventId, abilityId); + } + } else { + BundleActiveUsageStats& usageStats = GetOrCreateUsageStats(bundleName); + usageStats.Update("", timeStamp, eventId, abilityId); + } + if (timeStamp > m_endTime) { + m_endTime = timeStamp; + } +} +void BundleActiveIntervalStats::AddEvent(BundleActiveEvent event) { + event.m_bundleName = GetCachedString(event.m_bundleName); + if (!event.m_serviceName.empty()) { + event.m_serviceName = GetCachedString(event.m_serviceName); + } + m_events.Insert(event); + if (event.m_timeStamp > m_endTime) { + m_endTime = event.m_timeStamp; + } +} +void BundleActiveIntervalStats::CommitTime(long timeStamp) { + m_interactiveTracker.CommitTime(timeStamp); + m_noninteractiveTracker.CommitTime(timeStamp); + m_keyguardShownTracker.CommitTime(timeStamp); + m_keyguardHiddenTracker.CommitTime(timeStamp); +} +void BundleActiveIntervalStats::UpdateScreenInteractive(long timeStamp) { + m_interactiveTracker.Update(timeStamp); + m_noninteractiveTracker.CommitTime(timeStamp); +} +void BundleActiveIntervalStats::UpdateScreenNonInteractive(long timeStamp) { + m_noninteractiveTracker.Update(timeStamp); + m_interactiveTracker.CommitTime(timeStamp); +} +void BundleActiveIntervalStats::UpdateKeyguardShown(long timeStamp) { + m_keyguardShownTracker.Update(timeStamp); + m_keyguardHiddenTracker.CommitTime(timeStamp); +} +void BundleActiveIntervalStats::UpdateKeyguardHidden(long timeStamp) { + m_keyguardHiddenTracker.Update(timeStamp); + m_keyguardShownTracker.CommitTime(timeStamp); +} +void BundleActiveIntervalStats::AddEventStatsTo(std::vector& eventStatsList) { + m_interactiveTracker.AddToEventStats(eventStatsList, BundleActiveEvent::SCREEN_INTERACTIVE, m_beginTime, m_endTime); + m_noninteractiveTracker.AddToEventStats(eventStatsList, BundleActiveEvent::SCREEN_NON_INTERACTIVE, m_beginTime, m_endTime); + m_keyguardShownTracker.AddToEventStats(eventStatsList, BundleActiveEvent::KEYGUARD_SHOWN, m_beginTime, m_endTime); + m_keyguardHiddenTracker.AddToEventStats(eventStatsList, BundleActiveEvent::KEYGUARD_HIDDEN, m_beginTime, m_endTime); +} +std::string BundleActiveIntervalStats::GetCachedString(std::string str) { + std::set::iterator it; + it = m_packetNamesCache.find(str); + if (it == m_packetNamesCache.end()) { + m_packetNamesCache.insert(str); + return str; + } + return *it; +} + +} +} \ No newline at end of file diff --git a/services/common/src/bundle_active_usage_stats.cpp b/services/common/src/bundle_active_usage_stats.cpp new file mode 100644 index 0000000..8d4b9f1 --- /dev/null +++ b/services/common/src/bundle_active_usage_stats.cpp @@ -0,0 +1,172 @@ +#include "bundle_active_usage_stats.h" + +namespace OHOS { +namespace BundleActive { +BundleActiveUsageStats::BundleActiveUsageStats (const BundleActiveUsageStats& orig) { + m_bundleName = orig.m_bundleName; + m_beginTimeStamp = orig.m_beginTimeStamp; + m_endTimeStamp = orig.m_endTimeStamp; + m_lastTimeUsed = orig.m_lastTimeUsed; + m_lastTimeFrontServiceUsed = orig.m_lastTimeFrontServiceUsed; + m_totalTimeFrontServiceUsed = orig.m_totalTimeFrontServiceUsed; + m_totalTimeInFront = orig.m_totalTimeInFront; + m_launchedCount = orig.m_launchedCount; + m_bundleLaunchedCount = orig.m_bundleLaunchedCount; + m_abilities = orig.m_abilities; + m_frontServices = orig.m_frontServices; + m_lastEvent = orig.m_lastEvent; +} +std::string BundleActiveUsageStats::GetBundleName() { + return m_bundleName; +} +long BundleActiveUsageStats::GetBeginTimeStamp() { + return m_beginTimeStamp; +} +long BundleActiveUsageStats::GetEntTimeStamp() { + return m_endTimeStamp; +} +long BundleActiveUsageStats::GetLastTimeUsed() { + return m_lastTimeUsed; +} +long BundleActiveUsageStats::GetTotalTimeInFront() { + return m_totalTimeInFront; +} +long BundleActiveUsageStats::GetLastTimeFrontServiceUsed() { + return m_lastTimeFrontServiceUsed; +} +long BundleActiveUsageStats::GetTotalTimeFrontServiceUsed() { + return m_totalTimeFrontServiceUsed; +} +int BundleActiveUsageStats::GetLaunchedCount() { + return m_launchedCount; +} +int BundleActiveUsageStats::GetBundleLaunchedCount() { + return m_bundleLaunchedCount; +} +bool BundleActiveUsageStats::HasFrontAbility() { + for (auto ability : m_abilities) { + if (ability.second == BundleActiveEvent::ABILITY_FOREGROUND) { + return true; + } + } + return false; +} +bool BundleActiveUsageStats::AnyFrontServiceStarted() { + return !m_frontServices.empty(); +} +void BundleActiveUsageStats::IncrementTimeUsed(long timeStamp) { + if (timeStamp > m_lastTimeUsed) { + m_totalTimeInFront += timeStamp - m_lastTimeUsed; + m_lastTimeUsed = timeStamp; + } +} +void BundleActiveUsageStats::IncrementServiceTimeUsed(long timeStamp) { + if (timeStamp > m_lastTimeFrontServiceUsed) { + m_totalTimeFrontServiceUsed += timeStamp - m_lastTimeFrontServiceUsed; + m_lastTimeFrontServiceUsed = timeStamp; + } +} +void BundleActiveUsageStats::IncrementBundleLaunchedCount() { + m_bundleLaunchedCount += 1; +} +void BundleActiveUsageStats::UpdateActivity(long timeStamp, int eventId, int abilityId) { + if (eventId != BundleActiveEvent::ABILITY_FOREGROUND && eventId != BundleActiveEvent::ABILITY_BACKGROUND && + eventId != BundleActiveEvent::ABILITY_STOP) { + return; + } + std::map::iterator it; + it = m_abilities.find(abilityId); + if (it != m_abilities.end()) { + int lastEventId = it->second; + //When we recieve a new event, first update the time stats according to the last event in map. + switch (lastEventId) { + case BundleActiveEvent::ABILITY_FOREGROUND: + IncrementTimeUsed(timeStamp); + break; + default: + break; + } + } + + switch (eventId) { + case BundleActiveEvent::ABILITY_FOREGROUND: + if (!HasFrontAbility()) { + m_lastTimeUsed = timeStamp; + } + m_abilities[abilityId] = eventId; + break; + case BundleActiveEvent::ABILITY_BACKGROUND: + m_abilities[abilityId] = eventId; + break; + case BundleActiveEvent::ABILITY_STOP: + m_abilities.erase(abilityId); + default: + break; + } +} +void BundleActiveUsageStats::UpdateFrontService(std::string frontServiceName, long timeStamp, int eventId) { + if (eventId != BundleActiveEvent::FRONT_SERVICE_STARTTED && eventId != BundleActiveEvent::FRONT_SERVICE_STOPPED) { + return; + } + + //When we recieve a new event, first update the time stats according to the last service event in map. + std::map::iterator it; + it = m_frontServices.find(frontServiceName); + if (it != m_frontServices.end()) { + int lastEventId = it->second; + switch (lastEventId) { + case BundleActiveEvent::FRONT_SERVICE_STARTTED: + IncrementServiceTimeUsed(timeStamp); + default: + break; + } + } + + switch (eventId) { + case BundleActiveEvent::FRONT_SERVICE_STARTTED: + if(!AnyFrontServiceStarted()) { + m_lastTimeFrontServiceUsed = timeStamp; + } + m_frontServices[frontServiceName] = eventId; + break; + case BundleActiveEvent::FRONT_SERVICE_STOPPED: + m_frontServices.erase(frontServiceName); + default: + break; + } +} +void BundleActiveUsageStats::Update(std::string frontServiceName, long timeStamp, int eventId, int abilityId) { + switch (eventId) { + case BundleActiveEvent::ABILITY_FOREGROUND: + case BundleActiveEvent::ABILITY_BACKGROUND: + case BundleActiveEvent::ABILITY_STOP: + UpdateActivity(timeStamp, eventId, abilityId); + break; + case BundleActiveEvent::END_OF_THE_DAY: + if (HasFrontAbility()) { + IncrementTimeUsed(timeStamp); + } + case BundleActiveEvent::FRONT_SERVICE_STARTTED: + case BundleActiveEvent::FRONT_SERVICE_STOPPED: + UpdateFrontService(frontServiceName, timeStamp, eventId); + break; + case BundleActiveEvent::DEVICE_SHUTDOWN: + case BundleActiveEvent::FLUSH_TO_DISK: + if (HasFrontAbility()) { + IncrementTimeUsed(timeStamp); + } + if (AnyFrontServiceStarted()) { + IncrementServiceTimeUsed(timeStamp); + } + break; + default: + break; + } + m_endTimeStamp = timeStamp; + if (eventId == BundleActiveEvent::ABILITY_FOREGROUND) { + m_launchedCount += 1; + } +} + +} +} \ No newline at end of file diff --git a/services/common/src/bundle_active_user_service.cpp b/services/common/src/bundle_active_user_service.cpp new file mode 100644 index 0000000..26c3d3a --- /dev/null +++ b/services/common/src/bundle_active_user_service.cpp @@ -0,0 +1,55 @@ +#include "bundle_active_user_service.h" + +namespace OHOS { +namespace BundleActive { + +BundleActiveUserService::BundleActiveUserService(int userId){//,/*database定义待补充*/ BundleActiveService listener/*刷数据库监听器接口实现类*/) { + m_currentStats.reserve(BundleActiveIntervalStats::INTERVAL_COUNT); + //m_listener = listener; + m_userId = userId; +} +void BundleActiveUserService::NotifyStatsChanged() { + if (!m_statsChanged) { + m_statsChanged = true; + //m_listener.onStatsUpdated(); + } +} + +void BundleActiveUserService::ReportEvent(BundleActiveEvent event) { + BundleActiveIntervalStats currentDailyStats = m_currentStats[BundleActiveIntervalStats::INTERVAL_DAILY]; + if (event.m_eventId == BundleActiveEvent::ABILITY_FOREGROUND) { + if (!event.m_bundleName.empty() && event.m_bundleName != m_lastBackgroundBundle) { + m_incrementBundleLaunch = true; + } + } else if (event.m_eventId == BundleActiveEvent::ABILITY_BACKGROUND) { + if (!event.m_bundleName.empty()) { + m_lastBackgroundBundle = event.m_bundleName; + } + } + for (int i = 0; i < m_currentStats.size(); i++) { + switch (event.m_eventId) + { + case BundleActiveEvent::SCREEN_INTERACTIVE: + m_currentStats[i].UpdateScreenInteractive(event.m_timeStamp); + break; + case BundleActiveEvent::SCREEN_NON_INTERACTIVE: + m_currentStats[i].UpdateScreenNonInteractive(event.m_timeStamp); + break; + case BundleActiveEvent::KEYGUARD_SHOWN: + m_currentStats[i].UpdateKeyguardShown(event.m_timeStamp); + break; + case BundleActiveEvent::KEYGUARD_HIDDEN: + m_currentStats[i].UpdateKeyguardHidden(event.m_timeStamp); + break; + default: + m_currentStats[i].Update(event.m_bundleName, event.m_serviceName, event.m_timeStamp, event.m_eventId, event.m_abilityId); + if (m_incrementBundleLaunch) { + m_currentStats[i].m_bundleStats[event.m_bundleName].IncrementBundleLaunchedCount(); + } + break; + } + } +} + +} +} \ No newline at end of file diff --git a/services/include/bundle_active_iservice.h b/services/include/bundle_active_iservice.h new file mode 100644 index 0000000..cb8c875 --- /dev/null +++ b/services/include/bundle_active_iservice.h @@ -0,0 +1,42 @@ +#ifndef BUNDLE_ACTIVE_ISERVICE_H +#define BUNDLE_ACTIVE_ISERVICE_H + +#include +#include +#include +#include +#include +#include +#include "bundle_active_log.h" +#include "iremote_broker.h" +#include "iremote_stub.h" +#include "iremote_proxy.h" +#include "iremote_object.h" +#include "system_ability.h" +#include "system_ability_definition.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace BundleActive { + +class IBundleActiveService : public IRemoteBroker { +public: + virtual int ReportEvent(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId, const int& eventId) = 0; + virtual int IsBundleIdle(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) = 0; + virtual int Query(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) = 0; + +public: + enum { + REPORT_EVENT = 1, + IS_BUNDLE_IDLE = 2, + QUERY = 3, + }; +public: + DECLARE_INTERFACE_DESCRIPTOR(u"Resourceschedule.IBundleActiveService"); +}; + +} +} + +#endif \ No newline at end of file diff --git a/services/include/bundle_active_log.h b/services/include/bundle_active_log.h new file mode 100644 index 0000000..c8af8ab --- /dev/null +++ b/services/include/bundle_active_log.h @@ -0,0 +1,21 @@ +#ifndef BUNDLE_ACTIVE_LOG_H +#define BUNDLE_ACTIVE_LOG_H + +#include "hilog/log.h" + +#define LOG_TAG_BUNDLE_ACTIVE "BUNDLE_ACTIVE" +#define LOG_TAG_DOMAIN_ID_BUNDLE_ACTIVE 0xD001700 + +static constexpr OHOS::HiviewDFX::HiLogLabel BUNDLE_ACTIVE_LOG_LABEL = { + LOG_CORE, + LOG_TAG_DOMAIN_ID_BUNDLE_ACTIVE, + LOG_TAG_BUNDLE_ACTIVE +}; + +#define BUNDLE_ACTIVE_LOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(BUNDLE_ACTIVE_LOG_LABEL, __VA_ARGS__) +#define BUNDLE_ACTIVE_LOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(BUNDLE_ACTIVE_LOG_LABEL, __VA_ARGS__) +#define BUNDLE_ACTIVE_LOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(BUNDLE_ACTIVE_LOG_LABEL, __VA_ARGS__) +#define BUNDLE_ACTIVE_LOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(BUNDLE_ACTIVE_LOG_LABEL, __VA_ARGS__) +#define BUNDLE_ACTIVE_LOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(BUNDLE_ACTIVE_LOG_LABEL, __VA_ARGS__) + +#endif \ No newline at end of file diff --git a/services/include/bundle_active_service.h b/services/include/bundle_active_service.h new file mode 100644 index 0000000..846823b --- /dev/null +++ b/services/include/bundle_active_service.h @@ -0,0 +1,33 @@ +#ifndef BUNDLE_ACTIVE_SERVICE_H +#define BUNDLE_ACTIVE_SERVICE_H + +#include "bundle_active_iservice.h" +#include "bundle_active_stub.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveService : public SystemAbility, public BundleActiveStub { + DECLARE_SYSTEM_ABILITY(BundleActiveService); + +public: + int ReportEvent(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId, const int& eventId) override; + int IsBundleIdle(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) override; + int Query(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) override; + //void onStatsUpdated() override; + //void onstatsReloaded() override; + //oid onNewUpdate(int userId) override; +public: + BundleActiveService(int32_t systemAbilityId, int runOnCreate) + : SystemAbility(systemAbilityId, runOnCreate) {} + ~BundleActiveService() {} + +protected: + void OnStart() override; + void OnStop() override; + +}; + +} +} +#endif \ No newline at end of file diff --git a/services/include/bundle_active_stub.h b/services/include/bundle_active_stub.h new file mode 100644 index 0000000..5f9f0d4 --- /dev/null +++ b/services/include/bundle_active_stub.h @@ -0,0 +1,20 @@ +#ifndef BUNDLE_ACTIVE_STUB_H +#define BUNDLE_ACTIVE_STUB_H + +#include "bundle_active_iservice.h" + +namespace OHOS { +namespace BundleActive { + +class BundleActiveStub : public IRemoteStub { +public: + virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel &reply, MessageOption &option) override; + +public: + BundleActiveStub() {}; + ~BundleActiveStub() {}; +}; + +} +} +#endif diff --git a/services/src/bundle_active_service.cpp b/services/src/bundle_active_service.cpp new file mode 100644 index 0000000..1a93a41 --- /dev/null +++ b/services/src/bundle_active_service.cpp @@ -0,0 +1,39 @@ +#include "bundle_active_service.h" + +namespace OHOS { +namespace BundleActive { +REGISTER_SYSTEM_ABILITY_BY_ID(BundleActiveService, BUNDLE_ACTIVE_SYS_ABILITY_ID, true); + +void BundleActiveService::OnStart() +{ + int ret = Publish(this); + if (!ret) { + BUNDLE_ACTIVE_LOGE("[Server] OnStart, Register SystemAbility[1906] FAIL."); + return; + } + BUNDLE_ACTIVE_LOGI("[Server] OnStart, Register SystemAbility[1906] SUCCESS."); +} +//void BundleActiveService::onStatsUpdated() {} +//void BundleActiveService::onstatsReloaded() {} +//void BundleActiveService::onNewUpdate(int userId) {} +void BundleActiveService::OnStop() +{ + BUNDLE_ACTIVE_LOGI("[Server] OnStop"); +} +int BundleActiveService::ReportEvent(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId, const int& eventId) { + BUNDLE_ACTIVE_LOGI("Report event called"); + return 111; +} + +int BundleActiveService::IsBundleIdle(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) { + BUNDLE_ACTIVE_LOGI("Is bundle active called"); + return true; +} + +int BundleActiveService::Query(std::string& bundleName, std::string& abilityName, const int& abilityId, const int& userId) { + BUNDLE_ACTIVE_LOGI("Query called"); + return 222; +} + +} +} \ No newline at end of file diff --git a/services/src/bundle_active_stub.cpp b/services/src/bundle_active_stub.cpp new file mode 100644 index 0000000..825abd4 --- /dev/null +++ b/services/src/bundle_active_stub.cpp @@ -0,0 +1,41 @@ +#include +#include "bundle_active_stub.h" + +namespace OHOS { +namespace BundleActive { + +int32_t BundleActiveStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel &reply, MessageOption &option) { + switch(code) { + case REPORT_EVENT: { + std::string bundleName = data.ReadString(); + std::string ablityName = data.ReadString(); + int abilityId = data.ReadInt32(); + int userId = data.ReadInt32(); + int eventId = data.ReadInt32(); + int result = ReportEvent(bundleName, ablityName, abilityId, userId, eventId); + return reply.WriteInt32(result); + } + case IS_BUNDLE_IDLE: { + std::string bundleName = data.ReadString(); + std::string ablityName = data.ReadString(); + int abilityId = data.ReadInt32(); + int userId = data.ReadInt32(); + int result = IsBundleIdle(bundleName, ablityName, abilityId, userId); + return reply.WriteInt32(result); + } + case QUERY: { + std::string bundleName = data.ReadString(); + std::string ablityName = data.ReadString(); + int abilityId = data.ReadInt32(); + int userId = data.ReadInt32(); + int result = Query(bundleName, ablityName, abilityId, userId); + return reply.WriteInt32(result); + } + + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } +} + +} +} \ No newline at end of file diff --git a/test/.gitkeep b/test/.gitkeep new file mode 100644 index 0000000..e69de29 -- Gitee From ad5413bf0478ab6b222f4b8a1ecbb5945b069ee3 Mon Sep 17 00:00:00 2001 From: houdisheng Date: Mon, 10 Jan 2022 15:11:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- .../innerkits/include/bundle_active_client.h | 15 +++++++++++++++ .../innerkits/include/bundle_active_proxy.h | 15 +++++++++++++++ interfaces/innerkits/src/bundle_active_client.cpp | 15 +++++++++++++++ interfaces/innerkits/src/bundle_active_proxy.cpp | 15 +++++++++++++++ services/common/include/bundle_active_event.h | 15 +++++++++++++++ .../common/include/bundle_active_event_list.h | 15 +++++++++++++++ .../common/include/bundle_active_event_stats.h | 15 +++++++++++++++ .../common/include/bundle_active_event_tracker.h | 15 +++++++++++++++ .../common/include/bundle_active_interval_stats.h | 15 +++++++++++++++ .../common/include/bundle_active_usage_stats.h | 15 +++++++++++++++ .../common/include/bundle_active_user_service.h | 15 +++++++++++++++ services/common/src/bundle_active_event.cpp | 15 +++++++++++++++ services/common/src/bundle_active_event_list.cpp | 15 +++++++++++++++ services/common/src/bundle_active_event_stats.cpp | 15 +++++++++++++++ .../common/src/bundle_active_event_tracker.cpp | 15 +++++++++++++++ .../common/src/bundle_active_interval_stats.cpp | 15 +++++++++++++++ services/common/src/bundle_active_usage_stats.cpp | 15 +++++++++++++++ .../common/src/bundle_active_user_service.cpp | 15 +++++++++++++++ services/include/bundle_active_iservice.h | 15 +++++++++++++++ services/include/bundle_active_log.h | 15 +++++++++++++++ services/include/bundle_active_service.h | 15 +++++++++++++++ services/include/bundle_active_stub.h | 15 +++++++++++++++ services/src/bundle_active_service.cpp | 15 +++++++++++++++ services/src/bundle_active_stub.cpp | 15 +++++++++++++++ 24 files changed, 360 insertions(+) diff --git a/interfaces/innerkits/include/bundle_active_client.h b/interfaces/innerkits/include/bundle_active_client.h index 135145f..20fb365 100644 --- a/interfaces/innerkits/include/bundle_active_client.h +++ b/interfaces/innerkits/include/bundle_active_client.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_CLIENT_H #define BUNDLE_ACTIVE_CLIENT_H diff --git a/interfaces/innerkits/include/bundle_active_proxy.h b/interfaces/innerkits/include/bundle_active_proxy.h index fdebc38..a12e1d9 100644 --- a/interfaces/innerkits/include/bundle_active_proxy.h +++ b/interfaces/innerkits/include/bundle_active_proxy.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_PROXY_H #define BUNDLE_ACTIVE_PROXY_H diff --git a/interfaces/innerkits/src/bundle_active_client.cpp b/interfaces/innerkits/src/bundle_active_client.cpp index c69240e..0540c44 100644 --- a/interfaces/innerkits/src/bundle_active_client.cpp +++ b/interfaces/innerkits/src/bundle_active_client.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_client.h" namespace OHOS { diff --git a/interfaces/innerkits/src/bundle_active_proxy.cpp b/interfaces/innerkits/src/bundle_active_proxy.cpp index feb8204..1187cbd 100644 --- a/interfaces/innerkits/src/bundle_active_proxy.cpp +++ b/interfaces/innerkits/src/bundle_active_proxy.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_proxy.h" namespace OHOS{ diff --git a/services/common/include/bundle_active_event.h b/services/common/include/bundle_active_event.h index 6588e75..7d3158f 100644 --- a/services/common/include/bundle_active_event.h +++ b/services/common/include/bundle_active_event.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_EVENT_H #define BUNDLE_ACTIVE_EVENT_H diff --git a/services/common/include/bundle_active_event_list.h b/services/common/include/bundle_active_event_list.h index 6b3ec12..e8c0076 100644 --- a/services/common/include/bundle_active_event_list.h +++ b/services/common/include/bundle_active_event_list.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_EVENT_LIST_H #define BUNDLE_ACTIVE_EVENT_LIST_H diff --git a/services/common/include/bundle_active_event_stats.h b/services/common/include/bundle_active_event_stats.h index 9d0de8c..e7a789e 100644 --- a/services/common/include/bundle_active_event_stats.h +++ b/services/common/include/bundle_active_event_stats.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_EVENT_STATS_H #define BUNDLE_ACTIVE_EVENT_STATS_H diff --git a/services/common/include/bundle_active_event_tracker.h b/services/common/include/bundle_active_event_tracker.h index 80ef511..09dc98a 100644 --- a/services/common/include/bundle_active_event_tracker.h +++ b/services/common/include/bundle_active_event_tracker.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_EVENT_TRACKER_H #define BUNDLE_ACTIVE_EVENT_TRACKER_H diff --git a/services/common/include/bundle_active_interval_stats.h b/services/common/include/bundle_active_interval_stats.h index ba0ac38..ea7e74e 100644 --- a/services/common/include/bundle_active_interval_stats.h +++ b/services/common/include/bundle_active_interval_stats.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_INTERVAL_STATS_H #define BUNDLE_ACTIVE_INTERVAL_STATS_H diff --git a/services/common/include/bundle_active_usage_stats.h b/services/common/include/bundle_active_usage_stats.h index e01a8a7..f97e3b8 100644 --- a/services/common/include/bundle_active_usage_stats.h +++ b/services/common/include/bundle_active_usage_stats.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_USAGE_STATS_H #define BUNDLE_ACTIVE_USAGE_STATS_H diff --git a/services/common/include/bundle_active_user_service.h b/services/common/include/bundle_active_user_service.h index fc92466..3e68c03 100644 --- a/services/common/include/bundle_active_user_service.h +++ b/services/common/include/bundle_active_user_service.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_USER_SERVICE_H #define BUNDLE_ACTIVE_USER_SERVICE_H diff --git a/services/common/src/bundle_active_event.cpp b/services/common/src/bundle_active_event.cpp index bc1db12..e8b3e2e 100644 --- a/services/common/src/bundle_active_event.cpp +++ b/services/common/src/bundle_active_event.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_event.h" namespace OHOS { diff --git a/services/common/src/bundle_active_event_list.cpp b/services/common/src/bundle_active_event_list.cpp index 0db705c..9b58f81 100644 --- a/services/common/src/bundle_active_event_list.cpp +++ b/services/common/src/bundle_active_event_list.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_event_list.h" namespace OHOS { diff --git a/services/common/src/bundle_active_event_stats.cpp b/services/common/src/bundle_active_event_stats.cpp index 062c7e4..3e162ce 100644 --- a/services/common/src/bundle_active_event_stats.cpp +++ b/services/common/src/bundle_active_event_stats.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_event_stats.h" namespace OHOS { diff --git a/services/common/src/bundle_active_event_tracker.cpp b/services/common/src/bundle_active_event_tracker.cpp index 0d9e5b3..239226f 100644 --- a/services/common/src/bundle_active_event_tracker.cpp +++ b/services/common/src/bundle_active_event_tracker.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_event_tracker.h" namespace OHOS { diff --git a/services/common/src/bundle_active_interval_stats.cpp b/services/common/src/bundle_active_interval_stats.cpp index c3e4da0..c73b8b1 100644 --- a/services/common/src/bundle_active_interval_stats.cpp +++ b/services/common/src/bundle_active_interval_stats.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_interval_stats.h" #include "bundle_active_event.h" diff --git a/services/common/src/bundle_active_usage_stats.cpp b/services/common/src/bundle_active_usage_stats.cpp index 8d4b9f1..c39c8f4 100644 --- a/services/common/src/bundle_active_usage_stats.cpp +++ b/services/common/src/bundle_active_usage_stats.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_usage_stats.h" namespace OHOS { diff --git a/services/common/src/bundle_active_user_service.cpp b/services/common/src/bundle_active_user_service.cpp index 26c3d3a..f010d27 100644 --- a/services/common/src/bundle_active_user_service.cpp +++ b/services/common/src/bundle_active_user_service.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_user_service.h" namespace OHOS { diff --git a/services/include/bundle_active_iservice.h b/services/include/bundle_active_iservice.h index cb8c875..bb04206 100644 --- a/services/include/bundle_active_iservice.h +++ b/services/include/bundle_active_iservice.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_ISERVICE_H #define BUNDLE_ACTIVE_ISERVICE_H diff --git a/services/include/bundle_active_log.h b/services/include/bundle_active_log.h index c8af8ab..49aa5b8 100644 --- a/services/include/bundle_active_log.h +++ b/services/include/bundle_active_log.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_LOG_H #define BUNDLE_ACTIVE_LOG_H diff --git a/services/include/bundle_active_service.h b/services/include/bundle_active_service.h index 846823b..b52bbd0 100644 --- a/services/include/bundle_active_service.h +++ b/services/include/bundle_active_service.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_SERVICE_H #define BUNDLE_ACTIVE_SERVICE_H diff --git a/services/include/bundle_active_stub.h b/services/include/bundle_active_stub.h index 5f9f0d4..b43e436 100644 --- a/services/include/bundle_active_stub.h +++ b/services/include/bundle_active_stub.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef BUNDLE_ACTIVE_STUB_H #define BUNDLE_ACTIVE_STUB_H diff --git a/services/src/bundle_active_service.cpp b/services/src/bundle_active_service.cpp index 1a93a41..3fdec33 100644 --- a/services/src/bundle_active_service.cpp +++ b/services/src/bundle_active_service.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "bundle_active_service.h" namespace OHOS { diff --git a/services/src/bundle_active_stub.cpp b/services/src/bundle_active_stub.cpp index 825abd4..d5910d4 100644 --- a/services/src/bundle_active_stub.cpp +++ b/services/src/bundle_active_stub.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 #include "bundle_active_stub.h" -- Gitee From 7f506cf8514e9c1f92a4d3f067eb9b47c671331a Mon Sep 17 00:00:00 2001 From: houdisheng Date: Mon, 10 Jan 2022 16:20:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?OTA=E6=89=AB=E6=8F=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: houdisheng --- BUILD.gn | 13 +++++++++++++ OTA.log | 18 ++++++++++++++++++ sa_profile/1906.xml | 14 ++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 OTA.log diff --git a/BUILD.gn b/BUILD.gn index 37f9b52..f6e950f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,3 +1,16 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import("//build/ohos.gni") import("//build/ohos/sa_profile/sa_profile.gni") diff --git a/OTA.log b/OTA.log new file mode 100644 index 0000000..5016038 --- /dev/null +++ b/OTA.log @@ -0,0 +1,18 @@ + +Invalid File Type Total Count: 0 + +License Not Compatible Total Count: 0 + +License Header Invalid Total Count: 0 + +Copyright Header Invalid Total Count: 0 + +No License File Total Count: 0 + +No Readme.OpenSource Total Count: 0 + +No Readme Total Count: 0 + +Import Invalid Total Count: 0 + +Redundant License File Total Count: 0 diff --git a/sa_profile/1906.xml b/sa_profile/1906.xml index 070b556..60c148a 100644 --- a/sa_profile/1906.xml +++ b/sa_profile/1906.xml @@ -1,4 +1,18 @@ + bundleactive_service -- Gitee