Method for supporting secure mounting of storage partitions in multi-user system

User management services (UMS) initialize and remount the user storage partition in a multi-user system, and use the broadcast notification mechanism to protect file access, solving the problem of application process interruption and data errors during user switching and storage partition mounting, realizing system stability and data security.

CN119902894APending Publication Date: 2025-04-29HANGZHOU ARCVIDEO TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411988968.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

In multi-user systems, user switching operations often cause the application process that is accessing the user storage partition file to be interrupted or crashed, and some applications are prone to errors when accessing files before the user storage partition is mounted.

Method used

User Management Service (UMS) is initialized and remounted at the system startup, and the broadcast notification mechanism ensures that the application process stops accessing files before the user switches and the storage partition mount is completed. After the mount is completed, the index is recreated and the application process can be notified to safely access the files.

Benefits of technology

It realizes file access protection during user switching and storage partition mount in multi-user systems, ensuring the stable operation of application processes and data security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119902894A_ABST
    Figure CN119902894A_ABST
Patent Text Reader

Abstract

The invention discloses a method for supporting a multi-user system to safely mount a storage partition. The method comprises the following steps: a started application process switches a user broadcast receiver and a user partition mount ending broadcast receiver through a Context registration system; carrying out system switching user operation, and calling a UMS (User Management System) to set a main user method; then, the UMS collects the available Userid of the current system, and the Userid user storage partition is remounted through the corresponding storage management service; the storage management service of the operation user completes mounting of the corresponding User partition and then sends a partition mounting broadcast to the MediaProvider component of the corresponding user space; and after receiving the partition mounting broadcast, the MediaProvider component re-creates an index for a corresponding user storage partition file, after the index is created, a user-defined user partition mounting ending broadcast is sent, before the user storage partition mounting is completed, a running process already exists in a user space, and the user storage partition mounting ending broadcast is sent to the MediaProvider component. And receiving the corresponding broadcast for the process registered with the user partition mounting ending broadcast receiver.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer technology, and in particular relates to a method for supporting a multi-user system to safely mount a storage partition. Background Art

[0002] Nowadays, social work increasingly requires the participation of computers, and the application of computers in multi-user functions is becoming more and more extensive, including computers, mobile phones, smart cars and other smart devices. Their operating systems are integrated with multi-user functions. Faced with multi-tasking execution scenarios, they can easily cope with them through the participation of multiple users.

[0003] The multi-user function in the Android system will design a main user for each user, and will create many sub-users during the operation process. Each sub-user is a process running in the main user environment. The process can access the files in the storage partition associated with the main user, that is, each user adopts the design mode of user-associated process and process access to files. When switching system users under normal system operation, the system will first close all user processes and remount the multi-user storage partition, then recreate the multi-user process, and then switch to the target user. However, user switching during system operation often interrupts the application process that is accessing the user storage partition file or even destroys the files accessed by the application. Similarly, for some applications that access files before the corresponding user storage partition is mounted, the application operation is prone to errors or even crashes. Summary of the invention

[0004] In view of the above problems, the present invention provides a method for supporting multi-user systems to securely mount storage partitions, which provides a reliable protection mechanism for user processes to access corresponding main user partition files, making the Android system more stable and secure when running in a multi-user environment.

[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0006] A method for supporting a multi-user system to securely mount a storage partition comprises the following steps:

[0007] The Android system starts and enters the system service initialization. The Android user management service UMS initializes the users created by the current system one by one. According to the sequence of Userid, a storage management service is built for each user storage partition. UMS mounts the corresponding user storage partition through Userid, and then clones the Android system service.

[0008] After the service is started, the system is officially entered. The Android system first logs in the user. For the user who needs to run, the system first runs the media provider application MediaProvider in the corresponding user space. MediaProvider creates an index for the user partition file.

[0009] After the user partition file index is created, the MediaProvider of its space keeps running in the background, and then the Android system connects to the user storage partition and enters the desktop program;

[0010] After entering the desktop, the core components of the system running the user are enabled, and other application processes are started through the main process of each user space;

[0011] The started application process can switch the user broadcast receiver and the user partition mount end broadcast receiver through the process Context registration system;

