Channel construction method of electronic fence and electronic equipment

By establishing a channel between upper-layer applications and electronic fence drivers in electronic devices, and utilizing the characteristic information of cellular networks and Wi-Fi networks for precise positioning, the real-time and accuracy issues of scanning electronic fences when the screen is off are solved, enabling synchronous service calls across multiple devices and improving the user experience.

CN121985290APending Publication Date: 2026-05-05HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-10-25
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

In existing technologies, electronic devices cannot effectively scan electronic fences when the screen is off, resulting in poor scanning real-time performance, continuity, and positioning accuracy. This makes it impossible to provide accurate service calls in multiple locations, and the upper-layer application cannot communicate directly with the electronic fence driver, leading to service call delays.

Method used

By establishing a channel between upper-layer applications and electronic fence drivers in electronic devices, precise positioning is achieved by utilizing the characteristic information of cellular networks and Wi-Fi networks. Combined with callback functions and mapping relationships, electronic fence scanning and service calls are realized, reducing power consumption and improving real-time performance and accuracy.

Benefits of technology

It enables accurate scanning of electronic fences even when the screen is off, improving the real-time performance, continuity, and positioning accuracy of scanning, reducing power consumption, enhancing user experience, and supporting simultaneous service calls from multiple devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121985290A_ABST
    Figure CN121985290A_ABST
Patent Text Reader

Abstract

The invention discloses a channel construction method of an electronic fence and electronic equipment, relates to the technical field of electronics, and is used for establishing a channel between an upper application and an electronic fence driver. The channel construction method of the electronic fence comprises the steps that an electronic fence driver scans the electronic fence according to feature information of the electronic fence and sends a first event or a second event to an AIDL module, the first event indicates that electronic equipment enters the electronic fence, and the second event indicates that the electronic equipment leaves the electronic fence; the AIDL module determines a first callback function of the MSDP according to the identifier of the electronic fence in the first event or the second event, the fourth mapping relation and the first mapping relation; and the first callback function determines a second callback function of the upper-layer application according to the identifier of the electronic fence in the first event or the second event, the third mapping relationship and the second mapping relationship. In response to the first event, the second callback function calls the service corresponding to the electronic fence, or in response to the second event, the service corresponding to the electronic fence is ended.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic technology, and in particular to a method for constructing a passageway for an electronic fence and an electronic device. Background Technology

[0002] Electronic fence technology is widely used in various service scenarios, such as payment processing, subway rides, and package delivery. An electronic fence refers to a virtual area where, when a user enters with an electronic device, the device can automatically invoke corresponding services. For example, it can automatically open a payment code (or scan a QR code) in a store, automatically activate a subway card in a subway station, or automatically notify the user of a package waiting to be picked up at a courier station.

[0003] The software of electronic devices is layered, with different layers of software modules performing different functions. The electronic fence driver, which scans electronic fences, is located at the bottom layer of the software, while the upper-layer application that calls services based on the electronic device entering the electronic fence is located at the top layer of the software. The upper-layer application and the electronic fence driver cannot communicate directly. Summary of the Invention

[0004] This application provides a method for constructing a channel for an electronic fence and an electronic device for establishing a channel between an upper-layer application and the electronic fence driver.

[0005] To achieve the above objectives, this application adopts the following technical solution:

[0006] Firstly, a method for constructing electronic fence channels is provided, which is applied to electronic devices, including upper-layer applications and a multimodal sensor data platform (MSDP). The method comprises an Android Interface Definition Language (AIDL) module, a Hardware Abstraction Layer (HAL) module, and an electronic fence driver. The method includes: the MSDP registering a first callback function with the AIDL module; the AIDL module establishing a first mapping relationship between the first callback function and an MSDP identifier; the upper-layer application registering a second callback function with the MSDP; the MSDP establishing a second mapping relationship between the second callback function and an upper-layer application identifier; the upper-layer application configuring electronic fence feature information with the MSDP, the electronic fence feature information being indexed by the electronic fence identifier; the MSDP establishing a third mapping relationship between the electronic fence feature information and an upper-layer application identifier; the MSDP configuring the electronic fence feature information with the AIDL module; the AIDL module establishing a fourth mapping relationship between the electronic fence feature information and an MSDP identifier; and the AIDL module configuring the electronic fence feature information with the electronic fence driver through the HAL module. The driver scans the electronic fence based on its characteristic information and sends a first event or a second event to the AIDL module via the HAL module. The first event indicates that the electronic device enters the electronic fence, and the second event indicates that the electronic device leaves the electronic fence. The AIDL module determines the first callback function of the MSDP based on the electronic fence identifier, the fourth mapping relationship, and the first mapping relationship in the first or second event, and triggers the MSDP to execute the first callback function. The first callback function of the MSDP determines the second callback function of the upper-layer application based on the electronic fence identifier, the third mapping relationship, and the second mapping relationship in the first or second event, and triggers the upper-layer application to execute the second callback function. In response to the first event, the second callback function of the upper-layer application calls the service corresponding to the electronic fence, or in response to the second event, the second callback function of the upper-layer application ends the call to the service corresponding to the electronic fence.

[0007] The electronic fence channel construction method provided in this application, for upper-layer and lower-layer software modules located in adjacent layers: On the one hand, the upper-layer software module registers a callback function with the lower-layer software module, and the lower-layer software module establishes a mapping relationship between the callback function and the upper-layer software module; on the other hand, the upper-layer software module configures the electronic fence feature information with the lower-layer software module, and the lower-layer software module establishes a mapping relationship between the electronic fence feature information and the upper-layer software module. Since the electronic fence feature information is indexed by the electronic fence identifier, and the electronic fence driver reports the first event of an electronic device entering the electronic fence or the second event of an electronic device leaving the electronic fence, the identifier of the upper-layer software module can be determined through the electronic fence identifier, thereby determining the callback function of the upper-layer software module. Starting from the electronic fence driver, by executing the callback function of the upper-layer software module, using the first event or the second event as the input parameter of the callback function, and passing it upwards layer by layer until it is passed to the upper-layer application, a channel between the upper-layer application and the electronic fence driver can be established.

[0008] In one possible implementation, the AIDL module determines the first callback function of the MSDP based on the geofence identifier, the fourth mapping relationship, and the first mapping relationship in the first or second event. This includes: the AIDL module obtaining the MSDP identifier based on the geofence identifier in the first or second event and the fourth mapping relationship; and the AIDL module determining the first callback function corresponding to the MSDP identifier based on the MSDP identifier and the first mapping relationship. Since the feature information of each geofence is indexed by the geofence identifier, the fourth mapping relationship between the geofence feature information and the MSDP identifier essentially includes the mapping relationship between the geofence identifier and the MSDP identifier. Therefore, the AIDL module can query the MSDP identifier based on the geofence identifier in the first or second event and the fourth mapping relationship between the geofence feature information and the MSDP identifier, thereby determining which MSDP has configured the corresponding geofence feature information.

[0009] In one possible implementation, the first callback function of the MSDP determines the second callback function of the upper-layer application based on the geofence identifier, the third mapping relationship, and the second mapping relationship in the first or second event. This includes: the MSDP obtaining the identifier of the upper-layer application based on the geofence identifier in the first or second event and the third mapping relationship; and the MSDP determining the second callback function corresponding to the upper-layer application identifier based on the upper-layer application identifier and the second mapping relationship. Since the feature information of each geofence is indexed by the geofence identifier, the third mapping relationship between the geofence feature information and the upper-layer application identifier essentially includes the mapping relationship between the geofence identifier and the upper-layer application identifier. Therefore, the MSDP can query the upper-layer application identifier based on the geofence identifier in the first or second event and the third mapping relationship between the geofence feature information and the upper-layer application identifier, thereby determining which upper-layer application has configured the corresponding geofence feature information.

