Android group right management method and system based on callback mechanism
Technical field
The invention belongs to computer software technical fields, are related to Android operation system, and in particular to based on callback mechanism
Android group right management method and system.
Background technique
With the rapid development of mobile Internet, mobile phone is using more and more abundant, while application installation and operation, they
Just have some permissions for collecting data in mobile phone, while enriching us and living personal privacy be also possible to therewith by
Leakage, in we do not perceive, largely applies and is grabbing our consumption information and consumption habit on the internet, that is such as
What avoids personal multi information of crossing from being compromised? Android system introduces rights management mechanism since 4.4.
So-called rights management, is to the permission of some App of manual configuration, and then prevents Malware and prevent hidden
Private leakage.Certainly, further rights management is can to provide a kind of notice when App dynamic uses some permission
Mechanism prompts user to allow and refuse.
Existing permission prompt uses AlertDialog mechanism, and this mechanism is excessively stiff, and inflexible, it can be interrupted
It is currently running Activity, user must make a choice in real time, so needing weight when Activity restores again
New load latest authorization state value.If not doing selection in real time to be defaulted as ignoring, the several seconds dialog boxes are waited at this time
It can disappear, it is not smooth enough using operation.If the application permission of some application is excessive, user will be to the permission of this all application
It selects, user is caused to do selection operation for a long time excessively, easily cause user's irritated psychology.
The all permissions of Android system are exactly grouped management by so-called group of rights management, can allow system in this way
Numerous permissions classify, and orderliness is clear, and can improve the efficiency of management to these permissions, can save system money to a certain extent
Source reduces equipment power dissipation.
Although Android primary system proposes the concept of group permission, substantially classify to all permissions of system, not
It is provided with effective group rights management mechanism.System on the market based on Android exploitation, such as Ali's cloud OS, mushroom system, also
Single rights management function is only provided, all without offer group right management method.
The Chinese invention patent application of publication number CN105184148A is mentioned through customized View mechanism and manages Android
Application permission.But the customized View is inherited from AlertDialog, although ensure that application program is run on certain procedures
Fluency, but solves the problem of it is a large amount of really weigh prompting frames and pop up simultaneously make troubles to user.
The Chinese invention patent application of Publication No. CN103679007A discloses a kind of side for managing application program permission
Method, comprising: whether monitor terminal has Android application program to request monitoring service;When the request for receiving Android application program monitors
When service, display reminding selects information, chooses whether to allow to monitor for user;When receive user selection allow monitor trigger
When, then start to start the solicited message for monitoring Android application program in real time, and corresponding monitor strategy control information is set.The hair
The problem of equally unresolved a large amount of really power prompting frames of the method for bright proposition are popped up simultaneously, are made troubles to user.
Summary of the invention
The purpose of the present invention is: the existing application rights management method above shortcomings of Android system are directed to, provide one
Group rights management mechanism of the kind based on callback mechanism, the category which is grouped all permissions, and will occur simultaneously
It collects in a prompt in same group of multiple permissions, is handled for user.To be brought convenience to user.The present invention continues simultaneously
Customized View mechanism can pop up the authority request of multiple permission groups simultaneously, to improve the flexibility of system.
To achieve the above object, present invention firstly provides a kind of Android group right management method based on callback mechanism,
Include:
Step S1: a certain permission grant of application program;
Step S2: authorized application prompt is issued the user with;
Step S3: user selects authorization or refusal;
It is characterized in that, all permission of Android is divided into multiple groups, the step S2 includes:
Step S2-1: it is judged whether or not processed authorized application prompts, and include in authorized application prompt
There are the other permissions for belonging to same group with authority items applied in step S1 if the determination result is YES then to enter step S2-2,
If judging result be it is no, then follow the steps S2-3;
Step S2-2: authority items applied in step S1 are added described in step S2-1 as newly-increased entry then and are awarded
In power application prompt.
Step S2-3: the authorized application prompt comprising applied authority items in step S1 is issued.
Further, the Android group right management method of the present invention based on callback mechanism, further includes:
Step S0: while the registered callbacks interface IOnCallback in SystemUI and AppOpsService, Android are set
When standby structural regime column SystemUI, a customized View object is instantiated
GroupPermissionsCheckPanelView, the object represent a group permission prompting frame.It will by IOnCallback interface
Rights management service AppOpsService and system mode column connect, and are communicated between the two by Binder.
The step S2 further includes that step S2-0:AppOpsService carries out validity checking to applicant.
The step S2-3 includes:
Step S2-3-1:AppOpsService service call askOperationLocked method,
Step S2-3-2: it is called in IOnCallback interface in askOperationLocked method
OnAddRequest method,
Step S2-3-3: the onAddRequest called in GroupPermissionCallback is communicated by binder
Method,
Step S2-3-4: message MSG_GROUP_PERMISSION_CHECK_PANEL is sent, in the processing of the message
It constructs a GroupPermissionsCheckPanelView object and shows.
Further, OnItemClickListener is realized in GroupPermissionsCheckPanelView object
With OnTouchListener interface, to respond the selection operation of user.
Further, all permissions of Android incorporate into as ten groups, are respectively: PRIVATE_INFO group, LOCATION_
INFO group, SYSTEM_INFO group, COST group, ACCOUNT_MGR group, HARDWARE_MGR group, WIRELESS_MGR group,
PHONE_MGR group, STORAGE_MGE group and NETWORK group.
Wherein PRIVATE_INFO group represent operation user's private data permission group, including short message, contact person, calendar,
Email etc..LOCATION_INFO group represents the permission group of position operation, including GPS positioning, WLAN positioning and data network
Positioning.SYSTEM_INFO group represents operating system application programming interfaces.
Based on the above group right management method, present invention further propose that a kind of Android group permission pipe based on callback mechanism
Reason system, comprising:
Application rights management unit carries out legitimacy inspection to applicant for the permission grant application of response application program
Look into, it is judged whether or not processed authorized application prompts, and judge in authorized application prompt whether include with
The authority items of application program authorization belong to same group of other authority items, adjust back the realization in authorized application prompt unit
Class;
Authorized application prompt unit includes that application program applies for that the authorized application of the authority items authorized mentions for issuing
Show.
Further, the application rights management unit includes authority library, and grouping stores all Android permissions in authority library.
Further, in authority library, all permissions of Android are incorporated into as ten groups, are respectively:
PRIVATE_INFO group, LOCATION_INFO group, SYSTEM_INFO group, COST group, ACCOUNT_MGR group,
HARDWARE_MGR group, WIRELESS_MGR group, PHONE_MGR group, STORAGE_MGE group and NETWORK group.
Wherein PRIVATE_INFO group represent operation user's private data permission group, including short message, contact person, calendar,
Email etc..LOCATION_INFO group represents the permission group of position operation, including GPS positioning, WLAN positioning and data network
Positioning.SYSTEM_INFO group represents operating system application programming interfaces.
Further, the application rights management unit includes AppOpsService service, is infused in AppOpsService
Volume has callback interface IOnCallback.
Further, the authorized application prompt unit includes SystemUI class, registers with readjustment in SystemUI class and connects
Mouth IOnCallback.
Further, AppOpsService is connected with SystemUI by IOnCallback interface, is passed through between the two
Binder communication.
Further, when SystemUI structural regime column, a customized View object is instantiated
GroupPermissionsCheckPanelView, the object represent a group permission prompting frame.
Further, when application program permission grant, AppOpsService carries out legitimacy inspection to applicant
It looks into.Inspection sorts out this application permission after passing through, and can finally call askOperationLocked method,
The onAddRequest method in IOnCallback interface is called in askOperationLocked method.And then pass through
The onAddRequest method in GroupPermissionCallback is called in binder communication, sends message MSG_GROUP_
PERMISSION_CHECK_PANEL constructs a GroupPermissionsCheckPanelView in the processing of the message
Object is simultaneously shown.
Further, if having permission application again when a group permission is really weighed and do not completed, equally operation application is closed
Method inspection, then sorts out, and the group is added to if belonging to the group having been displayed, as an item in group permission prompting frame
Mesh.If being not belonging to any group had been displayed, just a GroupPermissionsCheckPanelView object is instantiated simultaneously
Display.
Further, GroupPermissionsCheckPanelView object has realized OnItemClickListener
With OnTouchListener interface, the selection operation of user can be responded.
The invention has the advantages that: this group of rights management mechanisms based on callback mechanism to be grouped to all permissions, and will
Belonging to for occurring simultaneously collects in a prompt with the multiple permissions organized, and handles for user, application permission can be effectively reduced
The frequency of prompting frame pop-up when very much, to be brought convenience to user.The present invention has continued customized View mechanism simultaneously, can be simultaneously
The authority request of multiple permission groups is popped up, to improve the flexibility of system.
Detailed description of the invention
Fig. 1 is the Android group right management method flow diagram of the present invention based on callback mechanism.
Fig. 2 is the Android group Rights Management System tissue block diagram of the present invention based on callback mechanism.
Specific embodiment
Android group right management method and system to of the present invention based on callback mechanism in an illustrative manner below
It is described further.
The present invention is based on callback mechanisms to realize the group rights management in Android system, first to all permissions of Android system
Classify, the general character of certain operations is taken out, in order to centralized operation.As PRIVATE_INFO group represents operation user individual
Data, short message, contact person, calendar, Email etc..LOCATION_INFO group represents position operation, GPS positioning, WLAN positioning
With data network positions.SYSTEM_INFO group represents operating system application programming interfaces etc..
Then, the registered callbacks interface IOnCallback while in SystemUI and AppOpsService, when there is application
When applying for permission operation, client service is called by Binder operation requests being transmitted to rights management service
(AppOpsService).When such as Baidu map application positioning service, Location Request can pass through LocationManagerService
Service is transmitted to AppOpsService.Rights management service first does validity checking to this application, such as checks the body of applicant
Part, User ID etc., inspection again sorts out this operation after passing through, if the operation of accessing address list is grouped into PRIVATE_INFO group,
Positioning operation is grouped into LOCATION_INFO group etc..Recall the onAddRequest method in interface IOnCallBack.Simultaneously
This method in SystemUI can be adjusted back, a group permission prompt object can be instantiated in the method, which presents current
All group permissions applied in system.Wait the selection operation of user.
Several relatively preferred specific embodiments are given below based on the above design.In the examples below, Android is all
Permission be grouped.
Embodiment 1
Android group right management method of the present invention based on callback mechanism, comprising:
Step S0: while the registered callbacks interface IOnCallback in SystemUI and AppOpsService, Android are set
When standby structural regime column SystemUI, a customized View object is instantiated
GroupPermissionsCheckPanelView, the object represent a group permission prompting frame.It will by IOnCallback interface
Rights management service AppOpsService and system mode column connect, and are communicated between the two by Binder.
Step S1: a certain permission grant of application program.
Step S2-1: it is judged whether or not processed authorized application prompts, and include in authorized application prompt
There are the other permissions for belonging to same group with authority items applied in step S1 if the determination result is YES then to enter step S2-2,
If judging result be it is no, then follow the steps S2-3;
Step S2-2: authority items applied in step S1 are added described in step S2-1 as newly-increased entry then and are awarded
In power application prompt.
Step S2-3: the authorized application prompt comprising applied authority items in step S1 is issued.
Step S3: user selects authorization or refusal.
Embodiment 2
Android group right management method of the present invention based on callback mechanism, comprising:
Step S0: while the registered callbacks interface IOnCallback in SystemUI and AppOpsService, Android are set
When standby structural regime column SystemUI, a customized View object is instantiated
GroupPermissionsCheckPanelView, the object represent a group permission prompting frame.It will by IOnCallback interface
Rights management service AppOpsService and system mode column connect, and are communicated between the two by Binder.
Step S1: a certain permission grant of application program.
Step S2-0:AppOpsService carries out validity checking to applicant.
Step S2-1: it is judged whether or not processed authorized application prompts, and include in authorized application prompt
There are the other permissions for belonging to same group with authority items applied in step S1 if the determination result is YES then to enter step S2-2,
If judging result be it is no, then follow the steps S2-3;
Step S2-2: authority items applied in step S1 are added described in step S2-1 as newly-increased entry then and are awarded
In power application prompt.
Step S2-3-1:AppOpsService service call askOperationLocked method,
Step S2-3-2: it is called in IOnCallback interface in askOperationLocked method
OnAddRequest method,
Step S2-3-3: the onAddRequest called in GroupPermissionCallback is communicated by binder
Method,
Step S2-3-4: message MSG_GROUP_PERMISSION_CHECK_PANEL is sent, in the processing of the message
It constructs a GroupPermissionsCheckPanelView object and shows.
OnItemClickListener and OnTouchListener is realized in GroupPermissionsCheckPanelView object
Interface, to respond the selection operation of user.
Step S3: user selects authorization or refusal.
Embodiment 3
Android group Rights Management System of the present invention based on callback mechanism, comprising: application rights management unit and award
Power application prompt unit.The application rights management unit includes AppOpsService service, is registered in AppOpsService
There is callback interface IOnCallback.The authorized application prompt unit includes SystemUI class, is registered with back in SystemUI class
Adjust interface IOnCallback.AppOpsService is connected with SystemUI by IOnCallback interface, is passed through between the two
Binder communication.When the structural regime column SystemUI, a customized View object is instantiated
GroupPermissionsCheckPanelView, the object represent a group permission prompting frame.
Application rights management unit is used for the permission grant application of response application program, carries out legitimacy inspection to applicant
Look into, it is judged whether or not processed authorized application prompts, and judge in authorized application prompt whether include with
The authority items of application program authorization belong to same group of other authority items, adjust back the realization in authorized application prompt unit
Class.Authorized application prompt unit is used to issue the authorized application prompt for applying for the authority items of authorization comprising application program.
The application rights management unit includes authority library, and grouping stores all Android permissions in authority library.In authority library
In, all permissions of Android are grouped storage, such as the permission group of operation user's private data is represented with PRIVATE_INFO group,
Including short message, contact person, calendar and Email etc..LOCATION_INFO group represents the permission group of position operation, including GPS
Positioning, WLAN positioning and data network positions.SYSTEM_INFO group represents operating system application programming interfaces.
When application program permission grant, AppOpsService carries out validity checking to applicant.Inspection passes through
This application permission is sorted out afterwards, askOperationLocked method can be finally called, in the side askOperationLocked
The onAddRequest method in IOnCallback interface is called in method.And then it is communicated and is called by binder
OnAddRequest method in GroupPermissionCallback sends message MSG_GROUP_PERMISSION_
CHECK_PANEL constructs a GroupPermissionsCheckPanelView object and is shown in the processing of the message.
If having permission application again when a group permission is really weighed and do not completed, validity checking equally is done to operation application,
Then sort out, the group is added to if belonging to the group having been displayed, as an entry in group permission prompting frame.If do not belonged to
In any group had been displayed, just instantiates a GroupPermissionsCheckPanelView object and show.
GroupPermissionsCheckPanelView object has realized OnItemClickListener and OnTouchListener
Interface can respond the selection operation of user.
Embodiment 4
Referring to Fig. 2, all permissions of Android are incorporated into as ten groups in this example, are respectively: PRIVATE_INFO group,
LOCATION_INFO group, SYSTEM_INFO group, COST group, ACCOUNT_MGR group, HARDWARE_MGR group, WIRELESS_
MGR group, PHONE_MGR group, STORAGE_MGE group and NETWORK group.
It is real when the registered callbacks interface IOnCallback in SystemUI class, Android device structural regime column SystemUI
Exampleization one customized View object GroupPermissionsCheckPanelView, the object represent a group permission prompt
Frame.Rights management service AppOpsService and system mode column are connected by IOnCallback interface class, the two
Between pass through Binder communicate.When application program has permission request operation, AppOpsService service can be applicant respectively
Kind validity checking, inspection can apply for this operation classification after passing through.AskOperationLocked method can be finally called,
The onAddRequest method in IOnCallback interface is called in askOperationLocked method.And then pass through
The onAddRequest method in GroupPermissionCallback is called in binder communication.
GroupPermissionCallback realizes that the essence of realization is exactly to send to onAddRequest method
Message MSG_GROUP_PERMISSION_CHECK_PANEL constructs one in the processing of the message
GroupPermissionsCheckPanelView object is simultaneously shown.The object represents this group of authority application prompt.Such as
Fruit has permission application when a group permission is really weighed and do not completed again, equally validity checking is done to operation application, then to this
Application operation is sorted out, and the group is added to if belonging to the group having been displayed, as an entry in group permission prompting frame.If
It is not belonging to any group had been displayed, just instantiate a new GroupPermissionsCheckPanelView object and is shown.
GroupPermissionsCheckPanelView object realized OnItemClickListener and
OnTouchListener interface can respond the selection operation of user.
Embodiment 5
Fig. 2 show the Android group rights management system based on callback mechanism for realizing of the present invention group of right management method
System, including application rights management unit and authorized application prompt unit.
The application rights management unit includes AppOpsService service and authority library, and the authorized application prompt is single
Member includes SystemUI class.
Grouping stores all Android permissions in the authority library.In authority library, it is ten that all permissions of Android, which incorporate into,
Group is respectively: PRIVATE_INFO group, LOCATION_INFO group, SYSTEM_INFO group, COST group, ACCOUNT_MGR group,
HARDWARE_MGR group, WIRELESS_MGR group, PHONE_MGR group, STORAGE_MGE group and NETWORK group.
AppOpsService is connected with SystemUI by callback interface IOnCallback, passes through Binder between the two
Communication.
When the structural regime column SystemUI, a customized View object is instantiated
GroupPermissionsCheckPanelView, the object represent a group permission prompting frame.When application program permission is awarded
Temporary, AppOpsService carries out validity checking to applicant.Inspection sorts out this application permission after passing through, and finally adjusts
With askOperationLocked method, called in IOnCallback interface in askOperationLocked method
OnAddRequest method.And then it is communicated and is called in GroupPermissionCallback by binder
OnAddRequest method, the onAddRequest method can send message MSG_GROUP_PERMISSION_CHECK_
PANEL constructs a GroupPermissionsCheckPanelView object and is shown in the processing of the message.If
One group permission is really weighed has permission application when not completing again, equally does validity checking to operation application, then sorts out, if belonged to
It is just added to the group in the group having been displayed, as an entry in group permission prompting frame.If being not belonging to have been displayed any
Group just instantiates a GroupPermissionsCheckPanelView object and shows.
The above content is the explanation to technical solution of the present invention, the limit made not directed to the scope of the present invention
It is fixed, it is contemplated that, it is any to be based on inventive concept proposed by the present invention, in conjunction with this field Conventional wisdom without creative labor and
The specific embodiment made belongs to that a kind of implementation of the invention should be fallen within the scope of the invention.