[0012] Perform the system user switching operation and call the UMS method to set the main user. First, send a customized system user switching broadcast to all running user spaces. The processes in each user space that have registered the system user switching broadcast receiver stop accessing the corresponding user partition files.

[0013] Then UMS collects the available Userids of the current system and remounts the Userid user storage partition through the corresponding storage management service;

[0014] After the storage management service of the running user completes mounting the corresponding Userid partition, it sends a partition mounting broadcast to the corresponding user space MediaProvider component;

[0015] After receiving the partition mount broadcast, the MediaProvider component re-creates the index of the corresponding user storage partition file. After the index creation is completed, a customized user partition mount end broadcast is sent. Before the user storage partition is mounted, there are already running processes in the user space. The process that has registered the user partition mount end broadcast receiver receives the corresponding broadcast and can start accessing the corresponding user partition file.

[0016] In a possible implementation manner, the Android system services in the cloned Android system services include: package manager service, activity manager service and window manager service.

[0017] In one possible implementation, the partition mount broadcast includes: (1) Intent.ACTION_MEDIA_MOUNTED indicates that the storage device has been successfully mounted and is available. It must be dynamically registered and cannot be declared in the manifest in a static manner; (2) Intent.ACTION_MEDIA_UNMOUNTED indicates that the storage device has been unmounted but is still physically connected; (3) Intent.ACTION_MEDIA_REMOVED indicates that the storage device has been removed; (4) Intent.ACTION_MEDIA_BAD_REMOVAL indicates that the storage device has been removed abnormally, which may result in data loss; (5) Intent.ACTION_MEDIA_EJECT indicates that the storage device is being safely removed

[0018] The present invention has the following beneficial effects:

[0019] (1) Independently design a broadcast notification solution: Create an Intent object in the logic of setting the main user (administrator) of UMS to encapsulate the broadcast information of the system switching user, and then remind all user processes of the current system by broadcasting, so that they can close the file access operations in the user process in time to ensure that the files are not damaged. Then UMS will initialize the Userid available in the current system and remount the storage partition corresponding to the Userid. Then the storage management service of the corresponding user space will notify the MediaProvider application by sending a partition mount broadcast. In the logic of MediaProvider ending the scanned user partition file index, an Intent object is created and the user partition mount end broadcast information is encapsulated. Then, the user space where MediaProvier is running is notified by broadcast again to ensure that all processes in the user space can safely access the files under the corresponding user storage partition.

[0020] (2) Reasonably limit broadcast receiving users: When the system performs a user switching operation, the system switching user broadcast information is used in the UMS setting main user (administrator) logic to create an Intent object, and then the Intent object and UserHandle.ALL are used as parameters to call the sendBroadcastAsUser method of Context. When the specified user parameter of the sendBroadcastAsUser method is UserHandle.ALL, the broadcast will be sent to all user spaces running in the current system. Then UMS will initialize all available Userids in the current system one by one and remount the storage partition corresponding to the userid. Then the storage management service of the corresponding user space will notify the MediaProvider application by sending a partition mounting broadcast. When the partition file index in MediaProvider ends, the sendBroadcast method in the Context object is called and the Intent object encapsulating the user partition mounting end broadcast information is passed in. The sendBroadcast method will notify the process of the specified user space of the partition mounting end message. Sending the user partition mounting end broadcast information by sending a broadcast notification to the specified user space can ensure that all processes under the corresponding user space can safely access the user storage partition file.

