Method and device for monitoring and collecting key data of remote controller

By creating the AccessibilityService service class in the Android set-top box, listening and delaying the processing of global key events of the remote control, the problem of inability to effectively collect global keys in the existing technology is solved, and efficient key data acquisition is achieved.

CN120281948APending Publication Date: 2025-07-08SHANDONG ARTAPLAY INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510301380.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-14
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

In the prior art, Android set-top box cannot effectively monitor and collect global key information of the remote control, especially background applications cannot directly obtain global key data such as HOME keys.

Method used

By creating a service class inherited from AccessibilityService, it listens to the global key events of the device, and filters the raised key events in the onKeyEvent() method, records the key values and names, delays processing of key events, generates only one event data with the same key values, and uses Handler to send a delay message to process key events.

Benefits of technology

Effectively reduce data redundancy, improve the efficiency of remote control button data acquisition, is suitable for set-top boxes and other equipment, and improves the efficiency of manager data acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120281948A_ABST
    Figure CN120281948A_ABST
Patent Text Reader

Abstract

The invention relates to the field of Android set top boxes, and particularly provides a method and a device for monitoring and collecting key data of a remote controller, which are characterized in that a service class inherited from Accessibilization Service is created, raised key events are filtered in an onKeyEvent () method, and key values and names of keys are recorded; only one piece of event data is generated for continuous same key values, the number of times of key pressing is recorded, key pressing events are processed through Handler delay, if the same key is pressed again within delay time, counting is updated, timing is conducted again, and if different keys are pressed, a message is sent immediately, and counting is reset. Compared with the prior art, data redundancy can be effectively reduced through a delay processing mechanism, the method is suitable for remote controller key monitoring of equipment such as a set top box, and the data acquisition efficiency of a manager is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Android set-top boxes, and specifically provides a method and device for monitoring and collecting remote control button data. Background Art

[0002] In the management of Android system set-top boxes, the background manager needs to collect and analyze device usage data, including the data of user operations on the remote control buttons. Usually, the foreground application can only monitor non-global buttons, and the global buttons cannot be directly obtained. For example, the HOME button needs to receive a broadcast sent by the system for indirect monitoring; the background application cannot even monitor the remote control buttons using conventional methods.

[0003] For the scenario of collecting Android set-top box button data, a method for the background application to monitor and collect remote control global button information is needed. Summary of the Invention

[0004] The present invention aims at the deficiencies of the above-mentioned prior art and provides a method for monitoring and collecting remote control button data with strong practicability.

[0005] A further technical task of the present invention is to provide a device for monitoring and collecting remote control button data with reasonable design, safety and applicability.

[0006] The technical solution adopted by the present invention to solve its technical problems is as follows:

[0007] A method for monitoring and collecting remote control button data, creating a service class that inherits from AccessibilityService, filtering the lifted button events in the onKeyEvent() method, and recording the button key value and name;

[0008] For consecutive identical key values, only generate one event data and record the button press count. Delay the processing of button events through Handler. If the same button is pressed again within the delay time, update the count and restart the timer. If a different button is pressed, send a message immediately and reset the count.

[0009] Further, the specific steps are as follows:

[0010] S1. Create a service class that inherits from AccessibilityService in the application project to monitor the global button events of the device;

[0011] S2. Override the onKeyEvent() method in the service class to handle button events;

[0012] S3. In the onKeyEvent() method, determine the key press action through KeyEvent.getAction(), filter the key release events, and record the Android key value of the key and the corresponding key name.

[0013] S4. For consecutive same key values, only collect and generate one key event data, and record the number of key presses.

[0014] S5. After monitoring the user's key event, use the sendMessageDelayed() method of Handler to send a delayed message, and then determine whether to generate a collected data information and report the key event after a period of delay.

[0015] Further, in step S1, the key events include volume keys, back key, and Home key.

[0016] Further, for monitoring the key values of volume keys, back key, and Home key, it includes: in the onCreate() callback of the application, set the system setting item Settings.Secure.ACCESSIBILITY_ENABLED to 1 to enable the global accessibility service;

[0017] Add the application package name and the full path of the accessibility service class in the system setting item Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES to enable the accessibility service.

[0018] Further, modify the permission of the system setting item to WRITE_SECURE_SETTINGS, which needs to be granted through system-level permissions or ADB commands.

[0019] Further, in step S2, the onKeyEvent() method also includes uploading the key value, key name, and number of key presses of the key to the server.

[0020] Further, in step S5, if the user presses the same key again within the delay time, cancel the message in the message queue that is waiting to be sent after the delay, update the key press count, and resend the delay message for timing.

