Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 205
Registered: ‎07-14-2008
My Device: 7230, 8700, 8820, 9000

ApplicationPermissions and ApplicationMenuItem issue

Hello,

I believe I have uncovered a bug related to how application permissions are maintained. In an ApplicationMenuItem's run() context, the ApplicationPermissionsManager.invokePermissionRequest(...) is being called in the context of the calling application rather than the application of the ApplicationMenuItem.

 

The bug can be reproduced through the following scenario:

 

The Application requires PERMISSION_CROSS_APPLICATION_COMMUNICATION to startup.  When the user attempts to perform an action, PERMISSION_RECORDING, PERMISSION_FILE_API must be granted.  An ApplicationPermissionsManager prompt is made whenever permissions are required to complete an action. The prompt clearly indicates that:  "Application is requesting changes to its application control permissions."

 

The user only grants the application PERMISSION_CROSS_APPLICATION_COMMUNICATION.

 

At startup, the application registers a MENUITEM_SYSTEM ApplicationMenuItem.

 

When the installed ApplicationMenuItem is invoked, the ApplicationPermissionsManager prompts the user for the three required permissions.  Except the application requesting changes is the "BlackBerry 4.6 Core Applications".  Specifically, it is the SecurIDLib module that wants the required permissions.  This is clearly incorrect and misleading to the user.  My application is requesting the user to give permissions to an alternate application.  If I grant the permissions then the action still fails (because the permissions were granted to "BlackBerry 4.6 Core Applications" and not my Application).  The code for requesting permissions inside of the ApplicationMenuItem is provided below.

 

I believe that ApplicationPermissionsManager.invokePermissionRequest( requesed permission) should be called in the context of the Application rather than the "BlackBerry 4.6 Core Applications".

 

As a work around, if I grant the required permissions in Application then the ApplicationMenuItem has the required priviledges and never prompts the user to adjust the permissions of the ""BlackBerry 4.6 Core Applications".

 

Earl

 

// Try to setup the recording permissions ApplicationPermissionsManager pManager = ApplicationPermissionsManager.getInstance(); if (pManager.getPermission(ApplicationPermissions.PERMISSION_RECORDING) != ApplicationPermissions.VALUE_ALLOW || pManager.getPermission(ApplicationPermissions.PERMISSION_FILE_API) != ApplicationPermissions.VALUE_ALLOW || pManager.getPermission(ApplicationPermissions.PERMISSION_CROSS_APPLICATION_COMMUNICATION) != ApplicationPermissions.VALUE_ALLOW) { ApplicationPermissions pAppPermission = new ApplicationPermissions(); pAppPermission.addPermission( ApplicationPermissions.PERMISSION_RECORDING); pAppPermission.addPermission( ApplicationPermissions.PERMISSION_FILE_API); pAppPermission.addPermission( ApplicationPermissions.PERMISSION_CROSS_APPLICATION_COMMUNICATION); if (! pManager.invokePermissionsRequest(pAppPermission)) { // The app does not have permission to capture any images. // The capture will later fail. return false; } } return true;

 

 

 

 

 

 

 

 

 

 

 

Earl Oliver
Developer
Posts: 205
Registered: ‎07-14-2008
My Device: 7230, 8700, 8820, 9000

Re: ApplicationPermissions and ApplicationMenuItem issue

I forgot to mention that I am running App Version 4.6.0.162.

Earl Oliver
BlackBerry Development Advisor
Posts: 14,952
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: ApplicationPermissions and ApplicationMenuItem issue

The is the expected behaviour based on the design of an ApplicationMenuItem (and many of the listener interfaces in the BlackBerry API set).

 

The run method of an ApplicationMenuItem is executed in a different process than your main application (that registered the ApplicationMenuItem).  When a request to change permissions is invoked, it is done so for the application who's process is executing the code. 

 

This means that the permission request should be made by the application that is registering the ApplicationMenuItem, not within the run method.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker