Application control method, apparatus, and electronic device

By sending a permission request message when a permission is requested, the problem of resource waste caused by continuous permission requests by the application is solved, and more efficient resource management is achieved.

CN115167990BActive Publication Date: 2026-07-21GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
Filing Date
2021-04-07
Publication Date
2026-07-21

Smart Images

  • Figure CN115167990B_ABST
    Figure CN115167990B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses an application program control method and device and electronic equipment. It belongs to the technical field of terminals. The method comprises the following steps: an application program requests to obtain a device use permission corresponding to a target device, wherein the application program that obtains the device use permission is allowed to use the target device; if the application program receives a permission occupation message, the application program stops requesting to obtain the device use permission, and the permission occupation message is used for notifying the application program that the device use permission is occupied by other application programs. Thus, through the above method, the application program will not continuously consume system resources to request to obtain the device use permission in the case that the device use permission is preempted by other application programs, and thus, the waste of system resources is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal technology, and more specifically, to an application control method, apparatus, and electronic device. Background Technology

[0002] As electronic devices support more and more functions, they are equipped with various components, such as microphones and cameras. When an application in an electronic device needs to access data collected by these components, it must first obtain permission to use the corresponding component. For example, a voice recognition application needs to obtain permission to use the audio component associated with the microphone to access audio data collected by the microphone. Summary of the Invention

[0003] In view of the above problems, this application proposes an application control method, apparatus, and electronic device to improve the above problems.

[0004] In a first aspect, this application provides an application control method applied to an application, the method comprising: an application requesting to obtain device usage permission corresponding to a target device, wherein the application obtaining the device usage permission is permitted to use the target device; if the application receives a permission occupancy message, the application stops requesting to obtain the device usage permission, the permission occupancy message being used to notify the application that the device usage permission has been occupied by another application.

[0005] Secondly, this application provides an application control method applied to a system service. The method includes: if a first application obtains device usage permission corresponding to a target device and obtains a request from a second application to obtain the device usage permission, sending a permission occupancy message to the second application to cause the second application to stop obtaining the device usage permission, wherein the second application is the application that requested the device usage permission; the permission occupancy message is used to notify the second application that the device usage permission is occupied by another application.

[0006] Thirdly, this application provides an application control method applied to a device management module, which manages the device usage permissions of a target device. The method includes: after a first application obtains the device usage permissions of the target device, if a request to obtain the device usage permissions of the target device is received from a second application; sending a permission occupation message to the second application to cause the second application to stop obtaining the device usage permissions, wherein the second application is the application that requested to obtain the device usage permissions; the permission occupation message is used to notify the second application that the device usage permissions are occupied by another application.

[0007] Fourthly, this application provides an application control device running on an application. The device includes: a permission acquisition unit, used by the application to request and acquire device usage permission corresponding to a target device, wherein the application acquiring the device usage permission is allowed to use the target device; and an information communication unit, used to receive messages. After the device usage permission is occupied, if the information communication unit receives a permission occupation message, the permission acquisition unit stops re-acquiring the device usage permission, and the permission occupation message is used to notify the second application that the device usage permission has been occupied by another application.

[0008] Fifthly, this application provides an application control device running on a system service. The device includes: a message sending unit, configured to send a permission occupation message to the second application if a first application obtains device usage permission corresponding to a target device and obtains a request from a second application to obtain the device usage permission, so as to cause the second application to stop obtaining the device usage permission, wherein the second application is the application that requested to obtain the device usage permission; the permission occupation message is used to notify the second application that the device usage permission is occupied by another application.

[0009] Sixthly, this application provides an application control device running in a device management module. The device management module is used to manage the device usage permissions of a target device. The device includes: a permission management unit, used to, after a first application obtains the device usage permissions of the target device, receive a request from a second application to obtain device usage permissions of the target device; and a message sending unit, used to send a permission occupation message to the second application to cause the second application to stop obtaining the device usage permissions, wherein the second application is the application that requested to obtain the device usage permissions; the permission occupation message is used to notify the second application that the device usage permissions are occupied by another application.

[0010] In a seventh aspect, this application provides an electronic device including one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the methods described above.

[0011] Eighthly, this application provides a computer-readable storage medium storing processor-executable program code, the computer-readable storage medium including stored program code, wherein the above-described method is executed when the program code is run by a processor.

[0012] This application provides an application control method, apparatus, and electronic device that, after an application requests device usage rights for a target device, sends a permission occupation message to the application if those rights are already occupied by another application. Upon receiving this message, the application stops attempting to re-acquire device usage rights. This method prevents the application from continuously consuming system resources to request device usage rights when they are already occupied by another application, thus reducing resource waste. Attached Figure Description

[0013] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 A schematic diagram illustrating an application scenario of the application control method proposed in this application is shown;

[0015] Figure 2 A flowchart of an application control method proposed in an embodiment of this application is shown;

