Method and apparatus for sharing device
Embodiments of this application provide a method and an apparatus for sharing a device. The method is: A first electronic device displays a first interface, where the first interface includes N to-be-shared devices; the first electronic device receives an operation that a user selects a target device and a target user, and displays a second interface, where the second interface includes a plurality of options, different options in the plurality of options correspond to different use permissions, and different use permissions allow the target user to use different function properties; the first electronic device receives an operation that the user selects a target option from the plurality of options and an operation that the user determines to share the target device with the target user by using a use permission corresponding to the target option.
1 . A method for sharing a device, wherein the method comprises:
displaying, by a first electronic device, a first interface, wherein the first interface comprises a first control and one or more to-be-shared devices, and the first control is configured to indicate that the first interface is an interface for sharing a device;
receiving, by the first electronic device, an operation that a user selects a target device from the one or more to-be-shared devices;
receiving, by the first electronic device, an operation that the user selects a target user;
displaying, by the first electronic device, a second interface, wherein the second interface comprises a plurality of options, different options in the plurality of options correspond to different use permissions, and different use permissions allow the target user to use different function properties;
receiving, by the first electronic device, an operation that the user selects a target option from the plurality of options;
receiving, by the first electronic device, an operation that the user determines to share the target device with the target user by using a use permission corresponding to the target option;
sending, by the first electronic device, a device sharing request to a second electronic device via a cloud server, wherein the device sharing request carries an identifier of the target user and a use permission of the target user; and
causing the second electronic device to display a third interface, wherein the third interface comprises a first control corresponding to a function property that is of the target device and that the target user is allowed to use, and the first control is in an operable state.
2 . The method according to claim 1 , wherein the receiving, by the first electronic device, an operation of selecting a target user comprises:
displaying, by the first electronic device, a fourth interface, wherein the fourth interface comprises one or more sharing protocols used to share the target device; and receiving, by the first electronic device, an operation that the user selects a first sharing protocol from the one or more sharing protocols used to share the target device, and receiving an operation that the user selects the target user by using the first protocol; or
displaying, by the first electronic device, a fifth interface, wherein the fifth interface comprises one or more sharing protocols used to share the target device and an option used to directly share the target device with one or more users; and receiving, by the first electronic device, an operation that the user selects the target user from the option used to directly share the target device with one or more users.
3 . The method according to claim 1 ,
wherein the cloud server is configured to:
receive the device sharing request, and matching the use permission of the target user with a function property label of the target device to obtain a first matching result, wherein the function property label is used to describe a type of a function property of the target device, and the matching result is used to indicate a function property that the target user is allowed to use and a function property that the target user is not allowed to use;
generate a first plug-in based on the first matching result, wherein the first plug-in comprises the function property that the target user is allowed to use; and
send the first plug-in to the second electronic device
to allow the second electronic device to install the first plug-in.
4 . The method according to claim 1 , wherein
types of function properties are classified based on at least one of operation complexity
security requirements, or
roles of the function properties.
5 . The method according to claim 4 , wherein the function property comprises at least one of the following fields: a property identifier ID, a data type, and an access manner, and the access manner comprises at least one of reading, writing, listening, or setting to null.
6 . The method according to claim 1 , wherein the method further comprises:
establishing, by the first electronic device, a communication connection and binding to the target device.
7 . The method according to claim 1 , wherein the method further comprises:
in response to an operation that the user opens a control interface of the target device, displaying, by the first electronic device, the control interface of the target device, wherein the control interface displayed on the first electronic device comprises a second control corresponding to all function properties of the target device, and the second control is in an operable state.
8 . The method according to claim 1 , wherein the use permission of the target user is set by the first electronic device by default.
9 . The method according to claim 1 , wherein
the plurality of options respectively correspond to a first permission, a second permission, and a third permission, wherein
the first permission is used to indicate that a first function property of the target device is allowed to be directly used, the second permission is used to indicate that a second function property of the target device is allowed to be directly used, the third permission is used to indicate that a third function property of the target device is allowed to be directly used, and the first function property, the second function property, and the third function property are not entirely the same.
10 . The method according to claim 9 , wherein if the target device is a door lock device,
the first function property comprises at least one of real-time status checking, near-field door opening, or battery level checking;
the second function property comprises the first function property and at least one of remote door opening or biological information entering; and
the third function property comprises the second function property and at least one of password management or checking a historical video of a camera.
11 . The method according to claim 8 , wherein the permission of the target user is a fourth permission, the fourth permission is used to indicate that a fourth function property of the target device is allowed to be directly used, and that a fifth function property of the target device is allowed to be used after a preset password is entered, and the fourth function property is different from the fifth function property.
12 . The method according to claim 1 , wherein
the cloud server is further configured to receive a device profile of the target device from the target device or the first electronic device, wherein the device profile comprises a plurality of function properties of the target device, and each of the plurality of function properties corresponds to one function property label.
13 . The method according to claim 3 , wherein
the first plug-in comprises all the function properties of the target device, and in all the function properties, the function property that the target user is allowed to use is readable and writable, and the function property that the target user is not allowed to use is unreadable and unwritable; or
the first plug-in comprises only the function property that the target user is allowed to use in all the function properties of the target device, and the function property that the target user is allowed to use is readable and writable.
14 . The method according to claim 7 , wherein the second electronic device is further configured to:
display the first control, wherein the first control is in an operable state; or
the second control corresponding to all the function properties of the target device is displayed, wherein the second control comprises the first control and a third control corresponding to the function property that the target user is not allowed to use, the first control is in an operable state, and the third control is set to gray.
15 . A non-transitory computer-readable storage medium storing computer-readable instructions, which when executed, cause a first electronic device to at least:
display a first interface, wherein the first interface comprises a first control and one or more to-be-shared devices, and the first control is configured to indicate that the first interface is an interface for sharing a device;
receive an operation that a user selects a target device from the one or more to-be-shared devices;
receive an operation that the user selects a target user;
display a second interface, wherein the second interface comprises a plurality of options, different options in the plurality of options correspond to different use permissions, and different use permissions allow the target user to use different function properties;
receive an operation that the user selects a target option from the plurality of options;
receive an operation that the user determines to share the target device with the target user by using a use permission corresponding to the target option; and
send a device sharing request to a second electronic device via a cloud server, wherein the device sharing request carries an identifier of the target user and a use permission of the target user; wherein
the second electronic device is configured to display a third interface, wherein the third interface comprises a first control corresponding to a function property that is of the target device and that the target user is allowed to use, and the first control is in an operable state.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein the cloud server is configured to:
receive the device sharing request, and match the use permission of the target user with a function property label of the target device to obtain a first matching result, wherein the function property label is used to describe a type of a function property of the target device, and the matching result is used to indicate a function property that the target user is allowed to use and a function property that the target user is not allowed to use;
generate a first plug-in based on the first matching result, wherein the first plug-in comprises the function property that the target user is allowed to use; and
send the first plug-in to the second electronic device, wherein the second electronic device is configured to install the first plug-in.
17 . The non-transitory computer-readable storage medium according to claim 15 , wherein the receiving an operation of selecting a target user comprises:
displaying a fourth interface, wherein the fourth interface comprises one or more sharing protocols used to share the target device; and receiving an operation that the user selects a first sharing protocol from the one or more sharing protocols used to share the target device, and receiving an operation that the user selects the target user by using the first protocol; or
displaying a fifth interface, wherein the fifth interface comprises one or more sharing protocols used to share the target device and an option used to directly share the target device with one or more users; and receiving an operation that the user selects the target user from the option used to directly share the target device with one or more users.
18 . A first electronic device, comprising one or more processors and a memory, wherein
the memory is coupled to the one or more processors, the memory is configured to store computer program code, the computer program code comprises computer instructions, and the one or more processors invoke the computer instructions to cause the first electronic device to:
display a first interface, wherein the first interface comprises a first control and one or more to-be-shared devices, and the first control is configured to indicate that the first interface is an interface for sharing a device;
receive an operation that a user selects a target device from the one or more to-be-shared devices;
receive an operation that the user selects a target user;
display a second interface, wherein the second interface comprises a plurality of options, different options in the plurality of options correspond to different use permissions, and different use permissions allow the target user to use different function properties;
receive an operation that the user selects a target option from the plurality of options;
receive an operation that the user determines to share the target device with the target user by using a use permission corresponding to the target option;
send a device sharing request to a second electronic device via a cloud server, wherein the device sharing request carries an identifier of the target user and a use permission of the target user; wherein
the second electronic device is configured to display a third interface, wherein the third interface comprises a first control corresponding to a function property that is of the target device and that the target user is allowed to use, and the first control is in an operable state.
19 . The first electronic device according to claim 18 , wherein the cloud server is configured to:
receive the device sharing request, and match the use permission of the target user with a function property label of the target device to obtain a first matching result, wherein the function property label is used to describe a type of a function property of the target device, and the matching result is used to indicate a function property that the target user is allowed to use and a function property that the target user is not allowed to use;
generate a first plug-in based on the first matching result, wherein the first plug-in comprises the function property that the target user is allowed to use; and
send the first plug-in to the second electronic device, wherein the second electronic device is configured to install the first plug-in.
20 . The first electronic device according to claim 18 , wherein receiving an operation of selecting a target user comprises:
displaying a fourth interface, wherein the fourth interface comprises one or more sharing protocols used to share the target device; and receiving an operation that the user selects a first sharing protocol from the one or more sharing protocols used to share the target device, and receiving an operation that the user selects the target user by using the first protocol; or
displaying a fifth interface, wherein the fifth interface comprises one or more sharing protocols used to share the target device and an option used to directly share the target device with one or more users; and receiving an operation that the user selects the target user from the option used to directly share the target device with one or more users.