Application authority management method and terminal
By parsing the permission configuration file of the application installation package and adding it to the native permission management pool, the problem of recompiling and burning of each new permission definition in the existing technology is solved, and the simplified addition and efficient management of custom permissions are achieved.
Patent Information
- Application Number
- CN202411617527.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-03-25
AI Technical Summary
In the prior art, every time the permission definition is added, the terminal version needs to be recompiled and burned, resulting in inefficient testing and development process.
By receiving the installation request of the application installation package, parsing the installation package information, and determining whether it matches the preset permission definition format. If it matches, obtain the permission configuration file from the installation package, parse and add custom permissions to the native permission management pool.
There is no need to burn every time you add custom permissions, which simplifies the process of adding custom permissions and improves the efficiency of testing and development.
Smart Images

Figure CN119691761A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of system development, and in particular to an application authority management method and a terminal. Background Art
[0002] During the terminal development process, many modules will need to add custom permission definitions. These permission definitions need to be defined in the permission definition file of the terminal system in advance, so that when an application needs to use custom permissions, it can apply for authorization. In the prior art, each time a new permission definition is added, the terminal version needs to be recompiled and the version needs to be re-burned, which makes the test development process inefficient. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide an application authority management method and a terminal to simplify the process of customizing authority.
[0004] In order to solve the above technical problems, a technical solution adopted by the present invention is: A method for managing application permissions, comprising the steps of: After receiving an installation request for an application installation package, parsing the application installation package to obtain installation package information; Determine whether the installation package information matches a preset permission definition format, and if so, obtain a permission configuration file from the application installation package; The permission configuration file is parsed to obtain at least one custom permission, and the custom permission is added to the native permission management pool.
[0005] In order to solve the above technical problems, another technical solution adopted by the present invention is: An application rights management terminal comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: After receiving an installation request for an application installation package, parsing the application installation package to obtain installation package information; Determine whether the installation package information matches a preset permission definition format, and if so, obtain a permission configuration file from the application installation package; The permission configuration file is parsed to obtain at least one custom permission, and the custom permission is added to the native permission management pool.
[0006] The beneficial effects of the present invention are as follows: custom permissions are added in the form of an application installation package, and there is no need to perform a burning operation each time a custom permission is added; by presetting the permission definition format in advance, if the obtained installation package information can match the preset permission definition format, it is considered that it is not an ordinary application installation process, but an application installation package for adding custom permissions; by parsing the application installation package to obtain the permission configuration file therein, the custom permissions in the permission configuration file are added to the native permission management pool, thereby indicating that the application installation package is used to install custom permissions by setting a specific installation package information format, thereby simplifying the process of adding custom permissions. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] Figure 1 A flowchart of a method for managing application permissions according to an embodiment of the present invention; Figure 2 A flowchart of the steps of an application permission management method in an actual application scenario according to an embodiment of the present invention; Figure 3 A schematic diagram of the structure of an application authority management terminal according to an embodiment of the present invention; Description of labels: 1. An application permission management terminal; 2. A processor; 3. A memory. DETAILED DESCRIPTION
[0008] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0009] Please refer to Figure 1 , an application permission management method, comprising the steps of: After receiving an installation request for an application installation package, parsing the application installation package to obtain installation package information; Determine whether the installation package information matches a preset permission definition format, and if so, obtain a permission configuration file from the application installation package; The permission configuration file is parsed to obtain at least one custom permission, and the custom permission is added to the native permission management pool.
[0010] From the above description, it can be seen that the beneficial effects of the present invention are: custom permissions are added in the form of an application installation package, and there is no need to perform a burning operation each time a custom permission is added; by pre-setting the permission definition format in advance, if the obtained installation package information can match the preset permission definition format, it is considered that it is not an ordinary application installation process, but an application installation package for adding custom permissions; by parsing the application installation package to obtain the permission configuration file therein, the custom permissions in the permission configuration file are added to the native permission management pool, thereby indicating that the application installation package is used to install custom permissions by setting a specific installation package information format, thereby simplifying the process of adding custom permissions.
[0011] Further, the parsing the application installation package to obtain installation package information includes: Parsing the application installation package to obtain a package name; The determining whether the installation package information matches a preset permission definition format includes: Determine whether the package name matches a preset permission definition format.
[0012] From the above description, it can be seen that a preset permission definition format is set for the package name. When the application installation package to be installed is obtained, it is determined whether the package name matches the preset permission definition format. If so, it means that the application installation package is an installation package for installing custom permissions. In this way, the permission configuration file therein is extracted, the custom permissions in the permission configuration file are obtained, and the custom permissions are added to the native permission management pool to complete the addition of custom permissions, thereby realizing the addition of custom permissions through the installation of the application without the need for burning, which simplifies the steps of adding.
[0013] Further, adding the custom permission to the native permission management pool includes: Associating the installation package information with the custom permission and adding it to the native permission management pool; Install the application installation package normally.
[0014] From the above description, it can be seen that the custom permissions and the corresponding installation package information are associated and saved in the permission management pool, and the application installation package is installed normally. It can be determined whether the corresponding custom permissions in the permission management pool need to be increased or decreased according to the installation or uninstallation status of the application installation package, and the corresponding custom permissions in the permission management pool can be increased or decreased according to the installation and uninstallation of the application corresponding to the installation package information, which facilitates the unified management of custom permissions.
[0015] Furthermore, after adding the custom permission to the native permission management pool, the method further includes: Determine whether an application uninstall request is received, and if so, obtain target installation package information of the application; The target custom permission corresponding to the target installation package information is obtained from the permission management pool, and the target installation package information and the target custom permission are removed.
[0016] From the above description, it can be seen that when an application is uninstalled, its corresponding target installation package information is obtained. If the corresponding target custom permission can be matched in the permission management pool, the target custom permission is removed accordingly, and the installation and uninstallation status of the application is associated with whether the custom permission corresponding to the application in the permission management pool exists, thereby realizing the management of the effective status of custom permissions without changing the custom permissions by burning.
[0017] Further, the determining whether the installation package information matches a preset permission definition format also includes: If there is no match, the application installation package is marked as a regular installation package, and the regular installation package is parsed to obtain a permission application list; It is determined whether the permissions in the permission application list are in the permission management pool. If so, authorization is passed; otherwise, authorization is not passed.
[0018] From the above description, it can be seen that in the normal process of application installation, for the permissions applied for by the application, it is determined whether they already exist in the permission management pool. If they do, it means that the permission operation can be performed and the authorization is passed; if they do not exist, it means that the relevant permissions have not been defined and authorization cannot be performed, then the authorization is not passed, and the actual authorization operation on the application is realized through the permission management pool.
[0019] Furthermore, the authorization also includes: Obtain the application custom permissions in the permission application list; The mapping relationship between the package name of the conventional installation package and the application for custom permissions is recorded.
[0020] From the above description, it can be seen that after the authorization is passed, if the authorization is for custom permissions, the mapping relationship between the package name of the regular installation package and the custom permissions is recorded. If the custom permissions are changed later, the corresponding application can be quickly found to revoke the authorization, ensuring that the uninstalled application can revoke the corresponding custom permissions in time.
[0021] Furthermore, it also includes: After receiving the application uninstallation request, obtaining the uninstallation custom permission in the application installation package corresponding to the application uninstallation request; A target package name that is mapped to the uninstall custom permission is obtained, and the uninstall custom permission in the permission application list corresponding to the target package name is modified to authorization failure.
[0022] From the above description, it can be seen that if the application is uninstalled, the corresponding package name can be obtained according to the mapping relationship, and then the permission application list in the installed application can be obtained through the package name, and the uninstall custom permission can be modified to authorization failure. This realizes the automatic cancellation of the corresponding authorization in the application after the custom permission is uninstalled, avoiding the problem of other applications applying for permission after the custom permission is deleted, and improving the process of custom permission management by installing application programs, avoiding the program execution error caused by the display of authorization passing in the application requesting the corresponding permission after the corresponding custom permission is closed.
[0023] Further, the determining whether the permission in the permission application list is in the permission management pool includes: Install the regular installation package.
[0024] From the above description, it can be seen that after applying for the permissions in the permission application list, the regular installation package is installed normally, and the user can normally use the functions in the application that have been authorized with the corresponding permissions or can be used without authorization.
[0025] Furthermore, the application installation package is in APK format.
[0026] From the above description, it can be seen that packaging custom permissions in an installation package in APK format can adapt to most devices, thereby increasing the applicability of the solution.
[0027] Please refer to Figure 3 An application permission management terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step in the above-mentioned application permission management method is implemented.
[0028] In the existing related technologies, new permission definitions are defined in a system native way. For example, the Android system has a manifest file AndroidManifest.xml, which contains all the system native permission definitions. If you need to add custom permissions, you can also add them directly to the manifest file, which requires recompiling the terminal version, re-burning or system upgrade, which is complex to manage and not flexible enough.
[0029] The above-mentioned application permission management method and terminal of the present invention can be applied to scenarios where permission customization is required, such as scenarios where customized permissions need to be added or deleted in the system.
[0030] Please refer to Figure 1-2 , Embodiment 1 of the present invention is: A method for managing application permissions, comprising the steps of: S1. After receiving an installation request for an application installation package, parse the application installation package to obtain installation package information.
[0031] Parsing the application installation package to obtain installation package information in S1 includes: parsing the application installation package to obtain a package name. The package name is a relatively convenient installation package information to obtain. Directly using the package name as an identifier can reduce the time required to parse the application installation package. Other installation package information such as version name, version number, etc. can also be used as an identifier. The method for obtaining installation package information has been specifically described in the prior art, such as the getPackageArchiveInfo method of the PackageManager (package manager) object of the Android system, which will not be repeated here.
[0032] S2. Determine whether the installation package information matches the preset permission definition format. If so, execute S21; otherwise, execute S22-S23.
[0033] Determining whether the installation package information matches the preset permission definition format in S2 includes: determining whether the package name matches the preset permission definition format. The permission definition format corresponding to the preset package name, if it meets the permission definition format, indicates that the application installation package is an application installation package for custom permissions, and a permission extraction operation is required, which is different from the installation process of an ordinary installation package. For example, the package name with the keyword admin can be set as an application installation package for permission definition, and the application installation package that meets the corresponding format can also be limited to the application installation package for permission definition, for example, the application installation package with a package name that meets the format of "five characters_three characters" is an application installation package for permission definition; a combination of the two can also be used, for example, the application installation package with a package name that meets the format of "admin_three characters" is an application installation package for permission definition, which will not be repeated here.
[0034] In an optional implementation, a package name configuration file is set, which includes a preset package name. The package name configuration file can be added in a dedicated terminal configuration module. If the package name in the installation package information is in the package name configuration file, S21 is executed. That is, when a new custom permission needs to be added, it can be achieved by reconfiguring the application installation package, or by directly adding permissions to the previous application installation package, which is equivalent to the version update process of the same APP.
[0035] S21. Obtain a rights configuration file from the application installation package.
[0036] In an optional implementation, the assets directory of the application installation package contains a JSON file (permission configuration file), which contains all newly added custom permissions. That is, for a successfully matched application installation package, a step of obtaining custom permissions from it needs to be added. For example, the JSON file can be named define_permission.json.
[0037] S22, marking the application installation package as a regular installation package, and parsing the regular installation package to obtain a permission application list; S23. Determine whether the permissions in the permission application list are in the permission management pool. If so, authorization is passed; otherwise, authorization is not passed.
[0038] That is, the normal installation package is installed in the normal process. During the installation process, the corresponding authorization is obtained in the permission management pool according to the permission application list of the application. If the permission is in the permission management pool, a judgment operation can be added, that is, the user's selection information is obtained, and the authorization is passed only after the user chooses to authorize. In this way, the user's privacy is protected. For example, if you apply for the permission to wake up another application, the user needs to confirm before you have the permission to directly wake up another application. You can also configure sensitive permissions to require user confirmation, such as retrieving usage records and waking up the camera.
[0039] In an optional implementation, the authorization in S23 also includes: obtaining the requested custom permissions in the permission application list; and recording the mapping relationship between the package name of the conventional installation package and the requested custom permissions. Because the permissions in the system are usually not changeable, for example, the permission to use the system camera cannot be deleted, the custom permissions in the permission application list are recorded. After the corresponding custom permissions are uninstalled, the corresponding authorization in the application can be cancelled in time, and the permissions in the application can be adjusted in time to avoid program errors caused by the application continuing to request response permissions.
[0040] During the normal application installation process, if the custom permissions have been added to the system's permission pool, they can be applied for by other applications without the need to frequently compile versions every time new custom permissions need to be added.
[0041] S24, installing the conventional installation package. That is, after completing the authorization operation, the conventional installation package is installed normally so that the user can use the application. Among them, the application developer can configure not to install the application when certain key permissions cannot be obtained. This process is judged during the installation of the conventional installation package. It is a common method in the application development process and will not be repeated here.
[0042] S3. Parse the permission configuration file to obtain at least one custom permission, and add the custom permission to the native permission management pool.
[0043] Adding the custom permission to the native permission management pool in S3 includes: associating the installation package information with the custom permission and adding it to the native permission management pool; installing the application installation package normally. In the permission management pool, the custom permission can be associated with the installation package information and saved one by one, or a table corresponding to the installation package information can be established to save the corresponding custom permission in the table; that is, one installation package information can correspond to one or more permission definitions. After saving the custom permission, the application installation package is installed normally, and the status of the custom permission can be identified by the installation status of the application installation package. When installing the application installation package, the corresponding custom permission can be added. When uninstalling the application installation package, the corresponding custom permission is deleted according to the association relationship saved in the permission management pool. The custom permission can be automatically increased or decreased by changing the installation status of the application without directly operating the permission management pool.
[0044] In an optional implementation, a judgment process for custom permissions is further added. By naming the custom permissions, it is judged whether the corresponding custom permissions already exist in the permission management pool. If so, the custom permissions are skipped. Otherwise, the custom permissions are added to the permission management pool. In this way, the waste of storage space caused by repeated addition of custom permissions is avoided.
[0045] That is, an application installation package with custom permissions that need to be added is provided. When the application installation package is installed, the package manager will parse its internal permission configuration file to obtain custom permissions and add them to the system's permission pool, so that other applications can apply for them. For example, in the Android system, when installing an APK, the underlying system will parse out all the permission definitions carried in the APK, such as the pinpad (password key) permission definition: com.permission.pinpad_system (password key access permission, only special applications such as manufacturer applications are allowed to apply, with a high security level), com.permission.pinpad_normal (password key access permission, allowing ordinary applications to apply). After parsing these permission definitions from the apk, this definition will be added to the system's permission pool. Only permissions that exist in the permission pool can be applied for authorization.
[0046] In an optional embodiment, S3 further includes S41-S42. S41. Determine whether an application uninstallation request is received, and if so, obtain target installation package information of the application.
[0047] S42: Obtain the target custom permission corresponding to the target installation package information from the permission management pool, and remove the target installation package information and the target custom permission.
[0048] In an optional implementation, between S41 and S42, it is also included to determine whether the target installation package information matches the preset permission definition format, and if it matches, S42 is executed. In this way, only installation packages that are confirmed to be related to the custom permission configuration are matched in the permission management pool during uninstallation, and no matching operation in the permission management pool is performed for ordinary installation packages, thereby reducing the amount of data processing and accelerating the efficiency of uninstallation.
[0049] In an optional implementation, determining whether an application uninstall request is received further includes: S43: After receiving the application uninstall request, obtain the uninstall custom permission in the application installation package corresponding to the application uninstall request.
[0050] In an optional factual method, S01 also includes determining whether the installation package information of the application installation package corresponding to the application uninstall request matches the preset permission definition format, and if so, obtaining the uninstall custom permission in the application installation package. That is, for the received application uninstall request, if the corresponding installation package information matches the preset permission definition format, it means that the uninstalled application is an application for setting custom permissions. In the uninstall process, in addition to deleting the corresponding custom permissions in the permission management pool according to the registration, it is also necessary to cancel the authorization of other applications that have obtained the uninstall custom permission. Therefore, the uninstall custom permission is obtained at this time, and the authorization can be canceled through the mapping relationship between the package name of the regular installation package saved in S2 and the said application custom permission.
[0051] S44, obtaining a target package name that has a mapping relationship with the uninstall custom permission, and modifying the uninstall custom permission in the permission application list corresponding to the target package name to authorization failure.
[0052] In an optional implementation, the application installation package is in APK format, that is, different application installation package formats can be used according to different systems. If the above-mentioned application permission management method is used in an Android system, the application installation package can be packaged into an APK format.
[0053] Please refer to Figure 2 , Embodiment 2 of the present invention is: An application permission management terminal 1 includes a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, each step of an application permission management method in the first embodiment is implemented.
[0054] In summary, the present invention provides an application permission management method and terminal, which adds custom permissions to an application installation package, and sets a preset permission definition format in advance in the device. If the installation package information of the application installation package is confirmed to match the permission definition format during the installation of the application installation package, the corresponding application installation package is confirmed to be an application installation package for adding custom permissions. The custom permissions therein are obtained and added to the native permission management pool, so as to realize the installation and addition of custom permissions with the application installation package. There is no need to re-upgrade the entire system or burn it, which improves the flexibility of custom permission configuration. And the corresponding application installation package is installed normally, and the custom permissions in the permission management pool can be increased or decreased through the installation and uninstallation status of the application. In addition, when the normally installed application requests authorization, the association relationship between the package name of the application requesting authorization and the custom permissions it requests is further saved. After the corresponding application is uninstalled, the package name of the authorized application can be found according to the associated custom permissions, and the application requesting the corresponding custom permissions will be deauthorized, realizing the complete management process of custom permissions.
[0055] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for managing application permissions, characterized in that: Includes steps: After receiving an installation request for an application installation package, parsing the application installation package to obtain installation package information; Determine whether the installation package information matches a preset permission definition format, and if so, obtain a permission configuration file from the application installation package; The permission configuration file is parsed to obtain at least one custom permission, and the custom permission is added to the native permission management pool.
2. The application permission management method according to claim 1, characterized in that: The step of parsing the application installation package to obtain installation package information includes: Parsing the application installation package to obtain a package name; The determining whether the installation package information matches a preset permission definition format includes: Determine whether the package name matches a preset permission definition format.
3. The application permission management method according to claim 1, characterized in that: Adding the custom permission to the native permission management pool includes: Associating the installation package information with the custom permission and adding it to the native permission management pool; Install the application installation package normally.
4. The application permission management method according to claim 3, characterized in that: After adding the custom permission to the native permission management pool, the method further includes: Determine whether an application uninstall request is received, and if so, obtain target installation package information of the application; The target custom permission corresponding to the target installation package information is obtained from the permission management pool, and the target installation package information and the target custom permission are removed.
5. The application permission management method according to claim 1, characterized in that: The determining whether the installation package information matches a preset permission definition format further includes: If there is no match, the application installation package is marked as a regular installation package, and the regular installation package is parsed to obtain a permission application list; It is determined whether the permissions in the permission application list are in the permission management pool. If so, authorization is passed; otherwise, authorization is not passed.
6. The application rights management method according to claim 5, characterized in that: The authorization also includes: Obtain the application custom permissions in the permission application list; The mapping relationship between the package name of the conventional installation package and the application for custom permissions is recorded.
7. The application rights management method according to claim 6, characterized in that: Also includes: After receiving the application uninstallation request, obtaining the uninstallation custom permission in the application installation package corresponding to the application uninstallation request; A target package name that is mapped to the uninstall custom permission is obtained, and the uninstall custom permission in the permission application list corresponding to the target package name is modified to authorization failure.
8. The application permission management method according to claim 5, characterized in that: The step of determining whether the permission in the permission application list is in the permission management pool comprises: Install the regular installation package.
9. The application permission management method according to claim 1, characterized in that: The application installation package is in APK format.
10. An application rights management terminal, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of an application permission management method as described in any one of claims 1 to 9 when executing the computer program.