[0016] Figure 3 This diagram illustrates a cycle in which an application requests device usage rights.

[0017] Figure 4 A flowchart of an application control method according to another embodiment of this application is shown;

[0018] Figure 5 This illustration shows a schematic diagram of the device management module synchronizing device usage rights with the system service in an embodiment of this application, including the usage status and request status.

[0019] Figure 6 This illustration shows a schematic diagram of an application being switched to run in the background according to an embodiment of this application;

[0020] Figure 7 A flowchart of an application control method according to another embodiment of this application is shown;

[0021] Figure 8 This paper shows a structural block diagram of an application control device according to an embodiment of the present application;

[0022] Figure 9 A structural block diagram of an application control device according to another embodiment of this application is shown;

[0023] Figure 10 This paper shows a structural block diagram of an application control device according to another embodiment of the present application;

[0024] Figure 11 This invention illustrates a structural block diagram of an electronic device for performing an application control method according to an embodiment of the present invention;

[0025] Figure 12 This is a storage unit in this application embodiment for storing or carrying program code that implements the application control method according to this application embodiment. Detailed Implementation

[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0027] As electronic devices become increasingly feature-rich, they can achieve more advanced functions through installed components. For example, an electronic device equipped with a microphone can acquire and process audio data, then perform corresponding actions based on the recognition results. Similarly, an electronic device with an accelerometer can sense its own acceleration magnitude and direction, allowing for tailored operations. For instance, an electronic device can use acceleration to control operations within an application. Furthermore, an electronic device with a proximity sensor can control itself based on the data detected by the sensor. For example, it can control whether the screen is on or off.

[0028] When multiple applications can use a device within an electronic device, the device can assign specific usage permissions to that device, allowing only applications with the appropriate permissions to use it. For example, a voice recognition application needs to obtain microphone access permissions to access audio data collected by a microphone. Similarly, an image capture application needs flash access permissions to use the flash for supplemental lighting in a photo.

[0029] However, the inventors discovered that when related applications have already acquired device usage rights but are then preempted, they will attempt to reacquire those rights using a polling method until they successfully regain them, resulting in resource waste. Specifically, during the process of reacquiring device usage rights, applications consume processor and system resources. However, the device usage priority of the application whose rights were preempted is generally lower than that of the application that preempted the rights. Therefore, even if the application whose rights were preempted repeatedly attempts to reacquire them, it is actually unable to obtain the necessary permissions, thus wasting the processor and system resources consumed.

[0030] Therefore, the inventors have proposed an application control method, apparatus, and electronic device as described in this application. After an application requests device usage rights for a target device, if those rights are already occupied by another application, the method sends a permission occupation message to the application. Upon receiving this message, the application stops attempting to re-acquire device usage rights. This prevents the application from continuously consuming system resources to request device usage rights when they are already occupied by another application, thus reducing waste of system resources.

[0031] The application environment involved in this application will be introduced below.

[0032] like Figure 1 As shown, the application environment provided in this embodiment includes a hardware abstraction layer, a framework layer, system services, and applications.

[0033] The Framework layer includes a device management module and a data output module. The device management module manages whether applications can obtain device usage permissions and determines which specific application can obtain these permissions. The data output module, under the control of the device management module, executes the actual execution of data collection from the device (i.e.,...) Figure 1 The input stream (including the hardware abstraction layer) is transmitted to the application that has obtained the device's usage rights.

[0034] It should be noted that when an electronic device includes multiple components, the component management module and data output module can be configured separately for each component. For example, if the electronic device includes a microphone and a camera, then separate component management and data output modules can be configured for the microphone and the camera, respectively. For instance, if the electronic device runs on the Android operating system, the component management module for the microphone could be the AudioPolicy module, and the data output module could be the AudioFlinger module. The corresponding input stream in the hardware abstraction layer would then be an audio input stream.

[0035] System services serve as a medium for information transmission between the device management module and applications. Information can be transmitted between the device management module and system services via inter-process communication (IPC), such as through sockets. If the device management module needs to notify an application which application currently holds device usage rights, it can send a notification message to the system service. Upon receiving this message, the system service can then broadcast the application holding device usage rights to other applications via a broadcast message. The implementation of system services can differ across operating systems. For example, if the electronic device uses the Android operating system, the system service can be a service built upon the Service component.

[0036] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0037] Please see Figure 2 This application provides an application control method, applied to an application, the method comprising:

[0038] S110: The application requests to obtain device usage permission corresponding to the target device, wherein the application that obtains the device usage permission is allowed to use the target device.

[0039] In this process, an application will only be allowed to use a target device after obtaining the necessary device usage permissions from the electronic device on which the application resides. The application's use of the target device can include utilizing the device's functions or acquiring data collected by the device. For example, if the target device is a flash, the application, after obtaining the necessary device usage permissions, can activate the flash at the required time. Similarly, if the target device is a microphone, the application, after obtaining the necessary device usage permissions, can acquire the audio data collected by the microphone. And if the target device is a camera, the application, after obtaining the necessary device usage permissions, can acquire the image data collected by the camera.

