Method, device, equipment and medium for setting plug-ins in Android system
By changing and synchronizing the effective state of the plug-in object in the Android system, data loss and function abnormalities when plug-in is disabled are solved, and a safe plug-in status setting is achieved.
Patent Information
- Application Number
- CN202010595604.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-23
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2040-06-23
AI Technical Summary
When disabling plugins in Android systems, the prior art can easily lead to the risk of data loss and abnormal business functions by deleting plug-in information.
By changing the effective status field of the plug-in object and synchronizing the changed information to the database, the plug-in enable and disable status settings are achieved.
On the basis of ensuring complete data and normal business functions, security settings for plug-in status are implemented to avoid data loss and functional abnormalities.
Smart Images

Figure CN113900724B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular, to a method, device, equipment and medium for setting plugins in an Android system. Background Art
[0002] In traditional solutions, when there is a need to disable a certain plugin in the Android system, it is usually necessary to delete all the information of the plugin to be disabled. The disadvantages of implementing plugin disabling by deleting plugin information at least include: since the plugin information is directly deleted, useful data obtained by previously calling the plugin is likely to be deleted at the same time, and there is a risk of data loss and inability to retrieve it; in addition, part of the program code of the business function that previously called the plugin is also likely to be accidentally deleted, and there is a risk of abnormal business functions. Summary of the Invention
[0003] In view of this, the embodiments of the present invention provide a method, device, equipment and medium for setting plugins in an Android system, which can implement the setting of the plugin state on the basis of ensuring data integrity and normal business functions.
[0004] In a first aspect, the embodiments of the present invention provide a method for setting a plugin in an Android system, the method comprising:
[0005] Responding to a plugin state setting instruction, obtaining a state setting implementation class from the spring container, and calling a target state setting function in the state setting implementation class;
[0006] Constructing a plugin object according to an object construction method in the target state setting function, setting a plugin identifier of the plugin object according to an identifier setting method in the target state setting function, and setting an effective state of the plugin object according to a state setting method in the target state setting function;
[0007] Updating a state update time of the plugin object according to a time update method in the target state setting function, updating operator information of the plugin object according to an operator update method in the target state setting function, and updating the plugin object to a preset database according to an update plugin function in the state setting implementation class.
[0008] Optionally, the constructing a plugin object according to an object construction method in the target state setting function and the setting a plugin identifier of the plugin object according to an identifier setting method in the target state setting function includes:
[0009] Construct a plugin object according to the method Plugin plugin = new Plugin() in the target status setting function, and set the plugin identifier of the plugin object according to the method plugin.setId(pluginId) in the target status setting function;
[0010] Among them, new is the construction statement of the plugin object; setId is the plugin identifier setting statement of the plugin object; plugin is the name of the plugin object; pluginId is the plugin identifier of the plugin object.
[0011] Optionally, the target status setting function includes a disable plugin function and an enable plugin function;
[0012] Correspondingly, when the target status function is the disable plugin function, setting the effective status of the plugin object according to the status setting method in the target status setting function includes:
[0013] Set the plugin object to the disabled state according to the following method in the disable plugin function:
[0014] plugin.setDisabled(PluginDisabledEnum.DISABLED_TRUE.getId());
[0015] Correspondingly, when the target status function is the enable plugin function, setting the effective status of the plugin object according to the status setting method in the target status setting function includes:
[0016] Set the plugin object to the enabled state according to the following method in the enable plugin function:
[0017] plugin2update.setDisabled(PluginDisabledEnum.DISABLED_FALSE.getId());
[0018] Among them, setDisabled is the setting statement of the effective status of the plugin object; getId is the statement to obtain the plugin object corresponding to the plugin identifier; plugin and plugin2update are the names of the plugin objects in the disable plugin function and the enable plugin function respectively; PluginDisabledEnum is the enumeration object of the plugin effective field, and the enumeration object includes the disabled state DISABLED_TRUE and the enabled state DISABLED_FALSE.
[0019] Optionally, updating the status update time of the plugin object according to the time update method in the target status setting function, updating the operator information of the plugin object according to the operator update method in the target status setting function, and updating the plugin object to a preset database according to the update plugin function in the status setting implementation class, includes:
[0020] Updating the status update time of the plugin object according to the following method in the target status setting function: plugin.setLastUpdate(System.currentTimeMillis() / 1000);
[0021] Updating the operator information of the plugin object according to the plugin.setOperator(operator) method in the target status setting function;
[0022] Updating the plugin object to a preset database according to the updatePlugin function in the status setting implementation class;
[0023] Wherein, setLastUpdate is a statement for setting the status update time of the plugin object; System.currentTimeMillis is a statement for obtaining the current system time; setOperator is a statement for setting the operator information of the plugin object; plugin is the name of the plugin object; operator is the operator information of the plugin object.
[0024] Optionally, updating the plugin object to a preset database according to the updatePlugin function in the status setting implementation class, includes:
[0025] Searching for plugin list information that matches the host application identifier and package name of the input parameter according to the following method in the updatePlugin function:
[0026] List <plugin>plugins = pluginMapper.selectByAppIdAndPackageName(plugin.getAppId(), plugin.getPluginName());
[0027] Filter the plugin objects in the plugin list information according to the following method in the updatePlugin function:
[0028] Optional <plugin>first = plugins.stream().filter(x -> x.getId().equals(plugin.getId())).findFirst();
[0029] Judge whether the filtered plugin object exists according to the following method in the updatePlugin function:
[0030] if (!first.isPresent()) { throw new VenusException(500, String.format());}
[0031] If so, update the plugin object to the preset database according to the following method in the updatePlugin function:
[0032] pluginMapper.updateByPrimaryKeySelective(plugin);
[0033] Among them, List is of list type; plugins is the plugin list information; pluginMapper is the preset database of plugins; selectByAppIdAndPackageName is the query plugin statement, and getAppId in the query plugin statement is the statement to obtain the host application identifier of the input parameter; getPluginName is the statement to obtain the package name of the input parameter;
[0034] Among them, Optional is of optional type; first is the filtered plugin object; stream is the statement to convert the plugin list information into a stream object; filter is the filtering statement for the plugin object, and x -> x.getId().equals(plugin.getId()) in the filtering statement is the filtering condition for whether the plugin identifier is the same as the plugin identifier of the newly created plugin object; findFirst is to obtain the first plugin object that meets the filtering condition;
[0035] Among them, isPresen is the statement to judge whether the filtered plugin object exists; String.format is the statement to notify the existence of the plugin object;.updateByPrimaryKeySelective is the statement to update the existing plugin object to the preset database.
[0036] Optionally, the List <plugin>The method of selectByAppIdAndPackageName in the plugins method includes:
[0037] Define the select tag according to the following method:
[0038] <select id="selectbyappidandpackagename"resultmap="baseresultmap">< / select> ;
[0039] Obtain the plugin list information that matches the host application identifier and package name of the input parameter according to the following method:
[0040] select <include refid="Base_Column_List" / > from plugin where app_id = #{0} and package_name = #{1};
[0041] Among them, id = "selectByAppIdAndPackageName" in the select tag is used to point to the statement for finding the host application identifier and package name; resultMap = "BaseResultMap" is used to indicate that the type of the filtered result set is BaseResultMap; Base_Column_List represents the field information of the plugin object to be searched; where app_id = #{0} and package_name = #{1} are the query conditions, and #{0} represents the first input parameter, and #{1} represents the second input parameter.
[0042] Optionally, before the response to the plugin status setting instruction, it further includes:
[0043] Define the data structure of the plugin class including the effective status field, and define the interface layer including the disable plugin function, enable plugin function, and update plugin function;
[0044] Define the status setting implementation class, inherit the interface layer by the status setting implementation class, override the functions in the interface layer, and inject it into the spring container through the @Service annotation..
[0045] In a second aspect, an embodiment of the present invention provides a device for setting plugins in an Android system, and the device includes:
[0046] An instruction receiving module, configured to obtain a status setting implementation class from the spring container in response to a plugin status setting instruction, and call a target status setting function in the status setting implementation class;
[0047] A status setting module, configured to construct a plugin object according to the object construction method in the target status setting function, set the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, and set the effective status of the plugin object according to the status setting method in the target status setting function;
[0048] A plugin update module, configured to update the status update time of the plugin object according to the time update method in the target status setting function, update the operator information of the plugin object according to the operator update method in the target status setting function, and update the plugin object to a preset database according to the plugin update function in the status setting implementation class.
[0049] In a third aspect, an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the setting method of the plugin in the Android system as described in the first aspect above is implemented.
[0050] In a fourth aspect, an embodiment of the present invention provides a storage medium containing computer-executable instructions. When the computer-executable instructions are executed by a computer processor, the setting method of the plugin in the Android system as described in the first aspect above is implemented.
[0051] A setting method, device, device, and medium for a plugin in an Android system provided by an embodiment of the present invention. The setting method includes: in response to a plugin status setting instruction, obtaining a status setting implementation class from a spring container and calling a target status setting function in the status setting implementation class; constructing a plugin object according to the object construction method in the target status setting function, setting the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, and setting the effective status of the plugin object according to the status setting method in the target status setting function; updating the status update time of the plugin object according to the time update method in the target status setting function, updating the operator information of the plugin object according to the operator update method in the target status setting function, and updating the plugin object to a preset database according to the plugin update function in the status setting implementation class.
[0052] Compared with the traditional method of disabling plugins by deleting plugin information, by changing the effective status field in the plugin object and synchronizing the changed plugin information to the corresponding plugin object in the database, it is possible to set the status such as enabling and disabling of the plugin object on the basis of ensuring data integrity and normal business functions. Description of the Drawings
[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the description of the embodiments of the present invention. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on the content of the embodiments of the present invention and these drawings.
[0054] Figure 1 It is a schematic flowchart of a method for setting a plug-in in an Android system provided in Embodiment 1 of the present invention;
[0055] Figure 2 It is a schematic structural diagram of a device for setting a plug-in in an Android system provided in Embodiment 2 of the present invention;
[0056] Figure 3 It is a schematic structural diagram of an electronic device provided in Embodiment 3 of the present invention. Specific embodiments
[0057] To make the technical problems solved by the present invention, the technical solutions adopted, and the achieved technical effects clearer, the following will further describe in detail the technical solutions of the embodiments of the present invention with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present invention. In the following embodiments, optional features and examples are provided in each embodiment, and the features recorded in the embodiments can be combined to form multiple optional solutions. Each numbered embodiment should not be regarded as only one technical solution.
[0058] Embodiment 1
[0059] Figure 1 It is a schematic flowchart of a method for setting a plug-in in an Android system provided in Embodiment 1 of the present invention. The method for setting a plug-in in an Android system disclosed in this embodiment is applicable to the situation of setting the states such as enabling, disabling, and updating of a plug-in in an Android system. The method for setting a plug-in in an Android system disclosed in this embodiment can be executed by an electronic device, and can be specifically implemented by software and / or hardware in the electronic device.
[0060] See Figure 1 As shown, the method for setting a plug-in in this Android system includes the following steps:
[0061] S110. In response to a plug-in state setting instruction, obtain a state setting implementation class from the spring container, and call a target state setting function in the state setting implementation class.
[0062] In an embodiment of the present invention, an electronic device configured with a setting device for plugins in the Android system can receive a plugin status setting instruction through a user interface. The plugin status setting instruction may include, but is not limited to, the identifier, name of the plugin to be set, and the desired setting status. Correspondingly, a plugin object can be constructed according to the identifier and name of the plugin to be set, and a target status setting function can be determined from the status setting implementation class as a disable plugin function or an enable plugin function according to the desired setting status.
[0063] Optionally, before responding to the plugin status setting instruction, it further includes: defining a data structure of a plugin class including an effective status field, and defining an interface layer including a disable plugin function, an enable plugin function, and an update plugin function; defining a status setting implementation class, inheriting the interface layer by the status setting implementation class, overriding the functions in the interface layer, and injecting it into the spring container through the @Service annotation.
[0064] In a specific embodiment, the data structure of the pre-defined plugin class may specifically be:
[0065]
[0066]
[0067] Among them, Plugin is the class name of the plugin class, and the class name is not limited to this; pluginId is the plugin identifier field, and a unique corresponding plugin can be found according to the plugin identifier; platform is the platform type field, such as including Android, IPA, or PC platform; appId is the identifier field of the host application of the plugin; pluginName is the plugin name field, and a unique corresponding plugin can also be found according to the plugin name; disabled is the effective status field of the plugin. When the data of this field is true, it represents the disabled state, and when the data of the field is false, it represents the enabled state. In addition, by designing the effective status field as a byte type, it is possible to greatly reduce the memory space overhead and the space overhead of the database while describing the status information. By pre-defining the data structure of the plugin class, the description of the plugin at the data layer is realized, laying a foundation for subsequent business operations such as status setting or updating.
[0068] In a specific embodiment, the pre-defined interface layer may specifically be:
[0069]
[0070] Among them, PluginService is the name of the interface layer of the business functions of the plugin, and the name of the interface layer is not limited to this; disabledPlugin is the function to disable the plugin, enabledPlugin is the function to enable the plugin, and the input parameters of both functions include the plugin identifier pluginId and the operator information operator; updatePlugin is the function to update the plugin, and its input parameter includes the plugin object plugin. By defining the interface layer, it is beneficial for the subsequent business functions of the plugin to follow a unified protocol for business expansion and facilitate subsequent expansion and maintenance.
[0071] In a specific embodiment, the state setting implementation class can be defined through the following statement:
[0072] @Service
[0073] public class PluginServiceImpl implements PluginService{};
[0074] Among them, PluginServiceImpl is the name of the state setting implementation class, and the name of the state setting implementation class is not limited to this; through the statement implements PluginService, the state setting implementation class can inherit the interface layer and override the functions to disable the plugin, enable the plugin, and update the plugin in the interface layer. In addition, the state setting implementation class can be injected into the spring container through the @Service annotation, which can greatly facilitate the subsequent acquisition of the state setting implementation class.
[0075] S120. Construct a plugin object according to the object construction method in the target state setting function, set the plugin identifier of the plugin object according to the identifier setting method in the target state setting function, and set the effective state of the plugin object according to the state setting method in the target state setting function.
[0076] In this embodiment, after determining the target state setting function from the state setting implementation class, a new plugin object can be created, and parameters such as the identifier and effective state of the newly created plugin object can be set, so that the plugin matching the newly created plugin object can be found in the database subsequently, and the state of the plugin matching in the database can be updated using the effective state parameter of the newly created plugin object, thereby implementing the setting of the effective state of the plugin in the database.
[0077] Optionally, construct a plugin object according to the object construction method in the target status setting function, and set the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, including: construct a plugin object according to the Plugin plugin = new Plugin() method in the target status setting function, and set the plugin identifier of the plugin object according to the plugin.setId(pluginId) method in the target status setting function; where new is the construction statement of the plugin object; setId is the plugin identifier setting statement of the plugin object; plugin is the name of the plugin object; pluginId is the plugin identifier of the plugin object.
[0078] In the disabledPlugin function or the enabledPlugin function, you can first construct a plugin object plugin by calling the method Plugin plugin = new Plugin(), and then set the plugin identifier pluginId into the plugin object plugin by calling the method plugin.setId(pluginId). Among them, the names of the plugin objects in the disabledPlugin function and the enabledPlugin function can be different and are not limited to plugin.
[0079] Optionally, the target status setting function includes a disabledPlugin function and an enabledPlugin function;
[0080] Correspondingly, when the target status function is the disabledPlugin function, set the effective status of the plugin object according to the status setting method in the target status setting function, including:
[0081] Set the plugin object to the disabled state according to the following method in the disabledPlugin function:
[0082] plugin.setDisabled(PluginDisabledEnum.DISABLED_TRUE.getId());
[0083] Correspondingly, when the target status function is the enabledPlugin function, set the effective status of the plugin object according to the status setting method in the target status setting function, including:
[0084] Set the plugin object to the enabled state according to the following method in the enabledPlugin function:
[0085] plugin2update.setDisabled(PluginDisabledEnum.DISABLED_FALSE.getId());
[0086] Among them, setDisabled is a statement for setting the effective state of the plugin object; getId is a statement for obtaining the plugin object corresponding to the plugin identifier; plugin and plugin2update are the names of the plugin objects in the disable plugin function and the enable plugin function respectively; PluginDisabledEnum is an enumeration object of the plugin effective field, and the enumeration object includes the disabled state DISABLED_TRUE and the enabled state DISABLED_FALSE.
[0087] In this embodiment, after constructing a new plugin object and setting the plugin identifier for the plugin object in the disable plugin function disabledPlugin or the enable plugin function enabledPlugin, different state setting statements will be used to set different effective states for the plugin object. Specifically, in the disable plugin function disabledPlugin, the effective state of the plugin object is set to the disabled state by the method of plugin.setDisabled(PluginDisabledEnum.DISABLED_TRUE.getId()); in the enable plugin function enabledPlugin, the effective state of the plugin object is set to the enabled state by the method of plugin2update.setDisabled(PluginDisabledEnum.DISABLED_FALSE.getId()). It should be noted that the name of the plugin object in the disable plugin function disabledPlugin is not limited to plugin, and the name of the plugin object in the enable plugin function enabledPlugin is not limited to plugin2update.
[0088] Among them, the data of the plugin effective state field can be defined as an enumeration object, which can make there be no duplicate states in the effective state, effectively ensuring the uniqueness of the state.
[0089] S130. Update the status update time of the plugin object according to the time update method in the target status setting function, update the operator information of the plugin object according to the operator update method in the target status setting function, and update the plugin object to the preset database according to the update plugin function in the status setting implementation class.
[0090] In this embodiment, after constructing a new plugin object and setting the effective state of the plugin object, then the update time and the updated operator of the plugin object can be updated. Finally, the relevant information of the newly created plugin object can be updated to the plugin object that matches in the database, thereby realizing the setting of the disabled or enabled state of the plugin object in the database.
[0091] Optionally, update the status update time of the plugin object according to the time update method in the target status setting function, update the operator information of the plugin object according to the operator update method in the target status setting function, and update the plugin object to a preset database according to the update plugin function in the status setting implementation class, including: updating the status update time of the plugin object according to the following method in the target status setting function: plugin.setLastUpdate(System.currentTimeMillis() / 1000); updating the operator information of the plugin object according to the plugin.setOperator(operator) method in the target status setting function; updating the plugin object to a preset database according to the updatePlugin function in the status setting implementation class;
[0092] Among them, setLastUpdate is a statement for setting the status update time of the plugin object; System.currentTimeMillis is a statement for obtaining the current system time; setOperator is a statement for setting the operator information of the plugin object; plugin is the name of the plugin object; operator is the operator information of the plugin object.
[0093] In this embodiment, in the disabledPlugin or enabledPlugin of the plugin function, the status update time of the plugin object plugin can be updated by calling the method of plugin.setLastUpdate(System.currentTimeMillis() / 1000), and the operator information of the plugin object can be updated by calling the method of plugin.setOperator(operator). Among them, the plugin object names in the disabledPlugin and enabledPlugin of the plugin function can be different and are not limited to plugin.
[0094] Further, updating the plugin object to a preset database according to the updatePlugin function in the status setting implementation class includes:
[0095] Search for the plugin list information that matches the host application identifier and package name of the input parameter according to the following method in the updatePlugin function:
[0096] List <plugin>plugins = pluginMapper.selectByAppIdAndPackageName(plugin.getAppId(), plugin.getPluginName());
[0097] Filter the plugin objects in the plugin list information according to the following method in the updatePlugin function:
[0098] Optional <plugin>first = plugins.stream().filter(x -> x.getId().equals(plugin.getId())).findFirst();
[0099] Determine whether the filtered plugin object exists according to the following method in the updatePlugin function:
[0100] if (!first.isPresent()) {throw new VenusException(500, String.format());}
[0101] If so, update the plugin object to the preset database according to the following method in the updatePlugin function:
[0102] pluginMapper.updateByPrimaryKeySelective(plugin);
[0103] Among them, List is of the list type; plugins is the plugin list information; pluginMapper is the preset database of the plugin; selectByAppIdAndPackageName is the statement for querying the plugin, and in the query plugin statement, getAppId is the statement for obtaining the host application identifier of the input parameter; getPluginName is the statement for obtaining the package name of the input parameter;
[0104] Among them, Optional is of the optional type; first is the filtered plugin object; stream is the statement for converting the plugin list information into a stream object; filter is the statement for filtering the plugin object, and in the filtering statement, x -> x.getId().equals(plugin.getId()) is the filtering condition for whether the plugin identifier is the same as the plugin identifier of the newly created plugin object; findFirst is for obtaining the first plugin object that meets the filtering condition;
[0105] Among them, isPresen is the statement for determining whether the filtered plugin object exists; String.format is the statement for notifying the existence of the plugin object;.updateByPrimaryKeySelective is the statement for updating the existing plugin object to the preset database.
[0106] Among them, the plugin update function is the updatePlugin function. The plugin update function can first find the plugin list information that matches the host application identifier and package name of the input parameter to obtain a List <plugin>objects of type plugins; then, the List can be obtained through the method plugins.stream() <plugin>Objects of type plugins are converted into stream objects; then, the filter filtering method can be called to filter out the plugin objects whose plugin identifiers are the same as those of the newly created plugin objects, that is, the plugin objects with the filtering condition of x.getId().equals(plugin.getId()); finally, the first matching plugin object can be obtained through the.findFirst() method, and the plugin object is newly described as Optional <plugin>The object of type first. Among them, through the.findFirst() method, it can effectively handle the situation where there may be multiple matching plugin objects due to data disorder.
[0107] Among them, after filtering out the matching plugin object first, it can be further determined whether the object exists. Among them, if the first object exists, the String.format() method can be called, and the String.format() method can specifically be String.format("The plugin with the package name [%s] already exists", plugin.getPluginName()) to notify the user that the plugin object matching the input parameter exists. In addition, if the first object does not exist, an exception can be thrown to terminate the execution of the entire business process.
[0108] Among them, when the first object exists, the status setting logic of the plugin object can be continued, that is, the plugin object is updated to the preset database according to the pluginMapper.updateByPrimaryKeySelective(plugin) method in the updatePlugin function, so that the status information of the plugin object in the database is updated. At the same time, the update of the plugin object can also be synchronized to the cache by calling the cacheManager.addPlugin(this.findPlugin(plugin.getId())) method for subsequent use.
[0109] Furthermore, List <plugin>The method of selectByAppIdAndPackageName in the plugins method includes:
[0110] Define the select tag according to the following method:
[0111] <select id="selectbyappidandpackagename"resultmap="baseresultmap">< / select> ;
[0112] Obtain the plugin list information that matches the host application identifier and package name of the input parameter according to the following method:
[0113] select <include refid="Base_Column_List" / > from plugin where app_id = #{0} and package_name = #{1};
[0114] Among them, id = "selectByAppIdAndPackageName" in the select tag is used to point to the statement for finding the host application identifier and package name; resultMap = "BaseResultMap" is used to indicate that the type of the filtered result set is BaseResultMap; Base_Column_List represents the field information of the plugin object to be found; where app_id = #{0} and package_name = #{1} are the query conditions, and #{0} represents the first input parameter, and #{1} represents the second input parameter.
[0115] In this embodiment, a List is obtained <plugin>The specific steps for the object plugins of the type can be as follows:
[0116] First, define a select tag; where the id is used to point to the function name, that is, to the function selectByAppIdAndPackageName for finding the host application identifier and package name. By finding the host application identifier and package name, the plugin object matching the host application identifier and package name of the input parameter can be found; where the resultMap is used to represent the BaseResultMap type of the result set, and this type is the above-mentioned List <plugin>Mapping type.
[0117] Then, the plugin object that matches the host application ID and package name of the input parameter can be found through the select query statement. Among them, Base_Column_List represents the column information to be searched, that is, the field information of the plugin object Plugin. Among them, where app_id = #{0} and package_name = #{1} are the query conditions; among them, #{0} represents the first input parameter, that is, the passed-in plugin.getAppId(); among them, #{1} represents the second input parameter, that is, the passed-in plugin.getPluginName().
[0118] Through the above query steps, a List can be obtained <plugin>Object plugins of the type.
[0119] A method for setting plugins in an Android system provided in this embodiment responds to a plugin status setting instruction, obtains a status setting implementation class from the spring container, and calls the target status setting function in the status setting implementation class; constructs a plugin object according to the object construction method in the target status setting function, sets the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, and sets the effective status of the plugin object according to the status setting method in the target status setting function; updates the status update time of the plugin object according to the time update method in the target status setting function, updates the operator information of the plugin object according to the operator update method in the target status setting function, and updates the plugin object to a preset database according to the update plugin function in the status setting implementation class.
[0120] Compared with the traditional method of disabling plugins by deleting plugin information, by changing the effective status field in the plugin object and synchronizing the changed plugin information to the corresponding plugin object in the database, it is possible to set the status such as enabling and disabling of the plugin object on the basis of ensuring data integrity and normal business functions.
[0121] Embodiment 2
[0122] Figure 2 It is a schematic structural diagram of a device for setting plugins in an Android system provided in Embodiment 2 of the present invention. Refer to Figure 2 As shown, the device for setting plugins in an Android system includes:
[0123] An instruction receiving module 210, which is used to respond to a plugin status setting instruction, obtain a status setting implementation class from the spring container, and call the target status setting function in the status setting implementation class;
[0124] A status setting module 220, which is used to construct a plugin object according to the object construction method in the target status setting function, set the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, and set the effective status of the plugin object according to the status setting method in the target status setting function;
[0125] A plugin update module 230, which is used to update the status update time of the plugin object according to the time update method in the target status setting function, update the operator information of the plugin object according to the operator update method in the target status setting function, and update the plugin object to a preset database according to the update plugin function in the status setting implementation class.
[0126] Optionally, the status setting module is specifically used for:
[0127] Construct a plugin object using the Plugin plugin = new Plugin() method in the target status setting function, and set the plugin identifier of the plugin object using the plugin.setId(pluginId) method in the target status setting function;
[0128] Among them, new is the construction statement of the plugin object; setId is the plugin identifier setting statement of the plugin object; plugin is the name of the plugin object; pluginId is the plugin identifier of the plugin object.
[0129] Optionally, the target status setting function includes a disable plugin function and an enable plugin function;
[0130] Correspondingly, when the target status function is the disable plugin function, the status setting module is specifically used for:
[0131] Set the plugin object to the disabled state according to the following method in the disable plugin function:
[0132] plugin.setDisabled(PluginDisabledEnum.DISABLED_TRUE.getId());
[0133] Correspondingly, when the target status function is the enable plugin function, the status setting module is specifically used for:
[0134] Set the plugin object to the enabled state according to the following method in the enable plugin function:
[0135] plugin2update.setDisabled(PluginDisabledEnum.DISABLED_FALSE.getId());
[0136] Among them, setDisabled is the setting statement of the effective state of the plugin object; getId is the statement to obtain the plugin object corresponding to the plugin identifier; plugin and plugin2update are the names of the plugin objects in the disable plugin function and the enable plugin function respectively; PluginDisabledEnum is the enumeration object of the plugin effective field, and the enumeration object includes the disabled state DISABLED_TRUE and the enabled state DISABLED_FALSE.
[0137] Optionally, the plugin update module is specifically used for:
[0138] Update the status update time of the plugin object according to the following method in the target status setting function: plugin.setLastUpdate(System.currentTimeMillis() / 1000);
[0139] Update the operator information of the plugin object according to the plugin.setOperator(operator) method in the target status setting function;
[0140] Update the plugin object to the preset database according to the updatePlugin function in the status setting implementation class;
[0141] Among them, setLastUpdate is the statement for setting the status update time of the plugin object; System.currentTimeMillis is the statement for obtaining the current system time; setOperator is the statement for setting the operator information of the plugin object; plugin is the name of the plugin object; operator is the operator information of the plugin object.
[0142] Optionally, the plugin update module is specifically used for:
[0143] Find the plugin list information that matches the host application identifier and package name of the input parameter according to the following method in the updatePlugin function:
[0144] List <plugin>plugins = pluginMapper.selectByAppIdAndPackageName(plugin.getAppId(), plugin.getPluginName());
[0145] Filter the plugin objects in the plugin list information according to the following method in the updatePlugin function:
[0146] Optional <plugin>first = plugins.stream().filter(x -> x.getId().equals(plugin.getId())).findFirst();
[0147] Judge whether the filtered plugin object exists according to the following method in the updatePlugin function:
[0148] if (!first.isPresent()) { throw new VenusException(500, String.format());}
[0149] If so, update the plugin object to the preset database according to the following method in the updatePlugin function:
[0150] pluginMapper.updateByPrimaryKeySelective(plugin);
[0151] Among them, List is of list type; plugins is the plugin list information; pluginMapper is the preset database of plugins; selectByAppIdAndPackageName is the query plugin statement, and getAppId in the query plugin statement is the statement to obtain the host application identifier of the input parameter; getPluginName is the statement to obtain the package name of the input parameter;
[0152] Among them, Optional is of optional type; first is the filtered plugin object; stream is the statement to convert the plugin list information into a stream object; filter is the filtering statement for the plugin object, and x -> x.getId().equals(plugin.getId()) in the filtering statement is the filtering condition for whether the plugin identifier and the plugin identifier of the newly created plugin object are the same; findFirst is to obtain the first plugin object that meets the filtering condition;
[0153] Among them, isPresen is the statement to judge whether the filtered plugin object exists; String.format is the statement to notify the existence of the plugin object;.updateByPrimaryKeySelective is the statement to update the existing plugin object to the preset database.
[0154] Optionally, List <plugin>The method of selectByAppIdAndPackageName in the plugins method includes:
[0155] Define the select tag according to the following method:
[0156] <select id="selectbyappidandpackagename"resultmap="baseresultmap">< / select> ;
[0157] Obtain the plugin list information that matches the host application identifier and package name of the input parameter according to the following method:
[0158] select <include refid="Base_Column_List" / > from plugin where app_id = #{0} and package_name = #{1};
[0159] Among them, id = "selectByAppIdAndPackageName" in the select tag is used to point to the statement for finding the host application identifier and package name; resultMap = "BaseResultMap" is used to indicate that the type of the filtered result set is BaseResultMap; Base_Column_List represents the field information of the plugin object to be searched; where app_id = #{0} and package_name = #{1} are the query conditions, and #{0} represents the first input parameter, and #{1} represents the second input parameter.
[0160] Optionally, the device for setting plugins in the Android system further includes:
[0161] A predefined module, which is used to define the data structure of the plugin class including the effective status field and define the interface layer including the disable plugin function, enable plugin function, and update plugin function before responding to the plugin status setting instruction; define the status setting implementation class, inherit the interface layer by the status setting implementation class, override the functions in the interface layer, and inject it into the spring container through the @Service annotation.
[0162] The device for setting plugins in the Android system provided by the embodiments of the present invention can execute the method for setting plugins in the Android system provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For the technical details not described in detail, reference can be made to the method for setting plugins in the Android system provided by any embodiment of the present invention.
[0163] Embodiment Three
[0164] Figure 3 It is a schematic structural diagram of an electronic device provided in Embodiment 3 of the present invention. Figure 3 It shows a block diagram of an exemplary electronic device 12 suitable for implementing any embodiment of the present invention. Figure 3 The shown electronic device 12 is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present invention. The device 12 is typically an electronic device responsible for the settings of plugins in the Android system.
[0165] Such as Figure 3 As shown, the electronic device 12 is presented in the form of a general-purpose computing device. The components of the electronic device 12 may include but are not limited to: one or more processors or processing units 16, a memory 28, and a bus 18 connecting different components (including the memory 28 and the processing unit 16).
[0166] The bus 18 represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any bus structure in a variety of bus structures. For example, these architectures include but are not limited to the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MCA) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0167] The electronic device 12 typically includes a variety of computer-readable media. These media can be any available media accessible by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0168] The memory 28 may include computer-readable media in the form of volatile memory, such as a Random Access Memory (RAM) 30 and / or a cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer storage media. By way of example only, a storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 3 not shown, commonly referred to as a "hard disk drive"). Although Figure 3 Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (such as a "floppy disk") and an optical disk drive for reading and writing a removable non-volatile optical disk (such as a Compact Disc-Read Only Memory (CD-ROM), a Digital Video Disc-Read Only Memory (DVD-ROM), or other optical media) can be provided. In these cases, each drive can be connected to the bus 18 through one or more data medium interfaces. The memory 28 can include at least one program product 40, and this program product 40 has a set of program modules 42, and these program modules are configured to execute the functions of various embodiments of the present invention. The program product 40 can be stored in, for example, the memory 28. Such program modules 42 include, but are not limited to, one or more application programs, other program modules, and program data. The implementation of a network environment may be included in each or some combination of these examples. The program modules 42 generally execute the functions and / or methods in the embodiments described in the present invention.
[0169] The electronic device 12 can also communicate with one or more external devices 14 (such as a keyboard, a mouse, a camera, etc. and a display), and can also communicate with one or more devices that enable a user to interact with the electronic device 12, and / or communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through the input / output (I / O) interface 22. And, the electronic device 12 can also communicate with one or more networks (such as a Local Area Network (LAN), a Wide Area Network (WAN), and / or a public network, such as the Internet) through the network adapter 20. As shown in the figure, the network adapter 20 communicates with other modules of the electronic device 12 through the bus 18. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in combination with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) devices, tape drives, and data backup storage devices, etc.
[0170] The processor 16 executes various functional applications and data processing by running the programs stored in the memory 28, for example, implementing the information encryption method provided in the above embodiments of the present invention. The method includes:
[0171] In response to the plugin status setting instruction, obtain the status setting implementation class from the spring container, and call the target status setting function in the status setting implementation class; construct a plugin object according to the object construction method in the target status setting function, set the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, and set the effective status of the plugin object according to the status setting method in the target status setting function; update the status update time of the plugin object according to the time update method in the target status setting function, update the operator information of the plugin object according to the operator update method in the target status setting function, and update the plugin object to a preset database according to the update plugin function in the status setting implementation class.
[0172] Of course, those skilled in the art can understand that the processor can also implement the technical solutions of the information encryption method or decryption method provided in any embodiment of the present invention.
[0173] Embodiment 5
[0174] Embodiment 5 of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the method for setting a plugin in the Android system provided in the embodiment of the present invention. The method includes:
[0175] In response to the plugin status setting instruction, obtain the status setting implementation class from the spring container, and call the target status setting function in the status setting implementation class; construct a plugin object according to the object construction method in the target status setting function, set the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, and set the effective status of the plugin object according to the status setting method in the target status setting function; update the status update time of the plugin object according to the time update method in the target status setting function, update the operator information of the plugin object according to the operator update method in the target status setting function, and update the plugin object to a preset database according to the update plugin function in the status setting implementation class.
[0176] Of course, the computer program stored on the computer-readable storage medium provided in the embodiment of the present invention is not limited to the above method operations, and can also execute the related operations in the method for setting a plugin in the Android system provided in any embodiment of the present invention.
[0177] The computer storage medium of an embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage medium include: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0178] The computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries the computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0179] The program code contained on the computer-readable medium may be transmitted by any appropriate medium, including but not limited to wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the above.
[0180] The computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0181] Note that the above is only a preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments here, and various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments only. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.< / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin> < / plugin>
Claims
1. A method for setting plugins in an Android system, characterized in that Including: In response to the plugin status setting instruction, obtain the status setting implementation class from the spring container and call the target status setting function in the status setting implementation class; Construct a plugin object according to the object construction method in the target status setting function, set the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, and set the effective status of the plugin object according to the status setting method in the target status setting function; wherein, use "disabled" as the effective status field of the plugin, and design the effective status field as a byte type; when the data of the effective status field is true, it represents the disabled state, and when the data of the effective status field is false, it represents the enabled state; Update the status update time of the plugin object according to the time update method in the target status setting function, update the operator information of the plugin object according to the operator update method in the target status setting function, and update the plugin object to a preset database according to the update plugin function in the status setting implementation class; The step of updating the plugin object to a preset database according to the update plugin function in the status setting implementation class includes: Find the plugin list information that matches the host application identifier and package name of the input parameter according to the following method in the update plugin function: List <plugin>plugins = pluginMapper.selectByAppIdAndPackageName(plugin.getAppId(), plugin.getPluginName());< / plugin> Filter the plugin objects in the plugin list information according to the following method in the update plugin function: Optional <plugin>first = plugins.stream().filter(x -> x.getId().equals(plugin.getId())).findFirst();< / plugin> Judge whether the filtered plugin object exists according to the following method in the update plugin function: if (!first.isPresent()) {throw new VenusException(500, String.format())}; If so, update the plugin object to a preset database according to the following method in the update plugin function: pluginMapper.updateByPrimaryKeySelective(plugin); Among them, List is a list type; plugins is the plugin list information; pluginMapper is the preset database of the plugin; selectByAppIdAndPackageName is the query plugin statement, and getAppId in the query plugin statement is the statement to obtain the host application identifier of the input parameter; getPluginName is the statement to obtain the package name of the input parameter; Among them, Optional is of the selectable type; first is the plugin object to be filtered; stream is a statement that converts the plugin list information into a stream object; filter is a filtering statement for the plugin object, and in the filtering statement, x->x.getId().equals(plugin.getId()) is a filtering condition for whether the plugin identifier of the plugin object and the plugin identifier of the newly created plugin object are the same; findFirst is to obtain the first plugin object that meets the filtering condition; Among them, isPresen is a statement for judging whether the filtered plugin object exists; String.format is a statement for notifying the existence of the plugin object;.updateByPrimaryKeySelective is a statement for updating the existing plugin object to a preset database.
2. The method according to claim 1, characterized in that, Constructing a plugin object according to the object construction method in the target status setting function, and setting the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, includes: Constructing a plugin object according to the method Plugin plugin = new Plugin() in the target status setting function, and setting the plugin identifier of the plugin object according to the method plugin.setId(pluginId) in the target status setting function; Among them, new is a statement for constructing the plugin object; setId is a statement for setting the plugin identifier of the plugin object; plugin is the name of the plugin object; pluginId is the plugin identifier of the plugin object.
3. The method according to claim 1, wherein The target status setting function includes a disable plugin function and an enable plugin function; Correspondingly, when the target status setting function is the disable plugin function, setting the effective status of the plugin object according to the status setting method in the target status setting function, includes: Setting the plugin object to the disabled state according to the following method in the disable plugin function: plugin.setDisabled(PluginDisabledEnum.DISABLED_TRUE.getId()); Correspondingly, when the target status setting function is the enable plugin function, setting the effective status of the plugin object according to the status setting method in the target status setting function, includes: Setting the plugin object to the enabled state according to the following method in the enable plugin function: plugin2update.setDisabled(PluginDisabledEnum.DISABLED_FALSE.getId()); Among them, setDisabled is the statement for setting the effective status of the plugin object; getId is the statement for obtaining the plugin object corresponding to the plugin identifier; plugin and plugin2update are the names of the plugin objects in the disable plugin function and enable plugin function respectively; PluginDisabledEnum is the enumeration object of the plugin effective field, and the enumeration object includes the disabled status DISABLED_TRUE and the enabled status DISABLED_FALSE.
4. The method according to claim 1, wherein Updating the status update time of the plugin object according to the time update method in the target status setting function, updating the operator information of the plugin object according to the operator update method in the target status setting function, and updating the plugin object to a preset database according to the update plugin function in the status setting implementation class, including: Updating the status update time of the plugin object according to the following method in the target status setting function: plugin.setLastUpdate(System.currentTimeMillis() / 1000); Updating the operator information of the plugin object according to the plugin.setOperator(operator) method in the target status setting function; Updating the plugin object to a preset database according to the updatePlugin function in the status setting implementation class; Among them, setLastUpdate is the statement for setting the status update time of the plugin object; System.currentTimeMillis is the statement for obtaining the current system time; setOperator is the statement for setting the operator information of the plugin object; plugin is the name of the plugin object; operator is the operator information of the plugin object.
5. The method according to claim 1, wherein The said List <plugin>The method of selectByAppIdAndPackageName in the plugins method, including: < / plugin> Defining the select tag according to the following method: <select id="selectByAppIdAndPackageName" resultmap="BaseResultMap"> < / select> ; Obtaining the plugin list information that matches the host application identifier and package name of the input parameter according to the following method: select <include refid="Base_Column_List" / > from plugin where app_id = #{0} and package_name=#{1}; Among them, id = "selectByAppIdAndPackageName" in the select tag is used to point to the statement for finding the host application identifier and package name; resultMap = "BaseResultMap" is used to indicate that the type of the filtered result set is BaseResultMap; Base_Column_List represents the field information of the plugin object to be found; where app_id = #{0} and package_name = #{1} is the query condition, and #{0} represents the first input parameter, and #{1} represents the second input parameter.
6. The method according to any one of claims 1-5, characterized in that Before responding to the plugin status setting instruction, it also includes: Define the data structure of the plugin class including the effective status field, and define the interface layer including the disable plugin function, enable plugin function, and update plugin function; Define the status setting implementation class, inherit the interface layer by the status setting implementation class, override the functions in the interface layer, and inject it into the spring container through the @Service annotation.
7. A setting device for plugins in an Android system, characterized in that, The device includes: An instruction receiving module, configured to obtain the status setting implementation class from the spring container in response to a plugin status setting instruction, and call the target status setting function in the status setting implementation class; A status setting module, configured to construct a plugin object according to the object construction method in the target status setting function, set the plugin identifier of the plugin object according to the identifier setting method in the target status setting function, and set the effective status of the plugin object according to the status setting method in the target status setting function; wherein, use disabled as the effective status field of the plugin, and design the effective status field as a byte type; when the data of the effective status field is true, it represents the disabled state, and when the data of the effective status field is false, it represents the enabled state; A plugin update module, configured to update the status update time of the plugin object according to the time update method in the target status setting function, update the operator information of the plugin object according to the operator update method in the target status setting function, and update the plugin object to a preset database according to the update plugin function in the status setting implementation class; The plugin update module is specifically configured to: Find the plugin list information that matches the host application identifier and package name of the input parameter according to the following method in the update plugin function: List <plugin>plugins=pluginMapper.selectByAppIdAndPackageName(plugin.getAppId(), plugin.getPluginName());< / plugin> Filter the plugin objects in the plugin list information according to the following method in the update plugin function: Optional <plugin>first=plugins.stream().filter(x->x.getId().equals(plugin.getId())).findFirst();< / plugin> Judge whether the filtered plugin object exists according to the following method in the update plugin function: if(!first.isPresent()) {throw new VenusException(500, String.format())}; If so, update the plugin object to the preset database according to the following method in the update plugin function: pluginMapper.updateByPrimaryKeySelective(plugin); Among them, List is of the list type; plugins is the plugin list information; pluginMapper is the preset database of the plugin; selectByAppIdAndPackageName is the statement for querying the plugin, and in the query plugin statement, getAppId is the statement for obtaining the host application identifier of the input parameter; getPluginName is the statement for obtaining the package name of the input parameter. Among them, Optional is of the selectable type; first is the plugin object to be filtered; stream is the statement for converting the plugin list information into a stream object; filter is the filtering statement for the plugin object, and in the filtering statement, x->x.getId().equals(plugin.getId()) is the filtering condition for whether the plugin identifier is the same as that of the newly created plugin object; findFirst is to obtain the first plugin object that meets the filtering condition. Among them, isPresen is the statement for judging whether the filtered plugin object exists; String.format is the statement for notifying the existence of the plugin object;.updateByPrimaryKeySelective is the statement for updating the existing plugin object to the preset database.
8. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for setting plugins in the Android system as described in any one of claims 1-6.
9. A storage medium containing computer-executable instructions, which implement the method for setting plugins in the Android system as described in any one of claims 1-6 when executed by a computer processor.