[0021] (3) Safe access to user storage partitions: There is a sequence of operations between the broadcast sender and the broadcast receiver. Only after the broadcast sender sends the broadcast information, the broadcast receiver that has registered the corresponding broadcast information can receive the corresponding information. In addition, the broadcast sender can limit the receiving users of the broadcast through the user category parameter of UserHandle. Based on this relationship between the broadcast sender and the broadcast receiver, for system-level operations such as switching users, UMS can directly send the system switching user broadcast to all user spaces through the sendBroadcastAsUser method in the method of setting the main user, so that all user processes can receive and stop accessing the corresponding user storage partition files in time to avoid abnormal file operations and damage. On the other hand, UMS will initialize all available userids in the current system one by one and remount the storage partition of the corresponding userid. Then the storage management service of the corresponding user space notifies MediaProvider to index the files scanned in the partition by sending a partition mount broadcast. After MediaProvider finishes indexing the partition files, it directly calls the sendBroadcast method to send the user partition mount end broadcast information to the current user process, so that all processes in the corresponding user space can safely access the user storage partition files after receiving the user partition mount end broadcast. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 The present invention is a flowchart of a method for supporting secure mounting of storage partitions by a multi-user system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0024] See also Figure 1 , which is a flowchart of a method for supporting a multi-user system to securely mount a storage partition according to an embodiment of the present invention, includes the following steps:

[0025] S10, the Android system starts and enters the system service initialization. The Android user management service UMS initializes the users created by the current system one by one; according to the Userid sequence, a storage management service is built for each user storage partition; UMS mounts the corresponding user storage partition through the Userid, and then clones the Android system service; the Android system services in the cloned Android system service include: package manager service, activity manager service and window manager service, etc.

[0026] S20, after the service is started, the system is officially entered. The Android system first logs in the user. For the user who needs to run, the system first runs the media provider application MediaProvider corresponding to the user space. MediaProvider creates an index for the user partition file.

[0027] S30, after the user partition file index is created, the MediaProvider of its space keeps running in the background, and then the Android system connects to the user storage partition and enters the desktop program;

[0028] S40, after entering the desktop, the core component functions of the running user's system are enabled, and other application processes are started through the main process of each user space;

[0029] S50, the started application process can switch the user broadcast receiver and the user partition mount end broadcast receiver through the process Context registration system; wherein Context is a very important class, which provides application environment information and is the interface for the application to interact with the Android system.

[0030] S60, performing a system user switching operation, calling the UMS method for setting the main user, first sending a customized system user switching broadcast to all running user spaces, and the processes in each user space that have registered a system user switching broadcast receiver stop accessing the corresponding user partition file;

[0031] S70, then the UMS collects the available Userids of the current system, and remounts the Userid user storage partition through the corresponding storage management service;

[0032] S80, after the storage management service of the running user completes mounting the corresponding Userid partition, it sends a partition mounting broadcast to the corresponding user space MediaProvider component;

[0033] S90, after receiving the partition mount broadcast, the MediaProvider component re-creates the index of the corresponding user storage partition file, and sends a customized user partition mount end broadcast after the index creation is completed. Before the user storage partition is mounted, there are already running processes in the user space. The process that has registered the user partition mount end broadcast receiver receives the corresponding broadcast and can start accessing the corresponding user partition file. The user storage partition belongs to the Media partition in the system, and the application is stored in the Data partition, so the App can run normally. When the system mounts the Media partition, the App can also run normally, but it cannot access the unfinished mount at this time, because the partition file index has not been generated, and the relevant files cannot be accessed, which will cause program execution errors or crashes. When the running App that has registered the user partition mount end broadcast receiver receives the user partition mount end broadcast, it means that the system has mounted the user partition. At this time, the App can access the Media partition of the corresponding user space.

[0034] In Android, custom broadcast refers to a broadcast action defined by the developer, and the broadcast is sent to the component (such as BroadcastReceiver) that has registered the corresponding listener. Therefore, in S60, messages or data can be transmitted between different modules of the application through custom broadcast. Action is a string defined by the developer, which can be written in the string format without special format requirements.

[0035] In a specific application example, the partition mount broadcast in S80 includes: (1) Intent.ACTION_MEDIA_MOUNTED indicates that the storage device has been mounted successfully and can be used. It must be registered dynamically and cannot be declared in the Manifest statically. (2) Intent.ACTION_MEDIA_UNMOUNTED indicates that the storage device has been unmounted but is still physically connected. (3) Intent.ACTION_MEDIA_REMOVED indicates that the storage device has been removed. (4) Intent.ACTION_MEDIA_BAD_REMOVAL indicates that the storage device has been removed abnormally, which may result in data loss. (5) Intent.ACTION_MEDIA_EJECT indicates that the storage device is being safely removed.