[0040] The target device refers to the device requested by the application. For example, if the application's function is voice recognition, then the device requested by the application for voice recognition could be a microphone. As another example, if the application's function is a flashlight, then the device requested by the application for a flashlight could be a flashlight. Yet another example, if the application's function is image acquisition, then the device requested by the application for image acquisition could be a microphone and a camera.

[0041] In this application embodiment, the application can request and obtain device usage rights for the target device under various circumstances.

[0042] As one approach, an application can request additional device usage permissions for a target device if those permissions are already in use. It's important to note that in electronic devices, different applications may have different usage priorities for the same device. For example, in the Android system, the microphone's usage priority can include both HOTWORD-based and non-HOTWORD-based priorities. HOTWORD-based priorities have the lowest priority.

[0043] Applications with higher usage priority are more likely to obtain device usage rights. When an electronic device receives a request from an application to use a device, it compares the usage priority of the requesting application with that of an application that already holds the device usage rights. If the usage priority of the application that already holds the device usage rights is lower than that of the requesting application, the electronic device will transfer the device usage rights to the requesting application.

[0044] For example, when it comes to microphones, voice recognition applications have lower usage priority than voice call applications (e.g., applications that can make Bluetooth voice calls). So, if a voice recognition application already has device access to the microphone, and the electronic device receives a request from a voice call application to use the microphone, it will transfer the microphone's device access to the voice call application. Conversely, if a voice recognition application's previously acquired microphone access has been preempted by the voice call application, the voice recognition application can request device access to the target device through a polling process.

[0045] As another approach, an application can request device access permissions for a target device while it is running. Specifically, an application can determine it is running once it detects that it has been launched. For example, some electronic devices have voice recognition capabilities, which can be implemented through a voice recognition application installed on the device. When the electronic device starts up, the installed voice recognition application can start simultaneously, and then request device access permissions for the microphone.

[0046] As another approach, the application can request device usage permissions for the target device after displaying the specified function interface. For example, some instant messaging applications also have QR code payment functionality; for such applications, they can request device usage permissions for the target device (e.g., a camera) when displaying the QR code scanning interface.

[0047] S120: If the application receives a permission occupancy message, the application stops requesting to obtain the device usage permission. The permission occupancy message is used to notify the application that the device usage permission has been occupied by another application.

[0048] In this process, the application can use a polling method to request device usage rights for a target device. If the application fails to obtain device usage rights, it will re-request the rights after a specified interval until it obtains them. However, initiating these requests consumes processor and system resources (e.g., memory). To avoid wasting processor and system resources, the system service in the electronic device can send a permission occupancy message to the application. Upon receiving this message, the application will become idle and stop requesting device usage rights. Correspondingly, as one approach, if the application receives a permission occupancy message, the application stops requesting device usage rights, including: if the application receives a permission occupancy message from the system service, the application stops requesting device usage rights.

[0049] It should be noted that, after the application stops requesting device usage rights for the target device, in order for the application to immediately resume using the target device, in this embodiment, the electronic device can also notify the application by sending a permission occupancy message. As one approach, if the application receives a permission occupancy message and stops requesting device usage rights, the method further includes: if the application receives a permission release message and resumes requesting device usage rights, the permission release message is used to notify the application that the device usage rights are in an idle state.

[0050] Specifically, the permission release message allows the application to promptly resume requesting device usage permissions after it has stopped acquiring them, thus facilitating the application's rapid use of the target device. For example, ... Figure 3As shown, assuming an application can request device usage rights for a target device every n intervals starting from time t, if a request fails, the application needs to wait n hours before making the next request. For example, if the application fails to request at time t+n, it will wait until time t+2n to make the next request. However, the application that has been holding device usage rights for the target device may have already released those rights between t+n and t+2n. Therefore, the application that originally obtained device usage rights cannot use the target device in a timely manner. The method provided in this embodiment allows an application that is idle and has stopped acquiring device usage rights to immediately resume requesting device usage rights upon receiving a permission release message. For example, if the application receives a permission release message at some point between t+n and t+2n, it can immediately resume requesting device usage rights upon receiving the message.

[0051] In one embodiment, the target device includes a microphone, and the data acquired by the target device includes audio data acquired by the microphone.

[0052] This embodiment provides an application control method that, after an application requests device usage rights for a target device, if those rights are already occupied by another application, sends a permission occupation message to the application. Upon receiving this message, the application stops attempting to re-acquire device usage rights. This method prevents the application from continuously consuming system resources to request device usage rights when they are already held by another application, thus reducing waste of system resources.

[0053] Please see Figure 4 This application provides an application control method for system services, the method comprising:

