Virtual location information generation method and device, electronic device and storage medium
By constructing a virtual gnss module and the system service LocationManagerService in the hardware abstraction layer to manage the location information of user identifiers, the problem of location information sharing in the Android multi-user environment is solved, and independent location information settings for each user are realized, improving the flexibility and privacy protection of the device.
Patent Information
- Application Number
- CN202410985354.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-23
AI Technical Summary
In a multi-user Android environment, existing technology cannot set independent location information for each user, resulting in location information sharing and failing to meet personalized needs.
A virtual gnss module is constructed in the hardware abstraction layer to listen for updates to the interaction interface file. The location information provider's last updated location information is managed through the system service LocationManagerService. The user identifier is used as the key to construct a specified data structure to implement independent location information settings for each user.
It enables the setting of independent virtual location information for each user in a multi-user environment, meeting personalized needs and improving the flexibility of device use and privacy protection.
Smart Images

Figure CN118519662B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud applications, and in particular to a method and device for generating virtual location information, an electronic device and a storage medium. Background Art
[0002] The multi-user function of the Android operating system allows a device to be used by multiple users with independent identities and spaces, and each user has their own independent applications, data and settings. This greatly improves the flexibility and privacy protection of device use, and is very practical whether in a home, business or educational environment. In fact, many practical application functions such as one device with multiple controls, multiple applications, elderly mode, child mode, etc., are all developed based on this technology. For example, multiple applications: on the same device, different users can use the same application independently without interfering with each other; for example, elderly mode and child mode, different interfaces and functions can be set according to the needs of different users, so that one device can meet the needs of different user groups.
[0003] There is an important problem in the implementation of multi-user functions: although each user has their own independent application and data space, at the location information level, the users are not independent. Specifically, no matter which user is using the device, the location information obtained by the application on the device is based on the location information of the device's primary user. In some actual application scenarios, other users want to set a location information different from the primary user to implement certain functions, and even each user needs to customize their own independent location information, which is not possible in the current Android system's multi-user function.
[0004] Therefore, how to develop a technology that can set independent location information for each user in a multi-user environment has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of the technical problems existing in the prior art, the embodiments of the present application provide a method and device for generating virtual location information, an electronic device and a storage medium.
[0006] In a first aspect, an embodiment of the present application provides a method for generating virtual location information, including:
[0007] When the virtual gnss module monitors that the preset interactive interface file is updated, it obtains the updated data in the interactive interface file, obtains the gnss data according to the data, and returns the gnss data to the system service LocationManagerService, wherein the gnss module is located in the hardware abstraction layer, the data includes the location information, and the gnss data includes the location information and the user identifier;
[0008] The system service LocationManagerService updates a specified data structure using the gnss data, wherein the specified data structure is used to store the location information last updated by the location information provider, and a key in the specified data structure is a pair constructed from the name of the location information provider and a user identifier.
[0009] In a second aspect, an embodiment of the present application further provides a virtual location information generating device, including:
[0010] A virtual gnss module is used to obtain updated data in a preset interactive interface file when monitoring that the interactive interface file is updated, obtain gnss data according to the data, and return the gnss data to the system service LocationManagerService, wherein the gnss module is located in the hardware abstraction layer, the data includes location information, and the gnss data includes location information and a user identifier;
[0011] The system service LocationManagerService is used to update a specified data structure using the gnss data, wherein the specified data structure is used to store the location information last updated by the location information provider, and the key in the specified data structure is a pair constructed from the name of the location information provider and the user identifier.
[0012] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the virtual location information generation method described in the first aspect are executed.
[0013] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the virtual location information generation method as described in the first aspect.
[0014] In summary, the virtual location information generation method and device, electronic device and storage medium provided in the embodiments of the present application construct a virtual gnss module in the hardware abstraction layer to monitor the update of the preset interactive interface file, and apply the update to the system service LocationManagerService, which stores the location information last updated by the location information provider and contains a specified data structure constructed with the name and user identifier of the location information provider as a key. Therefore, it is possible to update the virtual location information for each user in a multi-user environment through the interactive interface file, and manage the location information of each user in the multi-user environment through the system service LocationManagerService, that is, it is possible to set independent location information for each user in a multi-user environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 A flowchart of an embodiment of a method for generating virtual location information provided in an embodiment of the present application;
[0016] Figure 2 A schematic diagram of the structure of an embodiment of a virtual location information generating device provided in an embodiment of the present application;
[0017] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0019] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0020] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0021] Reference Figure 1 As shown, an embodiment of the present application provides a flow chart of a method for generating virtual location information, the method for generating virtual location information comprising:
[0022] S10, when the virtual gnss module monitors that the preset interactive interface file is updated, it obtains the updated data in the interactive interface file, obtains gnss data according to the data, and returns the gnss data to the system service LocationManagerService, wherein the gnss module is located in the hardware abstraction layer, the data includes location information, and the gnss data includes location information and user identification;
[0023] In this embodiment, it should be noted that the virtual gnss module is located in the hardware abstraction layer and is shared by all users. The implementation of the virtual gnss module mainly involves two threads: the main thread and the monitoring thread. The main thread can be used to manage the initialization and state maintenance of the gnss module. It constantly waits for instructions from the system service LocationManagerService of the Android system framework layer and executes the corresponding logic. The monitoring thread can be used to monitor the interactive interface file through the inotify mechanism, so that the updated location information can be returned to the system service LocationManagerService in a timely manner when the interactive interface file is updated.
[0024] In specific implementation, when the interactive interface file is written and closed, the monitoring thread will receive a callback message from the kernel, and then the monitoring thread can read the updated data in the interactive interface file, and construct gnss data containing a user identifier based on the data, wherein the name of the interactive interface file contains the user identifier or the updated data contains the user identifier. Afterwards, the monitoring thread or the main thread can return the gnss data to the system service LocationManagerService through the interface. The data in the interactive interface file contains the longitude and latitude information of the written Android device, in addition to which, it may also contain other information such as timestamp and speed. In order to achieve independent configuration of location information for a multi-user environment, an additional user identifier is added to the gnss data.
[0025] S11. The system service LocationManagerService uses the gnss data to update a specified data structure, wherein the specified data structure is used to store the location information last updated by the location information provider, and the key in the specified data structure is a pair constructed from the name of the location information provider and the user identifier.
[0026] In this embodiment, it should be noted that in the Android system, the core service that provides location information updates to applications is the system service LocationManagerService of the framework layer. In the system service LocationManagerService, only the acquisition of location information of a single user (i.e., the primary user) is supported, and several core data structures are maintained:
[0027] (1) ArrayList <locationprovider>mProviders, used to store all providers of location information, including the virtual gnss module;
[0028] (2) HashMap<Object,Receiver> mReceivers is used to store applications that monitor changes in location information;
[0029] (3) HashMap<String,Location> mLastLocation is used to store the location information data last updated by each location information provider;
[0030] (4) HashMap<String,Location> mLastLocationCoarseInterval is used to store the coarse location information data last updated by each location information provider.
[0031] In the embodiment of the present invention, the data structure in (3) and / or (4) (i.e., the specified data structure) can be reconstructed to support multi-user scenarios. The reconstructed data structures of (3) and (4) are respectively:
[0032] HashMap <Pair<String,Integer> ,Location>mLastLocation and
[0033] HashMap <Pair<String,Integer> ,Location>mLastLocationCoarseInterval.
[0034] It can be seen that the data structures of (3) and (4) originally only support the primary user to store the last updated location information data according to the name of the location information provider. After modification, they support the pair consisting of the location information provider name and the user ID.<String,Integer> To store the last updated location information data.
[0035] When using the interactive interface file to update the location information data, the gnss module can return the gnss data to the system service LocationManagerService. The system service LocationManagerService can then construct a pair based on the current location information provider gnss and the user identifier in the gnss data, and update the corresponding key value in the reconstructed data structure to the updated location information.
[0036] The virtual location information generation method provided in the embodiment of the present application constructs a virtual gnss module in the hardware abstraction layer to monitor the update of the preset interactive interface file, and applies the update to the specified data structure managed by the system service LocationManagerService, which stores the location information last updated by the location information provider and contains the name of the location information provider and the user identifier as the key. Therefore, it is possible to update the virtual location information for each user in a multi-user environment through the interactive interface file, and manage the location information of each user in the multi-user environment through the system service LocationManagerService, that is, it is possible to set independent location information for each user in a multi-user environment.
[0037] Based on the foregoing method embodiment, the method may further include:
[0038] The system service LocationManagerService obtains the updated location information from the specified data structure and sends the updated location information to a target listener, wherein the target listener is a listener that is monitoring changes in location information and whose user ID is the same as the user ID corresponding to the updated location information; and / or
[0039] When an application sends a request through an interface to obtain location information, the system service LocationManagerService determines the user ID of the user to which the application belongs, queries the specified data structure using the pair constructed using the name of the location information provider and the user ID carried in the request, obtains the location information corresponding to the constructed pair, and returns the location information to the application.
[0040] In this embodiment, it should be noted that for multi-user scenarios, when the location information of the specified data structure is updated, the system service LocationManagerService will determine the listener who is listening to the location information changes and whose user ID is the same as the user ID corresponding to the updated location information, i.e., the target listener, and send the updated location information to the target listener. For other listeners who are listening to the location information changes except the target listener, the sending of the updated location information needs to be skipped.
[0041] When an application requests the latest location information through the API interface getLastKnownLocation, the system service LocationManagerService will process the request. Specifically, it can first obtain the user ID of the user to which the application belongs, then query the specified data structure to determine the latest location information corresponding to the pair consisting of the name of the location information provider currently requested and the user ID, and then return the latest location information to the application.
[0042] Based on the foregoing method embodiment, the method may further include:
[0043] If the broadcast receiver in the system service LocationManagerService monitors the action of deleting a user, it deletes all location information associated with the user ID of the user in the specified data structure.
[0044] In this embodiment, it should be noted that in addition to the above processing logic for data flow, the system service LocationManagerService also needs to correctly manage and maintain the life cycle of each user data in a multi-user environment in the specified data structure. Specifically, a broadcast receiver can be added to the system service LocationManagerService to monitor the creation, deletion and other actions of users in the system. When a user is deleted, the last updated location information of all location information providers related to the user in the specified data structure will be cleared to prevent data leakage and confusion.
[0045] Reference Figure 2 FIG. 1 is a schematic diagram of a structure of a virtual location information generating device provided in an embodiment of the present application, the device comprising:
[0046] The virtual gnss module 20 is used to obtain updated data in the interactive interface file when monitoring that the preset interactive interface file is updated, obtain gnss data according to the data, and return the gnss data to the system service LocationManagerService, wherein the gnss module is located in the hardware abstraction layer, the data includes location information, and the gnss data includes location information and user identification;
[0047] The system service LocationManagerService21 is used to update a specified data structure using the gnss data, wherein the specified data structure is used to store the location information last updated by the location information provider, and the key in the specified data structure is a pair constructed from the name of the location information provider and the user identifier.
[0048] The virtual location information generating device provided in the embodiment of the present application constructs a virtual gnss module in the hardware abstraction layer to monitor the update of the preset interactive interface file, and applies the update to the designated data structure managed by the system service LocationManagerService, which stores the location information last updated by the location information provider and contains the name of the location information provider and the user identifier as the key. Therefore, it is possible to update the virtual location information for each user in a multi-user environment through the interactive interface file, and manage the location information of each user in the multi-user environment through the system service LocationManagerService, that is, it is possible to set independent location information for each user in a multi-user environment.
[0049] Based on the above device embodiment, the system service LocationManagerService can also be used for:
[0050] Acquire the updated location information from the specified data structure, and send the updated location information to a target listener, wherein the target listener is a listener that is monitoring the location information change and whose user ID is the same as the user ID corresponding to the updated location information; and / or
[0051] When an application sends a request through an interface to obtain location information, the user identifier of the user to which the application belongs is determined, the pair constructed using the name of the location information provider and the user identifier carried in the request is used to query the specified data structure, the location information corresponding to the constructed pair is obtained, and the location information is returned to the application.
[0052] Based on the above device embodiment, the system service LocationManagerService can also be used for:
[0053] If the action of deleting the user is monitored by the broadcast receiver, all the location information associated with the user identifier of the user in the specified data structure is deleted.
[0054] Based on the aforementioned device embodiment, the location information contained in the data and GNSS data may include longitude and latitude.
[0055] The implementation process of the virtual location information generating device provided in the embodiment of the present application is consistent with the virtual location information generating method provided in the embodiment of the present application, and the effect that can be achieved is also the same as the virtual location information generating method provided in the embodiment of the present application, which will not be repeated here.
[0056] like Figure 3 As shown, an electronic device provided by an embodiment of the present application includes: a processor 30, a memory 31 and a bus 32, wherein the memory 31 stores machine-readable instructions executable by the processor 30, and when the electronic device is running, the processor 30 communicates with the memory 31 through the bus 32, and the processor 30 executes the machine-readable instructions to perform the steps of the virtual location information generation method as described above.
[0057] Specifically, the above-mentioned memory 31 and processor 30 can be general-purpose memories and processors, which are not specifically limited here. When the processor 30 runs the computer program stored in the memory 31, the above-mentioned virtual location information generation method can be executed.
[0058] Corresponding to the above-mentioned virtual location information generating method, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned virtual location information generating method are executed.
[0059] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.< / locationprovider>
Claims
1. A method for generating virtual location information, characterized in that: include: When the virtual gnss module monitors that the preset interactive interface file is updated, it obtains the updated data in the interactive interface file, obtains the gnss data according to the data, and returns the gnss data to the system service LocationManagerService, wherein the gnss module is located in the hardware abstraction layer, the data includes the location information, the gnss data includes the location information and the user identifier, and the data in the interactive interface file includes the longitude and latitude information of the written Android device; The system service LocationManagerService updates a specified data structure using the gnss data, wherein the specified data structure is used to store the location information last updated by the location information provider, and the key in the specified data structure is a pair constructed by the name of the location information provider and the user identifier, updates the virtual location information for each user in a multi-user environment through an interactive interface file, and manages the location information of each user in the multi-user environment through the system service LocationManagerService, and can set independent location information for each user in a multi-user environment; The method further comprises: The system service LocationManagerService obtains the updated location information from the specified data structure, and sends the updated location information to a target listener, wherein the target listener is a listener that is monitoring changes in location information and whose user ID is the same as the user ID corresponding to the updated location information; and / or, When an application sends a request through an interface to obtain location information, the system service LocationManagerService determines the user ID of the user to which the application belongs, queries the specified data structure using the pair constructed using the name of the location information provider and the user ID carried in the request, obtains the location information corresponding to the constructed pair, and returns the location information to the application.
2. The method according to claim 1, characterized in that Also includes: If the broadcast receiver in the system service LocationManagerService monitors the action of deleting a user, it deletes all location information associated with the user ID of the user in the specified data structure.
3. The method according to claim 1, characterized in that The location information contained in the data and GNSS data includes longitude and latitude.
4. A virtual location information generating device, characterized in that: include: A virtual gnss module is used to obtain updated data in a preset interactive interface file when monitoring that the interactive interface file is updated, obtain gnss data according to the data, and return the gnss data to the system service LocationManagerService, wherein the gnss module is located in the hardware abstraction layer, the data includes location information, the gnss data includes location information and user identification, and the data in the interactive interface file includes longitude and latitude information of the written Android device; The system service LocationManagerService is used to update a specified data structure using the gnss data, wherein the specified data structure is used to store the location information last updated by the location information provider, and the key in the specified data structure is a pair constructed by the name of the location information provider and the user identifier. The virtual location information is updated for each user in a multi-user environment through an interactive interface file, and the location information of each user in the multi-user environment is managed by the system service LocationManagerService, so that independent location information can be set for each user in a multi-user environment; The system service LocationManagerService is also used to: Acquire updated location information from the specified data structure, and send the updated location information to a target listener, wherein the target listener is a listener that is monitoring location information changes and whose user ID is the same as the user ID corresponding to the updated location information; and / or, When an application sends a request through an interface to obtain location information, the user identifier of the user to which the application belongs is determined, the pair constructed using the name of the location information provider and the user identifier carried in the request is used to query the specified data structure, the location information corresponding to the constructed pair is obtained, and the location information is returned to the application.
5. The device according to claim 4, characterized in that The system service LocationManagerService is also used to: If the action of deleting the user is monitored by the broadcast receiver, all the location information associated with the user identifier of the user in the specified data structure is deleted.
6. The device according to claim 4, characterized in that The location information contained in the data and GNSS data includes longitude and latitude.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating virtual location information according to any one of claims 1 to 3 are executed.
8. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the virtual location information generation method as described in any one of claims 1 to 3.
