diff --git a/network/DistributedAbility/README.md b/network/DistributedAbility/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..6bd402fe58f8c8d31e397a2f44171f73da6ff67c
--- /dev/null
+++ b/network/DistributedAbility/README.md
@@ -0,0 +1,4 @@
+# Device and Service Discovery & Connection
+
+- This sample demonstrates the discovery and connection of near-field devices and services based on distributed capabilities.
+
diff --git a/network/DistributedAbility/README_zh.md b/network/DistributedAbility/README_zh.md
new file mode 100644
index 0000000000000000000000000000000000000000..1de5535472ffd18fecf24f860f756349977b221a
--- /dev/null
+++ b/network/DistributedAbility/README_zh.md
@@ -0,0 +1,4 @@
+# 设备和服务的发现 & 连接
+
+- 本示例主要通过分布式能力,从而实现近场设备和服务的发现、连接。
+
diff --git a/network/DistributedAbility/build.gradle b/network/DistributedAbility/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..264163d3e73fe98369c39d72c4a81e6bfe80d40d
--- /dev/null
+++ b/network/DistributedAbility/build.gradle
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
+buildscript {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.huawei.ohos:hap:2.4.4.2'
+ }
+}
+allprojects {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
+ }
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/client/build.gradle b/network/DistributedAbility/client/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..1c938769a31cc95b93d64184bc925d2a47d6d8fc
--- /dev/null
+++ b/network/DistributedAbility/client/build.gradle
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+apply plugin: 'com.huawei.ohos.hap'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+}
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+}
diff --git a/network/DistributedAbility/client/src/main/config.json b/network/DistributedAbility/client/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..1f9d41aad1ff38b41dd08a9e5b4544570f708850
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/config.json
@@ -0,0 +1,62 @@
+{
+ "app": {
+ "bundleName": "ohos.samples.distributedclient",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.samples.distributedclient",
+ "name": ".MainAbility",
+ "reqCapabilities": [
+ "video_support"
+ ],
+ "deviceType": [
+ "default"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "client",
+ "moduleType": "entry",
+ "installationFree":false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "portrait",
+ "formsEnabled": false,
+ "name": ".MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE"
+ },
+ {
+ "name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO"
+ },
+ {
+ "name": "ohos.permission.GET_BUNDLE_INFO"
+ },
+ {
+ "name": "ohos.permission.DISTRIBUTED_DATASYNC"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/client/src/main/idl/ohos/samples/distributedserver/IRemoteAgent.idl b/network/DistributedAbility/client/src/main/idl/ohos/samples/distributedserver/IRemoteAgent.idl
new file mode 100644
index 0000000000000000000000000000000000000000..a6545b53883b4895dfac6cb8c7b014c816edabbc
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/idl/ohos/samples/distributedserver/IRemoteAgent.idl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// IRemoteAgent.idl
+
+// Declare any non-default types here with sequenceable or interface statements
+
+interface ohos.samples.distributedserver.IRemoteAgent {
+ /*
+ * Demo service method use some parameters
+ */
+ void setRemoteObject();
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/DevicePlugin.java b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/DevicePlugin.java
new file mode 100644
index 0000000000000000000000000000000000000000..441976ac36b9ad69351f72a82e3b53f09e167c53
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/DevicePlugin.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedclient;
+
+import ohos.samples.distributedclient.interfaces.DeviceListener;
+import ohos.samples.distributedclient.utils.LogUtil;
+import ohos.samples.distributedserver.RemoteAgentProxy;
+import ohos.samples.distributedserver.RemoteAgentStub;
+
+import ohos.aafwk.ability.IAbilityConnection;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.Operation;
+import ohos.app.Context;
+import ohos.bundle.ElementName;
+import ohos.distributedschedule.interwork.DeviceInfo;
+import ohos.distributedschedule.interwork.DeviceManager;
+import ohos.distributedschedule.interwork.IDeviceStateCallback;
+import ohos.rpc.IRemoteObject;
+import ohos.rpc.RemoteException;
+
+import java.util.List;
+
+/**
+ * Device Plugin class
+ */
+public class DevicePlugin {
+ private static final String TAG = DevicePlugin.class.getSimpleName();
+
+ private static final String REMOTE_BUNDLE_NAME = "ohos.samples.distributedserver";
+
+ private static final String REMOTE_ABILITY_NAME = "ohos.samples.distributedserver.RemoteAbility";
+
+ private static volatile DevicePlugin instance = null;
+
+ private List deviceInfoList;
+
+ private Context context;
+
+ private String remoteDeviceId;
+
+ private DeviceListener listener;
+
+ private IAbilityConnection connection = new IAbilityConnection() {
+ @Override
+ public void onAbilityConnectDone(ElementName elementName, IRemoteObject iRemoteObject, int resultCode) {
+ LogUtil.info(TAG, "onAbilityConnectDone resultCode:" + resultCode);
+ RemoteAgentProxy remoteAgentProxy = new RemoteAgentProxy(iRemoteObject);
+ try {
+ remoteAgentProxy.setRemoteObject();
+ } catch (RemoteException e) {
+ LogUtil.error(TAG, "onAbilityConnectDone RemoteException");
+ }
+ listener.updateResult("Connect " + (resultCode == 0 ? "Success" : "Failed"));
+ }
+
+ @Override
+ public void onAbilityDisconnectDone(ElementName elementName, int resultCode) {
+ LogUtil.info(TAG, "ability disconnect done ");
+ listener.updateResult("Disconnect " + (resultCode == 0 ? "Success" : "Failed"));
+ }
+ };
+
+ private IDeviceStateCallback iDeviceStateCallback = new IDeviceStateCallback() {
+ @Override
+ public void onDeviceOffline(String deviceId, int deviceType) {
+ LogUtil.info(TAG, "onDeviceOffline , deviceId: " + deviceId);
+ DeviceInfo deviceInfo = DeviceManager.getDeviceInfo(deviceId);
+ listener.updateResult("Offline : " + (deviceInfo == null ? "Unknown" : deviceInfo.getDeviceName()));
+ }
+
+ @Override
+ public void onDeviceOnline(String deviceId, int deviceType) {
+ LogUtil.info(TAG, "onDeviceOnline , deviceId: " + deviceId);
+ DeviceInfo deviceInfo = DeviceManager.getDeviceInfo(deviceId);
+ listener.updateResult("Online : " + (deviceInfo == null ? "Unknown" : deviceInfo.getDeviceName()));
+ }
+ };
+
+ /**
+ * scan remote ability devices list
+ *
+ * @return current distribute net device list
+ */
+ public List scanRemoteAbility() {
+ deviceInfoList = DeviceManager.getDeviceList(DeviceInfo.FLAG_GET_ALL_DEVICE);
+ return deviceInfoList;
+ }
+
+ /**
+ * connect remote ability
+ *
+ * @param deviceInfo remoteAbility device info.
+ * @param context context.
+ */
+ public void connectAbility(Context context, DeviceInfo deviceInfo) {
+ remoteDeviceId = deviceInfo.getDeviceId();
+ Intent intent = new Intent();
+ Operation operation = new Intent.OperationBuilder().withDeviceId(remoteDeviceId)
+ .withBundleName(REMOTE_BUNDLE_NAME)
+ .withAbilityName(REMOTE_ABILITY_NAME)
+ .withFlags(Intent.FLAG_ABILITYSLICE_MULTI_DEVICE)
+ .build();
+ intent.setOperation(operation);
+ intent.setParam("ClientDeviceName", deviceInfo.getDeviceName());
+ context.connectAbility(intent, connection);
+ }
+
+ /**
+ * disconnect remote ability
+ *
+ * @return connect result
+ */
+ public boolean stopRemoteConnectedAbility() {
+ if (connection != null) {
+ context.disconnectAbility(connection);
+ LogUtil.info(TAG, "stopRemoteConnectAbility");
+ }
+ return true;
+ }
+
+ /**
+ * init device listener
+ *
+ * @param deviceListener device listener
+ */
+ public void initListener(DeviceListener deviceListener) {
+ listener = deviceListener;
+ }
+
+ /**
+ * register device state listener
+ */
+ public void registerDeviceStateListener() {
+ boolean registerResult = DeviceManager.registerDeviceStateCallback(iDeviceStateCallback);
+ listener.updateResult("Register " + (registerResult ? "Success" : "Failed"));
+ }
+
+ /**
+ * unregister device state listener
+ */
+ public void unRegisterDeviceStateListener() {
+ boolean unRegisterResult = DeviceManager.unregisterDeviceStateCallback(iDeviceStateCallback);
+ listener.updateResult("UnRegister " + (unRegisterResult ? "Success" : "Failed"));
+ }
+
+ /**
+ * Register context
+ *
+ * @param context context.
+ */
+ public void register(Context context) {
+ this.context = context;
+ }
+
+ /**
+ * Constructor used to create a DeviceManagerPlugin instance.
+ *
+ * @return instance of DeviceManagerPlugin
+ */
+ public static DevicePlugin getInstance() {
+ if (instance == null) {
+ synchronized (DevicePlugin.class) {
+ if (instance == null) {
+ instance = new DevicePlugin();
+ }
+ }
+ }
+ return instance;
+ }
+}
diff --git a/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/MainAbility.java b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..80363c44b5dec38bf94e637f771311bacdc320fc
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/MainAbility.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedclient;
+
+import ohos.samples.distributedclient.slice.MainAbilitySlice;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.bundle.IBundleManager;
+import ohos.security.SystemPermission;
+
+/**
+ * MainAbility
+ */
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+
+ requestPermission();
+ }
+
+ private void requestPermission() {
+ if (verifySelfPermission(SystemPermission.DISTRIBUTED_DATASYNC) != IBundleManager.PERMISSION_GRANTED) {
+ requestPermissionsFromUser(new String[] {SystemPermission.DISTRIBUTED_DATASYNC}, 0);
+ }
+ }
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/interfaces/DeviceListener.java b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/interfaces/DeviceListener.java
new file mode 100644
index 0000000000000000000000000000000000000000..95e7de4d4330b905ca06bf957ffaf006ba61d400
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/interfaces/DeviceListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedclient.interfaces;
+
+/**
+ * WifiEventListener
+ * Handles the callbacks for wifi events
+ */
+public interface DeviceListener {
+ void updateResult(String message);
+}
diff --git a/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/provider/DeviceProvider.java b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/provider/DeviceProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..e84cbcc2d4951d8311067c822ed57e954293bdbf
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/provider/DeviceProvider.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedclient.provider;
+
+import ohos.samples.distributedclient.DevicePlugin;
+import ohos.samples.distributedclient.ResourceTable;
+import ohos.samples.distributedclient.slice.MainAbilitySlice;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.RecycleItemProvider;
+import ohos.agp.components.Text;
+import ohos.app.Context;
+import ohos.distributedschedule.interwork.DeviceInfo;
+
+import java.util.List;
+
+/**
+ * DeviceProvider
+ */
+public class DeviceProvider extends RecycleItemProvider {
+ private Context context;
+
+ private List deviceInfoList;
+
+ private DevicePlugin devicePlugin;
+
+ public DeviceProvider(MainAbilitySlice mainAbilitySlice, List deviceInfoList,
+ DevicePlugin devicePlugin) {
+ this.context = mainAbilitySlice;
+ this.deviceInfoList = deviceInfoList;
+ this.devicePlugin = devicePlugin;
+ }
+
+ @Override
+ public int getCount() {
+ return deviceInfoList.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return deviceInfoList.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public Component getComponent(int position, Component component, ComponentContainer componentContainer) {
+ return getItemComponent(position);
+ }
+
+ private Component getItemComponent(int position) {
+ DeviceInfo item = deviceInfoList.get(position);
+ Component container = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_list_item, null, false);
+ Text deviceName = (Text) container.findComponentById(ResourceTable.Id_device_name);
+ Text deviceId = (Text) container.findComponentById(ResourceTable.Id_device_id);
+ deviceName.setText(item.getDeviceName() == null ? "Unknown" : item.getDeviceName());
+ deviceId.setText(item.getDeviceId());
+ container.setClickedListener(component -> devicePlugin.connectAbility(context, item));
+ return container;
+ }
+
+ /**
+ * update provider data
+ *
+ * @param data deviceInfo list data
+ */
+ public void updateData(List data) {
+ this.deviceInfoList = data;
+ notifyDataChanged();
+ }
+}
+
+
diff --git a/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/slice/MainAbilitySlice.java b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..9326d38bacc1e929ff689c46a102b49180b007e7
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/slice/MainAbilitySlice.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedclient.slice;
+
+import ohos.samples.distributedclient.DevicePlugin;
+import ohos.samples.distributedclient.ResourceTable;
+import ohos.samples.distributedclient.interfaces.DeviceListener;
+import ohos.samples.distributedclient.provider.DeviceProvider;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Button;
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.ListContainer;
+import ohos.agp.components.Text;
+import ohos.agp.window.dialog.CommonDialog;
+import ohos.agp.window.dialog.ToastDialog;
+import ohos.distributedschedule.interwork.DeviceInfo;
+import ohos.eventhandler.EventHandler;
+import ohos.eventhandler.EventRunner;
+import ohos.eventhandler.InnerEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * MainAbilitySlice
+ */
+public class MainAbilitySlice extends AbilitySlice implements DeviceListener {
+ private static final int DIALOG_WIDTH = 900;
+
+ private static final int DIALOG_HEIGHT = 300;
+
+ private static final int DIALOG_CORNER_RADIUS = 30;
+
+ private static final int UPDATE_RESULT_MESSAGE = 0x1000001;
+
+ private DevicePlugin devicePlugin;
+
+ private List deviceInfoList = new ArrayList<>();
+
+ private DeviceProvider deviceProvider;
+
+ private String dialogMessage;
+
+ private EventHandler handler = new EventHandler(EventRunner.current()) {
+ @Override
+ protected void processEvent(InnerEvent event) {
+ showDialog(dialogMessage);
+ scanRemoteAbility(false);
+ }
+ };
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_main_layout);
+
+ initDevicePlugin();
+ initComponents();
+ }
+
+ private void initDevicePlugin() {
+ devicePlugin = DevicePlugin.getInstance();
+ devicePlugin.register(this);
+ devicePlugin.initListener(this);
+ }
+
+ private void initComponents() {
+ Component scanBtn = findComponentById(ResourceTable.Id_scan_btn);
+ Component registerBtn = findComponentById(ResourceTable.Id_register_change_btn);
+ Component unRegisterBtn = findComponentById(ResourceTable.Id_unregister_btn);
+ Component unDisconnectBtn = findComponentById(ResourceTable.Id_disconnect_btn);
+ registerBtn.setClickedListener(component -> devicePlugin.registerDeviceStateListener());
+ unRegisterBtn.setClickedListener(component -> devicePlugin.unRegisterDeviceStateListener());
+ unDisconnectBtn.setClickedListener(component -> devicePlugin.stopRemoteConnectedAbility());
+ scanBtn.setClickedListener(component -> scanRemoteAbility(true));
+ deviceProvider = new DeviceProvider(this, deviceInfoList, devicePlugin);
+ ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_container_list);
+ listContainer.setItemProvider(deviceProvider);
+ }
+
+ private void scanRemoteAbility(boolean showToast) {
+ deviceInfoList = devicePlugin.scanRemoteAbility();
+ deviceProvider.updateData(deviceInfoList);
+ if (showToast) {
+ showTip("scan deviceInfoList size : " + deviceInfoList.size());
+ }
+ }
+
+ private void showTip(String msg) {
+ new ToastDialog(this).setContentText(msg).show();
+ }
+
+ @Override
+ public void updateResult(String message) {
+ dialogMessage = message;
+ handler.sendEvent(UPDATE_RESULT_MESSAGE);
+ }
+
+ private void showDialog(String message) {
+ Component container = LayoutScatter.getInstance(this).parse(ResourceTable.Layout_dialog_layout, null, false);
+ Text content = (Text) container.findComponentById(ResourceTable.Id_message);
+ content.setText(message);
+ CommonDialog commonDialog = new CommonDialog(this);
+ commonDialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
+ commonDialog.setCornerRadius(DIALOG_CORNER_RADIUS);
+ commonDialog.setContentCustomComponent(container);
+ commonDialog.show();
+ Button btnOk = (Button) container.findComponentById(ResourceTable.Id_btn_ok);
+ btnOk.setClickedListener(component -> commonDialog.hide());
+ }
+}
diff --git a/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/utils/LogUtil.java b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/utils/LogUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..2e12978e073fac5615ba19e6b0c33b87cf68613b
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/java/ohos/samples/distributedclient/utils/LogUtil.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedclient.utils;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+import java.util.Locale;
+
+/**
+ * Log utils
+ */
+public class LogUtil {
+ private static final String TAG_LOG = "[DistributedClient] ";
+
+ private static final int DOMAIN_ID = 0xD000F00;
+
+ private static final HiLogLabel LABEL_LOG = new HiLogLabel(3, DOMAIN_ID, LogUtil.TAG_LOG);
+
+ private static final String LOG_FORMAT = "%s: %s";
+
+ private LogUtil() {
+ }
+ /**
+ * Print info log
+ *
+ * @param tag log tag
+ * @param msg log message
+ */
+ public static void info(String tag, String msg) {
+ HiLog.info(LABEL_LOG, String.format(Locale.ROOT, LOG_FORMAT, tag, msg));
+ }
+
+ /**
+ * Print error log
+ *
+ * @param tag log tag
+ * @param msg log message
+ */
+ public static void error(String tag, String msg) {
+ HiLog.error(LABEL_LOG, String.format(Locale.ROOT, LOG_FORMAT, tag, msg));
+ }
+}
diff --git a/network/DistributedAbility/client/src/main/resources/base/element/string.json b/network/DistributedAbility/client/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..e66260c9906c504503edbb044ddeab2c877abde1
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "DistributedAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "hap sample empty page"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/client/src/main/resources/base/graphic/bg.xml b/network/DistributedAbility/client/src/main/resources/base/graphic/bg.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d5138e190734b0fa268ca98ab449e8be012016ac
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/resources/base/graphic/bg.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/network/DistributedAbility/client/src/main/resources/base/layout/dialog_layout.xml b/network/DistributedAbility/client/src/main/resources/base/layout/dialog_layout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..23a642962769463c2ce9876cd8b2afd18fee29ba
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/resources/base/layout/dialog_layout.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/network/DistributedAbility/client/src/main/resources/base/layout/list_item.xml b/network/DistributedAbility/client/src/main/resources/base/layout/list_item.xml
new file mode 100644
index 0000000000000000000000000000000000000000..765f8d6e5b2b27fd185b00faa12fe54bbb1d3577
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/resources/base/layout/list_item.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/network/DistributedAbility/client/src/main/resources/base/layout/main_layout.xml b/network/DistributedAbility/client/src/main/resources/base/layout/main_layout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..83e2c3357abf525d8d1459ab6377d02573c5f3bf
--- /dev/null
+++ b/network/DistributedAbility/client/src/main/resources/base/layout/main_layout.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/network/DistributedAbility/client/src/main/resources/base/media/icon.png b/network/DistributedAbility/client/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/network/DistributedAbility/client/src/main/resources/base/media/icon.png differ
diff --git a/network/DistributedAbility/screenshots/device/main.png b/network/DistributedAbility/screenshots/device/main.png
new file mode 100644
index 0000000000000000000000000000000000000000..038c07e88315de4bea458118e1acf9fa563ba8fb
Binary files /dev/null and b/network/DistributedAbility/screenshots/device/main.png differ
diff --git a/network/DistributedAbility/screenshots/phone/client_main.png b/network/DistributedAbility/screenshots/phone/client_main.png
new file mode 100644
index 0000000000000000000000000000000000000000..7277564b8e4706c8cbfcd2af3c81d2f572fabf2c
Binary files /dev/null and b/network/DistributedAbility/screenshots/phone/client_main.png differ
diff --git a/network/DistributedAbility/screenshots/phone/connect_msg.png b/network/DistributedAbility/screenshots/phone/connect_msg.png
new file mode 100644
index 0000000000000000000000000000000000000000..96ca7d4ef14a458a4cacf9bb78ce913f974f02af
Binary files /dev/null and b/network/DistributedAbility/screenshots/phone/connect_msg.png differ
diff --git a/network/DistributedAbility/screenshots/phone/permission.png b/network/DistributedAbility/screenshots/phone/permission.png
new file mode 100644
index 0000000000000000000000000000000000000000..19b23caacfdc5bbbaf6149fdcadfef18715cc93a
Binary files /dev/null and b/network/DistributedAbility/screenshots/phone/permission.png differ
diff --git a/network/DistributedAbility/screenshots/phone/server_disconnected.png b/network/DistributedAbility/screenshots/phone/server_disconnected.png
new file mode 100644
index 0000000000000000000000000000000000000000..862f560f050159c754904e461ecf134271c59216
Binary files /dev/null and b/network/DistributedAbility/screenshots/phone/server_disconnected.png differ
diff --git a/network/DistributedAbility/server/build.gradle b/network/DistributedAbility/server/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..a3c4f1ddc2f638851376bb15ae0877424eecc467
--- /dev/null
+++ b/network/DistributedAbility/server/build.gradle
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+apply plugin: 'com.huawei.ohos.hap'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+}
diff --git a/network/DistributedAbility/server/src/main/config.json b/network/DistributedAbility/server/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..bd4837d8017c9468fe9778bf6f59c366141bfd96
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/config.json
@@ -0,0 +1,66 @@
+{
+ "app": {
+ "bundleName": "ohos.samples.distributedserver",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.samples.distributedserver",
+ "name": ".MainAbility",
+ "reqCapabilities": [
+ "video_support"
+ ],
+ "deviceType": [
+ "default"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "server",
+ "moduleType": "entry",
+ "installationFree":false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "portrait",
+ "formsEnabled": false,
+ "name": ".MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "visible": true,
+ "name": ".RemoteAbility",
+ "icon": "$media:icon",
+ "description": "$string:serviceability_description",
+ "type": "service"
+ }
+ ],
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE"
+ },
+ {
+ "name": "ohos.permission.DISTRIBUTED_DATASYNC"
+ },
+ {
+ "name": "ohos.permission.SYSTEM_FLOAT_WINDOW"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/server/src/main/idl/ohos/samples/distributedserver/IRemoteAgent.idl b/network/DistributedAbility/server/src/main/idl/ohos/samples/distributedserver/IRemoteAgent.idl
new file mode 100644
index 0000000000000000000000000000000000000000..24b7da3951f781b46000dfddb79dafcb0233d216
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/idl/ohos/samples/distributedserver/IRemoteAgent.idl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// IRemoteAgent.idl
+
+// Declare any non-default types here with sequenceable or interface statements
+interface ohos.samples.distributedserver.IRemoteAgent {
+ /*
+ * Demo service method use some parameters
+ */
+ void setRemoteObject();
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/MainAbility.java b/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..c74083629b6364296da346a143fd3fd2e67f4fbf
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/MainAbility.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedserver;
+
+import ohos.samples.distributedserver.slice.MainAbilitySlice;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.bundle.IBundleManager;
+import ohos.security.SystemPermission;
+
+/**
+ * MainAbility
+ */
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+
+ requestPermission();
+ }
+
+ private void requestPermission() {
+ if (verifySelfPermission(SystemPermission.DISTRIBUTED_DATASYNC) != IBundleManager.PERMISSION_GRANTED) {
+ requestPermissionsFromUser(new String[] {SystemPermission.DISTRIBUTED_DATASYNC}, 0);
+ }
+ }
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/RemoteAbility.java b/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/RemoteAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..6bd69c697b8aff57ac38670eb0791a6332e4e03b
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/RemoteAbility.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedserver;
+
+import ohos.samples.distributedserver.utils.LogUtil;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Button;
+import ohos.agp.components.Component;
+import ohos.agp.components.DirectionalLayout;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.Text;
+import ohos.agp.window.dialog.CommonDialog;
+import ohos.event.notification.NotificationHelper;
+import ohos.event.notification.NotificationRequest;
+import ohos.rpc.IRemoteObject;
+import ohos.rpc.RemoteException;
+
+/**
+ * Custom service type atomic ability for distributed input method.
+ */
+public final class RemoteAbility extends Ability {
+ private static final String TAG = RemoteAbility.class.getSimpleName();
+
+ private static final String ABILITY_DESCRIPTION = "ohos.samples.distributedserver.RemoteAbility";
+
+ private static final int NOTIFICATION_ID = 10013;
+
+ private static final int DIALOG_WIDTH = 900;
+
+ private static final int DIALOG_CORNER_RADIUS = 30;
+
+ private RemoteAgentStub remoteAgent = new RemoteAgentStub(ABILITY_DESCRIPTION) {
+ @Override
+ public void setRemoteObject() {
+ LogUtil.info(TAG, " RemoteAgentStub setRemoteObject");
+ }
+ };
+
+ @Override
+ public IRemoteObject onConnect(Intent intent) {
+ String connectedDeviceName = intent.getStringParam("ClientDeviceName");
+ LogUtil.info(TAG, "onConnect Success , ConnectedDeviceName : " + connectedDeviceName);
+ super.onConnect(intent);
+ showDialog("Connect Success");
+ showNotification(this, NOTIFICATION_ID, "DistributedServer message", "Connect Success");
+ return remoteAgent;
+ }
+
+ @Override
+ public void onDisconnect(Intent intent) {
+ super.onDisconnect(intent);
+ showNotification(this, NOTIFICATION_ID, "DistributedServer message", "Disconnected");
+ showDialog("Disconnected");
+ cancelBackgroundRunning();
+ }
+
+ @Override
+ public void onStop() {
+ LogUtil.info(TAG, "onStop");
+ super.onStop();
+ cancelBackgroundRunning();
+ }
+
+ private void showNotification(Ability ability, int notificationId, String title, String text) {
+ NotificationRequest.NotificationNormalContent content = new NotificationRequest.NotificationNormalContent();
+ content.setTitle(title).setText(text);
+ NotificationRequest.NotificationContent notificationContent = new NotificationRequest.NotificationContent(
+ content);
+ NotificationRequest request = new NotificationRequest(notificationId);
+ request.setContent(notificationContent);
+ ability.keepBackgroundRunning(notificationId, request);
+ try {
+ NotificationHelper.publishNotification(request);
+ } catch (RemoteException e) {
+ LogUtil.error(TAG, "Exception in showNotification");
+ }
+ }
+
+ private void showDialog(String message) {
+ Component container = LayoutScatter.getInstance(this).parse(ResourceTable.Layout_dialog_layout, null, false);
+ Text content = (Text) container.findComponentById(ResourceTable.Id_message);
+ content.setText(message);
+ CommonDialog commonDialog = new CommonDialog(this);
+ commonDialog.setSize(DIALOG_WIDTH, DirectionalLayout.LayoutConfig.MATCH_CONTENT);
+ commonDialog.setCornerRadius(DIALOG_CORNER_RADIUS);
+ commonDialog.setContentCustomComponent(container);
+ commonDialog.show();
+ Button btnOk = (Button) container.findComponentById(ResourceTable.Id_btn_ok);
+ btnOk.setClickedListener(component -> commonDialog.hide());
+ }
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/slice/MainAbilitySlice.java b/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..e8e6757f24032bbca81c851e399a509a3bc7446d
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/slice/MainAbilitySlice.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedserver.slice;
+
+import ohos.samples.distributedserver.ResourceTable;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+
+/**
+ * MainAbilitySlice
+ */
+public class MainAbilitySlice extends AbilitySlice {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_main_layout);
+ }
+}
diff --git a/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/utils/LogUtil.java b/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/utils/LogUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..7233ee5a88536f95afa275b0ef46e7ac7c11d8f4
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/java/ohos/samples/distributedserver/utils/LogUtil.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ohos.samples.distributedserver.utils;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+import java.util.Locale;
+
+/**
+ * Custom log util.
+ */
+public class LogUtil {
+ private static final String TAG_LOG = "DistributedServer";
+
+ private static final int DOMAIN_ID = 0xD000F00;
+
+ private static final HiLogLabel LABEL_LOG = new HiLogLabel(3, DOMAIN_ID, LogUtil.TAG_LOG);
+
+ private static final String LOG_FORMAT = "%s: %s";
+
+ private static final String HI_LOG_FORMAT = "%{public}s";
+
+ private LogUtil() {
+ /* Do nothing */
+ }
+
+ /**
+ * Print info log message
+ *
+ * @param className class name
+ * @param msg info log message
+ */
+ public static void info(String className, String msg) {
+ HiLog.info(LABEL_LOG, HI_LOG_FORMAT, String.format(Locale.ROOT, LOG_FORMAT, className, msg));
+ }
+
+ /**
+ * Print error log message
+ *
+ * @param className class name
+ * @param msg error log message
+ */
+ public static void error(String className, String msg) {
+ HiLog.error(LABEL_LOG, HI_LOG_FORMAT, String.format(Locale.ROOT, LOG_FORMAT, className, msg));
+ }
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/server/src/main/resources/base/element/string.json b/network/DistributedAbility/server/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..31cfed78f46285b4a20ae215d7d72c20ed7a0724
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "DistributedServer"
+ },
+ {
+ "name": "mainability_description",
+ "value": "hap sample empty page"
+ },
+ {
+ "name": "serviceability_description",
+ "value": "hap sample empty service"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/network/DistributedAbility/server/src/main/resources/base/layout/dialog_layout.xml b/network/DistributedAbility/server/src/main/resources/base/layout/dialog_layout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..23a642962769463c2ce9876cd8b2afd18fee29ba
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/resources/base/layout/dialog_layout.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/network/DistributedAbility/server/src/main/resources/base/layout/main_layout.xml b/network/DistributedAbility/server/src/main/resources/base/layout/main_layout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ef166bb3fafa3128bbcb50dacf7c0c3cd065d660
--- /dev/null
+++ b/network/DistributedAbility/server/src/main/resources/base/layout/main_layout.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/network/DistributedAbility/server/src/main/resources/base/media/icon.png b/network/DistributedAbility/server/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/network/DistributedAbility/server/src/main/resources/base/media/icon.png differ
diff --git a/network/DistributedAbility/settings.gradle b/network/DistributedAbility/settings.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..53efddc4cbafef3cb5ad8b1c4b60ca00be2a3012
--- /dev/null
+++ b/network/DistributedAbility/settings.gradle
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+include ':client', ':server'