[0054] S210: If the first application obtains device usage rights corresponding to the target device, and receives a request from the second application to obtain the device usage rights, a permission occupancy message is sent to the second application to cause the second application to stop obtaining the device usage rights. The second application is the application that requested the device usage rights. The permission occupancy message is used to notify the second application that the device usage rights are occupied by another application.

[0055] In this embodiment of the application, the sending of messages to the application can be accomplished by a system service.

[0056] In one approach, the system service can determine the appropriate usage information based on the device's permission status and request status. In this method, the device management module for each device can synchronize the device permission status and request status to the system service, allowing the system service to also synchronously obtain the current device permission status and request status. Based on this information, the system service can then determine when to send a permission usage message.

[0057] For example, such as Figure 5 As shown, the system includes three modules: Module 1, Module 2, and Module 3. Module 1 manages the usage permissions of Device 1, and can synchronize the usage permission status and request information of Device 1 with the system service. Module 2 manages the usage permissions of Device 2, and can synchronize the usage permission status and request information of Device 2 with the system service. Module 3 manages the usage permissions of Device 3, and can synchronize the usage permission status and request information of Device 3 with the system service.

[0058] After receiving the occupancy status and request information from each device management module, the system service can generate... Figure 4 The data table shown contains the following information. This data table can record the current occupant and requester for each device. The current occupant is the application that currently occupies the device and has the corresponding device usage rights. The requester is any application that, after the current occupant is determined, sent a device usage rights request but failed to obtain the rights. Furthermore, there can be more than one requester for a device; for example, in... Figure 5 The requesters corresponding to device 1 can be application 2 and application 4. This indicates that during the period when the current occupant of device 1 was updated to application 1, both application 2 and application 4 sent requests for device usage rights to device 1, but neither successfully obtained device usage rights. Optionally, after the current occupant of the device is updated, the requesters corresponding to the device can be updated synchronously.

[0059] Furthermore, as another approach, the system service can determine the specific timing for sending a permission occupancy message based on instructions from the device management module. In this method, the device management module doesn't need to synchronize device usage permission request and occupancy status with the system service; instead, it can directly send a notification message, which the system service can interpret as a triggering instruction. For example, if device management module 1 wants the system service to broadcast a message stating that device usage permission for device 1 has been occupied by application 1, device management module 1 can send a notification message to the system service. The system service can then respond to this notification message by broadcasting a permission occupancy message indicating that device usage permission for device 1 has been occupied by application 1, thereby preventing other applications requesting device usage permission for device 1 from making their requests.

[0060] It should be noted that, as described above, permission occupancy messages can be triggered by system services based on occupancy and request status, or by notification messages sent by the device management module. The resource consumption of these two methods can differ. For example, if triggered by system services based on occupancy and request status, the increased decision-making steps required by the system service will result in higher resource consumption (processor and memory resources). However, in electronic devices, the resources allocated to each module are likely limited. If a module's resource requirements approach or exceed the allocated resources, the module's performance may lag, causing overall lag in the electronic device. Therefore, to reduce the probability of lag in electronic devices, the system service can determine which method to use to trigger the permission occupancy message sent to the application based on its own resource consumption.

[0061] Optionally, the system service can compare the occupied resources with the resources allocated to the electronic device. If the difference between the occupied and allocated resources meets a threshold condition, the system service determines to trigger a permission occupancy message based on the device management permission occupancy and request status sent by the device management module. Optionally, if the system service determines that the difference between the occupied and allocated resources does not meet the threshold condition, the system service can determine that the device management module determines the specific timing for sending the permission occupancy message.

[0062] After determining the triggering method for the permission occupancy message, the system service can send a message to the device management module. This message carries the determined triggering method, allowing the device management module to determine the content to send to the system service based on this information. For example, if the system service's message to the device management module indicates that the permission occupancy message is triggered by the system service based on the device management module's information regarding permission occupancy and requests, then the device management module will begin synchronizing the device usage permission occupancy and request information with the system service. Conversely, if the received message from the system service indicates that the device management module itself determines when to send the permission occupancy message, then the device management module will stop synchronizing the device usage permission occupancy and request information with the system service and will instead send a notification message to the system service when it determines that a permission occupancy message needs to be sent.

[0063] The threshold condition indicates that the resources occupied by the system service will not affect the normal operation of the system service. Optionally, the threshold condition may include the difference between the occupied resources and the allocated resources being lower than a specified threshold. Where there are multiple types of resources, a specified threshold may be assigned to each type of resource, and the threshold condition is determined to be met if the difference for each type of resource satisfies the specified threshold for that type of resource.

[0064] For example, the resources involved in the threshold condition may include processor resources and memory resources. There may be a specified threshold for processor resources and a specified threshold for memory resources. Therefore, if the difference between the occupied processor resources and the allocated processor resources is less than the specified threshold for processor resources, and the difference between the occupied memory resources and the allocated memory resources is less than the specified threshold for memory resources, then the threshold condition is determined to be met. Conversely, if the difference between the occupied processor resources and the allocated processor resources is not less than the specified threshold for processor resources, or the difference between the occupied memory resources and the allocated memory resources is not less than the specified threshold for memory resources, then the threshold condition is determined not to be met.

