Network coexistence control method and device based on Android system

文档序号:142946 发布日期:2021-10-22 浏览:32次 中文

阅读说明:本技术 基于Android系统的网络共存的控制方法及装置 (Network coexistence control method and device based on Android system ) 是由 王安兴 程玉 胡锐生 于 2021-07-16 设计创作,主要内容包括:本发明公开了一种基于Android系统的网络共存的控制方法及装置,其中方法包括以下步骤:配置网络的优先级,包括第一优先级、第二优先级和第三优先级,前两个优先级支持生成默认网关,第三优先级仅支持内网访问功能;开启网络共存的功能,系统根据路由表配置的优先级顺序重新刷新网络,并且将配置状态保存本地文件系统中,下次开机后自动再次完成网络优先级顺序的调整;设备接入和断开功能,在设备上接入两种以上的网络,包括连接一个网络和断开一个网络,系统会自动判断连接或断开的网络的优先级,重新调整路由表。(The invention discloses a method and a device for controlling network coexistence based on an Android system, wherein the method comprises the following steps: configuring network priorities, wherein the network priorities comprise a first priority, a second priority and a third priority, the first two priorities support generation of a default gateway, and the third priority only supports an intranet access function; starting a network coexistence function, refreshing the network again by the system according to the priority sequence configured by the routing table, saving the configuration state in the local file system, and automatically finishing the adjustment of the network priority sequence again after starting the system next time; the device access and disconnection function is characterized in that more than two networks are accessed to the device, including one network is connected and one network is disconnected, and the system can automatically judge the priority of the connected or disconnected network and readjust the routing table.)

1. A network coexistence control method based on an Android system is characterized by comprising the following steps:

configuring network priorities, wherein the network priorities comprise a first priority, a second priority and a third priority, the first two priorities support generation of a default gateway, and the third priority only supports an intranet access function;

starting a network coexistence function, refreshing the network again by the system according to the priority sequence configured by the routing table, saving the configuration state in the local file system, and automatically finishing the adjustment of the network priority sequence again after starting the system next time;

the device access and disconnection function is characterized in that more than two networks are accessed to the device, including one network is connected and one network is disconnected, and the system can automatically judge the priority of the connected or disconnected network and readjust the routing table.

2. The Android system-based network coexistence control method according to claim 1, wherein connecting a network specifically includes: firstly, judging whether the network is in a first priority or a second priority, if not, generating a default route, if the accessed network is in the first priority, judging whether the network of the second priority already exists in the system at the moment, if so, deleting the network default route of the second priority first, and finally generating all route information of the first priority; if the second priority does not exist, directly generating all routing information of the first priority; if the accessed network is the second priority network, whether the network with the first priority already exists in the system is judged, if so, the second priority network at the moment is not allowed to generate default routing information, and only the local routing is allowed to be generated.

3. The Android system-based network coexistence control method according to claim 1, wherein disconnecting a network specifically includes: firstly, judging whether the network is the third priority, if so, clearing the routing information of the third priority network; if the first priority network is not the second priority network, if the first priority network is the first priority network, the first priority network is disconnected, whether the second priority network in the system exists at the moment needs to be judged, and if the second priority network exists, the default gateway of the second priority network is added after all the routing information of the first priority network is cleared.

4. A control device for network coexistence based on an Android system is characterized by comprising:

a priority unit of a configuration network comprises a first priority, a second priority and a third priority, the first two priorities support generation of a default gateway, and the third priority only supports an intranet access function;

starting the functional units with coexisting networks, refreshing the networks again by the system according to the priority sequence configured by the routing table, saving the configuration state in the local file system, and automatically finishing the adjustment of the network priority sequence again after starting the system next time;

the equipment is connected with and disconnected from the network unit, more than two networks are connected with the equipment, including one network is connected and one network is disconnected, and the system can automatically judge the priority of the connected or disconnected network and readjust the routing table.

5. The Android-system-based network coexistence control device according to claim 4, wherein connecting a network specifically is: firstly, judging whether the network is in a first priority or a second priority, if not, generating a default route, if the accessed network is in the first priority, judging whether the network of the second priority already exists in the system at the moment, if so, deleting the network default route of the second priority first, and finally generating all route information of the first priority; if the second priority does not exist, directly generating all routing information of the first priority; if the accessed network is the second priority network, whether the network with the first priority already exists in the system is judged, if so, the second priority network at the moment is not allowed to generate default routing information, and only the local routing is allowed to be generated.

6. The Android-system-based network coexistence control device according to claim 4, wherein disconnecting a network specifically includes: firstly, judging whether the network is the third priority, if so, clearing the routing information of the third priority network; if the first priority network is not the second priority network, if the first priority network is the first priority network, the first priority network is disconnected, whether the second priority network in the system exists at the moment needs to be judged, and if the second priority network exists, the default gateway of the second priority network is added after all the routing information of the first priority network is cleared.