[0010] In one possible implementation, the method further includes: the AIDL module registers its detection of electronic fence driver crash events via the HAL module. If an electronic fence driver crash occurs, the AIDL module re-establishes its connection with the electronic fence driver via the HAL module and re-registers its detection of the crash event. Because the electronic fence driver may crash and restart, previously cached data is lost. Therefore, the AIDL module needs to re-establish its connection with the electronic fence driver via the HAL module and re-register its detection of crash events to achieve automatic recovery.

[0011] In one possible implementation, the method further includes: MSDP registering the detection of AIDL module crash events; if an AIDL module crash event occurs, MSDP re-establishes a connection with the AIDL module, re-registers the first callback function with the AIDL module, re-registers the detection of AIDL module crash events, and re-configures the geofence feature information with the AIDL module. Because the AIDL module may crash and restart, all previously cached data in the AIDL module is lost. Therefore, the MSDP module needs to re-establish a connection with the AIDL module, re-register the first callback function, re-register the detection of AIDL module crash events, and re-configure the geofence feature information with the AIDL module to achieve automatic recovery.

[0012] In one possible implementation, the system further includes: the AIDL module registers the detection of MSDP crash events; if an MSDP crash event occurs, the AIDL module clears the first callback function and the first mapping relationship. Because MSDP may crash and restart, the identifier (e.g., process ID) of the allocated MSDP will be different after restarting, and the first mapping relationship and the first callback function will become invalid. Therefore, clearing the first callback function and the first mapping relationship prevents data errors.

[0013] In one possible implementation, the method further includes: MSDP registering the detection of upper-layer application crash events; if an upper-layer application crash event occurs, MSDP clears the second callback function and the second mapping relationship. This is because the upper-layer application may crash and restart, and the assigned identifier (e.g., process ID) of the upper-layer application will be different after restarting, causing the second mapping relationship and the second callback function to become invalid. Therefore, clearing the second callback function and the second mapping relationship prevents data errors.

[0014] In a second aspect, an electronic device is provided, including a processor and a memory, wherein instructions are stored in the memory, and when the processor executes the instructions, the electronic device performs the method as described in the first aspect and any embodiment thereof.

[0015] Thirdly, a computer-readable storage medium is provided, including instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in the first aspect and any embodiment thereof.

[0016] Fourthly, a computer program product containing instructions is provided, which, when executed on the aforementioned electronic device, cause the electronic device to perform the method as described in the first aspect and any embodiment thereof.

[0017] The technical effects of any of the implementation methods in the second to fourth aspects mentioned above can be referred to the technical effects of different implementation methods in the first aspect, and will not be elaborated here. Attached Figure Description

[0018] Figure 1 A schematic diagram of an electronic fence provided for an embodiment of this application;

[0019] Figure 2 A schematic diagram illustrating services displayed at multiple locations, provided as an embodiment of this application;

[0020] Figure 3 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;

[0021] Figure 4 A schematic diagram of the software framework of an electronic device provided in an embodiment of this application;

[0022] Figure 5 A schematic diagram illustrating an electronic device displaying a payment code (or allowing scanning) according to an embodiment of this application;

[0023] Figure 6 This is a schematic diagram illustrating how an electronic device opens a virtual card, as provided in an embodiment of this application.

[0024] Figure 7 A schematic diagram illustrating an electronic device displaying product information sold in a store, provided as an embodiment of this application;

[0025] Figure 8 A flowchart illustrating a scanning electronic fence provided in this application embodiment;

[0026] Figure 9 This application provides a schematic diagram illustrating a configuration call to a service corresponding to an electronic fence.

[0027] Figure 10 This is a schematic diagram illustrating multi-device synchronization as provided in an embodiment of this application.

[0028] Figure 11 This is a schematic diagram of another scanning electronic fence provided in an embodiment of this application. Detailed Implementation

[0029] An electronic fence refers to a virtual area, that is, a virtual boundary enclosed by a virtual fence. For example, such as... Figure 1 The diagram illustrates an electronic fence. An electronic device 101 can access the cellular network provided by a base station 102. The electronic device 101 can also search for Wi-Fi networks provided by an access point (AP) device (also known as a Wi-Fi hotspot) 103. The AP device 103 can be located in places such as shops, express delivery stations, subway stations, schools, companies, shopping malls, scenic spots, and airports. It is possible that both the cellular network provided by base station 102 and the Wi-Fi network provided by AP device 103 may be present simultaneously. Furthermore, the coverage area of ​​the cellular network is much larger than the coverage area of ​​the Wi-Fi network, so the coverage area of ​​one cellular network can include the coverage areas of multiple Wi-Fi networks. The electronic device can determine the approximate coverage area of ​​the cellular network it is located in using the cellular information. This cellular network coverage area can include the coverage areas of multiple Wi-Fi networks. The electronic device can further determine the exact coverage area of ​​the Wi-Fi network it is located in using the Wi-Fi information, thereby determining the location of the AP device 103. The electronic fence described in this embodiment refers to an area covered by a Wi-Fi network.

[0030] In existing technologies, to reduce the power consumption of electronic devices, periodic scanning of Wi-Fi network information is used to determine whether an electronic device has entered a geofence. This period is relatively long; for example, the scanning period is 5 minutes when the screen is off and 160 seconds when the screen is on. This results in poor real-time performance, continuity, and positioning accuracy in geofence scanning. Currently, it only supports determining whether an electronic device has entered a geofence when the screen is on, not when the screen is off. In scenarios where the electronic device is hanging around the neck, in a bag, or in a pocket, service calls are delayed, making it inconvenient for users. Figure 2 As shown, due to poor positioning accuracy, current electronic devices can only broadly recommend services for multiple locations within a large surrounding area, and cannot precisely provide services for a specific location. For example, Figure 7 The image shows the new products in the store.

[0031] In addition, the software of electronic devices is layered (e.g., ... Figure 4 As shown, different layers of software modules perform different functions. The electronic fence driver, which scans the electronic fence, is located at the bottom layer of the software, while the upper-layer application, which calls services based on electronic devices entering the electronic fence, is located at the top layer of the software. The upper-layer application and the electronic fence driver cannot communicate directly; a channel needs to be established between them.

[0032] To address this, this application provides a method for constructing a channel for an electronic fence and an electronic device. For upper-layer and lower-layer software modules located in adjacent layers: on one hand, the upper-layer software module registers a callback function with the lower-layer software module, and the lower-layer software module establishes a mapping relationship between the callback function and the upper-layer software module; on the other hand, the upper-layer software module configures the feature information of the electronic fence with the lower-layer software module, and the lower-layer software module establishes a mapping relationship between the feature information of the electronic fence and the upper-layer software module. Since the feature information of the electronic fence is indexed by the electronic fence identifier, and the electronic fence driver reports the first event of the electronic device entering the electronic fence or the second event of the electronic device leaving the electronic fence, the identifier of the upper-layer software module can be determined through the electronic fence identifier, thereby determining the callback function of the upper-layer software module. Starting from the electronic fence driver, by executing the callback function of the upper-layer software module, using the first event or the second event as the input parameter of the callback function, and passing it upward layer by layer until it is passed to the upper-layer application, a channel between the upper-layer application and the electronic fence driver can be established.

[0033] In addition, the upper-layer application obtains the feature information database of the electronic fence from the cloud server. The upper-layer application then configures the electronic fence's feature information to the electronic fence driver. This feature information includes cellular network information and Wi-Fi network information. Since the coverage area of ​​a cellular network is much larger than that of a Wi-Fi network, the electronic device can first scan the cellular network information. When the scanned cellular information matches the cellular information in the electronic fence's feature information, it is determined that the electronic device has entered the coverage area of ​​the cellular network where the electronic fence is located. The electronic device further scans the Wi-Fi network information. When the scanned Wi-Fi information matches the Wi-Fi information in the electronic fence's feature information, it is determined that the electronic device has entered the electronic fence, thereby invoking the services corresponding to entering the electronic fence. Since mobile phones and other electronic devices already need to scan cellular network information, this does not increase the power consumption of the electronic device. Furthermore, the electronic device will only start periodically scanning the Wi-Fi network and determine whether it has entered the electronic fence if the scanned Wi-Fi information matches the Wi-Fi information in the feature information of the electronic fence. Therefore, it can reduce the power consumption of the electronic device scanning the electronic fence, shorten the scanning cycle of the Wi-Fi network, improve the real-time performance, continuity and positioning accuracy of scanning the electronic fence, and enhance the user experience.

[0034] The electronic fence channel construction method provided in this application embodiment can be applied to electronic devices, such as mobile phones, action cameras, smartwatches, wearable devices, digital cameras, tablets, desktop computers, laptops, handheld computers, notebook computers, in-vehicle devices, ultra-mobile personal computers (UMPCs), netbooks, cellular phones, personal digital assistants (PDAs), augmented reality (AR) devices, virtual reality (VR) devices, etc. This application embodiment does not impose any special limitations on the specific form of the electronic device.

[0035] For example, Figure 3A schematic diagram of the structure of electronic device 100 is shown. Electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, a camera 193, and a display screen 194, etc.

[0036] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0037] Processor 110 may include one or more processor units. For example, processor 110 may include a central processing unit (CPU), an application processor (AP), a modem-demodulator, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, a neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0038] In some embodiments of this application, processor 110 may further include an audio digital signal processor (ADSP). The ADSP may include a sensor hub, which is used to acquire sensor data from each sensor in sensor module 180. The sensor hub supports low-power always-on functionality.