[0065] Because the system service can determine the triggering method of permission occupation messages and permission release messages by whether the ratio of occupied resources to allocated resources meets the threshold condition mentioned above, the triggering of permission occupation messages and permission release messages is improved. At the same time, it is also helpful to avoid electronic device lag caused by adding extra judgment logic in the system service (i.e., the logic of triggering permission occupation messages and permission release messages based on the occupation and request status of device usage permissions).

[0066] Furthermore, to facilitate applications requesting device usage permissions to understand what operation they are actually performing once they have acquired device usage permissions, as a method, sending a permission occupancy message to the second application includes: sending a permission occupancy message to the second application carrying the identifier of the first application and the operation of the first application, wherein the operation is the first application occupies the device usage permissions. The application identifier can be a PID (Process ID) or the application's package name.

[0067] As one approach, if the first application obtains device usage permission corresponding to the target device and receives a request from the second application to obtain the device usage permission, after sending a permission occupation message to the second application, the method further includes: if the first application releases the device usage permission corresponding to the target device, sending a permission release message to the second application, so that the second application can resume requesting to obtain the device usage permission; the permission release message is used to notify the application that the device usage permission is in an idle state.

[0068] It should be noted that in this embodiment, there may be multiple ways to send the permission occupation message. After the specific method of sending the permission occupation message is determined, the method of sending the corresponding permission release message is the same as the method of sending the determined permission occupation message.

[0069] For example, if the system service triggers the permission occupancy message based on the occupancy and request information sent by the device management module, then the permission release message will also be triggered based on the same occupancy and request information sent by the device management module. As another example, if the device management module sends a notification message to the system service to trigger the permission occupancy message, then the permission release message will also be triggered by the device management module sending a notification message to the system service. It's important to understand that the content of the notification message that triggers the system service to send the permission occupancy message will differ from the content of the notification message that triggers the system service to send the permission release message.