[0021] Further, if a new non-repeated key event is received within the delay time, change the message in the message queue that is waiting to be sent after the delay to be sent immediately using the sendMessage() method, reset the key press count, update the current key value, and resend the delay message for timing.

[0022] Preferably, the value of the delay time is from 1 second to 10 seconds.

[0023] A device for monitoring and collecting remote control button data, comprising: at least one memory and at least one processor;

[0024] The at least one memory is used for storing machine-readable programs;

[0025] The at least one processor is used for calling the machine-readable program to execute a method for monitoring and collecting remote control button data.

[0026] Compared with the prior art, a method and device for monitoring and collecting remote control button data according to the present invention have the following outstanding beneficial effects:

[0027] The present invention effectively reduces data redundancy through a delay processing mechanism, is applicable to remote control button monitoring of devices such as set-top boxes, and improves the efficiency of managers in collecting data. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0029] Attached Figure 1 is a schematic flow chart of a method for monitoring and collecting remote control button data. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0030] In order to enable those skilled in the art to better understand the solutions of the present invention, the following will further elaborate on the present invention in conjunction with specific embodiments. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.

[0031] The following gives a preferred embodiment:

[0032] Such as Figure 1As shown in the figure, a method for monitoring and collecting remote control key data in this embodiment creates a service class that inherits from AccessibilityService. In the onKeyEvent() method, filter the key events of "lifting", and record the key value and name of the key; to avoid generating a large amount of data due to repeated key presses in a short period of time, only generate one event data for consecutive identical key values and record the number of key presses; handle the key events through Handler with a delay. If the same key is pressed again within the delay time, update the count and restart the timing. If a different key is pressed, send a message immediately and reset the count.

[0033] The specific steps are as follows:

[0034] S1. Create a service class that inherits from AccessibilityService in the application project to monitor the global key events of the device;

[0035] Among them, the key events include but are not limited to volume keys, back keys, and Home keys.

[0036] Monitor the key values of volume keys, back keys, and Home keys, including: in the onCreate() callback of the application, set the system setting item Settings.Secure.ACCESSIBILITY_ENABLED to 1 to enable the global accessibility service;

[0037] Add the application package name and the full path of the accessibility service class to the system setting item Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES to enable the accessibility service.

[0038] Modify the permission of the system setting item to WRITE_SECURE_SETTINGS, which needs to be granted through system-level permissions or ADB commands.

[0039] S2. Override the onKeyEvent() method in the service class to handle key events;

[0040] Among them, the onKeyEvent() method also includes uploading the key value, key name, and number of key presses of the key to the server or performing other processing.

[0041] S3. In the onKeyEvent() method, judge the key action through KeyEvent.getAction(), filter the key events of lifting, and record the Android key value of the key and the corresponding key name;

[0042] S4. Only collect and generate one key event data for consecutive identical key values, and record the number of key presses;

[0043] S5. After monitoring the user's key event, use the sendMessageDelayed() method of Handler to send a delayed message, and then determine whether to generate a data collection information and report the key event after a period of delay.

[0044] If the user presses the same key again within the delay time, cancel the message delayed to be sent in the message queue, update the key press count, and restart the delay message timing.

[0045] If a new and non-repeated key event is received within the delay time, change the message delayed to be sent in the message queue to be sent immediately using the sendMessage() method, reset the key press count, update the current key value, and restart the delay message timing.

[0046] This application is applicable to Android set-top box devices for monitoring the remote control key operations of users and generating corresponding key event data. It is also applicable to other Android devices for monitoring global key events and generating corresponding key event data.

[0047] In Android, the Accessibility Service can be used to monitor the key events of the device (such as volume keys, back keys, etc.), including global key events (such as HOME keys, etc.), and it can take effect even if the application is not in the foreground.

[0048] Create a service class that inherits from AccessibilityService in the application project. Create a configuration file android:canRequestFilterKeyEvents in the res / xml directory of the project: set it to true, indicating that the service can monitor key events. Register this accessibility service in AndroidManifest.xml and add the file name of the above configuration file to meta-data. So far, the callback method onKeyEvent() related to keys can be overridden inside the class.

[0049] In the onKeyEvent() callback, first determine the key action through KeyEvent.getAction(), filter out the "lifted" key events, and record the Android key value of the key and the corresponding key name. To avoid a large amount of data information being generated and burdening the device when the user repeatedly presses the same key within a short time interval in the actual usage scenario, it is required that only one key event data is collected and generated for consecutive identical key values, and the key press count is recorded. Therefore, after detecting the user's key event, delay for a period of time (such as 5 seconds) before processing whether to generate a collected data information and report the key event. The specific implementation method is to use the sendMessageDelayed method of Handler inside the accessibility service to send a delayed message. If the user presses the same key again within the delay time, cancel the message in the message queue that is waiting to be sent, update the key press count, and resend the delayed message for timing; if a new non-repeated key event is received within the delay time, change the message in the message queue that is waiting to be sent to be sent immediately using the sendMessage method, reset the key press count, update the current key value, and resend the delayed message for timing.

[0050] Under normal circumstances, the accessibility service of the application is defaultly closed and needs to be manually enabled by the user in the Android general settings.

[0051] In the usage scenario of the set-top box, if this step affects the user experience and functions, for set-top box devices with a lower Android version, the application can be granted the permission to modify system settings. In the onCreate() callback of the application, set the setting item Settings.Secure.ACCESSIBILITY_ENABLED to 1, and add the application package name and the full path of the accessibility service class auxiliary function service in Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES.

[0052] The device executes all or part of the steps of the methods described in the embodiments of this article. These storage media include various media that can store program codes, such as USB flash drives, external hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.

[0053] Based on the above method, a device for monitoring and collecting remote control key data in this embodiment includes: at least one memory and at least one processor;

[0054] The at least one memory is used to store machine-readable programs;

[0055] The at least one processor is used to call the machine-readable program and execute a method for monitoring and collecting remote control key data.

[0056] The above specific embodiments are only specific cases of the present invention. The scope of patent protection of the present invention includes but is not limited to the above specific embodiments. Any technical solution that conforms to the above specific embodiments of the present invention and any appropriate changes or substitutions made by those of ordinary skill in the relevant technical field shall fall within the scope of patent protection of the present invention.

[0057] Although the embodiments of the present invention have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for monitoring and collecting remote control button data, characterized in that, Create a service class that inherits from AccessibilityService. In the onKeyEvent() method, filter the key-up events and record the key value and name of the key. For consecutive identical key values, generate only one event data and record the number of key presses. Use Handler to handle key events with a delay. If the same key is pressed again within the delay time, update the count and restart the timing. If a different key is pressed, send a message immediately and reset the count.

2. The method for monitoring and collecting remote control button data according to claim 1, wherein The specific steps are as follows: S1. Create a service class in the application project that inherits from AccessibilityService to monitor the global key events of the device. S2. Override the onKeyEvent() method in the service class to handle key events. S3. In the onKeyEvent() method, use KeyEvent.getAction() to determine the key action, filter the key-up events, and record the Android key value of the key and the corresponding key name. S4. For consecutive identical key values, collect and generate only one key event data and record the number of key presses. S5. After monitoring the user's key event, use the sendMessageDelayed() method of Handler to send a delayed message. After a period of delay, process whether to generate a piece of collected data information and report the key event.

3. The method for monitoring and collecting remote control button data according to claim 2, wherein, In step S1, the key events include volume keys, back key, and Home key.

4. The method for monitoring and collecting remote control button data according to claim 4, wherein Monitor the key values of the volume keys, back key, and Home key, including: in the onCreate() callback of the application, set the system setting item Settings.Secure.ACCESSIBILITY_ENABLED to 1 to enable the global accessibility service. Add the application package name and the full path of the accessibility service class to the system setting item Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES to enable the accessibility service.

5. A method for monitoring and collecting remote control button data according to claim 4, characterized in that, Modify the permission of the system setting item to WRITE_SECURE_SETTINGS, which needs to be granted through system-level permissions or ADB commands.

6. The method for monitoring and collecting remote control button data according to claim 5, wherein In step S2, the onKeyEvent() method also includes uploading the key value, key name, and number of key presses of the key to the server.

7. A method for monitoring and collecting remote control button data according to claim 6, characterized in that, In step S5, if the user presses the same key again within the delay time, cancel the message in the message queue that is waiting to be sent with a delay, update the key press count, and resend the delayed message for timing.

8. A method for monitoring and collecting remote control button data according to claim 7, characterized in that, If a new non-repeated key event is received within the delay time, change the message in the message queue that is waiting to be sent with a delay to be sent immediately using the sendMessage() method, reset the key press count, update the current key value, and resend the delayed message for timing.

9. A method for monitoring and collecting remote control button data according to claim 8, characterized in that, The value range of the delay time is from 1 second to 10 seconds.

10. A monitoring and acquisition device for remote control button data, characterized in that Including: At least one memory and at least one processor; The at least one memory is used to store machine-readable programs. The at least one processor is configured to call the machine-readable program to execute the method according to any one of claims 1 to 9.