[0036] Furthermore, in S90, the mount completion broadcast is also a custom broadcast, a broadcast Action of string type, which is a broadcast message sent out through the application Context when the Android system mounts the system partition. It can be written in the string format without special format requirements.

[0037] Through the above-set method of supporting multi-user system to mount storage partitions securely, the Android system performs user switching operations in multi-user working mode, and UMS sends system switching user broadcasts to each user space. After receiving the broadcast, the user process can stop or end the file access in the corresponding user storage partition in time. After the current system reinitializes all available Userids and mounts the storage partition of the corresponding Userid, the storage management service of the corresponding user space will notify MediaProvider by sending a partition mounting broadcast. After MediaProvider creates an index for the files scanned in the partition, it will actively send the user partition mounting end broadcast information to the current user process, so that the system switching user operation and the corresponding user partition mounting status in the multi-user operating environment are visible to the user space process. At the same time, all processes in the corresponding user space that have registered the user partition mounting end broadcast receiver can start to securely access the user storage partition files after receiving the user partition mounting end broadcast, providing a reliable protection mechanism for user processes to access the corresponding main user partition files.

[0038] It should be understood that the exemplary embodiments described herein are illustrative rather than restrictive. Although one or more embodiments of the present invention have been described in conjunction with the accompanying drawings, it should be understood by those skilled in the art that various changes in form and detail may be made without departing from the spirit and scope of the present invention as defined by the appended claims.

Claims

1. A method for supporting secure mounting of storage partitions in a multi-user system, characterized in that: The following steps are involved: The Android system starts and enters the system service initialization. The Android user management service UMS initializes the users created by the current system one by one; according to the Userid sequence, a storage management service is built for each user storage partition; UMS mounts the corresponding user storage partition through Userid, and then clones the Android system service; After the service is started, the system is officially entered. The Android system first logs in the user. For the user who needs to run, the system first runs the media provider application MediaProvider in the corresponding user space. MediaProvider creates an index for the user partition file. After the user partition file index is created, the MediaProvider of its space keeps running in the background, and then the Android system connects to the user storage partition and enters the desktop program; After entering the desktop, the core components of the system running the user are enabled, and other application processes are started through the main process of each user space; The started application process switches the user broadcast receiver and the user partition mount ends the broadcast receiver through the process Context registration system; Perform the system user switching operation and call the UMS method to set the main user. First, send a customized system user switching broadcast to all running user spaces. The processes in each user space that have registered the system user switching broadcast receiver stop accessing the corresponding user partition files. Then UMS collects the available Userids of the current system and remounts the Userid user storage partition through the corresponding storage management service; After the storage management service of the running user completes mounting the corresponding Userid partition, it sends a partition mounting broadcast to the corresponding user space MediaProvider component; After receiving the partition mount broadcast, the MediaProvider component re-creates the index of the corresponding user storage partition file. After the index creation is completed, a customized user partition mount end broadcast is sent. Before the user storage partition is mounted, there are already running processes in the user space. The process that has registered the user partition mount end broadcast receiver receives the corresponding broadcast and can start accessing the corresponding user partition file.

2. The method for supporting secure mounting of storage partitions by a multi-user system according to claim 1, characterized in that: The Android system services in the cloned Android system services include: package manager service, activity manager service and window manager service.

3. The method for supporting secure mounting of storage partitions by a multi-user system according to claim 1, characterized in that: The partition mount broadcast includes: (1) Intent.ACTION_MEDIA_MOUNTED indicates that the storage device has been successfully mounted and is available. It must be dynamically registered and cannot be declared in the Manifest in a static manner; (2) Intent.ACTION_MEDIA_UNMOUNTED indicates that the storage device has been unmounted but is still physically connected; (3) Intent.ACTION_MEDIA_REMOVED indicates that the storage device has been removed; (4) Intent.ACTION_MEDIA_BAD_REMOVAL indicates that the storage device has been removed abnormally, which may result in data loss; (5) Intent.ACTION_MEDIA_EJECT indicates that the storage device is being safely removed.