[0070] As one approach, after the second application stops acquiring device usage permissions for the target device, besides restoring the requested device usage permissions by receiving a permission release message, there are other ways to restore the requested device usage permissions. It should be noted that applications typically only acquire device usage permissions for the target device while they are running. For example, a voice call application only acquires microphone usage permissions while it is running. Therefore, when an application exits its running state (e.g., the application's main process is closed), it will no longer occupy device usage permissions. Furthermore, after the device usage permissions acquired by an application are occupied, the application whose device usage permissions were preempted may be switched to run in the background. For example, such as... Figure 6 As shown. In Figure 6 The image on the left exemplarily illustrates the interface 10 of a voice recognition application. Figure 6 In the case of the smartwatch display interface 10 shown, the voice recognition application currently has device access to the microphone. When the smartwatch detects an incoming call, the voice call application will start, causing the smartwatch to switch to display mode. Figure 6 The incoming call interface 20 is shown in the image on the right. When the smartwatch displays the incoming call interface 20, the voice call application has already obtained the device access permission for the microphone, while the voice recognition application, whose device access permission for the microphone has been taken over, has been switched to run in the background, or in other words, the interface of the voice recognition application is covered by the incoming call interface of the voice call application.

[0071] In this approach, an application that stopped requesting device usage rights in response to a permission occupancy message can determine whether to resume requesting device usage rights based on whether it has been switched to the foreground or whether other applications' interfaces are covering its own. Optionally, if an application that stopped requesting device usage rights in response to a permission occupancy message detects that it has switched to the foreground, it can determine that the application that previously preempted device usage rights has exited, and thus can request to acquire device usage rights for the target device. Optionally, if an application that stopped requesting device usage rights in response to a permission occupancy message detects that no other applications' interfaces are covering its own, it can determine that the application that previously preempted device usage rights has exited, and thus can request to acquire device usage rights for the target device.

[0072] It should be noted that while an application can determine which method to use to restore access to the requested device through multiple methods, it can also choose the specific method based on its own circumstances. One approach is for the application to determine which method to use to restore access to the requested device, provided it does not include a user interface (e.g., ...). Figure 6 In the case of interface 10 shown, the permission to use the requested device is restored according to the permission reply message. Correspondingly, if it is determined that it includes the user operation interface, the permission to use the requested device can be restored if it is detected that it is running in the foreground or that no other application interface is covering its own interface.

[0073] This embodiment provides an application control method that, after a first application requests device usage rights for a target device, if those rights are already occupied by a second application, sends a permission occupation message to the second application. This prevents the first application from re-acquiring device usage rights if it receives the message. Therefore, this method ensures that if the first application has already acquired device usage rights, and those rights are subsequently preempted by the second application, it will not continuously consume system resources by requesting device usage rights again, thus reducing waste of system resources.

[0074] Please see Figure 7 This application provides an application control method applied to a device management module, which manages the device usage permissions of a target device. The method includes:

[0075] S310: After the first application obtains the device usage permission of the target device, if it receives a request from the second application to obtain the device usage permission of the target device, it sends a permission occupation message to the second application to make the second application stop obtaining the device usage permission. The second application is the application that requested to obtain the device usage permission.

[0076] The permission occupancy message is used to notify the second application that the device usage permission has been occupied by another application.

[0077] It should be noted that the device management module is used to manage the device usage permissions of the corresponding devices. Before an application needs to use a target device, it can send a request to the device management module to obtain the corresponding device usage permissions. After receiving the request from the application, the device management module compares the usage priority of the requesting application with the usage priority of the application that has already obtained the target device. If the usage priority of the requesting application is not higher than the usage priority of the application that has already obtained the target device, the device management module will reject the request and continue to maintain the device usage permissions of the application that has already obtained the target device.

[0078] As one method, sending the permission request message to the second application includes:

[0079] A notification message is sent to the system service, which triggers the system service to send the permission occupancy message to the first application.

[0080] As one approach, if the first application obtains device usage permission corresponding to the target device and receives a request from the second application to obtain the device usage permission, after sending a permission occupation message to the second application, the method further includes: if the first application releases the device usage permission corresponding to the target device, sending a permission release message to the second application, so that the second application can resume requesting to obtain the device usage permission; the permission release message is used to notify the application that the device usage permission is in an idle state.

[0081] This embodiment provides an application control method that, after a first application requests device usage rights for a target device, if those rights are already occupied by a second application, the device management module sends a permission occupation message to the second application. This prevents the first application from re-acquiring device usage rights if it receives the message. Therefore, this method ensures that if the first application has already acquired device usage rights, and those rights are subsequently preempted by the second application, it will not continuously consume system resources by requesting new device usage rights, thus reducing waste of system resources.

[0082] Please see Figure 8 This application provides an application control device 400, which runs on an application. The device 400 includes:

[0083] The permission acquisition unit 410 is used for an application to request and acquire device usage permission corresponding to the target device, wherein the application that acquires the device usage permission is allowed to use the target device;

[0084] Information communication unit 420, used for receiving messages;

[0085] After the device usage permission is occupied, if the information communication unit 420 receives a permission occupancy message, the permission acquisition unit 410 stops re-acquiring the device usage permission. The permission occupancy message is used to notify the second application that the device usage permission has been occupied by another application.

[0086] In one manner, the information communication unit 420 is specifically used to receive messages sent by the system service. In this manner, if the information communication unit 420 receives a permission occupancy message sent by the system service, the permission acquisition unit 410 stops re-acquiring the device usage permission.

[0087] In one manner, the permission acquisition unit 410 is also configured to, if the application receives a permission release message, resume requesting to acquire the device usage permission, wherein the permission release message is used to notify the application that the device usage permission is in an idle state.

[0088] Optionally, the target device includes a microphone, and the data collected by the target device includes audio data collected by the microphone.

[0089] Please see Figure 9 This application provides an application control device 500 that runs on system services. The device 500 includes:

[0090] The message sending unit 510 is configured to send a permission occupation message to the second application if the first application obtains the device usage permission corresponding to the target device and obtains a request from the second application to obtain the device usage permission, so as to cause the second application to stop obtaining the device usage permission, wherein the second application is the application that requested to obtain the device usage permission;

[0091] The permission occupancy message is used to notify the second application that the device usage permission has been occupied by another application.

[0092] In one manner, the message sending unit 510 is specifically used to send a permission occupancy message to the second application, which carries the identifier of the first application and the operation of the first application, wherein the operation is the first application occupying the device's usage permission.

[0093] The message sending unit 510 is further configured to send a permission release message to the second application if the first application releases the device usage permission corresponding to the target device, so that the second application can restore the request to obtain the device usage permission;

[0094] The permission release message is used to notify the application that the device's usage permission is in an idle state.

[0095] Please see Figure 10 This application provides an application control device 600, which runs in a device management module. The device management module is used to manage the device usage permissions of a target device. The device 600 includes:

[0096] The permission management unit 610 is used to, after the first application obtains the device usage permission of the target device, if it receives a request from the second application to obtain the device usage permission of the target device;

[0097] The message sending unit 620 is used to send a permission occupancy message to the second application to cause the second application to stop obtaining the device usage permission, wherein the second application is the application that requested to obtain the device usage permission;

[0098] The permission occupancy message is used to notify the second application that the device usage permission has been occupied by another application.

[0099] In one manner, the message sending unit 620 is specifically used to send a notification message to the system service, the notification message being used to trigger the system service to send the permission occupancy message to the first application.

[0100] This application provides an application control device and electronic device that, after an application requests device usage rights for a target device, sends a permission occupation message to the application if those rights are already occupied by another application. Upon receiving this message, the application will stop attempting to re-acquire device usage rights. This method prevents the application from continuously consuming system resources to request device usage rights when they are already occupied by another application, thus reducing waste of system resources.

[0101] It should be noted that the device embodiments in this application correspond to the aforementioned method embodiments. The specific implementation principles of each unit in the device embodiments are similar to those in the aforementioned method embodiments. The specific content in the device embodiments can be found in the method embodiments, but will not be repeated in the device embodiments.

[0102] The following will combineFigure 11 This application describes an electronic device.

[0103] Please see Figure 11 Based on the aforementioned text processing methods and apparatus, this application also provides another electronic device 200 capable of executing the aforementioned text processing methods. The electronic device 200 includes one or more (only one shown in the figure) processors 102, a memory 104, and a network module 106 coupled together. The memory 104 stores programs capable of executing the contents of the aforementioned embodiments, and the processors 102 can execute the programs stored in the memory 104.

[0104] The processor 102 may include one or more cores for processing data. The processor 102 connects to various parts of the electronic device 200 using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 104, and by calling data stored in the memory 104. Optionally, the processor 102 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 102 may integrate one or more of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 102 and may be implemented separately using a communication chip.

[0105] The memory 104 may include random access memory (RAM) or read-only memory (ROM). The memory 104 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 104 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method embodiments described below. The data storage area may also store data created by the terminal 100 during use (such as phonebook data, audio and video data, chat log data, etc.).

[0106] The network module 106 is used to receive and transmit electromagnetic waves, realizing the mutual conversion between electromagnetic waves and electrical signals, thereby communicating with communication networks or other devices, such as audio playback devices. The network module 106 may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, user identity modules (SIM cards), memory, etc. The network module 106 can communicate with various networks such as the Internet, corporate intranets, and wireless networks, or communicate with other devices through wireless networks. The aforementioned wireless networks may include cellular telephone networks, wireless local area networks (WLANs), or metropolitan area networks (MANs). For example, the network module 106 can interact with base stations.

[0107] Please refer to Figure 12 This diagram illustrates a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. The computer-readable medium 1100 stores program code that can be called by a processor to execute the methods described in the above method embodiments.

[0108] The computer-readable storage medium 1100 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 1100 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 1100 has storage space for program code 1110 that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code 1110 may, for example, be compressed in a suitable form.

[0109] In summary, the application control method, apparatus, and electronic device provided in this application, after an application requests device usage rights corresponding to a target device, sends a permission occupation message to the application if those rights are already occupied by another application. This prevents the application from re-acquiring device usage rights upon receiving the message. Therefore, this method ensures that the application will not continuously consume system resources to request device usage rights when they are preempted by other applications, thereby reducing waste of system resources.

[0110] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0111] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0112] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the function involved, as will be understood by those skilled in the art to which embodiments of this application pertain.

