Disclosure of Invention
Aiming at the problems in the prior art, the embodiments of the present invention provide a method for setting an associated application, a method and an apparatus for controlling the start of an associated application.
Specifically, the embodiment of the invention provides the following technical scheme:
in a first aspect, an embodiment of the present invention provides a method for setting an associated application, including:
adding sharedUserId attributes to android manifest files of a first application and a second application respectively, and setting the sharedUserId attributes corresponding to the first application and the second application to be the same; the first application and the second application are two applications to be associated;
and controlling the first application and the second application to be packaged into a first installation package file and a second installation package file respectively by using the same signature in the process of installing the first application and the second application to the intelligent equipment, so that the application identifications distributed to the first installation package file and the second installation package file are the same when the first installation package file and the second installation package file are installed to the intelligent equipment.
In a second aspect, an embodiment of the present invention further provides a related application starting control method based on the related application setting method in the first aspect, where the method includes:
when a call request for calling the second application by the first application is received, whether the application identifications of the first application and the second application are the same or not is judged, and if the application identifications of the first application and the second application are the same, the first application is allowed to call the second application.
Further, the associated application start control method further includes:
and if the application identifiers of the first application and the second application are different, prohibiting the first application from calling the second application.
In a third aspect, an embodiment of the present invention further provides an associated application setting apparatus, including:
the adding module is used for respectively adding sharedUserId attributes in android manifest files of a first application and a second application, and setting the sharedUserId attributes corresponding to the first application and the second application to be the same; the first application and the second application are two applications to be associated;
and the signature setting module is used for controlling the first application and the second application to be respectively packaged into a first installation package file and a second installation package file by using the same signature in the process of being installed on the intelligent equipment, so that the application identifications distributed to the first installation package file and the second installation package file are the same when the first installation package file and the second installation package file are installed on the intelligent equipment.
In a fourth aspect, an embodiment of the present invention further provides a related application starting control device based on the related application setting device in the third aspect, including:
and the associated application starting control module is used for judging whether the application identifications of the first application and the second application are the same or not when receiving a calling request for calling the second application by the first application, and allowing the first application to call the second application if the application identifications of the first application and the second application are the same.
Further, the associated application start control module is further configured to:
and if the application identifiers of the first application and the second application are different, prohibiting the first application from calling the second application.
In a fifth aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the associated application setting method according to the first aspect when executing the program, or implements the steps of the associated application start control method according to the second aspect when executing the program.
In a sixth aspect, the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program, when being executed by a processor, implementing the steps of the associated application setting method according to the first aspect, or the computer program, when being executed by the processor, implementing the steps of the associated application start control method according to the second aspect.
In a seventh aspect, an embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, the steps of the associated application setting method according to the first aspect are implemented.
In an eighth aspect, an embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, the steps of the associated application start control method according to the second aspect are implemented.
As can be seen from the above technical solutions, according to the method and the device for setting the associated application provided in the embodiments of the present invention, because the sharedUserId attribute is added to the android manifest files of the two applications with the same signature, and the values in the sharedUserId attribute are the same, the two applications are considered to be the same application in the android system, and therefore, the application identifiers allocated when the two applications are installed on the android smart device are the same, and further, background service invocation can be performed between the two applications, which is not limited by the android system background.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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, but 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.
Fig. 1 shows a flowchart of an associated application setting method according to an embodiment of the present invention. As shown in fig. 1, the method for setting an associated application according to the embodiment of the present invention includes the following steps:
step 101: adding sharedUserId attributes to android manifest files of a first application and a second application respectively, and setting the sharedUserId attributes corresponding to the first application and the second application to be the same; the first application and the second application are two applications to be associated;
step 102: and controlling the first application and the second application to be packaged into a first installation package file and a second installation package file respectively by using the same signature in the process of installing the first application and the second application to the intelligent equipment, so that the application identifications distributed to the first installation package file and the second installation package file are the same when the first installation package file and the second installation package file are installed to the intelligent equipment.
In this embodiment, before describing the content of this embodiment, the meanings of the android manifest file, the installation package file, and the sharedUserId attribute appearing in this embodiment are explained as follows:
the android manifest file is an information description file of an android application program, and the android manifest file is an android manifest file, wherein Activity, Service, Content provider and broadcastupdate component information contained in the application program are defined. Each application must contain an android manifest file under the root directory and the file name cannot be modified.
And secondly, the installation package file is an APK file, and the APK is an abbreviation of Android package, namely an application software installation package of an Android system. The APK is in a file format similar to Symbian Sis or Sisx, and can be installed by directly transmitting the APK file to an Android simulator or an Android mobile phone for execution.
The sharedUserId attribute refers to a shared user ID attribute in the android application, and has the following functions: when the sharedUserId attribute is added to the android Manifest files of the two applications and the sharedUserId attribute values of the two applications are set to be the same, the two applications can be assigned to the same UserId when packaged into APK files by using the same signature and installed to the intelligent device.
In this embodiment, it should be noted that, for each APK file installed in the smart device, the Android system allocates a separate user space to each APK process, allocates an application identification UserId to each APK process, and creates a sandbox for each APK process to prevent other applications from being affected (or other applications from affecting it). It should be noted that this application identification UserId is assigned when the application is installed in the smart device and remains permanent in this smart device.
Based on the above analysis, in order to implement the associated start between the first application and the second application, in this embodiment, sharedUserId attributes are respectively added to android files of the first application and the second application, and sharedUserId attribute values corresponding to the first application and the second application are set to be the same, so that the first application and the second application can have the same application identification UserId through the addition and the setting of the sharedUserId attributes. Since multiple APKs with the same UserId may be configured to run in the same process, data may be accessible to each other by default. Furthermore, since the Android system restricts that the same sharedUserId must use the same signature, two first and second applications that need to be associated must be packaged with the same signature.
In this embodiment, the first application and the second application may be learning applications APP, office applications APP, and security protection applications APP, which is not limited in this embodiment.
Furthermore, in this embodiment, it should be noted that the first application and the second application in this embodiment are only for distinguishing different applications, and are not limited to the method for setting the associated application provided in this embodiment and the method for controlling start of the associated application provided in the subsequent embodiment being only applicable to the problem of associated start between two applications. The principle is similar, and the description is omitted here.
As can be seen from the foregoing technical solution, in the method for setting a related application provided in the embodiment of the present invention, because the sharedUserId attribute is added to the Android manifest files of two applications with the same signature, and the values in the sharedUserId attribute are the same, the two applications are considered to be the same application in the Android system, and therefore, the application identifiers UserId allocated when the two applications are installed on the Android smart device are the same, and further, the two applications can perform background service invocation with each other, which is not limited by the Android system background.
The following describes the associated application setting method provided in this embodiment in detail with reference to fig. 2, fig. 3, and fig. 4.
As shown in fig. 2, when installing a first application and a second application before the sharedUserId attribute is not added, the userids of the two applications are completely different. In this case, if the first application attempts to invoke the background service of the second application or the second application attempts to invoke the background service of the first application, it may be intercepted in the smart device application launch management.
As described in the above embodiments, if the associated start of two applications is successfully performed, two situations need to be ensured:
A. two applications must be packaged using the same signature; B. the same shardsuserid attribute is set in the android file.
The result after processing according to the associated application setting method provided in this embodiment is shown in fig. 3. That is, sharedUserId attributes are added to android files of a first application and a second application respectively, sharedUserId attribute values corresponding to the first application and the second application are set to be the same, and after the sharedUserId attributes are packaged by the same signature, UserIds generated when the two applications are installed on the intelligent device are the same. Accordingly, it is found that there is no associated start-up restriction when the first application attempts to invoke the background service of the second application or the second application attempts to invoke the background service of the first application. As shown in fig. 4, the background service has been successfully turned on. Therefore, the method for setting the associated application provided by the embodiment can break through the Android and manufacturer background starting limit to successfully start the background service.
Based on the associated application setting method provided by the above embodiment, the embodiment of the present invention provides an associated application start control method. Fig. 5 is a flowchart illustrating an associated application start control method according to an embodiment of the present invention. As shown in fig. 5, the method for controlling the start of the associated application according to the embodiment of the present invention includes the following steps:
step 201: when a call request for calling the second application by the first application is received, whether the application identifications of the first application and the second application are the same or not is judged, and if the application identifications of the first application and the second application are the same, the first application is allowed to call the second application.
The present embodiment provides a related application start control method based on the related application setting method provided in the foregoing embodiment. That is, sharedUserId attributes are added to android files of a first application and a second application respectively, sharedUserId attribute values corresponding to the first application and the second application are set to be the same, and after the sharedUserId attributes are packaged by the same signature, application identifiers UserId generated when the two applications are installed on the intelligent device are the same. Therefore, in this embodiment, when a call request for the first application to call the second application is received (or when a call request for the second application to call the first application is received), it is determined whether the application identifiers userld of the first application and the second application are the same, and if the application identifiers userld of the first application and the second application are the same, it is determined that the first application and the second application are the same application, so that the first application is allowed to call the second application. As shown in fig. 4, when a first application calls a second application, the background service of the second application may be successfully started. Therefore, the method for setting the associated application provided by the embodiment can break through the Android and manufacturer background starting limit to successfully start the background service of the associated application.
Based on the content of the foregoing embodiment, in this embodiment, the method for controlling the start of the associated application further includes:
and if the application identifications UserId of the first application and the second application are different, prohibiting the first application from calling the second application.
In this embodiment, if the application identifiers UserId of the first application and the second application are different, it is indicated that the two applications are not of the same type, the Android system creates different sandboxes for the two applications respectively, the two applications run in the respective sandboxes respectively, and the Android system restricts mutual calling before the two applications.
Fig. 6 shows a schematic structural diagram of an associated application setting apparatus according to an embodiment of the present invention. As shown in fig. 6, the related application setting apparatus provided in this embodiment includes: an adding module 11 and a signature setting module 12, wherein:
the adding module 11 is configured to add sharedUserId attributes to android manifest files of a first application and a second application, and set sharedUserId attribute values corresponding to the first application and the second application to be the same; the first application and the second application are two applications to be associated;
the signature setting module 12 is configured to control the first application and the second application to be respectively packaged into a first installation package file and a second installation package file using the same signature in the process of being installed to the smart device, so that the application identifiers allocated to the first installation package file and the second installation package file when being installed to the smart device are the same.
Since the associated application setting device provided in the embodiment of the present invention can be used to execute the associated application setting method described in the above embodiment, and the working principle and the beneficial effect are similar, detailed descriptions are omitted here, and specific contents can be referred to the description of the above embodiment.
In this embodiment, it should be noted that each module in the apparatus according to the embodiment of the present invention may be integrated into a whole or may be separately disposed. The modules can be combined into one module, and can also be further split into a plurality of sub-modules.
Fig. 7 is a schematic structural diagram illustrating an associated application start control apparatus according to an embodiment of the present invention. As shown in fig. 7, the related application start control device provided in this embodiment includes: a related application start control module 21;
the associated application starting control module 21 is configured to, when receiving a call request for the first application to call the second application, determine whether the application identifiers of the first application and the second application are the same, and if so, allow the first application to call the second application.
Based on the content of the foregoing embodiment, in this embodiment, the associated application starting control module 21 is further configured to:
and if the application identifiers of the first application and the second application are different, prohibiting the first application from calling the second application.
Since the related application start control device provided in the embodiment of the present invention can be used to execute the related application start control method described in the above embodiment, and the working principle and the beneficial effect are similar, detailed descriptions are omitted here, and specific contents can be referred to the description of the above embodiment.
In this embodiment, it should be noted that each module in the apparatus according to the embodiment of the present invention may be integrated into a whole or may be separately disposed. The modules can be combined into one module, and can also be further split into a plurality of sub-modules.
Based on the same inventive concept, another embodiment of the present invention provides an electronic device, which specifically includes the following components, with reference to fig. 8: a processor 301, a memory 302, a communication interface 303, and a communication bus 304;
the processor 301, the memory 302 and the communication interface 303 complete mutual communication through the communication bus 304;
the processor 301 is configured to call a computer program in the memory 302, and when the processor executes the computer program, the processor implements all the steps of the above associated application setting method, for example, when the processor executes the computer program, the processor implements the following processes: adding sharedUserId attributes to android manifest files of a first application and a second application respectively, and setting the sharedUserId attributes corresponding to the first application and the second application to be the same; the first application and the second application are two applications to be associated; and controlling the first application and the second application to be packaged into a first installation package file and a second installation package file respectively by using the same signature in the process of installing the first application and the second application to the intelligent equipment, so that the application identifications distributed to the first installation package file and the second installation package file are the same when the first installation package file and the second installation package file are installed to the intelligent equipment.
It will be appreciated that the detailed functions and extended functions that the computer program may perform may be as described with reference to the above embodiments.
Based on the same inventive concept, yet another embodiment of the present invention provides a non-transitory computer-readable storage medium having stored thereon a computer program, which when executed by a processor implements all the steps of the above-mentioned associated application setting method, for example, the processor implements the following processes when executing the computer program: adding sharedUserId attributes to android manifest files of a first application and a second application respectively, and setting the sharedUserId attributes corresponding to the first application and the second application to be the same; the first application and the second application are two applications to be associated; and controlling the first application and the second application to be packaged into a first installation package file and a second installation package file respectively by using the same signature in the process of installing the first application and the second application to the intelligent equipment, so that the application identifications distributed to the first installation package file and the second installation package file are the same when the first installation package file and the second installation package file are installed to the intelligent equipment.
It will be appreciated that the detailed functions and extended functions that the computer program may perform may be as described with reference to the above embodiments.
Based on the same inventive concept, another embodiment of the present invention provides an electronic device, which specifically includes the following components, with reference to fig. 9: a processor 401, a memory 402, a communication interface 403, and a communication bus 404;
the processor 401, the memory 402 and the communication interface 403 complete mutual communication through the communication bus 404;
the processor 401 is configured to call a computer program in the memory 402, and the processor implements all the steps of the above-mentioned associated application starting control method when executing the computer program, for example, the processor implements the following processes when executing the computer program: when a call request for calling the second application by the first application is received, whether the application identifications of the first application and the second application are the same or not is judged, and if the application identifications of the first application and the second application are the same, the first application is allowed to call the second application.
It will be appreciated that the detailed functions and extended functions that the computer program may perform may be as described with reference to the above embodiments.
Based on the same inventive concept, yet another embodiment of the present invention provides a non-transitory computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements all the steps of the above-mentioned associated application start control method, for example, the processor implements the following processes when executing the computer program: when a call request for calling the second application by the first application is received, whether the application identifications of the first application and the second application are the same or not is judged, and if the application identifications of the first application and the second application are the same, the first application is allowed to call the second application.
It will be appreciated that the detailed functions and extended functions that the computer program may perform may be as described with reference to the above embodiments.
Based on the same inventive concept, another embodiment of the present invention provides a computer program product, which includes a computer program, when being executed by a processor, the computer program implements all the steps of the above-mentioned associated application setting method, for example, when the processor executes the computer program, the processor implements the following processes: adding sharedUserId attributes to android manifest files of a first application and a second application respectively, and setting the sharedUserId attributes corresponding to the first application and the second application to be the same; the first application and the second application are two applications to be associated; and controlling the first application and the second application to be packaged into a first installation package file and a second installation package file respectively by using the same signature in the process of installing the first application and the second application to the intelligent equipment, so that the application identifications distributed to the first installation package file and the second installation package file are the same when the first installation package file and the second installation package file are installed to the intelligent equipment.
It will be appreciated that the detailed functions and extended functions that the computer program may perform may be as described with reference to the above embodiments.
Based on the same inventive concept, another embodiment of the present invention provides a computer program product, which includes a computer program, when being executed by a processor, the computer program implements all the steps of the above-mentioned associated application starting control method, for example, when the processor executes the computer program, the processor implements the following processes: when a call request for calling the second application by the first application is received, whether the application identifications of the first application and the second application are the same or not is judged, and if the application identifications of the first application and the second application are the same, the first application is allowed to call the second application.
It will be appreciated that the detailed functions and extended functions that the computer program may perform may be as described with reference to the above embodiments.
In addition, the logic instructions in the memory may be implemented in the form of software functional units and may be stored in a computer readable storage medium when sold or used as a stand-alone product. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment of the present invention. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. Based on such understanding, the above technical solutions may be essentially or partially implemented in the form of software products, which may be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and include several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the associated application setting method according to the various embodiments or some parts of the embodiments.
Moreover, in the present invention, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Furthermore, in the present disclosure, reference to the description of the terms "one embodiment," "some embodiments," "an example," "a specific example," or "some examples" or the like means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.