Merge branch 'master' of gitee.com:openharmony/ability_dmsfwk into 721

This commit is contained in:
chen 2022-07-27 07:17:45 +00:00 committed by Gitee
commit 44d130d2e6
106 changed files with 3263 additions and 161 deletions

View File

@ -20,13 +20,13 @@ Distributed Scheduler is used for cross-device component management. It allows t
```
/foundation/ability
├── dmsfwk # DMS framework (DMS is short for Distributed Manager Service, also called the Distributed Scheduler Service)
├── dms_fwk_lite # Lightweight DMS framework
├── dmsfwk_lite # Lightweight DMS framework
```
## Repositories Involved<a name="section1371113476307"></a>
**Distributed Scheduler**
ability\_dms\_fwk
ability\_dmsfwk
ability\_dms\_fwk\_lite
ability\_dmsfwk\_lite

View File

@ -28,13 +28,13 @@
```
/foundation/ability
├── dmsfwk # 分布式组件管理部件模块
├── dms_fwk_lite # 轻量分布式组件管理部件模块
├── dmsfwk_lite # 轻量分布式组件管理部件模块
```
## 相关仓<a name="section1371113476307"></a>
**分布式组件管理部件**
ability\_dms\_fwk
ability\_dmsfwk
ability\_dms\_fwk\_lite
ability\_dmsfwk\_lite

View File

@ -1,9 +1,9 @@
{
"name": "@ohos/distributedschedule_dms_fwk",
"name": "@ohos/dmsfwk",
"description": "distributed ability manager service",
"version": "3.1",
"license": "Apache License 2.0",
"repository": "https://gitee.com/openharmony/distributedschedule_dms_fwk",
"repository": "https://gitee.com/openharmony/ability_dmsfwk",
"publishAs": "code-segment",
"segment": {
"destPath": "foundation/ability/dmsfwk"

View File

@ -4,6 +4,7 @@
"path" : ["/system/bin/sa_main", "/system/profile/distributedsched.xml"],
"uid" : "dms",
"gid" : ["dms", "shell"],
"permission" : ["ohos.permission.DISTRIBUTED_DATASYNC"],
"secon" : "u:r:distributedsche:s0"
}
]

View File

@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/startup/init_lite/services/etc/param/param_fixer.gni")
import("//base/startup/init/services/etc/param/param_fixer.gni")
import("//build/ohos.gni")
#################################################################################

View File

