Permission and API (Application Program Interface) representation method under Android framework evolution scene
By identifying and merging API and permission replacement items in the evolution of the Android framework, a unified representation is formed, which solves the problem of failure to effectively deal with API and permission deprecation in the existing technology, and improves the accuracy of Android program modeling.
Patent Information
- Application Number
- CN202411308447.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-20
AI Technical Summary
The existing Android program modeling methods fail to effectively consider the API and permission deprecation problems caused by the evolution of the Android framework, resulting in inaccurate modeling.
By collecting descriptions of each version of Android permissions and API, identifying deprecated permissions and APIs and their replacements, constructing collections and merging, forming permissions and API representations in the Android framework evolution scenario, ensuring that the permissions and APIs with the same functions are the same Have the same representation.
It improves the accuracy of functional modeling of Android programs, reduces the impact of Android framework evolution on modeling, and realizes effective handling of API and permission deprecation.
Smart Images

Figure CN119166205A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of software engineering and relates to a permission and API representation method in an Android framework evolution scenario. Background Art
[0002] Since Google launched Android 1.0 in September 2008, the Android framework has undergone several evolutions. Starting in August 2018, with the release of Android 9, the Android framework has been updated on a yearly basis, until Android 14 was released in October 2023. Each version of the Android framework is associated with a specific API level. For example, Android 2.0 corresponds to API level 5, while Android 8.0 corresponds to API level 26. The update of the Android framework also leads to the deprecation and addition of permissions and APIs. For example, getDeviceId() was deprecated in API level 26 and replaced by getImei() and getMeid(). These APIs are used to return the device ID and perform the same function, but due to the evolution of the Android framework, there are multiple corresponding APIs.
[0003] Existing modeling methods for Android programs usually directly use a subset of APIs or permissions, without considering the impact of API and permission deprecation caused by the evolution of the Android framework on modeling. Summary of the invention
[0004] In order to solve the problems existing in the background technology, the present invention provides a method for representing permissions and APIs in the scenario of Android framework evolution. The method mines the deprecation and replacement of permissions and APIs generated by the evolution of the Android framework, merges permissions (or APIs) with deprecation-replacement relationships into the same set, and each set is regarded as performing different functions; for permissions (or APIs) that do not have a deprecation-replacement relationship, the function set only includes the permission (or API) itself. This allows permissions (or APIs) that perform the same function to have the same representation, which can improve the accuracy of functional modeling of Android programs.
[0005] The objective of the present invention is achieved through the following technical solutions:
[0006] A permission and API representation method in an Android framework evolution scenario includes the following steps:
[0007] Step S1: Collect the permission descriptions of each version of Android and the code base of each version of Android framework;
[0008] Step S2: Obtain all deprecated permissions from the collected Android permission descriptions of various versions, where M deprecated permissions have replacement permissions, and obtain the corresponding replacement permissions;
[0009] Step S3: construct a set for each of the M deprecated permissions in step S2, each set contains a deprecated permission and its corresponding replacement permission, and merge the sets with common elements to finally obtain m mutually disjoint sets, i.e., the representation form of permissions in the Android framework evolution scenario;
[0010] Step S4: Obtain all deprecated APIs from the Android framework code base of each version, where N deprecated APIs have replacement APIs, and obtain the corresponding replacement APIs;
[0011] Step S5: construct a set for each of the N deprecated APIs in step S4, each set contains a deprecated API and its corresponding replacement API, and merge the sets with common elements to finally obtain n non-overlapping sets, which are the representation of APIs in the Android framework evolution scenario.
[0012] Compared with the prior art, the present invention has the following advantages:
[0013] The present invention fully considers the impact of the evolution of the Android framework on the modeling of Android applications. By mining the deprecation and replacement of permissions (or APIs) generated by the evolution of the Android framework, permissions (or APIs) with the same functions are merged, thereby realizing the integration of the Android framework and reducing the impact of the evolution of the Android framework on the modeling of Android functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 It is a flowchart of the permission and API representation method in the Android framework evolution scenario of the present invention;
[0015] Figure 2-Figure 4 It is the ChatGPT prompt words and examples used in the present invention. DETAILED DESCRIPTION
[0016] The technical solution of the present invention is further described below in conjunction with the accompanying drawings, but is not limited thereto. Any modification or equivalent replacement of the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention should be included in the protection scope of the present invention.
[0017] The present invention provides a permission and API representation method in an Android framework evolution scenario, which is accomplished by obtaining permission (or API) deprecation and replacement information and merging permissions (or APIs) with deprecation-replacement relationships. Figure 1 As shown, the specific steps include:
[0018] Step S1: Collect the permission descriptions of each version of Android and the code base of each version of Android framework. The specific steps are as follows:
[0019] Step S101: Use a crawler to collect all permissions and their related descriptions from the Android official documentation at https: / / developer.android.com / reference / android / Manifest.permission.
[0020] Step S102: According to the correspondence between Android versions and API levels, obtain the Android open source codes of various versions from the Android open source code library according to the tags in the code library, and obtain the API and its description, wherein the address of the open source code library is https: / / android.googlesource.com / platform / frameworks / base.
[0021] Step S2: Obtain all deprecated permissions from the collected Android permission descriptions of various versions, among which M deprecated permissions have replacement permissions, and obtain the corresponding replacement permissions.
[0022] In this step, a rule-based approach is used to obtain replacement permissions from the deprecated permission descriptions. Specifically, the following two rules are used:
[0023] (1) Deprecated permissions are given in the form of 'This constant was deprecated in API level…';
[0024] (2) If there is a replacement permission, the replacement permission is given in the form of 'use replacement permission instead' or 'request replacement permission instead'.
[0025] Step S3: construct a set for each of the M deprecated permissions in step S2, each set contains a deprecated permission and its corresponding replacement permission, and merge the sets with common elements to finally obtain m mutually disjoint sets, i.e., the representation of permissions in the Android framework evolution scenario. The specific steps are as follows:
[0026] Step S301: Initialize M empty sets, and add M deprecated permissions together with their replacement permissions to M sets respectively, so that each set finally contains a deprecated permission and its replacement permission.
[0027] Step S302: recursively compare the M sets in step S301 in pairs, and if there are common elements, merge the sets until m mutually non-overlapping sets are obtained, which are the representation forms of permissions in the Android framework evolution scenario.
[0028] Step S4: Obtain all deprecated APIs from the Android framework code base of each version, where N deprecated APIs have replacement APIs, and obtain the corresponding replacement APIs. The specific steps are as follows:
[0029] Step S401: For the collected Android framework code base, obtain deprecation and replacement information from the API and its corresponding description. The specific steps are as follows:
[0030] A rule-based approach is used to identify deprecated APIs and their replacement information from API descriptions, where: the extraction rules use the relevant rules proposed by Li L, Gao J, Bissyandé T F, et al. (Cda: Characterizing deprecated android apis[J]. Empirical Software Engineering, 2020, 25: 2058-2098.); the replacement information is given in two forms: (1) API-level replacement, that is, replacement information from deprecated API to replacement API, and (2) class-level replacement, that is, replacement information from deprecated class to replacement class.
[0031] Step S402: For API-level replacement information, a corresponding replacement API may be obtained.
[0032] Step S403: For class-level replacement information, the API of the deprecated class and its description are saved as a file, and the API of the replacement class and its description are also saved as one (or more) files accordingly. If the class names are the same, the replacement API is obtained by method name matching. Otherwise, ChatGPT is used to obtain the mapping between the deprecated API and the replacement API. The obtained result is merged with the result in step S402 to obtain a total of N replaced deprecated APIs. The specific steps are as follows:
[0033] Step S40301: For replacement information with the same class name, match the method names between the two classes and use the method with the same name as the replacement API.
[0034] Step S40302: For replacement information with different class names, upload the files related to the deprecated class and the replacement class to ChatGPT, and add prompts to obtain the mapping of the deprecated API to the replacement API. The prompt words refer to White J, Hays S, Fu Q, et al. (Chatgpt prompt patterns for improving code quality, refactoring, requirements elicitation, and software design [M] / / Generative AI for Effective Software Development. Cham: Springer Nature Switzerland, 2024: 71-108.) and other people's research on ChatGPT in the field of software engineering. The ChatGPT prompt words used in the present invention and their examples are as follows: Figure 2-Figure 4 shown.
[0035] Step S40303: Combine the obtained replacements between APIs with the result in step S402 to obtain a total of N replacements between APIs.
[0036] Step S5: construct a set for each of the N deprecated APIs in step S4, each set contains a deprecated API and its corresponding replacement API, and merge the sets with common elements to finally obtain n mutually non-intersecting sets, i.e., the representation form of the API in the Android framework evolution scenario. The specific steps are as follows:
[0037] Step S501: Initialize N empty sets, and add N deprecated APIs and their replacement APIs to the N sets respectively, so that each set eventually contains a deprecated API and its replacement API.
[0038] Step S502: recursively compare the N sets in pairs, and if there are common elements, merge the sets until n mutually non-overlapping sets are obtained, that is, the representation of the API in the Android framework evolution scenario.
Claims
1. A permission and API representation method in an Android framework evolution scenario, characterized in that The method comprises the following steps: Step S1: Collect the permission descriptions of each version of Android and the code base of each version of Android framework; Step S2: Obtain all deprecated permissions from the collected Android permission descriptions of various versions, where M deprecated permissions have replacement permissions, and obtain the corresponding replacement permissions; Step S3: construct a set for each of the M deprecated permissions in step S2, each set contains a deprecated permission and its corresponding replacement permission, and merge the sets with common elements to finally obtain m mutually disjoint sets, i.e., the representation form of permissions in the Android framework evolution scenario; Step S4: Obtain all deprecated APIs from the Android framework code base of each version, where N deprecated APIs have replacement APIs, and obtain the corresponding replacement APIs; Step S5: construct a set for each of the N deprecated APIs in step S4, each set contains a deprecated API and its corresponding replacement API, and merge the sets with common elements to finally obtain n non-overlapping sets, which are the representation of APIs in the Android framework evolution scenario.
2. The permission and API representation method in the Android framework evolution scenario according to claim 1 is characterized in that The specific steps of step S1 are as follows: Step S101: Collect all permissions and their related descriptions from the Android official documentation using a crawler; Step S102: obtaining Android open source codes of various versions from the Android open source code base according to the correspondence between Android versions and API levels and tags in the code base, and obtaining APIs and their descriptions.
3. The permission and API representation method in the Android framework evolution scenario according to claim 1 is characterized in that In step S2, a replacement permission is obtained from the deprecated permission description in a rule-based manner.
4. The permission and API representation method in the Android framework evolution scenario according to claim 3 is characterized in that The rules are as follows: (1) Deprecated permissions are given in the form of 'This constant was deprecated in API level…'; (2) If there is a replacement permission, the replacement permission is given in the form of 'use replacement permission instead' or 'request replacement permission instead'.
5. The permission and API representation method in the Android framework evolution scenario according to claim 1 is characterized in that The specific steps of step S3 are as follows: Step S301: Initialize M empty sets, and add M deprecated permissions together with their replacement permissions to M sets respectively, so that each set finally contains a deprecated permission and its replacement permission; Step S302: recursively compare the M sets in step S301 in pairs, and if there are common elements, merge the sets until m mutually non-overlapping sets are obtained, which are the representation forms of permissions in the Android framework evolution scenario.
6. The permission and API representation method in the Android framework evolution scenario according to claim 1 is characterized in that The specific steps of step S4 are as follows: Step S401: For the collected Android framework code base, obtain deprecation and replacement information from the API and its corresponding description; Step S402: For the API-level replacement information, obtain the corresponding replacement API; Step S403: For class-level replacement information, save the API of the deprecated class and its description as a file, and save the API of the replacement class and its description as one or more files accordingly. If the class names are the same, use method name matching to obtain the replacement API, otherwise use ChatGPT to obtain the mapping between the deprecated API and the replacement API, and merge the obtained result with the result in step S402 to obtain a total of N deprecated APIs with replacements.
7. The permission and API representation method in the Android framework evolution scenario according to claim 6 is characterized in that In step S401, a rule-based approach is used to identify deprecated APIs and their replacement information from the API description.
8. The permission and API representation method in the Android framework evolution scenario according to claim 6 is characterized in that The specific steps of step S403 are as follows: Step S40301: For replacement information with the same class name, match the method names between the two classes and use the method with the same name as the replacement API; Step S40302: For replacement information with different class names, upload the files related to the deprecated class and the replacement class to ChatGPT, and add a prompt to obtain the mapping of the deprecated API to the replacement API; Step S40303: Combine the obtained replacements between APIs with the result in step S402 to obtain a total of N replacements between APIs.
9. The permission and API representation method in the Android framework evolution scenario according to claim 1, characterized in that The specific steps of step S5 are as follows: Step S501: Initialize N empty sets, and add N deprecated APIs and their replacement APIs to the N sets respectively, so that each set eventually contains a deprecated API and its replacement API; Step S502: recursively compare the N sets in pairs, and if there are common elements, merge the sets until n mutually non-overlapping sets are obtained, that is, the representation of the API in the Android framework evolution scenario.
