CN114006698B - token refreshing method and device, electronic equipment and readable storage medium - Google Patents

token refreshing method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN114006698B
CN114006698B CN202111656025.3A CN202111656025A CN114006698B CN 114006698 B CN114006698 B CN 114006698B CN 202111656025 A CN202111656025 A CN 202111656025A CN 114006698 B CN114006698 B CN 114006698B
Authority
CN
China
Prior art keywords
token
network request
request
network
refreshing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111656025.3A
Other languages
Chinese (zh)
Other versions
CN114006698A (en
Inventor
李进
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Glory Smart Technology Development Co ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202111656025.3A priority Critical patent/CN114006698B/en
Publication of CN114006698A publication Critical patent/CN114006698A/en
Application granted granted Critical
Publication of CN114006698B publication Critical patent/CN114006698B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0891Revocation or update of secret information, e.g. encryption key update or rekeying
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/321Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving a third party or a trusted authority
    • H04L9/3213Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving a third party or a trusted authority using tickets or tokens, e.g. Kerberos

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Telephone Function (AREA)

Abstract

The application relates to the technical field of terminals, and provides a token refreshing method, a token refreshing device, an electronic device and a readable storage medium, wherein the method comprises the following steps: receiving returned information fed back by each service cloud based on a first network request, wherein the first network request comprises a plurality of different network requests; if the error code of the token in each piece of return information meets a preset refreshing condition, determining a target network request corresponding to the first network request, and refreshing the token based on the target network request; the second network requests corresponding to the first network requests are determined based on the refreshed tokens, the second network requests are sent to the corresponding service clouds respectively, error codes meeting preset conditions can be fed back when the tokens of the network requests are abnormal, the tokens can be refreshed in time by the mobile terminal according to the error codes meeting the preset refreshing conditions, the situation that the smart home APP fails in page refreshing or is abnormal in function is avoided, and user experience is improved.

Description

token refreshing method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a token refreshing method and apparatus, an electronic device, and a readable storage medium.
Background
At present, in the application of the smart home, the smart home can generally receive a control instruction sent by a user, and execute a corresponding action, the user can control the smart home based on a smart home APP installed on a mobile phone, and the like, the user can also know the current state of the smart home based on the smart home APP, the smart home APP acquires service data from a plurality of service clouds (for example, a device cloud, a scene cloud, and an operation cloud) and displays the service data, and in order to ensure the security of the service data, each service cloud can perform validity check on each received service request through a token in the request.
However, because the smart home APP is in butt joint with a plurality of service clouds, the error codes of the service clouds when the token is abnormal are different, and when the token is abnormal, the error codes of the service clouds returned to the smart home APP are different, so that the smart home APP cannot process different error codes in a unified manner, and the smart home APP is failed to refresh a page or has an abnormal function.
Disclosure of Invention
The application provides a token refreshing method and device, electronic equipment and a readable storage medium, and aims to refresh a token when an error code of the token meets a preset refreshing condition, so that a smart home APP can be successfully refreshed, and user experience is improved.
In a first aspect, the present application provides a token refreshing method, which is applied to a mobile terminal, and includes:
receiving returned information fed back by each service cloud based on a first network request, wherein the first network request comprises a plurality of different network requests;
if the error code of the token in each piece of return information meets a preset refreshing condition, determining a target network request corresponding to the first network request, and refreshing the token based on the target network request;
and determining second network requests corresponding to the first network requests based on the refreshed tokens, and respectively sending the second network requests to corresponding service clouds.
The token refreshing method provided by the application can feed back the error codes meeting the preset conditions when tokens requested by a plurality of networks are abnormal, so that the mobile terminal can timely refresh the tokens according to the error codes meeting the preset refreshing conditions, further the condition that the smart home APP fails to refresh the page or has abnormal functions is avoided, and the user experience is improved.
In a possible implementation manner, the step of determining a target network request corresponding to the first network request includes:
if the state of the screening module in the mobile terminal is a first state, determining the target network request based on each first network request, and adding each first network request to a target queue;
and if the state of the screening module is a second state, determining the target network requests based on the second state, and adding each first network request to a target queue.
In another possible implementation manner, the step of determining a target network request based on each first network request includes:
and respectively setting the state of the screening module based on each first network request, and determining the first network request which currently sets the state of the screening module to be the second state as a target network request.
In another possible implementation manner, the step of setting the states of the screening modules based on the respective first network requests includes:
for each first network request, setting a state of the screening module based on a CAS algorithm.
In another possible implementation manner, the step of determining, based on the refreshed token, a second network request corresponding to each first network request includes:
determining the second network request based on the network requests in the target queue and the refreshed token.
In another possible implementation manner, the step of determining a target network request corresponding to the first network request includes:
if the network request in the waiting state does not exist currently, determining a target network request in the first network request, and setting the network requests except the target network request in the first network request to be in the waiting state;
and if the network requests in the waiting state exist currently, determining the target network requests based on the waiting state, and setting each first network request to be in the waiting state.
In another possible implementation manner, the step of determining, based on the refreshed token, a second network request corresponding to each first network request includes:
determining the second network request based on the network request in the waiting state, the target network request and the refreshed token.
In another possible implementation manner, before the step of determining the target network request corresponding to the first network request if the error codes of tokens in the return messages are consistent, the method further includes:
and acquiring error codes corresponding to preset fields in each piece of return information, and determining whether each error code is consistent, wherein when each error code is consistent, determining that the error code of token in the return information meets preset refreshing conditions.
In another possible implementation manner, the step of requesting to refresh the token based on the target network includes:
and sending a token refreshing request to the account cloud based on the target network request, so that the account cloud executes token refreshing operation, and feeds back the refreshed token.
In another possible implementation manner, before the step of receiving the returned information fed back by each service cloud based on the first network request, the method further includes:
and respectively sending each first network request to different service clouds, wherein each service cloud respectively sends a token verification request corresponding to the received first network request to an account cloud, if the account cloud verifies that the token corresponding to each token verification request is abnormal, the account cloud feeds back an error code to each service cloud, and each service cloud feeds back information to the mobile terminal based on the error code.
In a second aspect, the present application provides a token refreshing method, which is applied to an account cloud, and includes:
receiving token verification requests corresponding to the first network requests sent by the service clouds;
verifying the token corresponding to each first network request;
and if the verification result of the verification operation is token abnormity, feeding back an error code to each service cloud so that each service cloud feeds back information to the mobile terminal based on the error code.
In another possible implementation manner, the method further includes:
and when a token refreshing request sent by the mobile terminal is received, executing token refreshing operation based on the token refreshing request, and feeding back the refreshed token to the mobile terminal.
In a third aspect, the present application provides a token refreshing apparatus, comprising: the device comprises a receiving module, a determining module and a sending module;
the receiving module is used for receiving return information fed back by each service cloud based on a first network request, wherein the first network request comprises a plurality of different network requests;
the determining module is configured to determine a target network request corresponding to the first network request if the error code of the token in each piece of the returned information meets a preset refresh condition, and refresh the token based on the target network request;
and the sending module is used for determining second network requests corresponding to the first network requests based on the refreshed tokens and respectively sending the second network requests to the corresponding service clouds.
In a fourth aspect, the present application provides an electronic device, comprising:
one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs comprising instructions which, when executed by the electronic device, cause the electronic device to perform the token refresh method as set forth in any one of the above first/second aspects or possible implementations of the first/second aspects.
In a fifth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, causes the processor to execute the token refresh method as described in any one of the above first/second aspects or possible implementations of the first/second aspects.
In a sixth aspect, the present application provides a chip, where the chip includes a processor and a data interface, and the processor reads an instruction stored in a memory through the data interface and executes the token refresh method according to the first aspect or any one of possible implementation manners of the first aspect.
Optionally, as a possible implementation manner, the chip may further include a memory, where the memory stores instructions, and the processor is configured to execute the instructions stored in the memory, and when the instructions are executed, the processor is configured to execute the token refresh method according to the first aspect or any one of the possible implementation manners of the first aspect.
Drawings
FIG. 1 is a schematic diagram of a token exception of a network request in the prior art;
fig. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 3 is a block diagram of a software structure of an electronic device according to an embodiment of the present disclosure;
FIG. 4 is a flowchart of a token refresh method according to an embodiment of the present application;
FIG. 5 is a module interaction diagram of a token refresh method according to an embodiment of the present application;
FIG. 6 is a flow chart of a token refresh method according to another embodiment of the present application;
FIG. 7 is a flowchart of a token refresh method according to another embodiment of the present application;
FIG. 8 is a flowchart of a token refresh method according to yet another embodiment of the present application;
fig. 9 is a schematic structural diagram of a token refresh apparatus provided in the present application.
Detailed Description
The terms "first", "second" and "third", etc. in the description and claims of this application and the description of the drawings are used for distinguishing between different objects and not for limiting a particular order.
In the embodiments of the present application, words such as "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "e.g.," is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "such as" is intended to present concepts related in a concrete fashion.
For clarity and conciseness of the description of the following embodiments, a brief introduction to an implementation of token refresh is first given:
at present, terminals such as mobile phones and tablet computers are basically loaded with application programs APP of smart homes. The smart home APPs are in communication connection with a cloud side, for example, the smart home APPs are in communication connection with cloud side servers such as an account cloud, a device cloud, a home cloud, a mall cloud, a scene cloud, and an operation cloud, respectively, a user can control the smart home based on the smart home APPs installed on a mobile phone, and the user can also know the current state of the smart home based on the smart home APPs, the smart home APPs acquire service data from a plurality of service clouds (e.g., the device cloud, the scene cloud, and the operation cloud), specifically, the smart home APPs send a plurality of network requests to the plurality of service clouds, the different service clouds receive one or more different network requests, in order to ensure the security of the service data, each service cloud sends the token of each received network request to the account cloud for validity check, after the account cloud verifies each token, when the token is normal, feeding back information that the token is normal to each service cloud, each service cloud feeds back service data corresponding to each network request to the smart home APP, and the smart home APP performs page refreshing according to the obtained service data to display the obtained service data.
As shown in fig. 1, fig. 1 is a schematic scene diagram of a token exception requested by a network in the prior art. In the prior art, as shown in fig. 1, a user operates a device through an intelligent home APP, a token is abnormal after a period of time, for example, the smart home APP operates the device before the user goes to sleep, the token of which the token is expired appears after the user gets up, and the smart home APP fails to refresh the token due to the fact that the smart home APP cannot uniformly process different error codes, and fails to refresh the token to cause the smart home APP to refresh a page and display the page with a failed refresh page; or, after the user operates through the smart home APP, for example, after a shopping mall page is opened, the smart home APP is switched to the background operation, the smart home APP is abnormal when the token is overdue after long-term operation in the background, when the user switches the smart home APP to the foreground operation, because the smart home APP cannot uniformly process different error codes, the token cannot be refreshed, and the function of the page currently displayed by the smart home APP is abnormal, for example, the keys of all functions in the page cannot be triggered.
Based on the problems in the technical scheme, the token refreshing method can refresh the token when the error code of the token meets the preset refreshing condition, the smart home APP can be guaranteed to be successfully refreshed, and the user experience is improved. The token refreshing method can be applied to electronic devices such as mobile phones, tablet computers, desktop computers, laptop computers, notebook computers, ultra-mobile Personal computers (UMPCs), handheld computers, netbooks, Personal Digital Assistants (PDAs), wearable electronic devices, smart watches and the like. The electronic device to which the token refresh method is applied may have a structure as shown in fig. 2.
As shown in fig. 2, fig. 2 is a diagram of an exemplary electronic device provided in the present application, the electronic device 200 may include a processor 210, an external memory interface 220, an internal memory 221, a Universal Serial Bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display 294, and a Subscriber Identity Module (SIM) card interface 295. The sensor module 280 may include a pressure sensor 280A, a gyroscope sensor 280B, an air pressure sensor 280C, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, a proximity light sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, an ambient light sensor 280L, a bone conduction sensor 280M, and the like.
It is to be understood that the illustrated structure of the present embodiment does not constitute a specific limitation to the electronic device 200. In other embodiments, the electronic device 200 may include more or fewer components than shown, or combine certain components, or split certain components, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Processor 210 may include one or more processing units, such as: the processor 210 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a video codec, a Digital Signal Processor (DSP), a baseband processor, and/or a neural-Network Processing Unit (NPU), among others. The different processing units may be separate devices or may be integrated into one or more processors.
The controller may be, among other things, a neural center and a command center of the electronic device 200. The controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of instruction fetching and instruction execution.
A memory may also be provided in processor 210 for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. The memory may hold instructions or data that have just been used or recycled by processor 210. If the processor 210 needs to use the instruction or data again, it can be called directly from the memory. Avoiding repeated accesses reduces the latency of the processor 210, thereby increasing the efficiency of the system.
In some embodiments, processor 210 may include one or more interfaces. The interface may include an integrated circuit (I2C) interface, an integrated circuit built-in audio (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, and/or a Universal Serial Bus (USB) interface, etc.
The I2C interface is a bi-directional synchronous serial bus that includes a serial data line (SDA) and a Serial Clock Line (SCL). In some embodiments, processor 210 may include multiple sets of I2C buses. The processor 210 may be coupled to the touch sensor 280K, the charger, the flash, the camera 293, etc. through different I2C bus interfaces. For example: the processor 210 may be coupled to the touch sensor 280K via an I2C interface, such that the processor 210 and the touch sensor 280K communicate via an I2C bus interface to implement the touch function of the electronic device 200.
The I2S interface may be used for audio communication. In some embodiments, processor 210 may include multiple sets of I2S buses. Processor 210 may be coupled to audio module 270 via an I2S bus to enable communication between processor 210 and audio module 270. In some embodiments, the audio module 270 may communicate audio signals to the wireless communication module 260 via the I2S interface, enabling answering of calls via a bluetooth headset.
The PCM interface may also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, audio module 270 and wireless communication module 260 may be coupled by a PCM bus interface. In some embodiments, the audio module 270 may also transmit audio signals to the wireless communication module 260 through the PCM interface, so as to implement a function of answering a call through a bluetooth headset. Both the I2S interface and the PCM interface may be used for audio communication.
The UART interface is a universal serial data bus used for asynchronous communications. The bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, a UART interface is generally used to connect the processor 210 with the wireless communication module 260. For example: the processor 210 communicates with the bluetooth module in the wireless communication module 260 through the UART interface to implement the bluetooth function. In some embodiments, the audio module 270 may transmit the audio signal to the wireless communication module 260 through a UART interface, so as to realize the function of playing music through a bluetooth headset.
The MIPI interface may be used to connect the processor 210 with peripheral devices such as the display screen 294, the camera 293, and the like. The MIPI interface includes a Camera Serial Interface (CSI), a Display Serial Interface (DSI), and the like. In some embodiments, processor 210 and camera 293 communicate via a CSI interface to implement the capture functionality of electronic device 200. The processor 210 and the display screen 294 communicate through the DSI interface to implement a display function of the electronic device 200.
The GPIO interface may be configured by software. The GPIO interface may be configured as a control signal and may also be configured as a data signal. In some embodiments, a GPIO interface may be used to connect processor 210 with camera 293, display 294, wireless communication module 260, audio module 270, sensor module 280, and the like. The GPIO interface may also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, and the like.
The USB interface 230 is an interface conforming to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB type c interface, or the like. The USB interface 230 may be used to connect a charger to charge the electronic device 200, and may also be used to transmit data between the electronic device 200 and a peripheral device. And the earphone can also be used for connecting an earphone and playing audio through the earphone. The interface may also be used to connect other electronic devices, such as AR devices and the like.
It should be understood that the connection relationship between the modules illustrated in the present embodiment is only an exemplary illustration, and does not limit the structure of the electronic device 200. In other embodiments of the present application, the electronic device 200 may also adopt different interface connection manners or a combination of multiple interface connection manners in the above embodiments.
The charge management module 240 is configured to receive a charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 240 may receive charging input from a wired charger via the USB interface 230. In some wireless charging embodiments, the charging management module 240 may receive a wireless charging input through a wireless charging coil of the electronic device 200. The charging management module 240 may also supply power to the electronic device 200 through the power management module 241 while charging the battery 242.
The power management module 241 is used to connect the battery 242, the charging management module 240 and the processor 210. The power management module 241 receives input from the battery 242 and/or the charging management module 240, and provides power to the processor 210, the internal memory 221, the display 294, the camera 293, and the wireless communication module 260. The power management module 241 may also be used to monitor parameters such as battery capacity, battery cycle number, battery state of health (leakage, impedance), etc. In some other embodiments, the power management module 241 may also be disposed in the processor 210. In other embodiments, the power management module 241 and the charging management module 240 may be disposed in the same device.
The wireless communication function of the electronic device 200 may be implemented by the antenna 1, the antenna 2, the mobile communication module 250, the wireless communication module 260, the modem processor, the baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device 200 may be used to cover a single or multiple communication bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed as a diversity antenna of a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
The mobile communication module 250 may provide a solution including 2G/3G/4G/5G wireless communication applied on the electronic device 200. The mobile communication module 250 may include at least one filter, a switch, a power amplifier, a Low Noise Amplifier (LNA), and the like. The mobile communication module 250 may receive the electromagnetic wave from the antenna 1, filter, amplify, etc. the received electromagnetic wave, and transmit the electromagnetic wave to the modem processor for demodulation. The mobile communication module 250 may also amplify the signal modulated by the modem processor, and convert the signal into electromagnetic wave through the antenna 1 to radiate the electromagnetic wave. In some embodiments, at least some of the functional modules of the mobile communication module 250 may be disposed in the processor 210. In some embodiments, at least some of the functional modules of the mobile communication module 250 may be disposed in the same device as at least some of the modules of the processor 210.
The modem processor may include a modulator and a demodulator. The modulator is used for modulating a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used for demodulating the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then passes the demodulated low frequency baseband signal to a baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and then transferred to the application processor. The application processor outputs sound signals through an audio device (not limited to the speaker 270A, the receiver 270B, etc.) or displays images or video through the display screen 294. In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be separate from the processor 210, and may be disposed in the same device as the mobile communication module 250 or other functional modules.
The wireless communication module 260 may provide a solution for wireless communication applied to the electronic device 200, including Wireless Local Area Networks (WLANs) (e.g., wireless fidelity (Wi-Fi) networks), bluetooth (bluetooth, BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and the like. The wireless communication module 260 may be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on electromagnetic wave signals, and transmits the processed signals to the processor 210. The wireless communication module 260 may also receive a signal to be transmitted from the processor 210, frequency-modulate and amplify the signal, and convert the signal into electromagnetic waves via the antenna 2 to radiate the electromagnetic waves.
In some embodiments, antenna 1 of electronic device 200 is coupled to mobile communication module 250 and antenna 2 is coupled to wireless communication module 260, such that electronic device 200 may communicate with networks and other devices via wireless communication techniques. The wireless communication technology may include global system for mobile communications (GSM), General Packet Radio Service (GPRS), code division multiple access (code division multiple access, CDMA), Wideband Code Division Multiple Access (WCDMA), time-division code division multiple access (time-division code division multiple access, TD-SCDMA), Long Term Evolution (LTE), LTE, BT, GNSS, WLAN, NFC, FM, and/or IR technologies, etc. The GNSS may include a Global Positioning System (GPS), a global navigation satellite system (GLONASS), a beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS), and/or a Satellite Based Augmentation System (SBAS).
The electronic device 200 implements display functions via the GPU, the display screen 294, and the application processor. The GPU is a microprocessor for image processing, and is connected to the display screen 294 and an application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 210 may include one or more GPUs that execute program instructions to generate or alter display information.
The display screen 294 is used to display images, video, and the like. The display screen 294 includes a display panel. The display panel may adopt a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (active-matrix organic light-emitting diode, AMOLED), a flexible light-emitting diode (FLED), a miniature, a Micro-OLED, a quantum dot light-emitting diode (QLED), and the like. In some embodiments, the electronic device 200 may include 1 or N display screens 294, N being a positive integer greater than 1.
A series of Graphical User Interfaces (GUIs) may be displayed on the display screen 294 of the electronic device 200, which are the main screens of the electronic device 200. Generally, the size of the display 294 of the electronic device 200 is fixed, and only limited controls can be displayed in the display 294 of the electronic device 200. A control is a GUI element, which is a software component contained in an application program and controls all data processed by the application program and interactive operations related to the data, and a user can interact with the control through direct manipulation (direct manipulation) to read or edit information related to the application program. Generally, a control may include a visual interface element such as an icon, button, menu, tab, text box, dialog box, status bar, navigation bar, Widget, and the like. For example, in the embodiment of the present application, the display 291 may display virtual keys (one-key layout, start layout, scene layout).
The electronic device 200 may implement a shooting function through the ISP, the camera 293, the video codec, the GPU, the display screen 294, and the application processor.
The ISP is used to process the data fed back by the camera 293. For example, when a photo is taken, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converting into an image visible to naked eyes. The ISP can also carry out algorithm optimization on the noise, brightness and skin color of the image. The ISP can also optimize parameters such as exposure, color temperature and the like of a shooting scene. In some embodiments, the ISP may be provided in camera 293.
The camera 293 is used to capture still images or video. The object generates an optical image through the lens and projects the optical image to the photosensitive element. The photosensitive element may be a Charge Coupled Device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The light sensing element converts the optical signal into an electrical signal, which is then passed to the ISP where it is converted into a digital image signal. And the ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into image signal in standard RGB, YUV and other formats. In some embodiments, electronic device 200 may include 1 or N cameras 293, N being a positive integer greater than 1.
The digital signal processor is used for processing digital signals, and can process digital image signals and other digital signals. For example, when the electronic device 200 selects a frequency bin, the digital signal processor is used to perform fourier transform or the like on the frequency bin energy.
Video codecs are used to compress or decompress digital video. The electronic device 200 may support one or more video codecs. In this way, the electronic device 200 may play or record video in a variety of encoding formats, such as: moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, and the like.
The NPU is a neural-network (NN) computing processor that processes input information quickly by using a biological neural network structure, for example, by using a transfer mode between neurons of a human brain, and can also learn by itself continuously. The NPU can implement applications such as intelligent recognition of the electronic device 200, for example: image recognition, face recognition, speech recognition, text understanding, and the like.
The external memory interface 220 may be used to connect an external memory card, such as a MicroSD card, to extend the memory capability of the electronic device 200. The external memory card communicates with the processor 210 through the external memory interface 220 to implement a data storage function. For example, files such as music, video, etc. are saved in an external memory card.
Internal memory 221 may be used to store computer-executable program code, including instructions. The processor 210 executes various functional applications of the electronic device 200 and data processing by executing instructions stored in the internal memory 221. For example, in the present embodiment, the processor 210 may perform scene composition by executing instructions stored in the internal memory 221. The internal memory 221 may include a program storage area and a data storage area. The storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required by at least one function, and the like. The storage data area may store data (e.g., audio data, a phone book, etc.) created during use of the electronic device 200, and the like. In addition, the internal memory 221 may include a high-speed random access memory, and may further include a nonvolatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (UFS), and the like. The processor 210 executes various functional applications of the electronic device 200 and data processing by executing instructions stored in the internal memory 221 and/or instructions stored in a memory provided in the processor.
Electronic device 200 may implement audio functions via audio module 270, speaker 270A, receiver 270B, microphone 270C, headset interface 270D, and an application processor, among other things. Such as music playing, recording, etc.
Audio module 270 is used to convert digital audio information into an analog audio signal output and also to convert an analog audio input into a digital audio signal. Audio module 270 may also be used to encode and decode audio signals. In some embodiments, the audio module 270 may be disposed in the processor 210, or some functional modules of the audio module 270 may be disposed in the processor 210.
The speaker 270A, also called a "horn", is used to convert an audio electrical signal into an acoustic signal. The electronic apparatus 200 can listen to music through the speaker 270A or listen to a handsfree call.
The receiver 270B, also called "earpiece", is used to convert the electrical audio signal into an acoustic signal. When the electronic apparatus 200 receives a call or voice information, it is possible to receive voice by placing the receiver 270B close to the human ear.
The microphone 270C, also referred to as a "microphone," is used to convert acoustic signals into electrical signals. When making a call or transmitting voice information, the user can input a voice signal to the microphone 270C by speaking the user's mouth near the microphone 270C. The electronic device 200 may be provided with at least one microphone 270C. In other embodiments, the electronic device 200 may be provided with two microphones 270C to achieve a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 200 may further include three, four or more microphones 270C to collect sound signals, reduce noise, identify sound sources, implement directional recording functions, and so on.
The headphone interface 270D is used to connect wired headphones. The headset interface 270D may be the USB interface 230, or may be an open mobile electronic device platform (OMTP) standard interface of 3.5mm, or a Cellular Telecommunications Industry Association (CTIA) standard interface.
The pressure sensor 280A is used to sense a pressure signal, which can be converted into an electrical signal. In some embodiments, the pressure sensor 280A may be disposed on the display screen 294. The pressure sensor 280A can be of a wide variety of types, such as a resistive pressure sensor, an inductive pressure sensor, a capacitive pressure sensor, and the like. The capacitive pressure sensor may be a sensor comprising at least two parallel plates having an electrically conductive material. When a force acts on the pressure sensor 280A, the capacitance between the electrodes changes. The electronic device 200 determines the intensity of the pressure from the change in capacitance. When a touch operation is applied to the display screen 294, the electronic apparatus 200 detects the intensity of the touch operation according to the pressure sensor 280A. The electronic apparatus 200 may also calculate the touched position from the detection signal of the pressure sensor 280A. In some embodiments, the touch operations that are applied to the same touch position but different touch operation intensities may correspond to different operation instructions. For example: and when the touch operation with the touch operation intensity smaller than the first pressure threshold value acts on the short message application icon, executing an instruction for viewing the short message. And when the touch operation with the touch operation intensity larger than or equal to the first pressure threshold value acts on the short message application icon, executing an instruction of newly building the short message.
The gyro sensor 280B may be used to determine the motion pose of the electronic device 200. In some embodiments, the angular velocity of the electronic device 200 about three axes (i.e., x, y, and z axes) may be determined by the gyroscope sensor 280B. The gyro sensor 280B may be used for photographing anti-shake. For example, when the shutter is pressed, the gyro sensor 280B detects a shake angle of the electronic device 200, calculates a distance to be compensated for by the lens module according to the shake angle, and allows the lens to counteract the shake of the electronic device 200 through a reverse movement, thereby achieving anti-shake. The gyro sensor 280B may also be used for navigation, somatosensory gaming scenes.
The air pressure sensor 280C is used to measure air pressure. In some embodiments, electronic device 200 calculates altitude, aiding in positioning and navigation, from barometric pressure values measured by barometric pressure sensor 280C.
The magnetic sensor 280D includes a hall sensor. The electronic device 200 may detect the opening and closing of the flip holster using the magnetic sensor 280D. In some embodiments, when the electronic device 200 is a flip, the electronic device 200 may detect the opening and closing of the flip according to the magnetic sensor 280D. And then according to the opening and closing state of the leather sheath or the opening and closing state of the flip cover, the automatic unlocking of the flip cover is set.
The acceleration sensor 280E may detect the magnitude of acceleration of the electronic device 200 in various directions (typically three axes). The magnitude and direction of gravity can be detected when the electronic device 200 is stationary. The method can also be used for identifying the posture of the electronic equipment 200, and is applied to horizontal and vertical screen switching, pedometers and other applications.
A distance sensor 280F for measuring distance. The electronic device 200 may measure the distance by infrared or laser. In some embodiments, taking a picture of a scene, the electronic device 200 may utilize the distance sensor 280F to range for fast focus.
The proximity light sensor 280G may include, for example, a Light Emitting Diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic apparatus 200 emits infrared light to the outside through the light emitting diode. The electronic device 200 detects infrared reflected light from nearby objects using a photodiode. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 200. When insufficient reflected light is detected, the electronic device 200 may determine that there are no objects near the electronic device 200. The electronic device 200 can utilize the proximity sensor 280G to detect that the user holds the electronic device 200 close to the ear for talking, so as to automatically turn off the screen to save power. The proximity light sensor 280G may also be used in a holster mode, a pocket mode automatically unlocks and locks the screen.
The ambient light sensor 280L is used to sense the ambient light level. The electronic device 200 may adaptively adjust the brightness of the display screen 294 based on the perceived ambient light level. The ambient light sensor 280L may also be used to automatically adjust the white balance when taking a picture. The ambient light sensor 280L may also cooperate with the proximity light sensor 280G to detect whether the electronic device 200 is in a pocket to prevent inadvertent contact.
The fingerprint sensor 280H is used to collect a fingerprint. The electronic device 200 can utilize the collected fingerprint characteristics to unlock the fingerprint, access the application lock, photograph the fingerprint, answer an incoming call with the fingerprint, and the like.
The temperature sensor 280J is used to detect temperature. In some embodiments, the electronic device 200 implements a temperature processing strategy using the temperature detected by the temperature sensor 280J. For example, when the temperature reported by the temperature sensor 280J exceeds the threshold, the electronic device 200 performs a reduction in performance of a processor located near the temperature sensor 280J, so as to reduce power consumption and implement thermal protection. In other embodiments, the electronic device 200 heats the battery 242 when the temperature is below another threshold to avoid the low temperature causing the electronic device 200 to shut down abnormally. In other embodiments, when the temperature is below a further threshold, the electronic device 200 performs a boost on the output voltage of the battery 242 to avoid an abnormal shutdown due to low temperature.
The touch sensor 280K is also referred to as a "touch device". The touch sensor 280K may be disposed on the display screen 294, and the touch sensor 280K and the display screen 294 form a touch screen, which is also called a "touch screen". The touch sensor 280K is used to detect a touch operation applied thereto or nearby. The touch sensor can communicate the detected touch operation to the application processor to determine the touch event type. Visual output related to touch operations may be provided through the display screen 294. In other embodiments, the touch sensor 280K can be disposed on a surface of the electronic device 200 at a different location than the display screen 294.
The bone conduction sensor 280M may acquire a vibration signal. In some embodiments, the bone conduction sensor 280M may acquire a vibration signal of the human vocal part vibrating the bone mass. The bone conduction sensor 280M may also contact the pulse of the human body to receive the blood pressure pulsation signal. In some embodiments, bone conduction sensor 280M may also be disposed in a headset, integrated into a bone conduction headset.
The audio module 270 may analyze a voice signal based on the vibration signal of the bone mass vibrated by the sound part acquired by the bone conduction sensor 280M, so as to implement a voice function. The application processor can analyze heart rate information based on the blood pressure pulsation signal acquired by the bone conduction sensor 280M, so as to realize a heart rate detection function.
The keys 290 include a power-on key, a volume key, etc. The keys 290 may be mechanical keys. Or may be touch keys. The electronic apparatus 200 may receive a key input, and generate a key signal input related to user setting and function control of the electronic apparatus 200.
The motor 291 may generate a vibration cue. The motor 291 can be used for both incoming call vibration prompting and touch vibration feedback. For example, touch operations applied to different applications (e.g., photographing, audio playing, etc.) may correspond to different vibration feedback effects. The motor 291 may also respond to different vibration feedback effects for touch operations on different areas of the display 294. Different application scenes (such as time reminding, receiving information, alarm clock, game and the like) can also correspond to different vibration feedback effects. The touch vibration feedback effect may also support customization.
Indicator 292 may be an indicator light that may be used to indicate a state of charge, a change in charge, or may be used to indicate a message, missed call, notification, etc.
The SIM card interface 295 is used to connect a SIM card. The SIM card can be attached to and detached from the electronic apparatus 200 by being inserted into the SIM card interface 295 or being pulled out from the SIM card interface 295. The electronic device 200 may support 1 or N SIM card interfaces, N being a positive integer greater than 1. The SIM card interface 295 may support a Nano SIM card, a Micro SIM card, a SIM card, etc. Multiple cards can be inserted into the same SIM card interface 295 at the same time. The types of the plurality of cards may be the same or different. The SIM card interface 295 may also be compatible with different types of SIM cards. The SIM card interface 295 may also be compatible with external memory cards. The electronic device 200 interacts with the network through the SIM card to implement functions such as communication and data communication. In some embodiments, the electronic device 200 employs esims, namely: an embedded SIM card. The eSIM card can be embedded in the electronic device 200 and cannot be separated from the electronic device 200.
In addition, an operating system runs on the above components. Such as the hongmeng system, the iOS operating system, the Android open source operating system, the Windows operating system, etc. A running application may be installed on the operating system.
Fig. 3 is a block diagram of a software structure of an electronic device according to an embodiment of the present disclosure.
The layered architecture divides the software into several layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. In some embodiments of the present application, the software architecture of the electronic device includes at least three layers, which are an application layer, an application framework layer, and a hardware abstraction layer from top to bottom.
The application layer may include a series of application packages. These application packages may include camera, gallery, calendar, phone, map, navigation, WLAN, bluetooth, music, video, short message, etc. applications. In the embodiment of the application, the application program layer comprises the smart home APP.
The application framework layer provides an Application Programming Interface (API) and a programming framework for the application program of the application layer. The application framework layer includes a number of predefined functions. As shown in FIG. 3, the application framework layers may include a window manager, content provider, view system, phone manager, resource manager, notification manager, and the like. For example, in some embodiments of the present application, the application framework layer may further include a device management module, a scenario management module, a mall management module, and a screening module. The equipment management module is used for managing various equipment of the smart home, such as air conditioners, televisions, hall lamps and other equipment. The scene management module is used for managing various scenes of the smart home, for example, the equipment corresponding to the smart home APP is controlled according to the preset scene selected by the user, the convenient control of the smart home is realized, and the user experience is improved. The mall management module is used for butting the mall clouds in the business cloud, processing the mall business data returned by the mall clouds and displaying the processed data. The screening module is used for screening a target network request from a plurality of network requests when the token is abnormal.
The window manager is used for managing window programs. The window manager can obtain the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
The content provider is used to store and retrieve data and make it accessible to applications. The data may include business data of various business clouds, and the like.
The view system includes visual controls such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications. The display interface may be composed of one or more views. For example, the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
The phone manager is used to provide communication functions of the electronic device. Such as management of call status (including on, off, etc.).
The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and the like.
The notification manager enables the application to display notification information in the status bar, can be used to convey notification-type messages, can disappear automatically after a short dwell, and does not require user interaction. Such as a notification manager used to inform download completion, message alerts, etc. The notification manager may also be a notification that appears in the form of a chart or scroll bar text at the top status bar of the system, such as a notification of a background running application, or a notification that appears on the screen in the form of a dialog window. For example, prompting text information in the status bar, sounding a prompt tone, vibrating the electronic device, flashing an indicator light, etc.
The hardware abstraction layer is an interface layer between the kernel of the operating system of the electronic device 200 and the hardware circuit, and is intended to abstract the hardware. In some embodiments of the application, the hardware abstraction layer includes a network communication module. The network communication module may be used to detect whether the electronic device 200 is in a networked state. The networking state in this application means that the electronic device 200 can communicate with other electronic devices through the mobile communication module 250 or the wireless communication module 260, and the communication can occur on a closed local area network or can be performed through the internet.
For convenience of understanding, the following embodiments of the present application will specifically describe a token refresh method provided in the embodiments of the present application by taking the electronic device 200 having the structure shown in fig. 2 and fig. 3 as an example, with reference to the accompanying drawings and application scenarios.
Fig. 4 is a flowchart of a token refresh method provided in an embodiment of the present application, and fig. 5 is a module interaction diagram of the token refresh method provided in an embodiment of the present application.
As shown in fig. 4 and 5, the token refreshing method is applied to a mobile terminal, and the token refreshing method may include:
step S401, receiving returned information fed back by each service cloud based on a first network request, wherein the first network request comprises a plurality of different network requests;
step S402, if the error code of the token in each piece of return information meets a preset refreshing condition, determining a target network request corresponding to the first network request, and refreshing the token based on the target network request;
step S403, determining second network requests corresponding to the first network requests based on the refreshed token, and sending the second network requests to corresponding service clouds respectively.
In this embodiment, the mobile terminal simultaneously sends a plurality of first network requests to a plurality of service clouds through the smart home APP, each service cloud sends a token verification request to the account cloud according to a token in the received first network request, the account cloud verifies whether each token is abnormal, and when the token is abnormal, an error code corresponding to the token verification request is fed back to each service cloud respectively, and each service cloud feeds back information to the mobile terminal (the smart home APP) according to the error code. Referring to fig. 5, a mobile terminal sends a family list obtaining request and a family information obtaining request to a home cloud in a service cloud, sends a device list obtaining request and a product information obtaining request to a device cloud in the service cloud, and simultaneously sends a scene list inquiring request to a scene cloud in the service cloud, then the home cloud sends a token verifying request to an account cloud according to the received family list obtaining request and the family information obtaining request, the device cloud sends the token verifying request to the account cloud according to the received device list obtaining request and the product information obtaining request, the scene cloud sends the token verifying request to the account cloud according to the received scene list inquiring request, and the account cloud verifies tokens corresponding to each first network request (including the family list obtaining request, the family information obtaining request, the device list obtaining request, the product information obtaining request and the scene list inquiring request), if the token corresponding to the first network request is abnormal, feeding back the same error code to the home cloud, the device cloud and the scene cloud respectively, and feeding back return information corresponding to each first network request according to the error code by the home cloud, the device cloud and the scene cloud respectively, wherein the error code may be "1106" or "11205" or the like.
Then, the mobile terminal obtains information of a preset field in each piece of return information, obtains an error code corresponding to each piece of return information, and determines whether each error code meets a preset refresh condition, for example, determines whether each error code is consistent (the same), if each error code is consistent (the same), determines that an error code of a token in each piece of return information meets the preset refresh condition, the mobile terminal obtains a target network request corresponding to a first network request, specifically, if no other network request with the exception of the token exists before the current time, the mobile terminal screens the target network request at the first network request, and if another network request with the exception of the token exists before the current time, the mobile terminal takes the target network request corresponding to the other network request with the exception of the token as the target network request corresponding to the first network request, and refreshes the token based on the target network request.
And then, the mobile terminal determines a second network request corresponding to each first network request based on the refreshed token, specifically, if no other network request with the token abnormality exists before the current time, the mobile terminal replaces the token in each first network request with the refreshed token to obtain a second network request, if other network requests with the token abnormality exist before the current time, the mobile terminal replaces the token in each first network request and the token in other network requests with the refreshed token to obtain a second network request, and then sends each second network request to the corresponding service cloud, so as to realize the timely refreshing of the token.
In one possible implementation manner, step S402 includes:
and sending a token refreshing request to the account cloud based on the target network request, so that the account cloud executes token refreshing operation, and feeds back the refreshed token.
In this embodiment, when a target network request is obtained, a token refreshing request is sent to an account cloud based on the target network request, the account cloud executes a token refreshing operation to obtain a refreshed token when receiving the token refreshing request, and feeds back the refreshed token to the mobile terminal, and the mobile terminal refreshes the refreshed token to a preset storage region, such as an SP, of the APP, that is, the token stored in the preset storage region is replaced with the refreshed token. When determining a second network request corresponding to each first network request based on the refreshed token, first obtaining the refreshed token in a preset storage region, and then generating the second network request.
In another possible implementation manner, before step S401, the method further includes: and respectively sending each first network request to different service clouds, wherein each service cloud respectively sends a token verification request corresponding to the received first network request to an account cloud, if the account cloud verifies that the token corresponding to each token verification request is abnormal, the account cloud feeds back an error code to each service cloud, and each service cloud feeds back information to the mobile terminal based on the error code.
In another possible implementation manner, before step S402, the method further includes:
and acquiring error codes corresponding to preset fields in each piece of return information, and determining whether each error code is consistent, wherein when each error code is consistent, determining that the error code of token in the return information meets preset refreshing conditions.
The mobile terminal obtains information of a preset field in each piece of return information to obtain an error code corresponding to each piece of return information, the preset field can be an error code field in the return information, then whether each error code is consistent (same) or not is judged, if all the error codes are consistent (same), the fact that the error code of token in each piece of return information meets a preset refreshing condition is determined, the accuracy of judging that the error code meets the preset refreshing condition is improved, and then the token refreshing efficiency is improved.
In this embodiment, the mobile terminal sends a plurality of first network requests to a plurality of different service clouds through the smart home APP, each service cloud sends a token verification request to the account cloud according to the token in the received first network request, the account cloud verifies whether each token is abnormal, and feeds back an error code corresponding to the token verification request to each service cloud when the token is abnormal, each service cloud feeds back information to the mobile terminal (smart home APP) according to the error code, and then a plurality of network requests feed back the same error code when the token is realized, thereby improving the efficiency and timeliness of the smart home APP in token refreshing.
In the token refreshing method provided by this embodiment, return information fed back by each service cloud based on a first network request is received, and then if an error code of a token in each return information meets a preset refreshing condition, a target network request corresponding to the first network request is determined, and the token is refreshed based on the target network request; then, second network requests corresponding to the first network requests are determined based on the refreshed tokens, the second network requests are sent to the corresponding service clouds respectively, when the tokens of the network requests are abnormal, error codes meeting preset conditions are fed back, the tokens can be refreshed in time by the mobile terminal according to the error codes meeting the preset refreshing conditions, the situation that the smart home APP fails in refreshing pages or is abnormal in function is avoided, and user experience is improved.
Fig. 6 is a flowchart of a token refresh method according to another embodiment of the present application, and as shown in fig. 6, the token refresh method may include:
step S601, if the state of the screening module in the mobile terminal is a first state, determining the target network request based on each first network request, and adding each first network request to a target queue;
step S602, if the state of the screening module is the second state, determining the target network request based on the second state, and adding each first network request to the target queue.
The state of the screening module includes a first state and a second state, for example, the first state is true, the second state is false, when the state of the screening module is the first state, no thread (network request) refreshes the token, at this time, a target network request is determined based on each first network request, so that the token is refreshed by the target network request, and each first network request is added to the target queue, so that the network request in the target queue is awakened by the refreshed token, and the refreshed token replaces the token of the network request in the target queue to obtain a second network request.
If the state of the screening module is the second state, the network request for refreshing the token currently exists, and then the target network request is determined based on the second state, namely the network request for refreshing the token currently is determined to be the target network request, and each first network request is added into the target queue.
When determining second network requests corresponding to the first network requests based on the refreshed tokens, determining the second network requests based on the network requests in the target queue and the refreshed tokens, specifically, replacing the tokens of the network requests in the target queue with the refreshed tokens to obtain the second network requests, and then resending all network requests with abnormal tokens according to the refreshed tokens, without manual operation of a user, thereby improving user experience.
In one possible implementation manner, step S601 includes:
and respectively setting the state of the screening module based on each first network request, and determining the first network request which currently sets the state of the screening module to be the second state as a target network request.
In specific implementation, for each first network request, the states of the screening modules are set based on a CAS (compare and swap) algorithm, if a certain first network request sets the state of a screening module to a second state, the first network request is determined to be a target network request, and for network requests with failed states of other screening modules set to the second state, all the network requests are added to the target queue.
Referring to fig. 5, in fig. 5, a screening module screens a target network request from a family list obtaining request, a family information obtaining request, an equipment list obtaining request, a product information obtaining request, and a scene list inquiring request, when the status of the screening module is true, each network request sets the status of the screening module according to a CAS algorithm, determines that the network request that sets the status of the screening module as false is the target network request, improves the target network request to refresh token, and simultaneously binds all first network requests to an observer class (target queue), a mobile terminal sends a token refresh request to an account cloud based on the target network request, and the account cloud executes a token refresh operation when receiving the token refresh request to obtain the refreshed token, and feeds back the refreshed token to the mobile terminal. When the mobile terminal receives the refreshed token, all observers (network requests) in an observer class (target queue) are waken up, the token in the network requests is replaced according to the refreshed token to obtain a new network request, a new family list acquisition request and a new family information acquisition request are respectively sent to a family cloud in a service cloud, a new equipment acquisition request and a new product information acquisition request are sent to an equipment cloud in the service cloud, a new scene query list request is sent to a scene cloud in the service cloud, data of an intelligent household APP page are refreshed according to service data fed back by the family cloud, the equipment cloud and the scene cloud, and normal refreshing of the page is achieved.
Fig. 7 is a flowchart of a token refresh method according to another embodiment of the present application. As shown in fig. 7, the token refresh method may include:
step S701, if no network request in a waiting state exists currently, determining a target network request in a first network request, and setting network requests except the target network request in the first network request to be in the waiting state;
step S702, if there is a network request in a waiting state currently, determining the target network request based on the waiting state, and setting each first network request to be in a waiting state.
In the specific implementation, when a plurality of tokens of other network requests appear before the current time, the mobile terminal screens one network request to refresh the token, and sets the rest network requests to a waiting state, so that the mobile terminal firstly judges whether a network request in the waiting state exists at present, if no network request in the waiting state exists at present, the mobile terminal indicates that no network request exists to refresh the token at present, and determines a target network request in the first network request, wherein the target network request can be any one of the first network requests, or screens one network request as the target network request through the screening module, and sets the network request except the target network request in the first network request to be the waiting state, thereby ensuring that only one network request refreshes the token, and improving the token refreshing efficiency.
If the network request in the waiting state exists currently, it is indicated that the network request exists currently to refresh the token, the target network request is determined based on the waiting state, and each first network request is set to be in the waiting state.
When determining second network requests corresponding to the first network requests based on the refreshed tokens, determining the second network requests based on the network requests in the waiting state, the target network requests and the refreshed tokens, specifically, replacing the tokens of the network requests in the waiting state and the target network requests with the refreshed tokens to obtain the second network requests, and then resending all network requests with token abnormality according to the refreshed tokens, without manual operation of a user, thereby improving user experience.
Fig. 8 is a flowchart of a token refreshing method according to still another embodiment of the present application, where the token refreshing method is applied to an account cloud, and the token refreshing method may include:
step S801, receiving token verification requests corresponding to first network requests sent by each service cloud;
step S802, verifying the token corresponding to each first network request;
step S803, if the verification result of the verification operation is token exception, feeding back an error code to each service cloud, so that each service cloud feeds back information to the mobile terminal based on the error code.
In the specific implementation, the mobile terminal simultaneously sends a plurality of first network requests to a plurality of service clouds through the smart home APP, each service cloud sends a token verification request to an account cloud according to a token in the received first network request, the account cloud receives the token verification request corresponding to the first network request sent by each service cloud, and verifies the token corresponding to each first network request to verify whether each token is abnormal or not, wherein the token abnormality comprises the expiration, the failure or the invalidity of the token.
If the verification result of the verification operation is token abnormity, the account cloud feeds back error codes to each service cloud so that each service cloud feeds back return information to the mobile terminal (intelligent home APP) based on the error codes, and the mobile terminal performs token refreshing operation according to the error codes of the return information.
Referring to fig. 5, a mobile terminal sends a family list obtaining request and a family information obtaining request to a home cloud in a service cloud, sends a device list obtaining request and a product information obtaining request to a device cloud in the service cloud, and simultaneously sends a scene list inquiring request to a scene cloud in the service cloud, then the home cloud sends a token verifying request to an account cloud according to the received family list obtaining request and the family information obtaining request, the device cloud sends the token verifying request to the account cloud according to the received device list obtaining request and the product information obtaining request, the scene cloud sends the token verifying request to the account cloud according to the received scene list inquiring request, and the account cloud verifies tokens corresponding to each first network request (including the family list obtaining request, the family information obtaining request, the device list obtaining request, the product information obtaining request and the scene list inquiring request), if the token corresponding to the first network request is abnormal, feeding back the same error code to the home cloud, the device cloud and the scene cloud respectively, and feeding back return information corresponding to each first network request according to the error code by the home cloud, the device cloud and the scene cloud respectively, wherein the error code may be "1106" or "11205" or the like.
In one possible implementation manner, the token refresh method further includes:
and when a token refreshing request sent by the mobile terminal is received, executing token refreshing operation based on the token refreshing request, and feeding back the refreshed token to the mobile terminal.
In the specific implementation, the mobile terminal sends a token refreshing request to the account cloud based on a target network request, the account cloud executes token refreshing operation to obtain a refreshed token when receiving the token refreshing request, the refreshed token is fed back to the mobile terminal, the mobile terminal refreshes the refreshed token into a preset storage region, such as an SP (service provider), of the APP, and the token stored in the preset storage region is replaced by the refreshed token to achieve token refreshing of the APP of the smart home.
According to the token refreshing method, token verification requests corresponding to first network requests sent by service clouds are received; then, verifying the token corresponding to each first network request; if the verification result of the verification operation is token abnormity, feeding back error codes to each service cloud so that each service cloud feeds back return information to the mobile terminal based on the error codes, and feeding back the same error codes to each service cloud when the token is abnormal, so that the mobile terminal can timely perform token refreshing operation according to the same error codes, thereby avoiding the situation that the smart home APP fails in refreshing the page or has abnormal functions, and improving the user experience.
Fig. 9 shows a schematic structural diagram of a token refreshing apparatus provided in the present application. The token refresh apparatus 900 provided in the present application includes: a receiving module 901, a determining module 902 and a sending module 903;
in one possible implementation form of the method,
the receiving module is used for receiving return information fed back by each service cloud based on a first network request, wherein the first network request comprises a plurality of different network requests;
the determining module is configured to determine a target network request corresponding to the first network request if the error code of the token in each piece of the returned information meets a preset refresh condition, and refresh the token based on the target network request;
and the sending module is used for determining second network requests corresponding to the first network requests based on the refreshed tokens and respectively sending the second network requests to the corresponding service clouds.
It should be understood that the electronic device herein is embodied in the form of a functional module. The term "module" herein may be implemented in software and/or hardware, and is not particularly limited thereto. For example, a "module" may be a software program, a hardware circuit, or a combination of both that implements the functionality described above. The hardware circuitry may include an Application Specific Integrated Circuit (ASIC), an electronic circuit, a processor (e.g., a shared processor, a dedicated processor, or a group of processors) and memory that execute one or more software or firmware programs, a combinational logic circuit, and/or other suitable components that support the described functionality.
The present application further provides an electronic device, comprising: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs comprising instructions which, when executed by the electronic device, cause the electronic device to perform the token refresh method as set forth in the first aspect above or any one of the possible implementations of the first aspect.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, causes the processor to perform the token refresh method as described in the first aspect above or any one of the possible implementations of the first aspect.
The present application further provides a chip, where the chip includes a processor and a data interface, and the processor reads an instruction stored in a memory through the data interface, and executes the token refresh method according to any one of the first aspect or possible implementation manners of the first aspect.
Optionally, the chip may further include a memory, where instructions are stored in the memory, and the processor is configured to execute the instructions stored in the memory, and when the instructions are executed, the processor is configured to execute the token refresh method according to the first aspect or any one of possible implementation manners of the first aspect.
The memory may be a read-only memory (ROM), other types of static storage devices that may store static information and instructions, a Random Access Memory (RAM), or other types of dynamic storage devices that may store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, etc.
In the embodiment of the present application, "and/or" describes an association relationship of associated objects, and indicates that three relationships may exist, for example, a and/or B may indicate that a exists alone, a and B exist simultaneously, and B exists alone. Wherein A and B can be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" and similar expressions refer to any combination of these items, including any combination of singular or plural items. For example, at least one of a, b, and c may represent: a, b, c, a-b, a-c, b-c, or a-b-c, wherein a, b, c may be single or multiple.
Those of ordinary skill in the art will appreciate that the various elements and algorithm steps described in connection with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or combinations of electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, any function, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present disclosure, and all the changes or substitutions should be covered by the protection scope of the present application. The protection scope of the present application shall be subject to the protection scope of the claims.

Claims (15)

1. A token refreshing method is applied to a mobile terminal, and comprises the following steps:
receiving returned information fed back by each service cloud based on a first network request, wherein the first network request comprises a plurality of different network requests;
if the error code of the token in each piece of return information meets a preset refreshing condition, determining a target network request corresponding to the first network request, and refreshing the token based on the target network request;
and determining second network requests corresponding to the first network requests based on the refreshed tokens, and respectively sending the second network requests to corresponding service clouds.
2. The token refresh method of claim 1, wherein the step of determining the target network request to which the first network request corresponds comprises:
if the state of the screening module in the mobile terminal is a first state, determining the target network request based on each first network request, and adding each first network request to a target queue;
and if the state of the screening module is a second state, determining the target network requests based on the second state, and adding each first network request to a target queue.
3. The token refresh method of claim 2, wherein the step of determining a target network request based on respective first network requests comprises:
and respectively setting the state of the screening module based on each first network request, and determining the first network request which currently sets the state of the screening module to be the second state as a target network request.
4. The token refresh method of claim 3, wherein the step of setting the state of the screening module based on each first network request respectively comprises:
for each first network request, setting a state of the screening module based on a CAS algorithm.
5. The token refresh method of claim 2, wherein the step of determining a second network request corresponding to each first network request based on the refreshed token comprises:
determining the second network request based on the network requests in the target queue and the refreshed token.
6. The token refresh method of claim 1, wherein the step of determining the target network request to which the first network request corresponds comprises:
if the network request in the waiting state does not exist currently, determining a target network request in the first network request, and setting the network requests except the target network request in the first network request to be in the waiting state;
and if the network requests in the waiting state exist currently, determining the target network requests based on the waiting state, and setting each first network request to be in the waiting state.
7. The token refresh method of claim 6, wherein the step of determining a second network request corresponding to each first network request based on the refreshed token comprises:
determining the second network request based on the network request in the waiting state, the target network request and the refreshed token.
8. The token refreshing method according to claim 1, wherein before the step of determining the target network request corresponding to the first network request if the error codes of the tokens in the respective return messages are consistent, the method further comprises:
and acquiring error codes corresponding to preset fields in each piece of return information, and determining whether each error code is consistent, wherein when each error code is consistent, determining that the error code of token in the return information meets preset refreshing conditions.
9. The token refresh method of claim 1, wherein the step of refreshing the token based on the target network request comprises:
and sending a token refreshing request to the account cloud based on the target network request, so that the account cloud executes token refreshing operation, and feeds back the refreshed token.
10. A token refresh method according to any one of claims 1 to 9, wherein before the step of receiving the returned information fed back by each service cloud based on the first network request, the method further comprises:
and respectively sending each first network request to different service clouds, wherein each service cloud respectively sends a token verification request corresponding to the received first network request to an account cloud, if the account cloud verifies that the token corresponding to each token verification request is abnormal, the account cloud feeds back an error code to each service cloud, and each service cloud feeds back information to the mobile terminal based on the error code.
11. A token refreshing method is applied to an account cloud, and comprises the following steps:
receiving token verification requests corresponding to the first network requests sent by the service clouds;
verifying the token corresponding to each first network request;
and if the verification result of the verification operation is token abnormity, feeding back an error code to each service cloud so that each service cloud feeds back information to the mobile terminal based on the error code.
12. The token refresh method of claim 11, the method further comprising:
and when a token refreshing request sent by the mobile terminal is received, executing token refreshing operation based on the token refreshing request, and feeding back the refreshed token to the mobile terminal.
13. A token refresh apparatus, comprising: the device comprises a receiving module, a determining module and a sending module;
the receiving module is used for receiving return information fed back by each service cloud based on a first network request, wherein the first network request comprises a plurality of different network requests;
the determining module is configured to determine a target network request corresponding to the first network request if the error code of the token in each piece of the returned information meets a preset refresh condition, and refresh the token based on the target network request;
and the sending module is used for determining second network requests corresponding to the first network requests based on the refreshed tokens and respectively sending the second network requests to the corresponding service clouds.
14. An electronic device, comprising: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs comprising instructions which, when executed by the electronic device, cause the electronic device to perform the token refresh method of any one of claims 1-10 or 11-12.
15. A computer-readable storage medium, in which a computer program is stored which, when executed by a processor, causes the processor to carry out the token refresh method of any one of claims 1 to 10 or 11-12.
CN202111656025.3A 2021-12-31 2021-12-31 token refreshing method and device, electronic equipment and readable storage medium Active CN114006698B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111656025.3A CN114006698B (en) 2021-12-31 2021-12-31 token refreshing method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111656025.3A CN114006698B (en) 2021-12-31 2021-12-31 token refreshing method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN114006698A CN114006698A (en) 2022-02-01
CN114006698B true CN114006698B (en) 2022-03-08

Family

ID=79932401

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111656025.3A Active CN114006698B (en) 2021-12-31 2021-12-31 token refreshing method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114006698B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114513313B (en) * 2022-04-20 2022-09-27 云账户技术(天津)有限公司 Token-based authentication method and device, electronic equipment and readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104348620A (en) * 2013-07-31 2015-02-11 中兴通讯股份有限公司 Method for authenticating intelligent household terminals, and corresponding devices
CN110266703A (en) * 2019-06-25 2019-09-20 广州小鹏汽车科技有限公司 Token method for refreshing, device, storage medium and controlling terminal
CN110430202A (en) * 2019-08-09 2019-11-08 百度在线网络技术(北京)有限公司 Authentication method and device
CN112671539A (en) * 2020-11-23 2021-04-16 苏州浪潮智能科技有限公司 Method, system, medium and device for processing overdue renewal of multi-request token

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150215277A1 (en) * 2014-01-28 2015-07-30 Electronics And Telecommunications Research Institute Network address translation apparatus with cookie proxy function and method for nat supporting cookie proxy function
KR102133755B1 (en) * 2014-02-19 2020-07-15 삼성전자주식회사 A method and apparatus for managing access information for registration of device in a smart home service
US11363007B2 (en) * 2020-03-27 2022-06-14 Comcast Cable Communications, Llc Methods and systems for accessing a resource

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104348620A (en) * 2013-07-31 2015-02-11 中兴通讯股份有限公司 Method for authenticating intelligent household terminals, and corresponding devices
CN110266703A (en) * 2019-06-25 2019-09-20 广州小鹏汽车科技有限公司 Token method for refreshing, device, storage medium and controlling terminal
CN110430202A (en) * 2019-08-09 2019-11-08 百度在线网络技术(北京)有限公司 Authentication method and device
CN112671539A (en) * 2020-11-23 2021-04-16 苏州浪潮智能科技有限公司 Method, system, medium and device for processing overdue renewal of multi-request token

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
面向云服务的Android金融支付终端软件设计与实现;黄学勤;《中国优秀硕士学位论文全文数据库 信息科技辑》;20170315(第03期);第I139-375页 *

Also Published As

Publication number Publication date
CN114006698A (en) 2022-02-01

Similar Documents

Publication Publication Date Title
WO2020259452A1 (en) Full-screen display method for mobile terminal, and apparatus
WO2021017889A1 (en) Display method of video call appliced to electronic device and related apparatus
WO2021213164A1 (en) Application interface interaction method, electronic device, and computer readable storage medium
WO2020062159A1 (en) Wireless charging method and electronic device
WO2020238728A1 (en) Login method for intelligent terminal, and electronic device
WO2021036898A1 (en) Application activation method for apparatus having foldable screen, and related device
WO2021052204A1 (en) Address book-based device discovery method, audio and video communication method, and electronic device
WO2020000448A1 (en) Flexible screen display method and terminal
CN113496426A (en) Service recommendation method, electronic device and system
WO2020150917A1 (en) Application permission management method and electronic device
CN114125130B (en) Method for controlling communication service state, terminal device and readable storage medium
US20230351048A1 (en) Application Permission Management Method and Apparatus, and Electronic Device
WO2022160991A1 (en) Permission control method and electronic device
CN114090102B (en) Method, device, electronic equipment and medium for starting application program
CN113641271A (en) Application window management method, terminal device and computer readable storage medium
CN114528581A (en) Safety display method and electronic equipment
CN114006698B (en) token refreshing method and device, electronic equipment and readable storage medium
CN113590346B (en) Method and electronic equipment for processing service request
CN117724863A (en) Target signal processing method and electronic equipment
CN116828100A (en) Bluetooth audio playing method, electronic equipment and storage medium
CN115701018A (en) Method for safely calling service, method and device for safely registering service
CN111339513A (en) Data sharing method and device
CN113905334B (en) Information sharing method and device
CN115529379B (en) Method for preventing Bluetooth audio Track jitter, electronic equipment and storage medium
WO2023197999A1 (en) Display method and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230908

Address after: 200120 building C, No.888, Huanhu West 2nd Road, Pudong New Area, Shanghai

Patentee after: Shanghai Glory Smart Technology Development Co.,Ltd.

Address before: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518000

Patentee before: Honor Device Co.,Ltd.