@ -28,9 +28,9 @@ config("continuation_manager_public_config") {
ohos_shared_library("continuation_manager") {
sources = [
"//foundation/ability/dmsfwk/services/dtbabilitymgr/src/continuationManager/continuation_extra_params.cpp",
"//foundation/ability/dmsfwk/services/dtbabilitymgr/src/continuationManager/continuation_result.cpp",
"//foundation/ability/dmsfwk/services/dtbabilitymgr/src/continuationManager/device_selection_notifier_stub.cpp",
"//foundation/ability/dmsfwk/services/dtbabilitymgr/src/continuation_manager/continuation_extra_params.cpp",
"//foundation/ability/dmsfwk/services/dtbabilitymgr/src/continuation_manager/continuation_result.cpp",
"//foundation/ability/dmsfwk/services/dtbabilitymgr/src/continuation_manager/device_selection_notifier_stub.cpp",
]
public_configs = [ ":continuation_manager_public_config" ]

View File

@ -40,7 +40,7 @@ class DtbschedmgrDeviceInfoStorage {
public:
bool Init();
bool Init(sptr<DmsNotifier> listener);
bool Init(const sptr<DmsNotifier>& listener);
void Stop();
bool GetLocalDeviceId(std::string& deviceId);
void DeviceOnlineNotify(const std::shared_ptr<DmsDeviceInfo> devInfo);

View File

@ -64,7 +64,7 @@ bool DtbschedmgrDeviceInfoStorage::Init()
return true;
}
bool DtbschedmgrDeviceInfoStorage::Init(sptr<DmsNotifier> listener)
bool DtbschedmgrDeviceInfoStorage::Init(const sptr<DmsNotifier>& listener)
{
listener_ = listener;
return Init();

View File

@ -32,14 +32,14 @@ config("distributed_ability_manager_config") {
ohos_shared_library("distributed_ability_manager_svr") {
install_enable = true
sources = [
"src/continuationManager/app_device_callback_stub.cpp",
"src/continuationManager/connect_status_info.cpp",
"src/continuationManager/continuation_extra_params.cpp",
"src/continuationManager/continuation_result.cpp",
"src/continuationManager/device_selection_notifier_proxy.cpp",
"src/continuationManager/device_selection_notifier_stub.cpp",
"src/continuationManager/notifier_death_recipient.cpp",
"src/continuationManager/notifier_info.cpp",
"src/continuation_manager/app_device_callback_stub.cpp",
"src/continuation_manager/connect_status_info.cpp",
"src/continuation_manager/continuation_extra_params.cpp",
"src/continuation_manager/continuation_result.cpp",
"src/continuation_manager/device_selection_notifier_proxy.cpp",
"src/continuation_manager/device_selection_notifier_stub.cpp",
"src/continuation_manager/notifier_death_recipient.cpp",
"src/continuation_manager/notifier_info.cpp",
"src/distributed_ability_manager_service.cpp",
"src/distributed_ability_manager_stub.cpp",
]
@ -52,10 +52,10 @@ ohos_shared_library("distributed_ability_manager_svr") {
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"startup_l2:syspara",
"utils_base:utils",
]

View File

@ -23,12 +23,12 @@
namespace OHOS {
namespace DistributedSchedule {
class IAppDeviceCallback : public IRemoteBroker {
class AppDeviceCallbackInterface : public IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedSchedule.IAppDeviceCallback");
IAppDeviceCallback() = default;
virtual ~IAppDeviceCallback() = default;
AppDeviceCallbackInterface() = default;
virtual ~AppDeviceCallbackInterface() = default;
virtual int32_t OnDeviceConnect(int32_t token, const std::vector<ContinuationResult>& continuationResults) = 0;
virtual int32_t OnDeviceDisconnect(int32_t token, const std::vector<std::string>& deviceIds) = 0;

View File

@ -21,7 +21,7 @@
#include "continuation_result.h"
#include "dms_notifier.h"
#include "iapp_device_callback_interface.h"
#include "app_device_callback_interface.h"
#include "iremote_stub.h"
#include "message_option.h"
#include "message_parcel.h"
@ -30,7 +30,7 @@
namespace OHOS {
namespace DistributedSchedule {
class AppDeviceCallbackStub : public IRemoteStub<IAppDeviceCallback> {
class AppDeviceCallbackStub : public IRemoteStub<AppDeviceCallbackInterface> {
public:
explicit AppDeviceCallbackStub(const sptr<DmsNotifier>& dmsNotifier);
virtual ~AppDeviceCallbackStub() = default;

View File

@ -16,7 +16,7 @@
#ifndef OHOS_DISTRIBUTED_ABILITY_MANAGER_SERVICE_H
#define OHOS_DISTRIBUTED_ABILITY_MANAGER_SERVICE_H
#include "continuationManager/notifier_info.h"
#include "continuation_manager/notifier_info.h"
#include "distributed_ability_manager_stub.h"
#include "dms_notifier.h"
#include "event_handler.h"

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "continuationManager/app_device_callback_stub.h"
#include "continuation_manager/app_device_callback_stub.h"
#include <string>
@ -38,7 +38,7 @@ int32_t AppDeviceCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& dat
MessageParcel& reply, MessageOption& option)
{
HILOGD("code = %{public}u", code);
std::u16string descriptor = IAppDeviceCallback::GetDescriptor();
std::u16string descriptor = AppDeviceCallbackInterface::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) {
HILOGE("descriptor check failed");
@ -46,7 +46,7 @@ int32_t AppDeviceCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& dat
}
int32_t token = -1;
switch (code) {
case IAppDeviceCallback::EVENT_DEVICE_CONNECT: {
case AppDeviceCallbackInterface::EVENT_DEVICE_CONNECT: {
PARCEL_READ_HELPER(data, Int32, token);
std::vector<ContinuationResult> continuationResults;
if (!ContinuationResult::ReadContinuationResultsFromParcel(data, continuationResults)) {
@ -55,14 +55,14 @@ int32_t AppDeviceCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& dat
int32_t result = OnDeviceConnect(token, continuationResults);
return result;
}
case IAppDeviceCallback::EVENT_DEVICE_DISCONNECT: {
case AppDeviceCallbackInterface::EVENT_DEVICE_DISCONNECT: {
PARCEL_READ_HELPER(data, Int32, token);
std::vector<std::u16string> deviceIds;
PARCEL_READ_HELPER(data, String16Vector, &deviceIds); // use u16string, because from app.
int32_t result = OnDeviceDisconnect(token, ContinationManagerUtils::Str16VecToStr8Vec(deviceIds));
return result;
}
case IAppDeviceCallback::EVENT_DEVICE_CANCEL: {
case AppDeviceCallbackInterface::EVENT_DEVICE_CANCEL: {
int32_t result = OnDeviceCancel();
return result;
}

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "continuationManager/connect_status_info.h"
#include "continuation_manager/connect_status_info.h"
namespace OHOS {
namespace DistributedSchedule {

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "continuationManager/device_selection_notifier_proxy.h"
#include "continuation_manager/device_selection_notifier_proxy.h"
#include <string>

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "continuationManager/notifier_death_recipient.h"
#include "continuation_manager/notifier_death_recipient.h"
#include <iosfwd>
#include <string>

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "continuationManager/notifier_info.h"
#include "continuation_manager/notifier_info.h"
namespace OHOS {
namespace DistributedSchedule {

View File

@ -19,9 +19,9 @@
#include <thread>
#include "adapter/dnetwork_adapter.h"
#include "continuationManager/app_device_callback_stub.h"
#include "continuationManager/device_selection_notifier_proxy.h"
#include "continuationManager/notifier_death_recipient.h"
#include "continuation_manager/app_device_callback_stub.h"
#include "continuation_manager/device_selection_notifier_proxy.h"
#include "continuation_manager/notifier_death_recipient.h"
#include "dlfcn.h"
#include "dtbschedmgr_device_info_storage.h"
#include "dtbschedmgr_log.h"
@ -67,7 +67,7 @@ void DistributedAbilityManagerService::OnStart()
}
notifierDeathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new NotifierDeathRecipient(this));
if (continuationHandler_ == nullptr) {
auto runner = AppExecFwk::EventRunner::Create("continuationManager");
auto runner = AppExecFwk::EventRunner::Create("continuation_manager");
continuationHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
}
Publish(this);

View File

@ -36,10 +36,10 @@ dtbabilitymgr_external_deps = [
"dsoftbus:softbus_client",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"startup_l2:syspara",
"utils_base:utils",
]
@ -51,13 +51,13 @@ dtbabilitymgr_public_deps = [
]
dtbabilitymgr_sources = [
"${distributed_service}/dtbabilitymgr/src/continuationManager/connect_status_info.cpp",
"${distributed_service}/dtbabilitymgr/src/continuationManager/continuation_extra_params.cpp",
"${distributed_service}/dtbabilitymgr/src/continuationManager/continuation_result.cpp",
"${distributed_service}/dtbabilitymgr/src/continuationManager/device_selection_notifier_proxy.cpp",
"${distributed_service}/dtbabilitymgr/src/continuationManager/device_selection_notifier_stub.cpp",
"${distributed_service}/dtbabilitymgr/src/continuationManager/notifier_death_recipient.cpp",
"${distributed_service}/dtbabilitymgr/src/continuationManager/notifier_info.cpp",
"${distributed_service}/dtbabilitymgr/src/continuation_manager/connect_status_info.cpp",
"${distributed_service}/dtbabilitymgr/src/continuation_manager/continuation_extra_params.cpp",
"${distributed_service}/dtbabilitymgr/src/continuation_manager/continuation_result.cpp",
"${distributed_service}/dtbabilitymgr/src/continuation_manager/device_selection_notifier_proxy.cpp",
"${distributed_service}/dtbabilitymgr/src/continuation_manager/device_selection_notifier_stub.cpp",
"${distributed_service}/dtbabilitymgr/src/continuation_manager/notifier_death_recipient.cpp",
"${distributed_service}/dtbabilitymgr/src/continuation_manager/notifier_info.cpp",
"${distributed_service}/dtbabilitymgr/src/distributed_ability_manager_client.cpp",
"${distributed_service}/dtbabilitymgr/src/distributed_ability_manager_proxy.cpp",
"${distributed_service}/dtbabilitymgr/src/distributed_ability_manager_service.cpp",
@ -66,7 +66,7 @@ dtbabilitymgr_sources = [
ohos_unittest("continuationmanagertest") {
module_out_path = module_output_path
sources = [ "unittest/continuationManager/continuation_manager_test.cpp" ]
sources = [ "unittest/continuation_manager/continuation_manager_test.cpp" ]
sources += dtbabilitymgr_sources
configs = [ ":test_config" ]
configs += dtbabilitymgr_configs

View File

@ -96,7 +96,6 @@ void ContinuationManagerTest::TearDown()
* @tc.name: RegisterTest_001
* @tc.desc: test register token
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, RegisterTest_001, TestSize.Level1)
{
@ -117,7 +116,6 @@ HWTEST_F(ContinuationManagerTest, RegisterTest_001, TestSize.Level1)
* @tc.name: RegisterTest_002
* @tc.desc: test register token with extra param
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterTest_002, TestSize.Level1)
{
@ -140,7 +138,6 @@ HWTEST_F(ContinuationManagerTest, RegisterTest_002, TestSize.Level1)
* @tc.name: UnregisterTest_001
* @tc.desc: test unregister token
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, UnregisterTest_001, TestSize.Level1)
{
@ -159,7 +156,6 @@ HWTEST_F(ContinuationManagerTest, UnregisterTest_001, TestSize.Level1)
* @tc.name: UnregisterTest_002
* @tc.desc: test unregister token with invalid token
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, UnregisterTest_002, TestSize.Level1)
{
@ -174,7 +170,6 @@ HWTEST_F(ContinuationManagerTest, UnregisterTest_002, TestSize.Level1)
* @tc.name: RegisterDeviceSelectionCallbackTest_001
* @tc.desc: test register device selection callback
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_001, TestSize.Level1)
{
@ -199,7 +194,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_001, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_002
* @tc.desc: test register device selection callback with invalid token
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_002, TestSize.Level1)
{
@ -220,7 +214,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_002, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_003
* @tc.desc: test register device selection callback with invalid callback type
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_003, TestSize.Level1)
{
@ -241,7 +234,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_003, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_004
* @tc.desc: test dms deviceConnect callback called when device selection callback has registered.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_004, TestSize.Level1)
{
@ -280,7 +272,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_004, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_005
* @tc.desc: test dms deviceConnect callback called when device selection callback has not registered.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_005, TestSize.Level1)
{
@ -319,7 +310,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_005, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_006
* @tc.desc: test dms deviceDisconnect callback called when device selection callback has registered.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_006, TestSize.Level1)
{
@ -351,7 +341,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_006, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_007
* @tc.desc: test dms deviceDisconnect callback called when device selection callback has not registered.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_007, TestSize.Level1)
{
@ -383,7 +372,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_007, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_008
* @tc.desc: test dms callback called when device selection callback has not registered.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_008, TestSize.Level1)
{
@ -424,7 +412,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_008, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_009
* @tc.desc: test dms callback called when token has not registered.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_009, TestSize.Level1)
{
@ -471,7 +458,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_009, TestS
* @tc.name: RegisterDeviceSelectionCallbackTest_010
* @tc.desc: test dms callback called when token and device selection callback has not registered.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_010, TestSize.Level1)
{
@ -509,7 +495,6 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_010, TestS
* @tc.name: UnregisterDeviceSelectionCallbackTest_001
* @tc.desc: test unregister device selection callback
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_001, TestSize.Level1)
{
@ -542,7 +527,6 @@ HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_001, Tes
* @tc.name: UnregisterDeviceSelectionCallbackTest_002
* @tc.desc: test unregister device selection callback that has not been registered
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_002, TestSize.Level1)
{
@ -566,7 +550,6 @@ HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_002, Tes
* @tc.name: UnregisterDeviceSelectionCallbackTest_003
* @tc.desc: test register device selection callback with invalid token
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_003, TestSize.Level1)
{
@ -586,7 +569,6 @@ HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_003, Tes
* @tc.name: UnregisterDeviceSelectionCallbackTest_004
* @tc.desc: test register device selection callback with invalid callback type
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_004, TestSize.Level1)
{
@ -606,7 +588,6 @@ HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_004, Tes
* @tc.name: StartDeviceManagerTest_001
* @tc.desc: test start device manager
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_001, TestSize.Level1)
{
@ -629,7 +610,6 @@ HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_001, TestSize.Level1)
* @tc.name: StartDeviceManagerTest_002
* @tc.desc: test start device manager with extra param
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_002, TestSize.Level1)
{
@ -655,7 +635,6 @@ HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_002, TestSize.Level1)
* @tc.name: StartDeviceManagerTest_003
* @tc.desc: test start device manager with invalid token
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_003, TestSize.Level1)
{
@ -676,7 +655,6 @@ HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_003, TestSize.Level1)
* @tc.name: UpdateConnectStatusTest_001
* @tc.desc: test update connect status when device selection callback has registered.
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_001, TestSize.Level1)
{
@ -703,7 +681,6 @@ HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_001, TestSize.Level1)
* @tc.name: UpdateConnectStatusTest_002
* @tc.desc: test update connect status when device selection callback has not registered.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_002, TestSize.Level1)
{
@ -725,7 +702,6 @@ HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_002, TestSize.Level1)
* @tc.name: UpdateConnectStatusTest_003
* @tc.desc: test update connect status with invalid token
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_003, TestSize.Level1)
{
@ -743,7 +719,6 @@ HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_003, TestSize.Level1)
* @tc.name: UpdateConnectStatusTest_004
* @tc.desc: test update connect status with empty deviceId
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_004, TestSize.Level1)
{
@ -765,7 +740,6 @@ HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_004, TestSize.Level1)
* @tc.name: UpdateConnectStatusTest_005
* @tc.desc: test update connect status with invalid status
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_005, TestSize.Level1)
{
@ -786,7 +760,6 @@ HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_005, TestSize.Level1)
* @tc.name: IsExceededRegisterMaxNumTest_001
* @tc.desc: test IsExceededRegisterMaxNum function.
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, IsExceededRegisterMaxNumTest_001, TestSize.Level1)
{
@ -809,7 +782,6 @@ HWTEST_F(ContinuationManagerTest, IsExceededRegisterMaxNumTest_001, TestSize.Lev
* @tc.name: IsContinuationModeValidTest_001
* @tc.desc: test IsContinuationModeValid function with invalid continuation mode.
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, IsContinuationModeValidTest_001, TestSize.Level1)
{
@ -829,7 +801,6 @@ HWTEST_F(ContinuationManagerTest, IsContinuationModeValidTest_001, TestSize.Leve
* @tc.name: IsContinuationModeValidTest_002
* @tc.desc: test IsContinuationModeValid function with correct continuation mode.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsContinuationModeValidTest_002, TestSize.Level1)
{
@ -849,7 +820,6 @@ HWTEST_F(ContinuationManagerTest, IsContinuationModeValidTest_002, TestSize.Leve
* @tc.name: IsConnectStatusValidTest_001
* @tc.desc: test IsConnectStatusValid function with invalid connect status.
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, IsConnectStatusValidTest_001, TestSize.Level1)
{
@ -869,7 +839,6 @@ HWTEST_F(ContinuationManagerTest, IsConnectStatusValidTest_001, TestSize.Level1)
* @tc.name: IsConnectStatusValidTest_002
* @tc.desc: test IsConnectStatusValid function with correct connect status.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsConnectStatusValidTest_002, TestSize.Level1)
{
@ -889,7 +858,6 @@ HWTEST_F(ContinuationManagerTest, IsConnectStatusValidTest_002, TestSize.Level1)
* @tc.name: IsTokenRegisteredTest_001
* @tc.desc: test IsTokenRegistered function with invalid token.
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, IsTokenRegisteredTest_001, TestSize.Level1)
{
@ -911,7 +879,6 @@ HWTEST_F(ContinuationManagerTest, IsTokenRegisteredTest_001, TestSize.Level1)
* @tc.name: IsTokenRegisteredTest_002
* @tc.desc: test IsTokenRegistered function with correct token.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsTokenRegisteredTest_002, TestSize.Level1)
{
@ -934,7 +901,6 @@ HWTEST_F(ContinuationManagerTest, IsTokenRegisteredTest_002, TestSize.Level1)
* @tc.name: IsNotifierRegisteredTest_001
* @tc.desc: test IsNotifierRegistered function with invalid token.
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredTest_001, TestSize.Level1)
{
@ -953,7 +919,6 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredTest_001, TestSize.Level1)
* @tc.name: IsNotifierRegisteredLockedTest_002
* @tc.desc: test IsNotifierRegisteredLocked function with invalid token.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_002, TestSize.Level1)
{
@ -972,7 +937,6 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_002, TestSize.L
* @tc.name: IsNotifierRegisteredLockedTest_003
* @tc.desc: test IsNotifierRegisteredLocked function with invalid callback type.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_003, TestSize.Level1)
{
@ -991,7 +955,6 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_003, TestSize.L
* @tc.name: IsNotifierRegisteredTest_004
* @tc.desc: test IsNotifierRegistered function with correct token.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredTest_004, TestSize.Level1)
{
@ -1014,7 +977,6 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredTest_004, TestSize.Level1)
* @tc.name: IsNotifierRegisteredLockedTest_005
* @tc.desc: test IsNotifierRegisteredLocked function with incorrect callback type.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_005, TestSize.Level1)
{
@ -1037,7 +999,6 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_005, TestSize.L
* @tc.name: IsNotifierRegisteredLockedTest_006
* @tc.desc: test IsNotifierRegisteredLocked function with incorrect token.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_006, TestSize.Level1)
{
@ -1060,7 +1021,7 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_006, TestSize.L
* @tc.name: IsNotifierRegisteredLockedTest_007
* @tc.desc: test IsNotifierRegisteredLocked function with correct token and callback type.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_007, TestSize.Level1)
{
@ -1083,7 +1044,6 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_007, TestSize.L
* @tc.name: QueryTokenByNotifier_001
* @tc.desc: test QueryTokenByNotifier function with incorrect notifier.
* @tc.type: FUNC
* @tc.require: SR000H34KJ
*/
HWTEST_F(ContinuationManagerTest, QueryTokenByNotifier_001, TestSize.Level1)
{
@ -1107,7 +1067,6 @@ HWTEST_F(ContinuationManagerTest, QueryTokenByNotifier_001, TestSize.Level1)
* @tc.name: QueryTokenByNotifier_002
* @tc.desc: test QueryTokenByNotifier function with correct notifier.
* @tc.type: FUNC
* @tc.require: AR000H34KK
*/
HWTEST_F(ContinuationManagerTest, QueryTokenByNotifier_002, TestSize.Level1)
{

View File

@ -71,11 +71,11 @@ ohos_shared_library("distributedschedsvr") {
"hitrace_native:hitrace_meter",
"hitrace_native:libhitrace",
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
"ipc:ipc_core",
"os_account:os_account_innerkits",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"startup_l2:syspara",
"utils_base:utils",
]

View File

@ -81,7 +81,6 @@ void AppConnectionStub::OnAbilityConnectDone(const AppExecFwk::ElementName& elem
return;
}
dmsNotifier_->ScheduleStartDeviceManager(remoteObject, token_, continuationExtraParams_);
return;
}
void AppConnectionStub::OnAbilityDisconnectDone(const AppExecFwk::ElementName& element,
@ -93,7 +92,6 @@ void AppConnectionStub::OnAbilityDisconnectDone(const AppExecFwk::ElementName& e
return;
}
dmsNotifier_->ScheduleStartDeviceManager(nullptr, token_, continuationExtraParams_);
return;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -28,6 +28,7 @@ config("test_config") {
include_dirs = [
"//foundation/ability/dmsfwk/utils/native/include",
"//foundation/ability/dmsfwk/services/base/include",
"//foundation/ability/dmsfwk/services/dtbschedmgr/test/unittest",
]
}
@ -45,11 +46,11 @@ dsched_external_deps = [
"hitrace_native:hitrace_meter",
"hitrace_native:libhitrace",
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
"ipc:ipc_core",
"os_account:os_account_innerkits",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"startup_l2:syspara",
"utils_base:utils",
]
@ -58,6 +59,8 @@ if (dmsfwk_mission_manager) {
}
dsched_public_deps = [
"//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
"//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
"//foundation/ability/dmsfwk/services/base:dmsbaseinner",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
@ -83,6 +86,7 @@ dtbschedmgr_sources = [
"${distributed_service}/dtbschedmgr/src/dms_free_install_callback_proxy.cpp",
"${distributed_service}/dtbschedmgr/src/dms_free_install_callback_stub.cpp",
"${distributed_service}/dtbschedmgr/src/dms_token_callback.cpp",
"unittest/distributed_sched_util.cpp",
]
if (dmsfwk_mission_manager) {

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"app": {
"bundleName": "com.dms.stage_manual_test_suite",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true
}
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "StageManualTestSuite"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,44 @@
# Stage模型手工测试套示例
本示例展示了分布式调度子系统基于stage模型手工测试套包含:
1、跨设备绑定ServiceExtensionAbility
效果图
![](screenshots/MainPage.png)
## 跨设备绑定ServiceExtensionAbility示例
### 简介
本示例展示了在eTS中如何构建stage模型跨设备绑定ServiceExtensionAbility包含:
1、远端实现待绑定 ServiceExtensionAbility
2、申请分布式权限DISTRIBUTED_DATASYNC
3、发起端调用 context.connectAbility() 接口,传入 deviceIdbundleNameabilityName 绑定远端 ServiceExtensionAbility
4、绑定成功获取远端 ServiceExtensionAbility 句柄,发起端使用句柄的 sendRequest() 接口调用远端定义的方法
效果图
![](screenshots/ConnectServiceExtensionAbility.png)
### 测试步骤
1、两台设备都安装此应用并组网成功计算器可以跨端拉起
2、在设置里给予此应用分布式权限
3、发起端设备 A 打开应用,选择待绑定远端设备 B 的 deviceId点击 connect 按钮发起绑定
4、发起端设备 A 日志区显示 “get proxy”代表绑定成功
5、发起端设备 A 在输入栏输入任意字符串,点击 send 按钮,信息被发送到远端设备 B
6、发起端设备 A 收到远端设备 B 的回复消息 “MyServiceExtensionAbility receive your message”
### 约束与限制
1、本示例仅支持标准系统上运行
2、本示例为Stage模型仅支持API version 9IDE版本3.0.1.900以上系统版本OpenHarmony3.1 release

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"app": {
"signingConfigs": [],
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [
{
"name": "default",
"signingConfig": "default"
}
],
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"apiType": 'stageMode',
"buildOption": {
},
"targets": [
{
"name": "default"
},
{
"name": "ohosTest",
}
]
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks

View File

@ -0,0 +1,5 @@
{
"name": "entry",
"version": "1.0.0",
"lockfileVersion": 1
}

View File

@ -0,0 +1,14 @@
{
"name": "entry",
"version": "1.0.0",
"ohos": {
"org": "ohos",
"buildTool": "hvigor",
"directoryLevel": "module"
},
"description": "example description",
"repository": {},
"license": "ISC",
"dependencies": {}
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}

View File

@ -0,0 +1,141 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import Ability from '@ohos.application.Ability'
import RemoteDeviceModel from '../Model/RemoteDeviceModel'
import rpc from '@ohos.rpc'
var printLog = '[MainAbility]'
var remoteDeviceModel = new RemoteDeviceModel
var messageProxy = null
var connectedAbility
var options = {
onConnect: async function (elementName, proxy) {
showLog(printLog + "service extension ability connect success")
if (proxy === null) {
showLog("can not get proxy")
return
}
messageProxy = proxy
showLog(printLog + "get proxy, elementName: " + elementName)
},
onDisconnect: function () {
showLog(printLog + "service extension ability disconnect success")
},
onFailed: function () {
showLog(printLog + "service extension ability connect fail")
}
}
function ConnectRemoteAbility() {
showLog(printLog + "connect service extension ability begin")
showLog(printLog + "connect remote device id is " + globalThis.selectDevice)
let want = {
bundleName: "com.dms.stage_manual_test_suite",
abilityName: "MyServiceExtensionAbility",
deviceId: globalThis.selectDevice
}
connectedAbility = globalThis.context.connectAbility(want, options)
showLog(printLog + "connect service extension ability, connectId = " + connectedAbility)
}
async function DisconnectRemoteAbility() {
showLog(printLog + "disconnect service extension ability begin")
showLog(printLog + "disconnect remote device id is " + globalThis.selectDevice)
await globalThis.context.disconnectAbility(connectedAbility)
showLog(printLog + "disconnect service extension ability, connectId = " + connectedAbility)
connectedAbility = null
}
async function SendMessage() {
if (messageProxy === null) {
showLog(printLog + "can not get proxy")
return
}
showLog(printLog + "send message : " + AppStorage.Get<string>("message"))
let option = new rpc.MessageOption()
let data = new rpc.MessageParcel()
let reply = new rpc.MessageParcel()
data.writeString(AppStorage.Get<string>("message"))
await messageProxy.sendRequest(1, data, reply, option)
showLog(printLog + "send message success")
globalThis.receiveMessage = reply.readString()
showLog(printLog + "receive reply message : " + globalThis.receiveMessage)
}
function showLog(logMessage) {
console.log(logMessage)
AppStorage.Set<string>("receiveMessage", AppStorage.Get<string>("receiveMessage") + logMessage + "\n")
}
function RegisterDeviceListCallback() {
remoteDeviceModel.registerDeviceListCallback(() => {
let deviceSize = remoteDeviceModel.deviceList.length
for (var i = 0; i < deviceSize; i++) {
globalThis.DeviceIdList.push(remoteDeviceModel.deviceList[i].deviceId)
}
})
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[ServiceExtensionDemo] MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.context = this.context
globalThis.DeviceIdList = []
globalThis.selectDevice
globalThis.receiveMessage = ""
RegisterDeviceListCallback()
}
onDestroy() {
AppStorage.Set<string>("receiveMessage", "")
console.log("[ServiceExtensionDemo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[ServiceExtension] MainAbility onWindowStageCreate")
globalThis.ConnectRemoteAbility = ConnectRemoteAbility
globalThis.DisconnectRemoteAbility = DisconnectRemoteAbility
globalThis.SendMessage = SendMessage
windowStage.loadContent("pages/MainPage", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[ServiceExtension] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[ServiceExtension] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[ServiceExtension] MainAbility onBackground")
}
};

View File

@ -0,0 +1,89 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import deviceManager from '@ohos.distributedHardware.deviceManager';
var SUBSCRIBE_ID = 100;
export default class RemoteDeviceModel {
deviceList = [];
discoverList = [];
callback;
authCallback = null;
MyDeviceManager;
constructor() {
}
registerDeviceListCallback(callback) {
if (typeof (this.MyDeviceManager) === 'undefined') {
console.log('[ServiceExtensionDemo] deviceManager.createDeviceManager begin');
let self = this;
deviceManager.createDeviceManager('com.example.serviceextensiondemo', (error, value) => {
if (error) {
console.error('createDeviceManager failed.');
return;
}
self.MyDeviceManager = value;
self.registerDeviceListCallback_(callback);
console.log('[ServiceExtensionDemo] createDeviceManager callback returned, error=' + error + ' value=' + value);
});
console.log('[ServiceExtensionDemo] deviceManager.createDeviceManager end');
} else {
this.registerDeviceListCallback_(callback);
}
}
registerDeviceListCallback_(callback) {
console.info('[ServiceExtensionDemo] registerDeviceListCallback');
this.callback = callback;
if (this.MyDeviceManager == undefined) {
console.error('[ServiceExtensionDemo] deviceManager has not initialized');
this.callback();
return;
}
console.info('[ServiceExtensionDemo] getTrustedDeviceListSync begin');
var list = this.MyDeviceManager.getTrustedDeviceListSync();
console.info('[ServiceExtensionDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list));
if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') {
this.deviceList = list;
}
this.callback();
console.info('[ServiceExtensionDemo] callback finished');
}
getTrustDeviceList(callback) {
console.info('[ServiceExtensionDemo] getTrustDeviceListSync begin');
var list = this.MyDeviceManager.getTrustedDeviceListSync();
console.info('[ServiceExtensionDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list));
if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') {
this.deviceList = list;
}
console.info('[ServiceExtensionDemo] getTrustDeviceListSync end');
callback();
}
unregisterDeviceListCallback() {
console.info('[dmsDemo] stopDeviceDiscovery ' + SUBSCRIBE_ID);
this.MyDeviceManager.stopDeviceDiscovery(SUBSCRIBE_ID);
this.MyDeviceManager.off('deviceStateChange');
this.MyDeviceManager.off('deviceFound');
this.MyDeviceManager.off('discoverFail');
this.MyDeviceManager.off('serviceDie');
this.deviceList = [];
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import rpc from '@ohos.rpc';
import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility';
var printLog = '[ServiceExtension]'
class MyServiceExtensionAbilityStub extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
showLog(printLog + "MyServiceExtensionAbility onRemoteRequest call")
if (code === 1) {
globalThis.receiveMessage = data.readString()
showLog(printLog + "receive message : " + globalThis.receiveMessage)
} else {
showLog(printLog + "unknown request code")
}
reply.writeString("MyServiceExtensionAbility receive your message")
return true
}
queryLocalInterface(descriptor) {
return null
}
getInterfaceDescriptor() {
return ''
}
sendRequest(code, data, reply, option) {
return null
}
getCallingPid() {
return 1
}
getCallingUid() {
return 1
}
attachLocalInterface(localInterface, descriptor) {}
}
function showLog(logMessage) {
console.log(logMessage)
AppStorage.Set<string>("receiveMessage", AppStorage.Get<string>("receiveMessage") + logMessage + "\n")
}
export default class MyServiceExtensionAbility extends ServiceExtensionAbility {
onCreate(want) {
console.log(printLog + 'MyServiceExtensionAbility OnCreate, want : ' + want.abilityName)
}
onRequest(want) {
console.log(printLog + 'MyServiceExtensionAbility onRequest, want : ' + want.abilityName)
}
onConnect(want) {
showLog(printLog + 'MyServiceExtensionAbility onConnect, want : ' + want.abilityName)
return new MyServiceExtensionAbilityStub('test')
}
onDisconnect(want) {
showLog(printLog + 'MyServiceExtensionAbility onDisconnect, want : ' + want.abilityName)
}
onDestroy() {
console.log(printLog + 'MyServiceExtensionAbility onDestroy')
}
}

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
var printLog = '[ServiceExtensionDemo]'
AppStorage.Link("message")
AppStorage.Link("receiveMessage")
@Entry
@Component
struct Index {
@State selectDeviceName : string = ""
@StorageLink("message") message : string = ""
@StorageLink("receiveMessage") receiveMessage : string = ""
build() {
Column() {
Row() {
Text("select device id : " + this.selectDeviceName)
.width('100%')
.height('100%')
.fontSize(20)
.textAlign(TextAlign.Start)
}
.height('10%')
.width('100%')
Row() {
Column() {
Button('connect')
.width(100)
.height(50)
.onClick(() => {
globalThis.ConnectRemoteAbility()
})
Button('discon')
.width(100)
.height(50)
.onClick(() => {
globalThis.DisconnectRemoteAbility()
})
List({ space: 10, initialIndex: 0}) {
ForEach(globalThis.DeviceIdList, (item : string) => {
ListItem() {
Button(item)
.width('100%').height(50).fontSize(10)
.onClick(() => {
console.log(printLog + "select device : " + item)
this.selectDeviceName = item
globalThis.selectDevice = item
AppStorage.Set<string>('receiveMessage', AppStorage.Get<string>("receiveMessage") + "select device:" + item + '\n')
})
}.editable(this.editFlag)
}, (item : string) => item.toString())
}.height('100%').width('100%').borderWidth(1).align(ItemAlign.Start)
}.width('30%').height('100%').padding(5)
Column() {
Text('日志')
.height('5%')
.width('100%')
.fontSize(20)
.borderWidth(1)
.textAlign(TextAlign.Center)
.backdropBlur(Color.Gray)
Scroll() {
Text(this.receiveMessage)
.width('100%')
.fontSize(15)
.textAlign(TextAlign.Start)
}.scrollBar(BarState.Auto)
.height('55%')
.align(ItemAlign.Start)
.borderWidth(1)
Text("待发送数据:")
.height('5%')
.width('100%')
.fontSize(20)
.borderWidth(1)
.textAlign(TextAlign.Center)
.backgroundColor(Color.Gray)
Text(this.message)
.height('10%')
.width('100%')
.fontSize(15)
.borderWidth(1)
.textAlign(TextAlign.Start)
TextInput("输入消息")
.width('100%')
.height('10%')
.borderStyle(BorderStyle.Solid)
.type(InputType.Normal)
.onChange((value : string) => {
AppStorage.Set<string>('message', value)
})
Row() {
Button('send')
.width(100)
.height(50)
.onClick(() => {
globalThis.SendMessage()
})
}.height('15%')
}.width('70%').height('100%')
}.width('100%').height('90%')
}.width('100%').height('100%')
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import router from '@system.router'
@Entry
@Component
struct Index {
build() {
Column() {
Text("StageManualTestSuite")
.width('100%')
.height('10%')
.fontSize(20)
.textAlign(TextAlign.Center)
Button('ConnectServiceExtensionAbility')
.width("90%")
.height(50)
.onClick(() => {
router.push({uri : 'pages/ConnectServiceExtensionAbility'})
})
Button('other')
.width("90%")
.height(50)
.onClick(() => {
})
}.width('100%').height('100%')
}
}

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "MyServiceExtensionAbility",
"icon": "$media:icon",
"description": "service",
"type": "service",
"visible": true,
"srcEntrance": "./ets/MyServiceExtensionAbility/MyServiceExtensionAbility.ts"
},
],
"requestPermissions": [
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
}
]
}
}

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}

View File

@ -0,0 +1,16 @@
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "StageManualTestSuite"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,6 @@
{
"src": [
"pages/ConnectServiceExtensionAbility",
"pages/MainPage"
]
}

View File

@ -0,0 +1,17 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
module.exports = require('@ohos/hvigor-ohos-plugin').appTasks

View File

@ -0,0 +1,17 @@
{
"name": "stagemanualtestsuite",
"version": "1.0.0",
"ohos": {
"org": "ohos",
"buildTool": "hvigor",
"directoryLevel": "project"
},
"description": "example description",
"repository": {},
"license": "ISC",
"dependencies": {
"@ohos/hypium": "1.0.1",
"@ohos/hvigor": "1.1.6",
"@ohos/hvigor-ohos-plugin": "1.1.6"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"app": {
"bundleName": "ohos.samples.continuationmanager",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true
}
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "ContinuationManager"
}
]
}

View File

@ -0,0 +1,30 @@
# ContinuationManager手工测试套
### 简介
本示例展示了ContinuationManager手工测试用例包括
1、传入正常值调用ContinuationManager接口
2、传入异常值调用ContinuationManager接口
3、使用ContinuationManager接口进行跨设备拉起以及绑定
效果图
![index](screenshots/device/index.png)
### 测试步骤
1、两台设备都安装此应用并组网成功计算器可以跨端拉起
2、对弹出的分布式权限弹框进行授权
3、点击startRemoteAbility按钮弹出设备选择器应用
4、选择组网设备后点击confirm按钮远端设备应用被拉起表示跨设备拉起成功
5、点击connectRemoteAbility按钮弹出设备选择器应用
6、选择组网设备后点击confirm按钮本设备下方Toast显示“connectRemoteAbilityWithDeviceId connect result: 100”
### 约束与限制
1、本示例仅支持标准系统上运行。 2、本示例为Stage模型仅支持API version 9IDE版本3.0.1.900以上。

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"app": {
"signingConfigs": [],
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [
{
"name": "default",
"signingConfig": "default",
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"apiType": 'stageMode',
"buildOption": {
},
"targets": [
{
"name": "default",
},
{
"name": "ohosTest",
}
]
}

View File

@ -0,0 +1,14 @@
{
"license": "ISC",
"devDependencies": {},
"name": "entry",
"ohos": {
"org": "ohos",
"directoryLevel": "module",
"buildTool": "hvigor"
},
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}

View File

@ -0,0 +1,761 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import abilityAccessCtrl from "@ohos.abilityAccessCtrl";
import bundle from '@ohos.bundle';
import continuationManager from '@ohos.continuation.continuationManager';
import prompt from '@system.prompt';
import rpc from '@ohos.rpc'
const SHOW_TOAST_TIME = 3000; // ms
const DEVICE_TYPE = "00E";
const INVALID_TOKEN = 1000000000;
const INVALID_CONTINUATION_MODE = 30;
const INVALID_CONNECT_STATUS = 30;
let mRemote;
let connectedAbility;
let token = -1;
async function requestPermission() {
let permissions: Array<string> = [
"ohos.permission.DISTRIBUTED_DATASYNC"
];
let needGrantPermission = false;
let accessManger = abilityAccessCtrl.createAtManager();
let bundleInfo = await bundle.getApplicationInfo('ohos.samples.continuationmanager', 0, 100)
for (const permission of permissions) {
console.info('[Demo]app permission query grant status' + permission);
try {
let grantStatus = await accessManger.verifyAccessToken(bundleInfo.accessTokenId, permission);
if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) {
needGrantPermission = true;
break;
}
} catch (err) {
console.error('[Demo]app permission query grant status error' + JSON.stringify(err));
needGrantPermission = true;
break;
}
}
if (needGrantPermission) {
console.info('[Demo]app permission needGrantPermission');
try {
await globalThis.context.requestPermissionsFromUser(permissions);
} catch (err) {
console.error('[Demo]app permission' + JSON.stringify(err));
}
} else {
console.info('[Demo]app permission already granted');
}
}
function register() {
console.info('[Demo]register begin');
continuationManager.register()
.then((data) => {
console.info('[Demo]register finished, ' + JSON.stringify(data));
token = data;
prompt.showToast({
message: "[Demo]register token: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]register failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]register err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]register end');
}
function registerWithExtraParams() {
console.info('[Demo]registerWithExtraParams begin');
let continuationExtraParams = {
deviceType: [DEVICE_TYPE],
targetBundle: "targetBundle",
description: "description",
filter: {"name": "filter", "length": 6},
continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
authInfo: {"name": "authInfo", "length": 8}
};
continuationManager.register(continuationExtraParams)
.then((data) => {
console.info('[Demo]registerWithExtraParams finished, ' + JSON.stringify(data));
token = data;
prompt.showToast({
message: "[Demo]registerWithExtraParams token: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]registerWithExtraParams failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]registerWithExtraParams err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]registerWithExtraParams end');
}
function registerWithInvalidFilter() {
console.info('[Demo]registerWithInvalidFilter begin');
let continuationExtraParams = {
deviceType: [DEVICE_TYPE],
targetBundle: "targetBundle",
description: "description",
filter: "invalid filter",
continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
authInfo: {"name": "authInfo", "length": 8}
};
continuationManager.register(continuationExtraParams)
.then((data) => {
console.info('[Demo]registerWithInvalidFilter finished, ' + JSON.stringify(data));
token = data;
prompt.showToast({
message: "[Demo]registerWithInvalidFilter token: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]registerWithInvalidFilter failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]registerWithInvalidFilter err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]registerWithInvalidFilter end');
}
function registerWithoutFilter() {
console.info('[Demo]registerWithoutFilter begin');
let continuationExtraParams = {
deviceType: [DEVICE_TYPE],
targetBundle: "targetBundle",
description: "description",
continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
authInfo: {"name": "authInfo", "length": 8}
};
continuationManager.register(continuationExtraParams)
.then((data) => {
console.info('[Demo]registerWithoutFilter finished, ' + JSON.stringify(data));
token = data;
prompt.showToast({
message: "[Demo]registerWithoutFilter token: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]registerWithoutFilter failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]registerWithoutFilter err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]registerWithoutFilter end');
}
function registerWithInvalidContinuationMode() {
console.info('[Demo]registerWithInvalidContinuationMode begin');
let continuationExtraParams = {
deviceType: [DEVICE_TYPE],
targetBundle: "targetBundle",
description: "description",
filter: {"name": "filter", "length": 6},
continuationMode: INVALID_CONTINUATION_MODE,
authInfo: {"name": "authInfo", "length": 8}
};
continuationManager.register(continuationExtraParams)
.then((data) => {
console.info('[Demo]registerWithInvalidContinuationMode finished, ' + JSON.stringify(data));
token = data;
prompt.showToast({
message: "[Demo]registerWithInvalidContinuationMode token: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]registerWithInvalidContinuationMode failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]registerWithInvalidContinuationMode err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]registerWithInvalidContinuationMode end');
}
function onDeviceConnect() {
console.info('[Demo]onDeviceConnect begin');
continuationManager.on("deviceConnect", token, (data) => {
console.info('[Demo]onDeviceConnect len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('[Demo]onDeviceConnect deviceId: ' + JSON.stringify(data[i].id));
console.info('[Demo]onDeviceConnect deviceType: ' + JSON.stringify(data[i].type));
console.info('[Demo]onDeviceConnect deviceName: ' + JSON.stringify(data[i].name));
}
prompt.showToast({
message: "[Demo]onDeviceConnect continuationResults: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
console.info('[Demo]onDeviceConnect finished.');
});
console.info('[Demo]onDeviceConnect end');
}
function onDeviceConnectWithInvalidToken() {
console.info('[Demo]onDeviceConnectWithInvalidToken begin');
continuationManager.on("deviceConnect", INVALID_TOKEN, (data) => {
console.info('[Demo]onDeviceConnectWithInvalidToken len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('[Demo]onDeviceConnectWithInvalidToken deviceId: ' + JSON.stringify(data[i].id));
console.info('[Demo]onDeviceConnectWithInvalidToken deviceType: ' + JSON.stringify(data[i].type));
console.info('[Demo]onDeviceConnectWithInvalidToken deviceName: ' + JSON.stringify(data[i].name));
}
prompt.showToast({
message: "[Demo]onDeviceConnectWithInvalidToken continuationResults: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
console.info('[Demo]onDeviceConnectWithInvalidToken finished.');
});
console.info('[Demo]onDeviceConnectWithInvalidToken end');
}
function onDeviceDisconnect() {
console.info('[Demo]onDeviceDisconnect begin');
continuationManager.on("deviceDisconnect", token, (data) => {
console.info('[Demo]onDeviceDisconnect len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('[Demo]onDeviceDisconnect deviceId: ' + JSON.stringify(data[i]));
}
prompt.showToast({
message: "[Demo]onDeviceDisconnect deviceIds: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
console.info('[Demo]onDeviceDisconnect finished.');
});
console.info('[Demo]onDeviceDisconnect end');
}
function onDeviceDisconnectWithInvalidToken() {
console.info('[Demo]onDeviceDisconnectWithInvalidToken begin');
continuationManager.on("deviceDisconnect", INVALID_TOKEN, (data) => {
console.info('[Demo]onDeviceDisconnectWithInvalidToken len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('[Demo]onDeviceDisconnectWithInvalidToken deviceId: ' + JSON.stringify(data[i]));
}
prompt.showToast({
message: "[Demo]onDeviceDisconnectWithInvalidToken deviceIds: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
console.info('[Demo]onDeviceDisconnectWithInvalidToken finished.');
});
console.info('[Demo]onDeviceDisconnectWithInvalidToken end');
}
function startDeviceManager() {
console.info('[Demo]startDeviceManager begin');
continuationManager.startDeviceManager(token)
.then((data) => {
console.info('[Demo]startDeviceManager finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]startDeviceManager data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]startDeviceManager failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]startDeviceManager err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]startDeviceManager end');
}
function startDeviceManagerWithExtraParam() {
console.info('[Demo]startDeviceManagerWithExtraParam begin');
let continuationExtraParams = {
deviceType: [DEVICE_TYPE],
targetBundle: "targetBundle",
description: "description",
filter: {"name": "filter", "length": 6},
continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
authInfo: {"name": "authInfo", "length": 8}
};
continuationManager.startDeviceManager(token, continuationExtraParams)
.then((data) => {
console.info('[Demo]startDeviceManagerWithExtraParam finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]startDeviceManagerWithExtraParam data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]startDeviceManagerWithExtraParam failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]startDeviceManagerWithExtraParam err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]startDeviceManagerWithExtraParam end');
}
function startDeviceManagerWithInvalidToken() {
console.info('[Demo]startDeviceManagerWithInvalidToken begin');
continuationManager.startDeviceManager(INVALID_TOKEN)
.then((data) => {
console.info('[Demo]startDeviceManagerWithInvalidToken finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]startDeviceManagerWithInvalidToken data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]startDeviceManagerWithInvalidToken failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]startDeviceManagerWithInvalidToken err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]startDeviceManagerWithInvalidToken end');
}
function startDeviceManagerWithInvalidFilter() {
console.info('[Demo]startDeviceManagerWithInvalidFilter begin');
let continuationExtraParams = {
deviceType: [DEVICE_TYPE],
targetBundle: "targetBundle",
description: "description",
filter: "invalid filter",
continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
authInfo: {"name": "authInfo", "length": 8}
};
continuationManager.startDeviceManager(token, continuationExtraParams)
.then((data) => {
console.info('[Demo]startDeviceManagerWithInvalidFilter finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]startDeviceManagerWithInvalidFilter data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]startDeviceManagerWithInvalidFilter failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]startDeviceManagerWithInvalidFilter err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]startDeviceManagerWithInvalidFilter end');
}
function startDeviceManagerWithoutFilter() {
console.info('[Demo]startDeviceManagerWithoutFilter begin');
let continuationExtraParams = {
deviceType: [DEVICE_TYPE],
targetBundle: "targetBundle",
description: "description",
continuationMode: continuationManager.ContinuationMode.COLLABORATION_MULTIPLE,
authInfo: {"name": "authInfo", "length": 8}
};
continuationManager.startDeviceManager(token, continuationExtraParams)
.then((data) => {
console.info('[Demo]startDeviceManagerWithoutFilter finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]startDeviceManagerWithoutFilter data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]startDeviceManagerWithoutFilter failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]startDeviceManagerWithoutFilter err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]startDeviceManagerWithoutFilter end');
}
function startDeviceManagerWithInvalidContinuationMode() {
console.info('[Demo]startDeviceManagerWithInvalidContinuationMode begin');
let continuationExtraParams = {
deviceType: [DEVICE_TYPE],
targetBundle: "targetBundle",
description: "description",
filter: {"name": "filter", "length": 6},
continuationMode: INVALID_CONTINUATION_MODE,
authInfo: {"name": "authInfo", "length": 8}
};
continuationManager.startDeviceManager(token, continuationExtraParams)
.then((data) => {
console.info('[Demo]startDeviceManagerWithInvalidContinuationMode finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]startDeviceManagerWithInvalidContinuationMode data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]startDeviceManagerWithInvalidContinuationMode failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]startDeviceManagerWithInvalidContinuationMode err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]startDeviceManagerWithInvalidContinuationMode end');
}
function updateConnectStatus() {
console.info('[Demo]updateConnectStatus begin');
let deviceId: string = "test deviceId";
let deviceConnectStatus = continuationManager.DeviceConnectState.CONNECTED;
continuationManager.updateConnectStatus(token, deviceId, deviceConnectStatus)
.then((data) => {
console.info('[Demo]updateConnectStatus finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]updateConnectStatus data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]updateConnectStatus failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]updateConnectStatus err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]updateConnectStatus end');
}
function updateConnectStatusWithInvalidToken() {
console.info('[Demo]updateConnectStatusWithInvalidToken begin');
let deviceId: string = "test deviceId";
let deviceConnectStatus = continuationManager.DeviceConnectState.CONNECTED;
continuationManager.updateConnectStatus(INVALID_TOKEN, deviceId, deviceConnectStatus)
.then((data) => {
console.info('[Demo]updateConnectStatusWithInvalidToken finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]updateConnectStatusWithInvalidToken data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]updateConnectStatusWithInvalidToken failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]updateConnectStatusWithInvalidToken err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]updateConnectStatusWithInvalidToken end');
}
function updateConnectStatusWithInvalidDeviceId() {
console.info('[Demo]updateConnectStatusWithInvalidDeviceId begin');
let deviceId: string = "";
let deviceConnectStatus = continuationManager.DeviceConnectState.CONNECTED;
continuationManager.updateConnectStatus(token, deviceId, deviceConnectStatus)
.then((data) => {
console.info('[Demo]updateConnectStatusWithInvalidDeviceId finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]updateConnectStatusWithInvalidDeviceId data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]updateConnectStatusWithInvalidDeviceId failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]updateConnectStatusWithInvalidDeviceId err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]updateConnectStatusWithInvalidDeviceId end');
}
function updateConnectStatusWithInvalidConnectStatus() {
console.info('[Demo]updateConnectStatusWithInvalidConnectStatus begin');
let deviceId: string = "test deviceId";
let deviceConnectStatus = INVALID_CONNECT_STATUS;
continuationManager.updateConnectStatus(token, deviceId, deviceConnectStatus)
.then((data) => {
console.info('[Demo]updateConnectStatusWithInvalidConnectStatus finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]updateConnectStatusWithInvalidConnectStatus data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]updateConnectStatusWithInvalidConnectStatus failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]updateConnectStatusWithInvalidConnectStatus err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]updateConnectStatusWithInvalidConnectStatus end');
}
function offDeviceConnect() {
console.info('[Demo]offDeviceConnect begin');
continuationManager.off("deviceConnect", token);
console.info('[Demo]offDeviceConnect end');
}
function offDeviceConnectWithInvalidToken() {
console.info('[Demo]offDeviceConnectWithInvalidToken begin');
continuationManager.off("deviceConnect", INVALID_TOKEN);
console.info('[Demo]offDeviceConnectWithInvalidToken end');
}
function offDeviceDisconnect() {
console.info('[Demo]offDeviceDisconnect begin');
continuationManager.off("deviceDisconnect", token);
console.info('[Demo]offDeviceDisconnect end');
}
function offDeviceDisconnectWithInvalidToken() {
console.info('[Demo]offDeviceDisconnectWithInvalidToken begin');
continuationManager.off("deviceDisconnect", INVALID_TOKEN);
console.info('[Demo]offDeviceDisconnectWithInvalidToken end');
}
function unregister() {
console.info('[Demo]unregister begin');
continuationManager.unregister(token)
.then((data) => {
console.info('[Demo]unregister finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]unregister data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]unregister failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]unregister err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]unregister end');
}
function unregisterWithInvalidToken() {
console.info('[Demo]unregisterWithInvalidToken begin');
continuationManager.unregister(INVALID_TOKEN)
.then((data) => {
console.info('[Demo]unregisterWithInvalidToken finished, ' + JSON.stringify(data));
prompt.showToast({
message: "[Demo]unregisterWithInvalidToken data: " + JSON.stringify(data),
duration: SHOW_TOAST_TIME
});
})
.catch((err) => {
console.error('[Demo]unregisterWithInvalidToken failed, cause: ' + JSON.stringify(err));
prompt.showToast({
message: "[Demo]unregisterWithInvalidToken err: " + err,
duration: SHOW_TOAST_TIME
});
});
console.info('[Demo]unregisterWithInvalidToken end');
}
function startRemoteAbility() {
let token = -1;
continuationManager.register()
.then((data) => {
console.info('[Demo]register finished, ' + JSON.stringify(data));
token = data;
globalThis.token = data;
console.info('[Demo]startRemoteAbility register token = ' + globalThis.token);
continuationManager.on("deviceConnect", token, (data) => {
console.info('[Demo]registerDeviceConnectCallback len: ' + data.length);
if (data.length <= 0) {
console.info('[Demo]no selected device');
return;
}
for (let i = 0; i < data.length; i++) {
startRemoteAbilityWithDeviceId(data[i].id);
}
});
continuationManager.startDeviceManager(token)
.then((data) => {
console.info('[Demo]startDeviceManager finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('[Demo]startDeviceManager failed, cause: ' + JSON.stringify(err));
});
})
.catch((err) => {
console.error('[Demo]register failed, cause: ' + JSON.stringify(err));
});
}
function startRemoteAbilityWithDeviceId(remoteDeviceId) {
console.info('[Demo]startRemoteAbilityWithDeviceId remoteDeviceId = ' + remoteDeviceId);
let want = {
deviceId: remoteDeviceId,
bundleName: 'ohos.samples.continuationmanager',
abilityName: 'MainAbility'
};
globalThis.context.startAbility(want).then((data) => {
console.info('StartRemoteAbility finished, ' + JSON.stringify(data));
});
}
function connectRemoteAbility() {
let token = -1;
continuationManager.register()
.then((data) => {
console.info('[Demo]register finished, ' + JSON.stringify(data));
token = data;
globalThis.token = data;
console.info('[Demo]connectRemoteAbility register token = ' + globalThis.token);
continuationManager.on("deviceConnect", token, (data) => {
console.info('[Demo]registerDeviceConnectCallback len: ' + data.length);
if (data.length <= 0) {
console.info('[Demo]no selected device');
return;
}
for (let i = 0; i < data.length; i++) {
connectRemoteAbilityWithDeviceId(data[i].id);
}
});
continuationManager.startDeviceManager(token)
.then((data) => {
console.info('[Demo]startDeviceManager finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('[Demo]startDeviceManager failed, cause: ' + JSON.stringify(err));
});
})
.catch((err) => {
console.error('[Demo]register failed, cause: ' + JSON.stringify(err));
});
}
function connectRemoteAbilityWithDeviceId(remoteDeviceId) {
console.info('[Demo]connectRemoteAbilityWithDeviceId remoteDeviceId = ' + remoteDeviceId);
async function onConnectCallback(element, remote) {
console.log('[Demo]connectRemoteAbilityWithDeviceId onConnectDone element: ' + element);
console.log('[Demo]connectRemoteAbilityWithDeviceId onConnectDone remote: ' + remote);
mRemote = remote;
if (mRemote == null) {
prompt.showToast({
message: "connectRemoteAbilityWithDeviceId not connected yet"
});
return;
}
let option = new rpc.MessageOption();
let data = new rpc.MessageParcel();
let reply = new rpc.MessageParcel();
data.writeInt(1);
data.writeInt(99);
await mRemote.sendRequest(1, data, reply, option);
let msg = reply.readInt();
prompt.showToast({
message: "connectRemoteAbilityWithDeviceId connect result: " + msg,
duration: SHOW_TOAST_TIME
});
}
function onDisconnectCallback(element) {
console.log('[Demo]connectRemoteAbilityWithDeviceId onDisconnectDone element: ' + element);
}
function onFailedCallback(code) {
console.log('[Demo]connectRemoteAbilityWithDeviceId onFailed errCode: ' + code);
}
connectedAbility = globalThis.context.connectAbility(
{
deviceId: remoteDeviceId,
bundleName: "ohos.samples.continuationmanager",
abilityName: "ServiceExtAbility",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.context = this.context;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
requestPermission();
globalThis.register = (()=>{ register(); })
globalThis.registerWithExtraParams = (()=>{ registerWithExtraParams(); })
globalThis.registerWithInvalidFilter = (()=>{ registerWithInvalidFilter(); })
globalThis.registerWithoutFilter = (()=>{ registerWithoutFilter(); })
globalThis.registerWithInvalidContinuationMode = (()=>{ registerWithInvalidContinuationMode(); })
globalThis.onDeviceConnect = (()=>{ onDeviceConnect(); })
globalThis.onDeviceConnectWithInvalidToken = (()=>{ onDeviceConnectWithInvalidToken(); })
globalThis.onDeviceDisconnect = (()=>{ onDeviceDisconnect(); })
globalThis.onDeviceDisconnectWithInvalidToken = (()=>{ onDeviceDisconnectWithInvalidToken(); })
globalThis.startDeviceManager = (()=>{ startDeviceManager(); })
globalThis.startDeviceManagerWithExtraParam = (()=>{ startDeviceManagerWithExtraParam(); })
globalThis.startDeviceManagerWithInvalidToken = (()=>{ startDeviceManagerWithInvalidToken(); })
globalThis.startDeviceManagerWithInvalidFilter = (()=>{ startDeviceManagerWithInvalidFilter(); })
globalThis.startDeviceManagerWithoutFilter = (()=>{ startDeviceManagerWithoutFilter(); })
globalThis.startDeviceManagerWithInvalidContinuationMode = (()=>{ startDeviceManagerWithInvalidContinuationMode(); })
globalThis.updateConnectStatus = (()=>{ updateConnectStatus(); })
globalThis.updateConnectStatusWithInvalidToken = (()=>{ updateConnectStatusWithInvalidToken(); })
globalThis.updateConnectStatusWithInvalidDeviceId = (()=>{ updateConnectStatusWithInvalidDeviceId(); })
globalThis.updateConnectStatusWithInvalidConnectStatus = (()=>{ updateConnectStatusWithInvalidConnectStatus(); })
globalThis.offDeviceConnect = (()=>{ offDeviceConnect(); })
globalThis.offDeviceConnectWithInvalidToken = (()=>{ offDeviceConnectWithInvalidToken(); })
globalThis.offDeviceDisconnect = (()=>{ offDeviceDisconnect(); })
globalThis.offDeviceDisconnectWithInvalidToken = (()=>{ offDeviceDisconnectWithInvalidToken(); })
globalThis.unregister = (()=>{ unregister(); })
globalThis.unregisterWithInvalidToken = (()=>{ unregisterWithInvalidToken(); })
globalThis.startRemoteAbility = (()=>{ startRemoteAbility(); })
globalThis.connectRemoteAbility = (()=>{ connectRemoteAbility(); })
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
console.info('[Demo]onBackground unregister, token = ' + globalThis.token);
continuationManager.unregister(globalThis.token)
.then((data) => {
console.info('[Demo]unregister finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('[Demo]unregister failed, cause: ' + JSON.stringify(err));
});
}
};

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Extension from '@ohos.application.ServiceExtensionAbility'
import rpc from '@ohos.rpc'
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
console.info('[Demo]onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
console.log("op1 = " + op1 + ", op2 = " + op2);
reply.writeInt(op1 + op2);
} else {
console.log("[Demo]StubTest unknown request code");
}
return true;
}
queryLocalInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
sendRequest(code, data, reply, options) {
return null;
}
getCallingPid() {
return START_DEVICE_MANAGER;
}
getCallingUid() {
return START_DEVICE_MANAGER;
}
attachLocalInterface(localInterface, descriptor){}
}
export default class ServiceExtAbility extends Extension {
onCreate(want) {
globalThis.mainAbilityContext = this.context;
console.info('[Demo]onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.info('[Demo]onRequest, want: ' + want.abilityName);
}
onConnect(want) {
console.info('[Demo]onConnect, want: ' + want.abilityName);
return new StubTest("test");
}
onDisconnect(want) {
console.info('[Demo]onDisconnect, want: ' + want.abilityName);
}
onDestroy() {
console.info('[Demo]onDestroy');
}
}

View File

@ -0,0 +1,476 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import prompt from '@system.prompt';
@Entry
@Component
struct Index {
private scroller: Scroller = new Scroller();
private aboutToAppear() {
prompt.showToast({
message: "MainAbility aboutToAppear"
});
}
build() {
Row() {
Column() {
Scroll(this.scroller) {
Column() {
Button() {
Text('register')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.register();
})
Button() {
Text('registerWithExtraParams')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.registerWithExtraParams();
})
Button() {
Text('registerWithInvalidFilter')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.registerWithInvalidFilter();
})
Button() {
Text('registerWithoutFilter')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.registerWithoutFilter();
})
Button() {
Text('registerWithInvalidContinuationMode')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.registerWithInvalidContinuationMode();
})
Button() {
Text('onDeviceConnect')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.onDeviceConnect();
})
Button() {
Text('onDeviceConnectWithInvalidToken')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.onDeviceConnectWithInvalidToken();
})
Button() {
Text('onDeviceDisconnect')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.onDeviceDisconnect();
})
Button() {
Text('onDeviceDisconnectWithInvalidToken')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.onDeviceDisconnectWithInvalidToken();
})
Button() {
Text('startDeviceManager')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.startDeviceManager();
})
Button() {
Text('startDeviceManagerWithExtraParam')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.startDeviceManagerWithExtraParam();
})
Button() {
Text('startDeviceManagerWithInvalidToken')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.startDeviceManagerWithInvalidToken();
})
Button() {
Text('startDeviceManagerWithInvalidFilter')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.startDeviceManagerWithInvalidFilter();
})
Button() {
Text('startDeviceManagerWithoutFilter')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.startDeviceManagerWithoutFilter();
})
Button() {
Text('startDeviceManagerWithInvalidContinuationMode')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.startDeviceManagerWithInvalidContinuationMode();
})
Button() {
Text('updateConnectStatus')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.updateConnectStatus();
})
Button() {
Text('updateConnectStatusWithInvalidToken')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.updateConnectStatusWithInvalidToken();
})
Button() {
Text('updateConnectStatusWithInvalidDeviceId')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.updateConnectStatusWithInvalidDeviceId();
})
Button() {
Text('updateConnectStatusWithInvalidConnectStatus')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.updateConnectStatusWithInvalidConnectStatus();
})
Button() {
Text('offDeviceConnect')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.offDeviceConnect();
})
Button() {
Text('offDeviceConnectWithInvalidToken')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.offDeviceConnectWithInvalidToken();
})
Button() {
Text('offDeviceDisconnect')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.offDeviceDisconnect();
})
Button() {
Text('offDeviceDisconnectWithInvalidToken')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.offDeviceDisconnectWithInvalidToken();
})
Button() {
Text('unregister')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.unregister();
})
Button() {
Text('unregisterWithInvalidToken')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.unregisterWithInvalidToken();
})
Button() {
Text('startRemoteAbility')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.startRemoteAbility();
})
Button() {
Text('connectRemoteAbility')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width(350)
.height(30)
.onClick(() => {
globalThis.connectRemoteAbility();
})
}
}
.width("100%").height("100%")
}
.width('100%')
}
.height('100%')
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"launchType": "standard",
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "ServiceExtAbility",
"icon": "$media:icon",
"description": "service",
"type": "service",
"visible": true,
"srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts"
}
],
"requestPermissions": [
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
}
]
}
}

View File

@ -0,0 +1,16 @@
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}

View File

@ -0,0 +1,18 @@
{
"license":"ISC",
"devDependencies":{},
"name":"continuationmanager",
"ohos":{
"org":"ohos",
"directoryLevel":"project",
"buildTool":"hvigor"
},
"description":"example description",
"repository":{},
"version":"1.0.0",
"dependencies":{
"@ohos/hvigor-ohos-plugin":"1.0.6",
"hypium":"^1.0.0",
"@ohos/hvigor":"1.0.6"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"app": {
"bundleName": "com.ohos.continuationManualTestSuite.hmservice",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true
}
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "单实例迁移"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,35 @@
# 跨端迁移手工测试套
### 简介
本示例展示了在eTS中如何构建stage模型跨端迁移Ability包含:
1、配置迁移属性字段continuable和launchType
2、申请分布式权限DISTRIBUTED_DATASYNC
3、实现数据保存和恢复发起端页面输入的文本迁移到远端后能够显示
4、在迁移中使用分布式对象传输数据
效果图
![index](screenshots/device/index.png) ![](screenshots/device/work.png)
### 测试步骤
1、两台设备都安装此应用并组网成功计算器可以跨端拉起
2、本机安装迁移发起应用
3、点击进入“工作”page输入任意字符然后通过迁移发起应用将当前界面迁移到远端设备
4、迁移后的远端界面与迁移之前本机页面一致包括输入的字符同时本机页面消失表示迁移成功
5、本机再次打开该应用点击进入“学习”page输入任意字符然后通过迁移发起应用将当前界面迁移到远端设备
6、迁移后的远端界面与迁移之前本机页面一致包括输入的字符同时本机页面消失表示迁移成功
7、在两次迁移后查看远端任务如果只有一个任务存在表示单实例迁移测试通过
### 约束与限制
1、本示例仅支持标准系统上运行。 2、本示例为Stage模型仅支持API version 9IDE版本3.0.1.900以上系统版本OpenHarmony3.1 release。

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"app": {
"signingConfigs": [],
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [
{
"name": "default",
"signingConfig": "default",
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"apiType": 'stageMode',
"buildOption": {
},
"targets": [
{
"name": "default",
},
{
"name": "ohosTest",
}
]
}

View File

@ -0,0 +1,17 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks

View File

@ -0,0 +1,5 @@
{
"name": "entry",
"version": "1.0.0",
"lockfileVersion": 1
}

View File

@ -0,0 +1,13 @@
{
"name": "entry",
"version": "1.0.0",
"ohos": {
"org": "ohos",
"buildTool": "hvigor",
"directoryLevel": "module"
},
"description": "example description",
"repository": {},
"license": "ISC",
"dependencies": {}
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
import Logger from '../MainAbility/Logger';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
Logger.info("[Demo] MyAbilityStage onCreate")
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Logger {
private prefix: string;
constructor(prefix: string) {
this.prefix = prefix;
}
debug(...args: any[]) {
console.debug(`[${this.prefix}] ${args.join('')}`);
}
info(...args: any[]) {
console.log(`[${this.prefix}] ${args.join('')}`);
}
error(...args: any[]) {
console.error(`[${this.prefix}] ${args.join('')}`);
}
}
export default new Logger('Continuation Demo');

View File

@ -0,0 +1,160 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import AbilityConstant from '@ohos.application.AbilityConstant'
import accessControl from "@ohos.abilityAccessCtrl";
import bundle from '@ohos.bundle';
import distributedObject from '@ohos.data.distributedDataObject';
import Logger from './Logger';
const BUNDLE_NAME = "com.ohos.continuationManualTestSuite.hmservice"
const PERMISSION_REJECT = -1
class ContentStorage {
}
var g_object = distributedObject.createDistributedObject({name:undefined});
export default class MainAbility extends Ability {
contentStorage : ContentStorage
sessionId : string
handleParam(want, launchParam) {
if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
this.sessionId = want.parameters.session
Logger.info(`continuation sessionId: ${this.sessionId}`)
g_object.name = undefined;
Logger.info(`set g_object.name undefined`)
g_object.setSessionId(this.sessionId); // set session id, so it will sync data from remote device
Logger.info(`g_object_name = ${g_object.name}`);
AppStorage.SetOrCreate<string>('ContinueStudy', g_object.name)
let workInput = want.parameters.work // get user data from want params
Logger.info(`work input ${workInput}`)
AppStorage.SetOrCreate<string>('ContinueWork', workInput)
this.contentStorage = new ContentStorage();
Logger.info('ready to restore');
this.context.restoreWindowStage(this.contentStorage);
}
}
onCreate(want, launchParam) {
Logger.info("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
this.handleParam(want, launchParam)
}
onContinue(wantParam : {[key: string]: any}) {
Logger.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`)
let workInput = AppStorage.Get<string>('ContinueWork');
Logger.info(`onContinue work input = ${workInput}`);
if (g_object.__sessionId === undefined) {
this.sessionId = distributedObject.genSessionId()
Logger.info(`onContinue generate new sessionId`)
}
else {
this.sessionId = g_object.__sessionId;
}
wantParam["session"] = this.sessionId
g_object.name = AppStorage.Get<string>('ContinueStudy');
Logger.info(`onContinue sessionId = ${this.sessionId}, name = ${g_object.name}`)
g_object.setSessionId(this.sessionId);
g_object.save(wantParam.targetDevice, (result, data)=>{
Logger.info("save callback");
Logger.info("save sessionId " + data.sessionId);
Logger.info("save version " + data.version);
Logger.info("save deviceId " + data.deviceId);
});
wantParam["work"] = workInput // set user input data into want params
return 0;
}
onNewWant(want, launchParam) {
Logger.info("MainAbility onNewWant")
this.handleParam(want, launchParam)
}
requestPermissions = async () => {
let permissions: Array<string> = [
"ohos.permission.DISTRIBUTED_DATASYNC"
];
let needGrantPermission = false
let accessManger = accessControl.createAtManager()
Logger.info("app permission get bundle info")
let bundleInfo = await bundle.getApplicationInfo(BUNDLE_NAME, 0, 100)
Logger.info(`app permission query permission ${bundleInfo.accessTokenId.toString()}`)
for (const permission of permissions) {
Logger.info(`app permission query grant status ${permission}`)
try {
let grantStatus = await accessManger.verifyAccessToken(bundleInfo.accessTokenId, permission)
if (grantStatus === PERMISSION_REJECT) {
needGrantPermission = true
break;
}
} catch (err) {
Logger.error(`app permission query grant status error ${permission} ${JSON.stringify(err)}`)
needGrantPermission = true
break;
}
}
if (needGrantPermission) {
Logger.info("app permission needGrantPermission")
try {
await this.context.requestPermissionsFromUser(permissions)
} catch (err) {
Logger.error(`app permission ${JSON.stringify(err)}`)
}
} else {
Logger.info("app permission already granted")
}
}
onDestroy() {
Logger.info("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
Logger.info("MainAbility onWindowStageCreate")
this.requestPermissions()
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageRestore(windowStage) {
Logger.info("MainAbility onWindowStageRestore")
this.requestPermissions()
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
Logger.info("MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
Logger.info("MainAbility onForeground")
}
onBackground() {
// Ability has back to background
Logger.info("MainAbility onBackground")
}
};

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default class pageName {
static page1 = "工作"
static page2 = "学习"
static backKey = "返回首页"
}

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
import pageName from '../MainAbility/stringConst';
import Logger from '../MainAbility/Logger';
async function routePage(pageIndex) {
Logger.info("routePage");
let options = {
uri: pageIndex
}
try {
await router.push(options)
} catch (err) {
Logger.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
@State message: string = '记事本(免安装)'
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text(pageName.page1)
.fontSize(35)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Normal)
.margin({
top: 30
})
.backgroundColor('#2cb3cb')
.onClick(() => routePage('pages/work'))
Button() {
Text(pageName.page2)
.fontSize(35)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Normal)
.margin({
top: 60
})
.backgroundColor('#2cb3cb')
.onClick(() => routePage('pages/study'))
}
.width('100%')
.height('100%')
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
import pageName from '../MainAbility/stringConst';
import Logger from '../MainAbility/Logger';
@Entry
@Component
struct Study {
private content: string = pageName.page2
@StorageLink('ContinueStudy') inputTxt2: string = '';
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Column() {
TextArea({ placeholder: 'please input', text: this.inputTxt2 }) // restore user input data on ui
.textAlign(TextAlign.Start)
.onChange((value) => {
Logger.info(`TextInput onChange: ${value}`);
this.inputTxt2 = value;
AppStorage.Set('ContinueStudy', value);
})
.width('50%')
.height(50)
}
Button() {
Text(pageName.backKey)
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
import pageName from '../MainAbility/stringConst';
import Logger from '../MainAbility/Logger';
@Entry
@Component
struct Work {
private content: string = pageName.page1;
@StorageLink('ContinueWork') inputTxt: string = '';
controller: CustomDialogController
cancel: () => void
confirm: () => void
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Column() {
TextArea({placeholder:'please input', text:this.inputTxt}) // restore user input data on ui
.textAlign(TextAlign.Start)
.onChange((value) => {
Logger.info(`TextInput onChange: ${value}`);
this.inputTxt = value;
AppStorage.Set('ContinueWork', value);
})
.width('50%')
.height(50)
}
Button() {
Text(pageName.backKey)
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 60
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": true,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"continuable": true,
"launchType": "singleton",
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
},
]
}
}

View File

@ -0,0 +1,16 @@
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "单实例迁移"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,7 @@
{
"src": [
"pages/index",
"pages/work",
"pages/study"
]
}

View File

@ -0,0 +1,17 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
module.exports = require('@ohos/hvigor-ohos-plugin').appTasks

View File

@ -0,0 +1,17 @@
{
"name": "myapplication",
"version": "1.0.0",
"ohos": {
"org": "ohos",
"buildTool": "hvigor",
"directoryLevel": "project"
},
"description": "example description",
"repository": {},
"license": "ISC",
"dependencies": {
"hypium": "^1.0.0",
"@ohos/hvigor": "1.0.6",
"@ohos/hvigor-ohos-plugin": "1.0.6"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -56,7 +56,6 @@ void BundleManagerInternalTest::SetUp()
* @tc.name: BundleManagerInternalTest_001
* @tc.desc: input invalid params
* @tc.type: FUNC
* @tc.require: AR000H3FD0
*/
HWTEST_F(BundleManagerInternalTest, BundleManagerInternalTest_001, TestSize.Level0)
{
@ -74,7 +73,6 @@ HWTEST_F(BundleManagerInternalTest, BundleManagerInternalTest_001, TestSize.Leve
* @tc.name: BundleManagerInternalTest_002
* @tc.desc: test ability info convert
* @tc.type: FUNC
* @tc.require: AR000H3FD0
*/
HWTEST_F(BundleManagerInternalTest, BundleManagerInternalTest_002, TestSize.Level0)
{

View File

@ -133,7 +133,6 @@ void DistributedSchedCallTest::TearDown()
* @tc.name: CallAbility_001
* @tc.desc: Call StartRemoteAbilityByCall with illegal want
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_001, TestSize.Level1)
{
@ -159,7 +158,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_001, TestSize.Level1)
* @tc.name: CallAbility_002
* @tc.desc: Call TryStartRemoteAbilityByCall with illegal parameter
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_002, TestSize.Level1)
{
@ -187,7 +185,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_002, TestSize.Level1)
* @tc.name: CallAbility_003
* @tc.desc: Call StartAbilityByCallFromRemote with illegal parameter
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_003, TestSize.Level1)
{
@ -217,7 +214,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_003, TestSize.Level1)
* @tc.name: CallAbility_004
* @tc.desc: Call StartAbilityByCall with illegal parameter
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_004, TestSize.Level1)
{
@ -242,7 +238,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_004, TestSize.Level1)
* @tc.name: CallAbility_005
* @tc.desc: Call ReleaseRemoteAbility with illegal parameter
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_005, TestSize.Level1)
{
@ -263,7 +258,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_005, TestSize.Level1)
* @tc.name: CallAbility_006
* @tc.desc: Call ReleaseAbilityFromRemote with illegal parameter
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_006, TestSize.Level1)
{
@ -299,7 +293,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_006, TestSize.Level1)
* @tc.name: CallAbility_007
* @tc.desc: Call ReleaseAbilityFromRemote with illegal callerInfo
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_007, TestSize.Level1)
{
@ -356,7 +349,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_007, TestSize.Level1)
* @tc.name: CallAbility_008
* @tc.desc: Call StartAbilityByCall with illegal parameter
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_008, TestSize.Level1)
{
@ -397,7 +389,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_008, TestSize.Level1)
* @tc.name: CallAbility_011
* @tc.desc: Call StartRemoteAbilityByCall with illegal callback
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_011, TestSize.Level1)
{
@ -422,7 +413,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_011, TestSize.Level1)
* @tc.name: CallAbility_012
* @tc.desc: Call StartRemoteAbilityByCall with illegal uid
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_012, TestSize.Level1)
{
@ -446,7 +436,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_012, TestSize.Level1)
* @tc.name: CallAbility_013
* @tc.desc: Call TryStartRemoteAbilityByCall with illegal callback
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_013, TestSize.Level1)
{
@ -472,7 +461,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_013, TestSize.Level1)
* @tc.name: CallAbility_014
* @tc.desc: Call TryStartRemoteAbilityByCall with illegal callerInfo
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_014, TestSize.Level1)
{
@ -516,7 +504,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_014, TestSize.Level1)
* @tc.name: CallAbility_015
* @tc.desc: Call StartAbilityByCallFromRemote with illegal callback
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_015, TestSize.Level1)
{
@ -551,7 +538,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_015, TestSize.Level1)
* @tc.name: CallAbility_016
* @tc.desc: Call StartAbilityByCall with illegal callback
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_016, TestSize.Level1)
{
@ -581,7 +567,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_016, TestSize.Level1)
* @tc.name: CallAbility_017
* @tc.desc: Call StartAbilityByCall with illegal token
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_017, TestSize.Level1)
{
@ -605,7 +590,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_017, TestSize.Level1)
* @tc.name: CallAbility_018
* @tc.desc: Call ReleaseRemoteAbility with illegal callback
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_018, TestSize.Level1)
{
@ -626,7 +610,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_018, TestSize.Level1)
* @tc.name: CallAbility_019
* @tc.desc: Call ReleaseRemoteAbility with illegal remote deviceId
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_019, TestSize.Level1)
{
@ -646,7 +629,6 @@ HWTEST_F(DistributedSchedCallTest, CallAbility_019, TestSize.Level1)
* @tc.name: CallAbility_020
* @tc.desc: Call ReleaseAbilityFromRemote with illegal callback
* @tc.type: FUNC
* @tc.require: AR000GK59A
*/
HWTEST_F(DistributedSchedCallTest, CallAbility_020, TestSize.Level1)
{

View File

@ -18,6 +18,7 @@
#define protected public
#include "ability_connect_callback_stub.h"
#include "distributed_sched_service.h"
#include "distributed_sched_util.h"
#include "if_system_ability_manager.h"
#include "ipc_skeleton.h"
#include "iservice_registry.h"
@ -109,6 +110,7 @@ void DistributedSchedConnectTest::TearDownTestCase()
void DistributedSchedConnectTest::SetUp()
{
DistributedSchedUtil::MockPermission();
}
void DistributedSchedConnectTest::TearDown()
@ -319,7 +321,6 @@ HWTEST_F(DistributedSchedConnectTest, ProcessConnectDied002, TestSize.Level0)
* @tc.name: ProcessConnectDied003
* @tc.desc: process connect died and check the trackingUidMap_
* @tc.type: FUNC
* @tc.require: AR000GI8IE
*/
HWTEST_F(DistributedSchedConnectTest, ProcessConnectDied003, TestSize.Level1)
{
@ -357,7 +358,6 @@ HWTEST_F(DistributedSchedConnectTest, ProcessConnectDied003, TestSize.Level1)
* @tc.name: ProcessConnectDied004
* @tc.desc: process connect died and check the connectAbilityMap_
* @tc.type: FUNC
* @tc.require: AR000GI8IE
*/
HWTEST_F(DistributedSchedConnectTest, ProcessConnectDied004, TestSize.Level1)
{
@ -498,7 +498,6 @@ HWTEST_F(DistributedSchedConnectTest, ProcessDeviceOffline003, TestSize.Level0)
* @tc.name: ProcessDeviceOffline004
* @tc.desc: process device offline and check the trackingUidMap_
* @tc.type: FUNC
* @tc.require: AR000GI8IE
*/
HWTEST_F(DistributedSchedConnectTest, ProcessDeviceOffline004, TestSize.Level1)
{
@ -535,7 +534,6 @@ HWTEST_F(DistributedSchedConnectTest, ProcessDeviceOffline004, TestSize.Level1)
* @tc.name: ProcessDeviceOffline005
* @tc.desc: process device offline and check the connectAbilityMap_
* @tc.type: FUNC
* @tc.require: AR000GI8IE
*/
HWTEST_F(DistributedSchedConnectTest, ProcessDeviceOffline005, TestSize.Level1)
{
@ -602,7 +600,6 @@ HWTEST_F(DistributedSchedConnectTest, DisconnectRemoteAbility001, TestSize.Level
* @tc.name: DisconnectRemoteAbility002
* @tc.desc: disconnect remote ability and check the trackingUidMap_
* @tc.type: FUNC
* @tc.require: AR000GI8IE
*/
HWTEST_F(DistributedSchedConnectTest, DisconnectRemoteAbility002, TestSize.Level1)
{

View File

@ -14,6 +14,7 @@
*/
#include "distributed_sched_continuation_test.h"
#include "distributed_sched_util.h"
#include "dtbschedmgr_device_info_storage.h"
#include "mock_distributed_sched.h"
@ -42,6 +43,7 @@ void DSchedContinuationTest::TearDownTestCase()
void DSchedContinuationTest::SetUp()
{
DistributedSchedUtil::MockPermission();
dschedContinuation_ = std::make_shared<DSchedContinuation>();
}
@ -494,7 +496,6 @@ HWTEST_F(DSchedContinuationTest, PopAbilityToken_003, TestSize.Level1)
* @tc.name: ContinueMission_001
* @tc.desc: test ContinueMission when srcDeviceId is empty.
* @tc.type: FUNC
* @tc.require: SR000GKT4A
*/
HWTEST_F(DSchedContinuationTest, ContinueMission_001, TestSize.Level1)
{
@ -510,7 +511,6 @@ HWTEST_F(DSchedContinuationTest, ContinueMission_001, TestSize.Level1)
* @tc.name: ContinueMission_002
* @tc.desc: test ContinueMission when dstDeviceId is empty.
* @tc.type: FUNC
* @tc.require: SR000GKT4A
*/
HWTEST_F(DSchedContinuationTest, ContinueMission_002, TestSize.Level1)
{
@ -526,7 +526,6 @@ HWTEST_F(DSchedContinuationTest, ContinueMission_002, TestSize.Level1)
* @tc.name: ContinueMission_003
* @tc.desc: test ContinueMission when callback is nullptr.
* @tc.type: FUNC
* @tc.require: SR000GKT4A
*/
HWTEST_F(DSchedContinuationTest, ContinueMission_003, TestSize.Level1)
{
@ -541,7 +540,6 @@ HWTEST_F(DSchedContinuationTest, ContinueMission_003, TestSize.Level1)
* @tc.name: ContinueMission_004
* @tc.desc: test ContinueMission when srcDeviceId == localDevId.
* @tc.type: FUNC
* @tc.require: SR000GKT4A
*/
HWTEST_F(DSchedContinuationTest, ContinueMission_004, TestSize.Level1)
{
@ -748,7 +746,6 @@ HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_004, TestSize.Level0
* @tc.name: StartFreeInstallFromRemote_005
* @tc.desc: call StartFreeInstallFromRemote with dms
* @tc.type: FUNC
* @tc.require: SR000GKT4A
*/
HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_005, TestSize.Level1)
{

Some files were not shown because too many files have changed in this diff Show More