From af5da7507fe427c6265de5e0fae052281dc0d636 Mon Sep 17 00:00:00 2001 From: zhaoyuan Date: Wed, 22 Sep 2021 20:27:00 +0000 Subject: [PATCH] modify codex Signed-off-by: zhaoyuan --- .../ability/native/include/ability_impl.h | 2 +- .../ability/native/src/ability_thread.cpp | 2 + .../src/ohos/aafwk/content/extra_params.cpp | 12 ++- .../cpp/src/ohos/aafwk/content/pac_map.cpp | 8 +- .../cpp/src/ohos/aafwk/content/want.cpp | 3 + .../test/mock/DemoAbility/mock_ability_test.h | 10 +- .../data_ability_helper_module_test.cpp | 3 + .../kits/js/@ohos.ability.featureAbility.d.ts | 24 +++++ .../js/@ohos.ability.particleAbility.d.ts | 25 +++++ .../kits/js/ability/connectOptions.d.ts | 52 ++++++++++ .../kits/js/ability/dataAbilityHelper.d.ts | 32 +++---- .../tools/aa/pageAbilityBundleForStart.hap | Bin 20616 -> 20626 bytes test/resource/tools/ohos_test.xml | 6 +- tools/aa/src/ability_command.cpp | 84 +++++++++++++++++ tools/test/moduletest/aa/BUILD.gn | 18 ++-- ...st.cpp => aa_command_dump_module_test.cpp} | 0 ...t.cpp => aa_command_start_module_test.cpp} | 0 ...> aa_command_stop_service_module_test.cpp} | 0 tools/test/systemtest/aa/BUILD.gn | 18 ++-- ...st.cpp => aa_command_dump_system_test.cpp} | 0 ...t.cpp => aa_command_start_system_test.cpp} | 0 ...> aa_command_stop_service_system_test.cpp} | 0 tools/test/unittest/aa/BUILD.gn | 32 +++---- ...dump_test.cpp => aa_command_dump_test.cpp} | 0 ...en_test.cpp => aa_command_screen_test.cpp} | 0 ...art_test.cpp => aa_command_start_test.cpp} | 0 ...t.cpp => aa_command_stop_service_test.cpp} | 0 ...y_command_test.cpp => aa_command_test.cpp} | 0 tools/zip/kits/napi/napi_zlib.cpp | 89 +++++++++++++----- tools/zip/kits/napi/napi_zlib_common.cpp | 2 +- tools/zip/src/zip.cpp | 3 +- tools/zip/src/zip_utils.cpp | 5 +- 32 files changed, 333 insertions(+), 97 deletions(-) mode change 100644 => 100755 frameworks/kits/content/cpp/src/ohos/aafwk/content/extra_params.cpp create mode 100644 interfaces/kits/js/ability/connectOptions.d.ts rename tools/test/moduletest/aa/{ability_command_dump_module_test.cpp => aa_command_dump_module_test.cpp} (100%) rename tools/test/moduletest/aa/{ability_command_start_module_test.cpp => aa_command_start_module_test.cpp} (100%) rename tools/test/moduletest/aa/{ability_command_stop_service_module_test.cpp => aa_command_stop_service_module_test.cpp} (100%) rename tools/test/systemtest/aa/{ability_command_dump_system_test.cpp => aa_command_dump_system_test.cpp} (100%) rename tools/test/systemtest/aa/{ability_command_start_system_test.cpp => aa_command_start_system_test.cpp} (100%) rename tools/test/systemtest/aa/{ability_command_stop_service_system_test.cpp => aa_command_stop_service_system_test.cpp} (100%) rename tools/test/unittest/aa/{ability_command_dump_test.cpp => aa_command_dump_test.cpp} (100%) rename tools/test/unittest/aa/{ability_command_screen_test.cpp => aa_command_screen_test.cpp} (100%) rename tools/test/unittest/aa/{ability_command_start_test.cpp => aa_command_start_test.cpp} (100%) rename tools/test/unittest/aa/{ability_command_stop_service_test.cpp => aa_command_stop_service_test.cpp} (100%) rename tools/test/unittest/aa/{ability_command_test.cpp => aa_command_test.cpp} (100%) diff --git a/frameworks/kits/ability/native/include/ability_impl.h b/frameworks/kits/ability/native/include/ability_impl.h index 7e63eb4ef94..eb3a50955ae 100644 --- a/frameworks/kits/ability/native/include/ability_impl.h +++ b/frameworks/kits/ability/native/include/ability_impl.h @@ -330,7 +330,7 @@ public: */ std::shared_ptr CreatePostEventTimeouter(std::string taskstr); - std::vector> ExecuteBatch(const std::vector> &operations); + virtual std::vector> ExecuteBatch(const std::vector> &operations); protected: /** diff --git a/frameworks/kits/ability/native/src/ability_thread.cpp b/frameworks/kits/ability/native/src/ability_thread.cpp index 79555f75afc..b2032c56374 100644 --- a/frameworks/kits/ability/native/src/ability_thread.cpp +++ b/frameworks/kits/ability/native/src/ability_thread.cpp @@ -1151,7 +1151,9 @@ std::vector> AbilityThread::ExecuteBatch( results.clear(); return results; } + APP_LOGI("AbilityThread::ExecuteBatch before abilityImpl_->ExecuteBatch"); results = abilityImpl_->ExecuteBatch(operations); + APP_LOGI("AbilityThread::ExecuteBatch after abilityImpl_->ExecuteBatch"); APP_LOGI("AbilityThread::ExecuteBatch end"); return results; } diff --git a/frameworks/kits/content/cpp/src/ohos/aafwk/content/extra_params.cpp b/frameworks/kits/content/cpp/src/ohos/aafwk/content/extra_params.cpp old mode 100644 new mode 100755 index b86cb4f4dc3..94099396a68 --- a/frameworks/kits/content/cpp/src/ohos/aafwk/content/extra_params.cpp +++ b/frameworks/kits/content/cpp/src/ohos/aafwk/content/extra_params.cpp @@ -216,17 +216,18 @@ bool ExtraParams::Marshalling(Parcel &parcel) const { bool ret = true; // devType - ret = parcel.WriteStringVector(devType_); + bool ret1 = parcel.WriteStringVector(devType_); // targetBundleName - ret &= parcel.WriteString16(Str8ToStr16(targetBundleName_)); + bool ret2 = parcel.WriteString16(Str8ToStr16(targetBundleName_)); // description - ret &= parcel.WriteString16(Str8ToStr16(description_)); + bool ret3 = parcel.WriteString16(Str8ToStr16(description_)); // jsonParams - ret &= parcel.WriteString16(Str8ToStr16(jsonParams_)); + bool ret4 = parcel.WriteString16(Str8ToStr16(jsonParams_)); + ret = (ret1 && ret2 && ret3 && ret4) ? true : false; return ret; } @@ -254,6 +255,9 @@ ExtraParams *ExtraParams::Unmarshalling(Parcel &parcel) ExtraParams *extraParams = new (std::nothrow) ExtraParams(devtype, targetBundleName, description, jsonParams); + if (extraParams == nullptr) { + return nullptr; + } return extraParams; } } // namespace AppExecFwk diff --git a/frameworks/kits/content/cpp/src/ohos/aafwk/content/pac_map.cpp b/frameworks/kits/content/cpp/src/ohos/aafwk/content/pac_map.cpp index df50cec5c3b..c1527c7bb78 100755 --- a/frameworks/kits/content/cpp/src/ohos/aafwk/content/pac_map.cpp +++ b/frameworks/kits/content/cpp/src/ohos/aafwk/content/pac_map.cpp @@ -1226,7 +1226,7 @@ bool PacMap::ToJson(const PacMapList &mapList, Json::Value &dataObject) const template static std::string RawTypeToString(const RawType value, unsigned int precisionAfterPoint) { - std::ostringstream out(' '); + std::ostringstream out("RawTypeToString"); out.precision(std::numeric_limits::digits10); out << value; @@ -1465,12 +1465,10 @@ bool PacMap::StringToMapList(const std::string &str, PacMapList &mapList) const int rawJsonLength = static_cast(str.length()); Json::CharReaderBuilder builder; - Json::CharReader *reader(builder.newCharReader()); - if (!reader->parse(str.c_str(), str.c_str() + rawJsonLength, &root, &err)) { + std::unique_ptr const jsonReader(builder.newCharReader()); + if (!jsonReader->parse(str.c_str(), str.c_str() + rawJsonLength, &root, &err)) { return false; } - delete reader; - reader = nullptr; if (!root.isMember("pacmap")) { return false; diff --git a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp index 249bb066a8e..9ffc20e7d38 100755 --- a/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp +++ b/frameworks/kits/content/cpp/src/ohos/aafwk/content/want.cpp @@ -1184,6 +1184,9 @@ Want *Want::ParseUri(const std::string &uri) content = uri.substr(begin, pos - begin); if (content.compare("PICK") == 0) { want = new (std::nothrow) Want(); + if (want == nullptr) { + return nullptr; + } inPicker = true; continue; } diff --git a/frameworks/kits/test/mock/DemoAbility/mock_ability_test.h b/frameworks/kits/test/mock/DemoAbility/mock_ability_test.h index 9aa908b3542..02b976a1a68 100644 --- a/frameworks/kits/test/mock/DemoAbility/mock_ability_test.h +++ b/frameworks/kits/test/mock/DemoAbility/mock_ability_test.h @@ -53,12 +53,20 @@ public: int fd; GTEST_LOG_(INFO) << "MockAbilityTest::OpenFile called"; FILE *fd1 = fopen("/dataability_openfile_test.txt", "w+"); + if(fd1 == nullptr) { + GTEST_LOG_(INFO) << "MockAbilityTest::OpenFile fd1 == nullptr"; + return -1; + } fputs("123456",fd1); fclose(fd1); FILE *fd2 = fopen("/dataability_openfile_test.txt", "r"); + if(fd2 == nullptr) { + GTEST_LOG_(INFO) << "MockAbilityTest::OpenFile fd2 == nullptr"; + return -1; + } fd = fileno(fd2); - + return fd; } diff --git a/frameworks/kits/test/moduletest/cpp/abilitytest/data_ability_helper_module_test.cpp b/frameworks/kits/test/moduletest/cpp/abilitytest/data_ability_helper_module_test.cpp index 4bb39e3e3dc..fd2bd3c3c86 100644 --- a/frameworks/kits/test/moduletest/cpp/abilitytest/data_ability_helper_module_test.cpp +++ b/frameworks/kits/test/moduletest/cpp/abilitytest/data_ability_helper_module_test.cpp @@ -238,6 +238,8 @@ HWTEST_F(DataAbilityHelperTest, AaFwk_DataAbilityHelper_OpenFile_Test_0100, Func Uri urivalue("dataability://device_id/com.domainname.dataability.persondata/person/10?test/te.txt"); std::string mode("r"); int fd = dataAbilityHelper->OpenFile(urivalue, mode); + EXPECT_NE(fd, -1); + std::string result = "123456"; FILE *file = fdopen(fd, "r"); EXPECT_NE(file, nullptr); @@ -274,6 +276,7 @@ HWTEST_F(DataAbilityHelperTest, AaFwk_DataAbilityHelper_OpenFile_Test_0200, Func Uri urivalue("dataability://device_id/com.domainname.dataability.persondata/person/10?test/te.txt"); std::string mode("r"); int fd = dataAbilityHelper->OpenFile(urivalue, mode); + EXPECT_NE(fd, -1); std::string result = "123456"; FILE *file = fdopen(fd, "r"); diff --git a/interfaces/kits/js/@ohos.ability.featureAbility.d.ts b/interfaces/kits/js/@ohos.ability.featureAbility.d.ts index 043a7951ec2..d92e73b8404 100644 --- a/interfaces/kits/js/@ohos.ability.featureAbility.d.ts +++ b/interfaces/kits/js/@ohos.ability.featureAbility.d.ts @@ -18,6 +18,7 @@ import { StartAbilityParameter } from './ability/startAbilityParameter'; import { AbilityResult } from './ability/abilityResult'; import { Context } from './app/context'; import { DataAbilityHelper } from './ability/dataAbilityHelper'; +import { ConnectOptions } from './ability/connectOptions'; /** * A Feature Ability represents an ability with a UI and is designed to interact with users. @@ -109,6 +110,29 @@ declare namespace featureAbility { function hasWindowFocus(callback: AsyncCallback): void; function hasWindowFocus(): Promise; + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param request The element name of the service ability + * @param options The remote object instance + * @return Returns the number of the ability connected + */ + function connectAbility(request: Want, options:ConnectOptions ): number; + + /** + * The callback interface was connect successfully. + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param connection The number of the ability connected + */ + function disconnectAbility(connection: number, callback:AsyncCallback): void; + function disconnectAbility(connection: number): Promise; + export enum AbilityWindowConfiguration { WINDOW_MODE_UNDEFINED = 0, WINDOW_MODE_FULLSCREEN = 1, diff --git a/interfaces/kits/js/@ohos.ability.particleAbility.d.ts b/interfaces/kits/js/@ohos.ability.particleAbility.d.ts index e6388be0229..44e794c32b5 100644 --- a/interfaces/kits/js/@ohos.ability.particleAbility.d.ts +++ b/interfaces/kits/js/@ohos.ability.particleAbility.d.ts @@ -14,6 +14,8 @@ */ import { AsyncCallback } from './basic'; import { StartAbilityParameter } from './ability/startAbilityParameter'; +import { Want } from './ability/want'; +import { ConnectOptions } from './ability/connectOptions'; /** * A Particle Ability represents an ability with service. @@ -35,5 +37,28 @@ declare namespace particleAbility { */ function startAbility(parameter: StartAbilityParameter, callback: AsyncCallback): void; function startAbility(parameter: StartAbilityParameter): Promise; + + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param request The element name of the service ability + * @param options The remote object instance + * @return Returns the number of the ability connected + */ + function connectAbility(request: Want, options:ConnectOptions ): number; + + /** + * The callback interface was connect successfully. + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param connection The number of the ability connected + */ + function disconnectAbility(connection: number, callback:AsyncCallback): void; + function disconnectAbility(connection: number): Promise; } export default particleAbility; \ No newline at end of file diff --git a/interfaces/kits/js/ability/connectOptions.d.ts b/interfaces/kits/js/ability/connectOptions.d.ts new file mode 100644 index 00000000000..c718f678c3b --- /dev/null +++ b/interfaces/kits/js/ability/connectOptions.d.ts @@ -0,0 +1,52 @@ +/* + * 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 { ElementName } from '../bundle/elementName'; +import rpc from './../@ohos.rpc'; + +export interface ConnectOptions { + /** + * The callback interface was connect successfully. + * + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param elementName The element name of the service ability + * @param remoteObject The remote object instance + */ + onConnect: (elementName: ElementName, remoteObject: RemoteObject) => void; + + /** + * The callback interface was disconnect successfully. + * + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param elementName The element name of the service ability + */ + onDisconnect: (elementName: ElementName) => void; + + /** + * The callback interface was connect failed. + * + * @default - + * @devices phone, tablet + * @since 7 + * @SysCap aafwk + * @param code The error code of the failed. + */ + onFailed: (code: number) => void; +} diff --git a/interfaces/kits/js/ability/dataAbilityHelper.d.ts b/interfaces/kits/js/ability/dataAbilityHelper.d.ts index 76a5abc9dfa..71dd47e5b0f 100644 --- a/interfaces/kits/js/ability/dataAbilityHelper.d.ts +++ b/interfaces/kits/js/ability/dataAbilityHelper.d.ts @@ -61,20 +61,6 @@ export interface DataAbilityHelper { */ off(type: 'dataChange', uri: string, callback?: AsyncCallback): void; - /** - * Calls the method defined by the Data ability. - * @devices phone, tablet - * @since 7 - * @SysCap AAFwk - * @param uri Indicates the Data ability to process. - * @param method Indicates the method name. - * @param arg Indicates the parameter of the String type. - * @param extras Indicates the parameter of the object type. - * @return callback Indicates the value returned by the called method. - */ - call(uri: string, method: string, arg: string, extras: object, callback: AsyncCallback): void; - call(uri: string, method: string, arg: string, extras: object): Promise; - /** * Inserts a single data record into the database. * @devices phone, tablet @@ -109,8 +95,8 @@ export interface DataAbilityHelper { * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. * @return Returns the query result. */ - query(URI: string, columns: Array, predicates: DataAbilityPredicates, callback: AsyncCallback): void; - query(URI: string, columns: Array, predicates: DataAbilityPredicates): Promise; + query(URI: string, columns: Array, predicates: DataAbilityPredicates, callback: AsyncCallback): void; + query(URI: string, columns: Array, predicates: DataAbilityPredicates): Promise; /** * Updates data records in the database. @@ -134,8 +120,8 @@ export interface DataAbilityHelper { * @param values Indicates the data records to insert. * @return Returns the number of data records inserted. */ - batchInsert(URI: string, values: Array, callback: AsyncCallback): void; - batchInsert(URI: string, values: Array): Promise; + batchInsert(URI: string, values: Array, callback: AsyncCallback): void; + batchInsert(URI: string, values: Array): Promise; /** * Performs batch operations on the database. @@ -220,6 +206,16 @@ export interface DataAbilityHelper { */ release(callback: AsyncCallback): void; release(): Promise; + + /** + * Notifies the registered observers of a change to the data resource specified by Uri. + * @devices phone, tablet + * @since 7 + * @SysCap AAFwk + * @param uri Indicates the {@link ohos.utils.net.Uri} object to notifyChange. + */ + notifyChange(URI: string, callback: AsyncCallback): void; + notifyChange(URI: string): Promise; } export interface DataAbilityResult { diff --git a/test/resource/tools/aa/pageAbilityBundleForStart.hap b/test/resource/tools/aa/pageAbilityBundleForStart.hap index 0a00c268ba56a202419def130d0213bca4006a6b..9c9537c49190b3c6c3e1ddab2c8277e8c239021c 100644 GIT binary patch delta 752 zcmV~lXDh8@xjPjKge;r&ms4z@73HQ^u z-&8NKSZO_pjOiQBbSbo{&e%--B)nn^-;Lg5m!J~%VpO5Ln=yKW8zF)RBgeE1t(v+b zc(R@j3|pgbWo&U-*Y)}4iZlO$N|i9^@CnYwRQbsV7^>dTKs(Mv8)({$$nRssyo1soSltQK#mA1Cr>Z_U)ZKOD{7IxPCfz2V zX{knZyF9-_(!}(Lp}*DCL#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_test.xml index c2ed5e5806a..d94a2929fc9 100644 --- a/test/resource/tools/ohos_test.xml +++ b/test/resource/tools/ohos_test.xml @@ -14,19 +14,19 @@ * limitations under the License. --> - + - + - +