[0113] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).

[0114] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical feature diagrams. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. An application control method, characterized in that, Applied to an application, the method includes: The application requests device usage permission corresponding to the target device, wherein the application that obtains the device usage permission is allowed to use the target device; If the application receives a permission occupancy message from the system service, the application stops requesting permission to use the device. The permission occupancy message is used to notify the application that the device usage permission has been occupied by another application. If the difference between the resources occupied by the system service and the allocated resources meets a threshold condition, it is determined that the system service sends the permission occupancy message based on the device management permission occupancy and request status sent by the device management module. If it is determined that the difference between the resources occupied by the system service and the allocated resources does not meet the threshold condition, it is determined that the system service sends the permission occupancy message in response to a notification message sent by the device management module, where the device management module is the management module corresponding to the target device. If the application receives a permission release message, it resumes the request to obtain permission to use the device. The permission release message is used to notify the application that the device usage permission is in an idle state.

2. The method according to claim 1, characterized in that, The application requests device usage permissions corresponding to the target device, including: If the device usage permission obtained by the application is occupied, the application requests to obtain the device usage permission corresponding to the target device.

3. The method according to any one of claims 1-2, characterized in that, The target device includes a microphone, and the data collected by the target device includes audio data collected by the microphone.

4. An application control method, characterized in that, Applied to system services, the method includes: If the first application obtains device usage permission corresponding to the target device and receives a request from the second application to obtain the device usage permission, a permission occupation message is sent to the second application to stop the second application from obtaining the device usage permission. The second application is the application that requested the device usage permission. If the difference between the resources occupied by the system service and the allocated resources meets a threshold condition, it is determined that the system service sends the permission occupation message based on the device management permission occupation and request status sent by the device management module. If it is determined that the difference between the resources occupied by the system service and the allocated resources does not meet the threshold condition, it is determined that the system service sends the permission occupation message in response to a notification message sent by the device management module. The device management module is the management module corresponding to the target device. The permission occupancy message is used to notify the second application that the device usage permission has been occupied by another application. If the first application releases the device usage permission corresponding to the target device, it sends a permission release message to the second application so that the second application can restore the request to obtain the device usage permission; The permission release message is used to notify the second application that the device usage permission is in an idle state.