Technical Field

The invention belongs to the technical field of Android system application, and particularly relates to a network coexistence control method and device based on an Android system.

Background

With the high-speed development of science and technology, a large number of different types of communication networks emerge, the types are various and are characterized, but in an Android system, only one network port can be used at the same time under the default condition, and various networks cannot be developed in a coexistence manner. However, a large number of practical projects require two or more network ports to be connected simultaneously, two or more networks to coexist simultaneously, and coexistence of multiple networks is a trend.

Disclosure of Invention

In view of the above technical problems, the present invention is directed to providing a method and an apparatus for controlling network coexistence based on an Android system.

In order to solve the technical problems, the invention adopts the following technical scheme:

one aspect of the embodiments of the present invention provides a method for controlling network coexistence based on an Android system, including the following steps:

configuring network priorities, wherein the network priorities comprise a first priority, a second priority and a third priority, the first two priorities support generation of a default gateway, and the third priority only supports an intranet access function;

starting a network coexistence function, refreshing the network again by the system according to the priority sequence configured by the routing table, saving the configuration state in the local file system, and automatically finishing the adjustment of the network priority sequence again after starting the system next time;

the device access and disconnection function is characterized in that more than two networks are accessed to the device, including one network is connected and one network is disconnected, and the system can automatically judge the priority of the connected or disconnected network and readjust the routing table.

Preferably, connecting a network specifically is: firstly, judging whether the network is in a first priority or a second priority, if not, generating a default route, if the accessed network is in the first priority, judging whether the network of the second priority already exists in the system at the moment, if so, deleting the network default route of the second priority first, and finally generating all route information of the first priority; if the second priority does not exist, directly generating all routing information of the first priority; if the access is a second priority network, judging whether the system has the first priority network or not, if so, not allowing the second priority network to generate default routing information, and only allowing the local routing to be generated;

preferably, disconnecting a network specifically is: firstly, judging whether the network is the third priority, if so, clearing the routing information of the third priority network; if the first priority network is not the second priority network, if the first priority network is the first priority network, the first priority network is disconnected, whether the second priority network in the system exists at the moment needs to be judged, and if the second priority network exists, the default gateway of the second priority network is added after all the routing information of the first priority network is cleared.

Another aspect of the embodiments of the present invention provides a control device for network coexistence based on an Android system, including:

a priority unit of a configuration network comprises a first priority, a second priority and a third priority, the first two priorities support generation of a default gateway, and the third priority only supports an intranet access function;

starting the functional units with coexisting networks, refreshing the networks again by the system according to the priority sequence configured by the routing table, saving the configuration state in the local file system, and automatically finishing the adjustment of the network priority sequence again after starting the system next time;

the equipment is connected with and disconnected from the network unit, more than two networks are connected with the equipment, including one network is connected and one network is disconnected, and the system can automatically judge the priority of the connected or disconnected network and readjust the routing table.

Preferably, connecting a network specifically is: firstly, judging whether the network is in a first priority or a second priority, if not, generating a default route, if the accessed network is in the first priority, judging whether the network of the second priority already exists in the system at the moment, if so, deleting the network default route of the second priority first, and finally generating all route information of the first priority; if the second priority does not exist, directly generating all routing information of the first priority; if the access is a second priority network, judging whether the system has the first priority network or not, if so, not allowing the second priority network to generate default routing information, and only allowing the local routing to be generated;

preferably, disconnecting a network specifically is: firstly, judging whether the network is the third priority, if so, clearing the routing information of the third priority network; if the first priority network is not the second priority network, if the first priority network is the first priority network, the first priority network is disconnected, whether the second priority network in the system exists at the moment needs to be judged, and if the second priority network exists, the default gateway of the second priority network is added after all the routing information of the first priority network is cleared.

The invention has the following beneficial effects:

(1) by the technical scheme of the embodiment of the invention, the coexistence of the networks can ensure that one device is simultaneously connected with 2 to 3 networks;

(2) by the technical scheme of the embodiment of the invention, the interface of the network priority can be adjusted, and the network sequence of WIFI, Ethernet and 4G can be configured at will.

Drawings

Fig. 1 is a schematic structural diagram of a network coexistence control device based on an Android system according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Method embodiment

The invention discloses a network coexistence control method based on an Android system, which comprises the following steps:

configuring network priorities, wherein the network priorities comprise a first priority, a second priority and a third priority, the first two priorities support generation of a default gateway, and the third priority only supports an intranet access function; the 3 priorities correspond to the 3 fixed scores, the higher the score is, the higher the priority is, the highest score is the first priority, the highest score is used as an external network access interface, and similarly, the lowest priority is the third priority, and only the access to the internal network is supported. In the AgentInfo of each network, the getScore () is returned to the corresponding score, so that the score of each network can be configured.