[0039] It should be noted that in some scenarios, SensorHub can also be called... The Qualcomm Sensing Hub (QSH) is not limited in the name of the Sensor Hub in this application embodiment. As long as it can achieve the above functions, it is within the protection scope of this application embodiment.

[0040] The aforementioned controller can serve as the central nervous system and command center of the electronic device 100. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. The processor 110 can handle services related to base station communication, such as telephone calls, SMS messages, and internet access, via a modem.

[0041] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0042] In some embodiments, the processor 110 may include one or more interfaces. These interfaces may include an I2C interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, a universal serial bus (USB) interface 130, etc.

[0043] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0044] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be stored on the external memory card.

[0045] Internal memory 121 can be used to store one or more computer programs, which include instructions. Processor 110 can execute the instructions stored in internal memory 121, thereby causing electronic device 100 to perform the methods provided in the embodiments of this application, as well as various functional applications and data processing. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system; the program storage area may also store one or more applications (such as a gallery, contacts, etc.). The data storage area may store data created during the use of electronic device 100 (such as photos, contacts, etc.). In addition, internal memory 121 may include high-speed random access memory; it may also include non-volatile memory, such as one or more disk storage devices, flash memory devices, universal flash storage (UFS), etc. In other embodiments, processor 110 executes instructions stored in internal memory 121 and instructions stored in memory disposed in processor 110, causing electronic device 100 to perform the methods provided in the embodiments of this application, as well as various functional applications and data processing.

[0046] The charging management module 140 is used for charging input from the charger interface. The charger can be a wireless charger or a wired charger.

[0047] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 can receive input from the battery 142 and / or the charging management module 140 to power the processor 110, internal memory 121, display 194, camera 193, and wireless communication module 160, etc.

[0048] The power management module 141 can be used to monitor performance parameters such as battery capacity, battery cycle count, battery charging voltage, battery discharging voltage, and battery health status (e.g., leakage current, impedance).

[0049] The wireless communication function of electronic device 100 can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor. In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module, enabling electronic device 100 to communicate with networks and other devices through wireless communication technology.

[0050] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals.

[0051] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include one or more filters, switches, power amplifiers, low-noise amplifiers (LANs), etc. The mobile communication module 150 can receive electromagnetic waves via the antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via the antenna 1. In some embodiments, at least some functions of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functions of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.

[0052] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as Wi-Fi), Bluetooth (BT), Global Navigation Satellite System (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR). The wireless communication module 160 can be one or more devices integrating one or more communication modules. The wireless communication module 160 interfaces with electromagnetic waves via antenna 2, frequency modulates and filters the electromagnetic wave signal, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, frequency modulate and amplify them, and then convert them into electromagnetic waves for radiation via antenna 2.

[0053] The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc., without limitation.

[0054] Of course, the electronic device 100 provided in this application embodiment may also include one or more of the following devices: positioning module 181, button 190, motor 191, indicator 192, and SIM card interface [1~N] 195, without limitation.

[0055] The methods described in the following embodiments can all be implemented in the electronic device 100 having the above-described hardware structure. To make the technical solutions of this application clearer and easier to understand, the following embodiments, in conjunction with the software structure of the electronic device 100, provide a detailed description of the technical solutions provided in the embodiments of this application.

[0056] Figure 4 This is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The software structure of the electronic device includes an application layer (APP) running on the AP (Application Platform), a native layer, a hardware abstraction layer (HAL), and a driver layer running on the SensorHub. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. Figure 4 Some hardware was also shown, such as a modem, an activity recognition (AR) sensor, and a Wi-Fi chip.

[0057] The application layer may include a multimodal sensor data platform (MSDP). Upper-layer applications (e.g., smart sensing services) can invoke services corresponding to entering an electronic fence, such as displaying a payment code (or scanning a QR code), opening a virtual card (e.g., a subway card, bus card, access card), or displaying smart reminders. Electronic devices can display corresponding content through notification bar interfaces, pull-down interfaces, lock screen interfaces, main interfaces, or negative one screen interfaces. Upper-layer applications can learn frequently visited locations (e.g., frequent payment locations), such as places users frequently shop at (e.g., restaurants, supermarkets, stores). Upper-layer applications collect characteristic information of these electronic fences (cellular network information and Wi-Fi network information), and statistically determine the number of times electronic devices enter the electronic fence within a preset time period and the number of times they invoke the service corresponding to the service identifier after entering the electronic fence, thereby configuring the characteristic information of the electronic fence to the electronic fence driver. The YOYO application involved in this application embodiment is one such upper-layer application. MSDP is used for communication between upper-layer applications and lower-layer applications. In addition, the application layer may also include applications not shown, such as camera, gallery, calendar, call, map, navigation, Bluetooth, music, video, payment, smart card, and in-store reminders.

[0058] For example, such as Figure 5 As shown in Figure A, the upper-layer application displays the payment code, specifically QR code 401, which is used by the payment software for payment. When a merchant scans this QR code using a scanning device (such as a barcode scanner or mobile phone), the payment software processes the payment. Figure 5 As shown in Figure B, the "Scan" option displays the payment software's scanning frame for payment and the image captured by the camera. When the scanning frame includes an image of a QR code for receiving payment, the payment software processes the payment.

[0059] For example, such as Figure 6 As shown, the upper-layer application can include multiple virtual cards, such as subway cards, bus cards, and access control cards. When an electronic device enters an electronic fence, the upper-layer application can automatically display the virtual card corresponding to that electronic fence, providing users with instant card-swiping services. For example, when an electronic device enters the electronic fence of a subway station, the electronic device will automatically activate its subway card. The user can bring the electronic device close to the card reader at the subway station to enable communication between the electronic device and the card reader, thus completing the card swipe. When an electronic device enters the electronic fence of a company, the electronic device will automatically display the company's access control card. The user can bring the electronic device close to the company's card reader to enable communication between the electronic device and the card reader corresponding to the company's access control card, thus completing the card swipe for entry.

[0060] For example, the upper-layer application can also provide users with intelligent reminder services. These intelligent reminder services could be delivery arrival reminders, store arrival reminders, warning reminders, or notification reminders, etc. When an electronic device enters the electronic fence of a location, the upper-layer application can display an intelligent reminder. For example, when an electronic device enters the electronic fence of a delivery station, the upper-layer application will automatically display a delivery arrival reminder. For example, such as... Figure 7 As shown, when an electronic device enters the store's geofence, the upper-level application can automatically display information about the various products sold in that store. This includes, for example, product names, prices, and promotional offers.

[0061] The modem driver in the driver layer is a virtual software module in the ADSP subsystem used to obtain cellular information from the modem, including but not limited to at least one of the following: Cell Identifier (CellId), Location Area Code (LAC), Primary Cell, Neighboring Cells, etc. The LAC identifies different location areas within the cellular network, which are used for paging electronic devices. An LAC includes multiple cells. The Cell Identifier (CellId) identifies the cell. An electronic device may be covered by cellular signals from multiple cells simultaneously. The Primary Cell refers to the cell currently covering and providing service to the electronic device, while Neighboring Cells refer to cells currently covering the electronic device but not providing service.

[0062] The Wi-Fi driver in the driver layer is a virtual software module in the ADSP subsystem used to obtain Wi-Fi information from the Wi-Fi chip, including but not limited to at least one of the following: Basic Service Set Identifier (BSSID), Service Set Identifier (SSID), and Received Signal Strength Indication (RSSI). SSID is the local area network name of the AP device, BSSID is the media access control (MAC) address of the AP device, and RSSI is the signal strength of the Wi-Fi signal received by the electronic device.

[0063] The geofence driver can acquire motion information from activity recognition sensors, such as whether the electronic device is in motion or the number of steps taken by the user while carrying the device. The geofence driver can also acquire cellular network information via a modem driver and Wi-Fi network information via a Wi-Fi driver. Based on the cellular information, Wi-Fi information, and optionally the motion information of the electronic device, the geofence driver determines the event of the electronic device entering the geofence (first event) or the event of the electronic device leaving the geofence (second event). The geofence driver can also report the event of the electronic device entering the geofence to the upper-layer application, which will automatically provide services, such as displaying a payment code (or scanning a QR code). Similarly, the geofence driver can report the event of the electronic device leaving the geofence to the upper-layer application, which will then terminate the service, such as stopping the display of the payment code (or scanning a QR code).

[0064] If an electronic device is connected to other electronic devices (such as a smartwatch in a wearable device), the electronic device can also synchronize events of entering or leaving the geofence with other electronic devices through inter-device communication, so that services can be automatically provided on other electronic devices. For example, when a smartwatch detects a wrist raise, it can display a payment code (or scan a QR code) to facilitate payment for the user.

[0065] The local layer includes The Android Interface Definition Language (AIDL) module (e.g., the Activity Recognition (AR) AIDL module) is included in the HAL module (e.g., the AR HAL module). The AIDL module and the HAL module belong to the same process and are used together for inter-process communication (IPC). The HAL module is used to adapt data transmission between the AIDL module and the electronic fence driver.

[0066] The electronic fence driver communicates with the HAL module, Wi-Fi driver, modem driver, and activity recognition sensor via... Communication is achieved through the Qualcomm Messaging Interface (QMI). The modem driver communicates with the modem via QMI. The Wi-Fi driver communicates with the Wi-Fi chip via an inter-integrated circuit (I2C) bus and interrupts. The Wi-Fi chip can be a custom-designed chip, resulting in lower power consumption when scanning for Wi-Fi signals.

[0067] This application provides a method for constructing a passageway in an electronic fence, such as... Figure 8 As shown, it includes: S101-S113:

[0068] S101, upper-layer applications (such as intelligent sensing services), MSDP, AIDL module, HAL module, electronic fence driver, Wi-Fi driver, and modem driver complete initialization.

[0069] The initialization of these modules includes the creation of thread resources and the allocation of array resources. Generally, lower-level modules are more likely to be called by higher-level modules, and therefore complete their initialization before the higher-level modules. For example, the electronic fence driver, Wi-Fi driver, and modem driver are all located in SensorHub, so they are initialized first. The AIDL module and HAL module belong to the same process and are initialized together. Then MSDP completes its initialization. Finally, the upper-level application completes its initialization.

[0070] S102, The cloud server generates a full database of electronic fence feature information.

[0071] The comprehensive database of electronic fence feature information includes the feature information of all electronic fences and the corresponding location data, such as the feature information of electronic fences in all cities across the country and the corresponding location data. To facilitate data maintenance, each city can have its own dedicated database of electronic fence feature information. The feature information of each electronic fence can be indexed by its identifier.

[0072] Location data includes, but is not limited to, location name, storefront photo, product information (e.g., product name, price, promotional activities), and Wi-Fi information for the location's Wi-Fi network. The geofence's characteristic information includes cellular network information and Wi-Fi network information; for specific meanings, please refer to [link / reference needed]. Figure 4 Related descriptions.

[0073] Electronic devices connected to a cloud server (such as a merchant's electronic device) can upload the feature information of the electronic fence and the location data corresponding to the electronic fence to the cloud server. In this embodiment of the application, the cellular information of the cellular network in the feature information of the electronic fence is referred to as the first cellular information. The Wi-Fi information of the Wi-Fi network in the feature information of the electronic fence is referred to as the second Wi-Fi information.

[0074] S103. The upper-layer application of the electronic device obtains the characteristic information of the electronic fence from the cloud server.

[0075] When a certain service in the upper-layer application is turned on, the electronic device can execute S103 and subsequent steps. For example, such as Figure 9 As shown, the settings interface of the YOYO Suggestions app allows you to configure the invocation of services corresponding to entering a geofence. For example, in response to a user clicking the first button 701 (payment code) in the YOYO Suggestions app settings interface, the user will be redirected to the service management interface. In response to a user clicking the second button 702 (payment code) in the service management interface, the function of displaying the payment code (or scanning it) after entering a geofence can be turned on or off. Users can choose "Multi-device synchronization" or "App suggestions".

[0076] Users select "App suggestions", such as Figure 10 As shown in Figure A, when an electronic device (such as a mobile phone) enters the electronic fence of a consumption venue, a payment code can be displayed on the electronic device (or scanned). The user selects "Multi-device synchronization," as shown below. Figure 10 As shown in Figure B, when an electronic device (such as a mobile phone) enters the electronic fence of a shopping venue, a payment code (or a QR code for scanning) can be displayed on other electronic devices (such as wearable devices like smartwatches). For example, a smartwatch can display the payment code (or scan it) when the user raises their wrist. These electronic devices can establish connections with each other via short-range communication (such as Bluetooth). This prompts the user to scan the code to make a purchase, thus improving the user's shopping experience.

[0077] Electronic devices can obtain the feature information database of the geofence in their current city from the cloud server, without having to obtain the full database. When they arrive in a new city, they can obtain the feature information database of the geofence in that city from the cloud server, thus saving storage space for the electronic devices.

[0078] Electronic devices can further filter the feature information database of the city's electronic fence by combining user usage habits, so as to further save storage space of electronic devices.

[0079] For example, a city is divided into multiple areas, and a user's activity area is usually limited to a certain area. Therefore, electronic devices can filter the feature information database of electronic fences by combining the user's daily movement trajectory.

[0080] For example, some families with children frequently search for amusement parks and training institutions using electronic devices; others frequently search for restaurants and karaoke bars; and still others frequently travel for work and search for hotels. Therefore, electronic devices can combine user search behavior to filter the feature information database of electronic fences.

[0081] S104, upper-layer application, MSDP, AIDL module, HAL module, electronic fence driver, Wi-Fi driver, modem driver establish connection.

[0082] For adjacent modules, since the lower-level module typically completes initialization first, the upper-level module requests a connection from the lower-level module after initialization. Since the lower-level module has already completed initialization, the connection can only be established successfully. For example, the electronic fence driver requests connections with both the Wi-Fi driver and the modem driver, respectively. The AIDL module requests a connection with the electronic fence driver through the HAL module. Since the AIDL and HAL modules reside in the same process, they can directly establish a connection and communicate. The MSDP module requests a connection with the AIDL module, and the smart sensing module requests a connection with the MSDP module.

[0083] Optionally, both the Wi-Fi driver and the modem driver send response information to the geofence driver to indicate whether the Wi-Fi driver has successfully established a connection with the geofence driver. The geofence driver sends response information to the HAL module to indicate whether the geofence driver has successfully established a connection with the AIDL module through the HAL module. The AIDL module sends response information to the MSDP to indicate whether the AIDL module has successfully established a connection with the MSDP. The MSDP sends response information to the upper-layer application to indicate whether the MSDP has successfully established a connection with the upper-layer application.

[0084] S105. The upper-layer application configures the feature information of the electronic fence to the electronic fence driver.

[0085] Upper-layer applications can set weights W = f(X1, W1, X2, W2) for the characteristic information of electronic fences in various locations. Here, X1 is the number of times an electronic device enters the electronic fence within a preset time period (e.g., one week), X2 is the number of times an electronic device calls the service corresponding to the service identifier after entering the electronic fence within the preset time period, W1 is the weight coefficient of X1, and W2 is the weight coefficient of X2. The larger X1 or X2 is, the larger the weight W. A larger X1 indicates a higher probability that an electronic device enters the electronic fence of that location, and a larger X2 indicates a higher probability that an electronic device enters the electronic fence of that location and calls the service corresponding to the service identifier. If W1 is less than W2, then the number of times an electronic device calls the service corresponding to the service identifier after entering the electronic fence has a greater impact on W. For example, although an electronic device frequently enters the electronic fence of a company, the probability of it displaying a payment code (or scanning a QR code) after entering the company's electronic fence is very small. However, the probability of an electronic device entering the electronic fence of a consumer location is even smaller than entering the electronic fence of a company, but the probability of displaying a payment code (or scanning a QR code) is higher. Therefore, the electronic device should automatically display the payment code (or scan a QR code) in consumer locations. By configuring W1 and W2 in this way, when a user enters a geofence where they frequently need to access a particular service, the electronic device is more likely to automatically invoke that service, improving the user experience. For example, when an electronic device enters a geofence where frequent transactions are made, it is more likely to automatically display a payment code (or allow scanning).

[0086] Upper-layer applications can sort the feature information of each electronic fence in descending order of weight; add the feature information of the top N electronic fences with the highest weight to the electronic fence driver; delete the feature information of the N electronic fences that are not among the top N electronic fences with the highest weight from the electronic fence driver; delete all electronic fence feature information stored in the electronic fence driver; instruct the electronic fence driver to pause the use of a certain electronic fence's feature information; instruct the electronic fence driver to resume the use of a certain electronic fence's feature information; and continuously update the electronic fence feature information stored in the electronic fence driver.

[0087] The upper-layer application configures the electronic fence's feature information to the electronic fence driver sequentially through the MSDP, AIDL, and HAL modules. Both MSDP and the electronic fence driver cache the electronic fence's feature information.

[0088] S106, the electronic fence driver subscribes to cellular scanning tasks from the modem driver, and the modem driver obtains second cellular information by periodically scanning the cellular network.

[0089] Because mobile phones and other electronic devices need to periodically (e.g., every 10 seconds) scan the cellular information of the cellular network and access the cellular network during daily use, whether the screen is on or off, and whether it is in performance mode or power saving mode, the modem driver does not actually increase the power consumption of the electronic device by scanning the cellular network to obtain the second cellular information. It can simply feed back the second cellular information to the geofence driver according to the subscription period.

[0090] Base stations broadcast cellular information about the cellular network. Electronic devices do not need to access the cellular network, meaning they do not need to establish a connection with the base station. They can obtain secondary cellular information by scanning the broadcast messages of the cellular network. Because two adjacent cells in cellular communication overlap in their boundary areas, and because electronic devices move between different cells as the user moves, the modem driver can obtain more than one secondary cellular information by scanning the cellular network. For more information on cellular network information, please refer to [link to relevant documentation]. Figure 4 The relevant descriptions will not be repeated here.

[0091] S107. The electronic fence driver matches the first cellular information in the electronic fence feature information with the second cellular information obtained by scanning.

[0092] A match between first and second cellular information is considered successful if at least one of the following information is identical: cell identifier, LAC, primary cell, and neighboring cells. For example, the cell identifier of the first cellular information is the same as the cell identifier of the second cellular information; the LAC of the first cellular information is the same as the LAC of the second cellular information; the primary cell of the first cellular information is the same as the primary cell of the second cellular information; and the neighboring cells of the first cellular information are the same as the neighboring cells of the second cellular information. A match is considered successful if at least one of these conditions is met.

[0093] If the first cellular information does not match the second cellular information, the electronic fence driver continues to wait for new second cellular information and re-executes S107. A mismatch between the first and second cellular information means that the first and second cellular information in all the feature information of the electronic fence configured in the electronic fence driver do not match.

[0094] S108. If the first cellular information matches the second cellular information, the electronic fence driver subscribes to the Wi-Fi driver for a Wi-Fi scanning task, and the Wi-Fi driver obtains the second Wi-Fi information by scanning the cellular network.

[0095] Alternatively, the electronic fence driver can also acquire motion information of the electronic device through activity recognition sensors, such as whether the electronic device is in motion or the number of steps the user takes while carrying the electronic device.

[0096] Optionally, if the first cellular information matches the second cellular information, and the electronic device's state meets the conditions, the geofence driver subscribes to a Wi-Fi scanning task from the Wi-Fi driver. The electronic device scans the Wi-Fi network to obtain the second Wi-Fi information and matches the second Wi-Fi information with the first Wi-Fi information. For example, the electronic device's state meeting the conditions includes at least one of the following: the electronic device is in motion; the number of steps taken by the user carrying the electronic device within a preset period (e.g., 10 seconds) is greater than a step threshold (e.g., 20 steps); or the electronic device is in a screen-off or screen-on state.

[0097] If an electronic device is stationary, the user is unlikely to operate it, and there will be no events of entering or leaving the geofence. Therefore, the condition that the electronic device is stationary can be ruled out. That is, when an electronic device is stationary, it will not scan for Wi-Fi networks to reduce power consumption.

[0098] If a user's number of steps while carrying an electronic device exceeds a certain threshold within a preset period, it essentially further restricts the movement of the electronic device. For example, when making a payment by scanning a QR code at a shopping venue, the user will continuously move between the shopping area and the checkout area, which will increase the number of steps the user takes while carrying the electronic device within the preset period.

[0099] Whether an electronic device is in a screen-off or screen-on state can be determined based on the need to access the service corresponding to the electronic fence. For example, when an electronic device (e.g., a mobile phone) is syncing with other electronic devices (e.g., wearable devices like smartwatches), if the electronic device is in a screen-off state, the service corresponding to accessing the electronic fence can be accessed on other electronic devices. For instance, a smartwatch can display a payment code (or scan a QR code) when the user detects a wrist raise, reducing power consumption and improving the user experience without requiring the user to operate the electronic device. When an electronic device is not syncing with other electronic devices, if the electronic device is in a screen-on state, the service corresponding to accessing the electronic fence can be accessed on the device itself, such as displaying a payment code (or scanning a QR code). If the electronic device is in a screen-off state, the payment code does not need to be displayed, reducing resource consumption and power consumption. In other words, this implementation method can be applied not only to scenarios where the electronic device is in a screen-on state but also to scenarios where the electronic device is in a screen-off state. In scenarios where the electronic device is worn around the neck, placed in a bag, or in a pocket, the service access latency is low, making it convenient for the user to use the electronic device.

[0100] S109. The electronic fence driver matches the first Wi-Fi information in the feature information of the electronic fence with the second Wi-Fi information obtained by scanning.

[0101] The electronic fence driver can match the BSSID of the first Wi-Fi information with the BSSID of the second Wi-Fi information, match the SSID of the first Wi-Fi information with the SSID of the second Wi-Fi information, and determine the score of the second Wi-Fi information according to the RSSI in the second Wi-Fi information.

[0102] In a possible implementation, the RSSI of the Wi-Fi signal can be divided into multiple levels, each level corresponding to a score. The lower the RSSI level, the lower the score of the second Wi-Fi information corresponding to it, and the higher the RSSI level, the higher the score of the second Wi-Fi information corresponding to it. For example, the RSSI of the Wi-Fi signal can be divided into five levels L1, L2, L3, L4, L5, where L1 < L2 < L3 < L4 < L5. If the RSSI in the second Wi-Fi information is in (-∞, L1], the score of the second Wi-Fi information is 0; if the RSSI in the second Wi-Fi information is in (L1, L2], the score of the second Wi-Fi information is 0.2; if the RSSI in the second Wi-Fi information is in (L2, L3], the score of the second Wi-Fi information is 0.4; if the RSSI in the second Wi-Fi information is in (L3, L4], the score of the second Wi-Fi information is 0.6; if the RSSI in the second Wi-Fi information is in (L4, L5], the score of the second Wi-Fi information is 0.8; if the RSSI in the second Wi-Fi information is in (L5, +∞), the score of the second Wi-Fi information is 1. The embodiments of the present application do not limit the specific manner of determining the score of the second Wi-Fi information according to the RSSI in the second Wi-Fi information.

[0103] S110. If the first Wi-Fi information matches the second Wi-Fi information, the electronic fence driver can send a first event to the upper-layer application, and the first event indicates that the electronic device enters the electronic fence.

[0104] The matching of the first Wi-Fi information and the second Wi-Fi information includes: the score of the second Wi-Fi information determined according to the RSSI in the second Wi-Fi information is greater than the first score threshold, and at least one of the following information of the first Wi-Fi information and the second Wi-Fi information is the same: BSSID, SSID. For example, the score of the second Wi-Fi information determined according to the RSSI in the second Wi-Fi information (such as 0.8) is greater than the first score threshold (such as 0.7), the BSSID of the first Wi-Fi information is the same as the BSSID of the second Wi-Fi information, and the SSID of the first Wi-Fi information is the same as the SSID of the second Wi-Fi information.

[0105] The closer an electronic device is to an access point (AP), the stronger the Wi-Fi signal it detects; that is, the higher the RSSI (Real-Signal Significance) of the scanned second Wi-Fi information, and the higher the score of the second Wi-Fi information determined from the RSSI. Furthermore, AP devices are typically installed indoors, and walls significantly weaken their Wi-Fi signals. Therefore, the Wi-Fi signal strength detected by an electronic device outside the location is much lower than that detected inside. Consequently, the lower the RSSI score of the second Wi-Fi information when the electronic device is outside, and the higher the score when it is inside, the better. Therefore, a score greater than the first score threshold helps confirm that the electronic device has entered the location.

[0106] The first event can include the geofence identifier, the event type, and the time of the first event. The event type can indicate that the electronic device enters the geofence corresponding to the identifier, and the time of the event refers to the time relative to when the electronic device is turned on.

[0107] The electronic fence driver can send the first event to the upper-layer application in sequence through the HAL module, AIDL module, and MSDP.

[0108] S111 In response to the first event, the upper-layer application calls the service corresponding to the electronic fence.

[0109] Knowing that an electronic device has entered a geofence corresponding to a specific location, upper-layer applications can use the geofence's location data to invoke the services associated with that geofence. A specific example can be found here. Figures 5-7 The description will not be repeated here.

[0110] S112. After the electronic device enters the electronic fence, if the first Wi-Fi information does not match the second Wi-Fi information, the electronic fence driver can send a second event to the upper-layer application. The second event indicates that the electronic device leaves the electronic fence.

[0111] The first Wi-Fi information and the second Wi-Fi information do not match, including: the score of the second Wi-Fi information determined according to the RSSI in the second Wi-Fi information is less than a second score threshold (the second score threshold is less than a first score threshold); or, the following information of the first Wi-Fi information and the second Wi-Fi information are different: BSSID and SSID. For example, the score of the second Wi-Fi information determined according to the RSSI in the second Wi-Fi information (e.g., 0.2) is less than a second score threshold (e.g., 0.3); or, the BSSID of the first Wi-Fi information is different from the BSSID of the second Wi-Fi information, and the SSID of the first Wi-Fi information is different from the SSID of the second Wi-Fi information.

[0112] Based on the previous analysis, when an electronic device is outside the location, the smaller the score of the second Wi-Fi information determined by the RSSI in the second Wi-Fi information, the more likely it is to be determined that the electronic device has left the location.

[0113] The second event can include the geofence identifier, event type, and the time of occurrence of the second event. The event type indicates that the electronic device has left the geofence corresponding to the identifier, and the occurrence time refers to the time relative to when the electronic device was powered on. By comparing the difference between the occurrence times of the first and second events, the time the electronic device stayed within the geofence can be determined, facilitating the analysis of user behavior, such as user shopping time.

[0114] The electronic fence driver can send a second event to the upper-layer application in sequence through the HAL module, AIDL module, and MSDP.

[0115] S113. In response to the second event, the upper-layer application ends and enters the service corresponding to the electronic fence.

[0116] by Figures 5-7 For example, if entering an electronic fence corresponds to displaying a payment code (or scanning a QR code), then exiting that service would be stopping the display of the payment code (or scanning a QR code). If entering an electronic fence corresponds to opening a virtual card, then exiting that service would be disabling the virtual card. If entering an electronic fence corresponds to displaying a smart reminder, then exiting that service would be stopping the display of smart reminders. This can reduce the power consumption of electronic devices.

[0117] After executing S113, S107 can be executed, which is to perform the next round of scanning cellular information to detect whether the electronic device has left the coverage area of ​​the cellular network.

[0118] The method for constructing channels in an electronic fence described above is described below with reference to specific information. This application provides another method for constructing channels in an electronic fence, such as... Figure 11 As shown, this includes S201-S223:

[0119] S201, upper-layer applications (such as intelligent sensing services), MSDP, AIDL module, HAL module, electronic fence driver, Wi-Fi driver, and modem driver complete initialization.

[0120] The initialization of these modules includes the creation of thread resources and the allocation of array resources. The AIDL module and the HAL module belong to the same process and can be initialized together.

[0121] S202, the electronic fence driver establishes connections with the Wi-Fi driver and modem driver respectively.

[0122] The electronic fence driver can directly connect to the Wi-Fi driver and modem driver via the QMI interface.

[0123] The S203 and AIDL modules establish a connection with the electronic fence driver through the HAL module.

[0124] The HAL module can directly connect to the electronic fence driver via the QMI interface.

[0125] S204 and AIDL modules register the detection of electronic fence driver crash events through the HAL module.

[0126] If an electronic fence driver crash occurs, the AIDL module will re-execute steps S203 and S204. This means the AIDL module will re-establish a connection with the electronic fence driver via the HAL module and re-register for crash event detection. Because the electronic fence driver may crash and restart, previously cached data will be lost. Therefore, the AIDL module needs to re-establish a connection with the electronic fence driver via the HAL module and re-register for crash event detection to achieve automatic recovery.

[0127] S205, MSDP determines whether the current platform supports the electronic fence function involved in the embodiments of this application.

[0128] Electronic devices maintain a whitelist, which includes versions (i.e., platforms) of electronic devices that support the electronic fence function involved in the embodiments of this application. Electronic devices not on the whitelist do not support the electronic fence function.

[0129] S206. If the current platform supports the electronic fence function, the MSDP establishes a connection with the AIDL module.

[0130] If the current platform does not support the electronic fence function, exit.

[0131] Specifically, MSDP can obtain a handle to the first IBinder object by calling the `getService` method of the ServerManager. IBinder is... IBinder is an interface that defines a set of methods for inter-process communication. Through IBinder, data can be passed and methods can be invoked between different processes, thus achieving inter-process communication.

[0132] The AIDL module acts as the server in the server-client inter-process communication model, while MSDP acts as the client. There are multiple AIDL services; the `getService` method can specify the name of the AIDL service as its input parameter, such as the activity recognition service. The handle of the first `IBinder` object returned by the `getService` method corresponds to the AIDL module. MSDP can establish a connection and communicate with the AIDL module through the handle of the first `IBinder` object.

[0133] S207, MSDP registers the first callback function with the AIDL module.

[0134] The first callback function (e.g., the onFenceStatusChanged method) belongs to MSDP. MSDP processes the first event or the second event from the electronic fence module through the first callback function. The first event indicates that the electronic device enters a certain electronic fence, and the second event indicates that the electronic device leaves a certain electronic fence.

[0135] S208 and MSDP registration are used to detect AIDL module crash events.

[0136] If an AIDL module crash occurs, MSDP will re-execute steps S206-S208, triggering the AIDL module to re-execute steps S209 and S210. Specifically, MSDP will re-establish a connection with the AIDL module, re-register the first callback function, and re-register the detection of AIDL module crash events. MSDP will then re-execute step S217, re-configuring the geofence's feature information for the AIDL module, triggering the AIDL module to re-execute steps S218 and S219. Because the AIDL module may crash and restart, previously cached data is lost. Therefore, the MSDP module needs to re-establish a connection with the AIDL module, re-register the first callback function, re-register the detection of AIDL module crash events, and re-configure the geofence's feature information to achieve automatic recovery.

[0137] S209. The AIDL module binds the first callback function to the identifier (e.g., process ID) of the MSDP that registered the first callback function.

[0138] The AIDL module binds the first callback function to the identifier of the MSDP that registered the first callback function, establishing a primary mapping between the first callback function and the MSDP identifier. Since more than one MSDP may register the first callback function, the MSDP identifier can be used to determine which MSDP registered the first callback function. Specifically, S207 will trigger S209.

[0139] S210, AIDL module registration for MSDP crash event detection.

[0140] If an MSDP crash occurs, the AIDL module will clear the first callback function and the first mapping relationship between the first callback function and the MSDP identifier. This is because MSDP may crash and restart, and the assigned MSDP identifier (e.g., process ID) will be different after restarting. This would invalidate the first mapping relationship and the first callback function. Therefore, clearing the first callback function and the first mapping relationship prevents data corruption.

[0141] S211, The upper-layer application establishes a connection with MSDP.

[0142] Specifically, MSDP obtains a handle to the second IBinder object through the onBind method and publishes this handle to the framework so that other clients can obtain it. The onBind method takes a message passing object intent as its input parameter, which includes the MSDP process name and the MSDP path.

[0143] Upper-layer applications can establish a connection with an MSDP service by calling the MSDP's connectService method, which takes the aforementioned message passing object intent as its input parameter. Upper-layer applications can also disconnect from an MSDP service by calling the MSDP's disconnectService method.

[0144] MSDP determines whether the current platform supports the electronic fence function involved in the embodiments of this application.

[0145] If the current platform supports the geofencing feature, MSDP sends the handle of the second IBinder object to the upper-layer application via the onServiceConnected method. If the current platform does not support the geofencing feature, the process exits. The upper-layer application can then establish a connection and communicate with MSDP using the handle of the second IBinder object.

[0146] S212. The upper-layer application registers a second callback function with MSDP.

[0147] The second callback function belongs to the upper-layer application, which processes the first or second event from the electronic fence module through the second callback function.

[0148] S213, MSDP binds the second callback function to the identifier (e.g., process ID) of the upper-layer application that registered the second callback function.

[0149] MSDP binds the second callback function to the identifier of the upper-layer application that registered the second callback function, establishing a second mapping relationship between the second callback function and the upper-layer application's identifier. Since more than one upper-layer application may register the second callback function with MSDP, the upper-layer application's identifier can be used to determine which upper-layer application registered the second callback function.

[0150] S214, MSDP registration for detecting crash events in upper-layer applications.

[0151] If an upper-layer application crashes, MSDP will clear the second callback function and the second mapping relationship between the second callback function and the upper-layer application's identifier. This is because the upper-layer application may crash and restart, and the assigned identifier (e.g., process ID) will be different after restarting. This would invalidate the second mapping relationship and the second callback function. Therefore, clearing the second callback function and the second mapping relationship prevents data corruption.

[0152] S215. Upper-layer applications configure the feature information of the electronic fence to the electronic fence driver through the MSDP, AIDL, and HAL modules.

[0153] Upper-layer applications configure geofence feature information to MSDP. Upper-layer applications add geofence feature information by calling MSDP's `addXXXFences` method. Upper-layer applications pause, resume, or delete geofence feature information by calling MSDP's `operateFences` method. Upper-layer applications can also query whether an electronic device has entered a geofence by calling MSDP's `getCurrentFenceState` method.

[0154] S216, MSDP binds the feature information of the electronic fence to the identifier of the upper-layer application that sends the feature information of the electronic fence.

[0155] MSDP binds the feature information of the electronic fence to the identifier of the upper-layer application that sent the feature information, establishing a third mapping relationship between the feature information of the electronic fence and the identifier of the upper-layer application. Since more than one upper-layer application may send the feature information of the electronic fence to MSDP, the identifier of the upper-layer application can be used to determine which upper-layer application sent the feature information.

[0156] S217, MSDP configures the feature information of the electronic fence to the AIDL module.

[0157] S218, the AIDL module binds the feature information of the electronic fence with the MSDP identifier.

[0158] The AIDL module binds the feature information of the electronic fence to the identifier of the MSDP, establishing a fourth mapping relationship between the feature information of the electronic fence and the identifier of the MSDP. Since more than one MSDP may send the feature information of the electronic fence to the AIDL module, the identifier of the MSDP can be used to determine which MSDP sent the feature information.

[0159] S219, the AIDL module configures the feature information of the electronic fence to the electronic fence driver through the HAL module.

[0160] S220: The electronic fence driver scans the electronic fence based on its feature information and sends a first event or a second event to the AIDL module through the HAL module.

[0161] Regarding the electronic fence driver scanning of the electronic fence and sending the first or second event to the AIDL module through the HAL module, refer to S106-S113, which will not be repeated here.

[0162] S221. The AIDL module determines the first callback function of MSDP based on the identifier of the electronic fence, the fourth mapping relationship, and the first mapping relationship in the first or second event, and triggers MSDP to execute the first callback function.

[0163] Since the feature information of each electronic fence is indexed through the electronic fence's identifier, the fourth mapping relationship between the electronic fence's feature information and the MSDP's identifier essentially also includes the mapping relationship between the electronic fence's identifier and the MSDP's identifier. Therefore, the AIDL module can query the MSDP's identifier based on the electronic fence's identifier in the first or second event, and the fourth mapping relationship between the electronic fence's feature information and the MSDP's identifier, thereby determining which MSDP has configured the corresponding electronic fence's feature information.

[0164] The AIDL module then determines the first callback function corresponding to the MSDP identifier based on the MSDP identifier and the first mapping relationship between the first callback function and the MSDP identifier. The first event or the second event is then used as the input parameter to the first callback function, triggering the MSDP to execute the first callback function, thereby executing S222.

[0165] S222, the first callback function of MSDP determines the second callback function of the upper-layer application based on the identifier of the electronic fence, the third mapping relationship, and the second mapping relationship in the first or second event, and triggers the upper-layer application to execute the second callback function.

[0166] Since the feature information of each electronic fence is indexed through its identifier, the third mapping relationship between the electronic fence's feature information and the identifier of the upper-layer application essentially includes the mapping relationship between the electronic fence's identifier and the upper-layer application's identifier. Therefore, MSDP can query the identifier of the upper-layer application based on the electronic fence's identifier in the first or second event, and the third mapping relationship between the electronic fence's feature information and the upper-layer application's identifier, thereby determining which upper-layer application has configured the corresponding electronic fence's feature information.

[0167] MSDP then determines the second callback function corresponding to the upper-layer application's identifier based on the upper-layer application's identifier and the second mapping relationship between the second callback function and the upper-layer application's identifier. The first event or the second event is then used as the input parameter to the second callback function, triggering the upper-layer application to execute the second callback function, thereby executing S223.

[0168] S223. In response to the first event, the second callback function of the upper-layer application calls the service corresponding to the electronic fence; or, in response to the second event, the second callback function of the upper-layer application ends and enters the service corresponding to the electronic fence.

[0169] The electronic fence channel construction method and electronic device provided in this application, for upper-layer software modules and lower-layer software modules located in adjacent layers: On the one hand, the upper-layer software module registers a callback function with the lower-layer software module, and the lower-layer software module establishes a mapping relationship between the callback function and the upper-layer software module; on the other hand, the upper-layer software module configures the electronic fence feature information with the lower-layer software module, and the lower-layer software module establishes a mapping relationship between the electronic fence feature information and the upper-layer software module. Since the electronic fence feature information is indexed by the electronic fence identifier, and the electronic fence driver reports the first event of an electronic device entering the electronic fence or the second event of an electronic device leaving the electronic fence, the identifier of the upper-layer software module can be determined through the electronic fence identifier, thereby determining the callback function of the upper-layer software module. Starting from the electronic fence driver, by executing the callback function of the upper-layer software module, using the first event or the second event as the input parameter of the callback function, and passing it upwards layer by layer until it is passed to the upper-layer application, a channel between the upper-layer application and the electronic fence driver can be established.

[0170] It should be noted that the contents described in the various embodiments of this application can explain the technical solutions in other embodiments of this application, and the technical features described in the various embodiments can also be applied in other embodiments. New solutions can be formed by combining the technical features in other embodiments. This application only provides an exemplary list of several embodiments for illustration and does not mean that this application is limited thereto.

[0171] This application provides an electronic device that may include a memory and one or more processors. The memory stores computer program code, which includes computer instructions. When the computer instructions are executed by the processor, the electronic device performs the various functions or steps described in the above embodiments, such as executing... Figure 8 , Figure 11 The method shown above. The structure of this electronic device can be referred to the above. Figure 3 The structure of the electronic device 100 shown.

[0172] This application also provides a computer-readable storage medium including instructions that, when executed on the electronic device, cause the electronic device to perform the steps described in the method embodiments, such as executing... Figure 8 , Figure 11 The method shown.

[0173] This application also provides a computer program product including instructions, which, when executed on the aforementioned electronic device, cause the electronic device to perform the various steps in the method embodiments described above, such as executing... Figure 8 , Figure 11The method shown.

[0174] The technical effects of computer-readable storage media and computer program products are described in the preceding method embodiments.

[0175] It should be noted that the terms "first" and "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. "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 indicated technical features. Therefore, a feature defined with "first" and "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.

[0176] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.

[0177] It should be understood that in this application, "at least one (item)" means one or more. "More than one" means two or more. "At least two (items)" means two or three or more. "And / or" is used to describe the relationship between related objects, indicating that there can be three relationships. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the related objects before and after are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple. Both "...when" and "if" indicate that a corresponding action will be taken under certain objective circumstances. They are not time limits, nor do they require a judgment action to be taken when the action is taken, nor do they imply any other limitations.

[0178] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner to facilitate understanding.

[0179] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules according to the system, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0180] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0181] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0182] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional unit.

[0183] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0184] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for constructing a passageway in an electronic fence, characterized in that, Applied in electronic devices, the electronic devices include upper-layer applications, a multi-mode sensor data platform (MSDP), an Android interface definition language (AIDL) module, a hardware abstraction layer (HAL) module, and an electronic fence driver. The method includes: The MSDP registers a first callback function with the AIDL module; the AIDL module establishes a first mapping relationship between the first callback function and the identifier of the MSDP. The upper-layer application registers a second callback function with the MSDP; the MSDP establishes a second mapping relationship between the second callback function and the identifier of the upper-layer application; The upper-layer application configures the feature information of the electronic fence to the MSDP, and the feature information of the electronic fence is indexed by the identifier of the electronic fence; the MSDP establishes a third mapping relationship between the feature information of the electronic fence and the identifier of the upper-layer application; The MSDP configures the feature information of the electronic fence to the AIDL module; the AIDL module establishes a fourth mapping relationship between the feature information of the electronic fence and the identifier of the MSDP; The AIDL module configures the feature information of the electronic fence to the electronic fence driver through the hardware abstraction layer (HAL) module. The electronic fence driver scans the electronic fence according to its feature information and sends a first event or a second event to the AIDL module through the HAL module. The first event indicates that the electronic device enters the electronic fence, and the second event indicates that the electronic device leaves the electronic fence. The AIDL module determines the first callback function of the MSDP based on the identifier of the electronic fence in the first event or the second event, the fourth mapping relationship, and the first mapping relationship, and triggers the MSDP to execute the first callback function, with the first event or the second event serving as the input parameter of the first callback function; The first callback function of the MSDP determines the second callback function of the upper-layer application based on the identifier of the electronic fence in the first event or the second event, the third mapping relationship, and the second mapping relationship, and triggers the upper-layer application to execute the second callback function, with the first event or the second event serving as the input parameter of the second callback function; In response to the first event, the second callback function of the upper-layer application calls the service corresponding to the electronic fence; or, in response to the second event, the second callback function of the upper-layer application terminates and enters the service corresponding to the electronic fence.

2. The method according to claim 1, characterized in that, The AIDL module determines the first callback function of the MSDP based on the identifier of the electronic fence in the first event or the second event, the fourth mapping relationship, and the first mapping relationship, including: The AIDL module obtains the MSDP identifier based on the identifier of the electronic fence in the first event or the second event, and the fourth mapping relationship; The AIDL module determines the first callback function corresponding to the MSDP identifier based on the MSDP identifier and the first mapping relationship.

3. The method according to claim 1, characterized in that, The first callback function of the MSDP determines the second callback function of the upper-layer application based on the geofence identifier in the first event or the second event, the third mapping relationship, and the second mapping relationship, including: The MSDP obtains the identifier of the upper-layer application based on the identifier of the electronic fence in the first event or the second event, and the third mapping relationship; The MSDP determines the second callback function corresponding to the identifier of the upper-layer application based on the identifier of the upper-layer application and the second mapping relationship.

4. The method according to any one of claims 1-3, characterized in that, Also includes: The AIDL module registers the detection of electronic fence driver crash events through the HAL module. If the electronic fence driver crash event occurs, the AIDL module re-establishes a connection with the electronic fence driver through the HAL module and re-registers the detection of the electronic fence driver crash event.

5. The method according to any one of claims 1-4, characterized in that, Also includes: The MSDP registers the detection of AIDL module crash events. If an AIDL module crash event occurs, the MSDP re-establishes a connection with the AIDL module, re-registers the first callback function with the AIDL module, re-registers the detection of AIDL module crash events, and re-configures the feature information of the electronic fence with the AIDL module.

6. The method according to any one of claims 1-5, characterized in that, Also includes: The AIDL module registers the detection of MSDP crash events. If the MSDP crash event occurs, the AIDL module clears the first callback function and the first mapping relationship.

7. The method according to any one of claims 1-6, characterized in that, Also includes: The MSDP registration detects upper-layer application crash events. If an upper-layer application crash event occurs, the MSDP clears the second callback function and the second mapping relationship.

8. An electronic device, characterized in that, include: Memory and one or more processors; The memory stores computer program code, which includes computer instructions; when the computer instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1-7.

9. A computer-readable storage medium, characterized in that, Includes instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-7.

10. A computer program product containing instructions, characterized in that, When the instructions are executed on an electronic device, the electronic device causes the electronic device to perform the method as described in any one of claims 1-7.