5. The method according to claim 4, characterized in that, Send a permission request message to the second application, including: Send a permission occupancy message to the second application, which carries the identifier of the first application and the operation of the first application, wherein the operation is the first application occupying the device's usage permission.

6. An application control method, characterized in that, Applied to a device management module, which manages device usage permissions for target devices, the method includes: After the first application obtains the device usage permission for the target device, if it receives a request from the second application to obtain the device usage permission for the target device, and the difference between the resources occupied by the system service and the allocated resources does not meet the threshold condition, it sends a notification message to the system service. The notification message is used to trigger the system service to send the permission occupation message to the second application, so as to make the second application stop obtaining the device usage permission. The second application is the application that requests to obtain the device usage permission. Wherein, if the difference between the resources occupied by the system service and the allocated resources meets the threshold condition, the system service sends the permission occupation message according to the device management permission occupation status and request status sent by the device management module. The permission occupancy message is used to notify the second application that the device's usage permission has been occupied by another application. If the first application releases the device usage permission corresponding to the target device, it sends a permission release message to the second application so that the second application can resume requesting to obtain the device usage permission; the permission release message is used to notify the second application that the device usage permission is in an idle state.

7. An application control device, characterized in that, Running on an application, the device includes: The permission acquisition unit is used for an application to request and acquire device usage permission corresponding to a target device, wherein the application that acquires the device usage permission is allowed to use the target device; The information communication unit is used to receive messages; After the device usage permission is occupied, if the information communication unit receives a permission occupancy message sent by the system service, the permission acquisition unit stops re-acquiring the device usage permission. The permission occupancy message is used to notify the second application that the device usage permission has been occupied by another application. If the difference between the resources occupied by the system service and the allocated resources meets a threshold condition, it is determined that the system service sends the permission occupancy message based on the device management permission occupancy and request status sent by the device management module. If it is determined that the difference between the resources occupied by the system service and the allocated resources does not meet the threshold condition, it is determined that the system service sends the permission occupancy message in response to a notification message sent by the device management module. The device management module is the management module corresponding to the target device. The permission acquisition unit is further configured to, if the application receives a permission release message, resume requesting to acquire the device usage permission, wherein the permission release message is used to notify the application that the device usage permission is in an idle state.

8. An application control device, characterized in that, Running as a system service, the device includes: A message sending unit is configured to send a permission occupancy message to the second application if the first application obtains device usage permission corresponding to the target device and obtains a request from the second application to obtain the device usage permission, so as to cause the second application to stop obtaining the device usage permission. The second application is the application that requested to obtain the device usage permission. If the difference between the resources occupied by the system service and the allocated resources meets a threshold condition, it is determined that the system service sends the permission occupancy message according to the device management permission occupancy status and request status sent by the device management module. If it is determined that the difference between the resources occupied by the system service and the allocated resources does not meet the threshold condition, it is determined that the system service sends the permission occupancy message in response to a notification message sent by the device management module. The device management module is the management module corresponding to the target device. The permission occupancy message is used to notify the second application that the device's usage permission has been occupied by another application. The message sending unit is further configured to send a permission release message to the second application if the first application releases the device usage permission corresponding to the target device, so that the second application can resume requesting to obtain the device usage permission; the permission release message is used to notify the second application that the device usage permission is in an idle state.

9. An application control device, characterized in that, The device operates within a device management module, which manages the device usage permissions for the target device. The device includes: The permission management unit is used to assign device usage permissions to the target device; The message sending unit is configured to, after the first application obtains the device usage permission of the target device, if it receives a request from the second application to obtain the device usage permission of the target device, and the difference between the resources occupied by the system service and the allocated resources does not meet a threshold condition, send a notification message to the system service. The notification message is used to trigger the system service to send the permission occupation message to the second application, so as to make the second application stop obtaining the device usage permission. The second application is the application that requested to obtain the device usage permission. Wherein, if the difference between the resources occupied by the system service and the allocated resources meets the threshold condition, the system service sends the permission occupation message according to the device management permission occupation status and request status sent by the device management module. The permission occupancy message is used to notify the second application that the device's usage permission has been occupied by another application. The message sending unit is further configured to send a permission release message to the second application if the first application releases the device usage permission corresponding to the target device, so that the second application can resume requesting to obtain the device usage permission; the permission release message is used to notify the second application that the device usage permission is in an idle state.

10. An electronic device, characterized in that, Includes one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the method of any one of claims 1-3, or the method of any one of claims 4-5, or the method of claim 6.

11. A computer-readable storage medium storing processor-executable program code, characterized in that, The computer-readable storage medium includes stored program code, wherein the program code, when executed by a processor, performs the method of any one of claims 1-3, or the method of any one of claims 4-5, or the method of claim 6.