Accessing more than two networks on the equipment, including connecting one network and disconnecting one network;

and starting a network coexistence function, refreshing the network by the system according to the priority sequence configured by the routing table, storing the configuration state in the local file system, and automatically finishing the adjustment of the network priority sequence again after starting the system next time. In a specific application example, a function of network coexistence is started, the system readjusts a routing table of the system according to a configured priority order to generate a default gateway route of a first priority, only host routes are generated according to a second priority and a third priority, the routing table of each network is completed in a ConnectivityService update route method, and the corresponding routing table can be adjusted according to different network types in the method. And the configuration state is stored in a flash memory, the sequence is automatically read after the computer is started next time, and the adjustment of the network priority sequence is completed again.

In a specific application example, the embodiment of the present invention has the following basic conventions: (1) not allowing the third priority network to generate a default gateway (or default route); (2) when there are the first two priority networks present, there is and only one default gateway allowed.

In a specific application example, connecting a network specifically includes: firstly, judging whether the network is in a first priority or a second priority, if not, generating a default route, if the accessed network is in the first priority, judging whether the network of the second priority already exists in the system at the moment, if so, deleting the network default route of the second priority first, and finally generating all route information of the first priority; if the second priority does not exist, directly generating all routing information of the first priority; if the accessed network is the second priority network, whether the network with the first priority already exists in the system is judged, if so, the second priority network at the moment is not allowed to generate default routing information, and only the local routing is allowed to be generated. The specific operation can be as follows: and judging which network device the currently operated network routing table belongs to according to the netId in the updateRoutes, if the currently operated network routing table belongs to the first-priority network device, generating a default gateway, and if the currently operated network routing table does not belong to the first-priority network device, not generating the default gateway.

In a specific application example, disconnecting a network specifically includes: firstly, judging whether the network is the third priority, if so, clearing the routing information of the third priority network; if the first priority network is not the second priority network, if the first priority network is the first priority network, the first priority network is disconnected, whether the second priority network in the system exists at the moment needs to be judged, and if the second priority network exists, the default gateway of the second priority network is added after all the routing information of the first priority network is cleared. The specific operation can be as follows: when a network interface sends state change, the system calls a rematch network and requests method, when a first priority network is disconnected and a second priority network is accessed, the system needs a default gateway route at the moment, and a default gateway route is added to the second priority network in the rematch network and requests method.

The interface for adjusting the network priority is provided by the embodiment of the invention, and the network sequence of WIFI, Ethernet and 4G can be configured at will. After the opened interface is called, the changeNetworkpriority method is called, the network priority order is readjusted, and the system can refresh the network immediately to enable the three networks to meet the configuration. Meanwhile, the configuration can be saved in a local file system, and the network reconfiguration can be realized after the system is restarted.

Device embodiment

Corresponding to the method embodiment, referring to fig. 1, a schematic structural diagram of a control device for network coexistence based on an Android system in the embodiment of the present invention is shown, including:

a priority unit of a configuration network comprises a first priority, a second priority and a third priority, the first two priorities support generation of a default gateway, and the third priority only supports an intranet access function;

starting the functional units with coexisting networks, refreshing the networks again by the system according to the priority sequence configured by the routing table, saving the configuration state in the local file system, and automatically finishing the adjustment of the network priority sequence again after starting the system next time;

the equipment is connected with and disconnected from the network unit, more than two networks are connected with the equipment, including one network is connected and one network is disconnected, and the system can automatically judge the priority of the connected or disconnected network and readjust the routing table.

In a specific application example, connecting a network specifically includes: firstly, judging whether the network is in a first priority or a second priority, if not, generating a default route, if the accessed network is in the first priority, judging whether the network of the second priority already exists in the system at the moment, if so, deleting the network default route of the second priority first, and finally generating all route information of the first priority; if the second priority does not exist, directly generating all routing information of the first priority; if the access is a second priority network, judging whether the system has the first priority network or not, if so, not allowing the second priority network to generate default routing information, and only allowing the local routing to be generated;

in a specific application example, disconnecting a network specifically includes: firstly, judging whether the network is the third priority, if so, clearing the routing information of the third priority network; if the first priority network is not the second priority network, if the first priority network is the first priority network, the first priority network is disconnected, whether the second priority network in the system exists at the moment needs to be judged, and if the second priority network exists, the default gateway of the second priority network is added after all the routing information of the first priority network is cleared.

The technical details not described in the device embodiments are the same as those in the method embodiments and are not described herein again.

It is to be understood that the exemplary embodiments described herein are illustrative and not restrictive. Although one or more embodiments of the present invention have been described with reference to the accompanying drawings, it will be understood by those of ordinary skill in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present invention as defined by the following claims.

8页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于Android系统的以太网共享方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!