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: 91
Registered: ‎02-04-2009
My Device: Not Specified
Accepted Solution

ControlledAccessException on addGlobalEventListener

I've added a global event listener to my UiApplication.  On most devices I've tested on, it works well.  However, it was just brought to my attention that the call to addGlobalEventListener sometimes throws a ControlledAccessException.  I know this means my application requires an additional permission, but it's unclear which one I need.  I'm using ApplicationPermissionsManager at startup to request other permissions and I'd like to do the same for whatever permission I need for addGlobalEventListener.  None of the constants in ApplicationPermissions sound like what I want.  Any ideas?

BlackBerry Development Advisor
Posts: 15,207
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: ControlledAccessException on addGlobalEventListener

The ApplicationPermission.PERMISSION_CROSS_APPLICATION_COMMUNICATION constant applies to the GlobalEventListener.
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
Developer
Posts: 91
Registered: ‎02-04-2009
My Device: Not Specified

Re: ControlledAccessException on addGlobalEventListener

Great, thanks Mark.  I've found that I need PERMISSION_DEVICE_SETTINGS on some phones too, otherwise the phones freezes when the user tries to save the permissions changes.
New Developer
Posts: 5
Registered: ‎09-22-2009
My Device: Not Specified

Re: ControlledAccessException on addGlobalEventListener

We are also facing similar issue with our application and its built using JDE 4_21. I could not find any classes related to ApplicationPermissions in 4_21 library.

 

And more over this happens on few devices (9630 Tour and Curve) and only sometimes. I was wondering why would this happen on few devices and only sometimes. Is it something to do with OS and device? 

 

How can fix this issue?  Your help is great;y appreciated.

 

 

guid:0x9C3CD62E3320B498 time: Thu Sep 17 17:15:57 2009  severity:1 type:3 app:Java Exception data:
 ControlledAccessException
 No detail message
 net_rim_cldc-16(4A42F4E8)
  ApplicationControlImpl
  assertIPCAllowed
  0x2D1A
 net_rim_cldc-16(4A42F4E8)
  ApplicationControl
  assertIPCAllowed
  0x129B
 net_rim_cldc-6(4A42F4E8)
  Application
  addGlobalEventListener
  0x1852
 

 

New Developer
Posts: 5
Registered: ‎09-22-2009
My Device: Not Specified

Re: ControlledAccessException on addGlobalEventListener

Minor correction. 

            I do see ApplicationPermissions class but dont see constant PERMISSION_DEVICE_SETTINGS.

Developer
Posts: 91
Registered: ‎02-04-2009
My Device: Not Specified

Re: ControlledAccessException on addGlobalEventListener

In 4.2.1, the permissions you want are called PERMISSION_INTER_PROCESS_COMMUNUCATION and PERMISSION_CHANGE_DEVICE_SETTINGS.  Please notice that "communication" is misspelled as "communucation" in 4.2.1.
New Developer
Posts: 5
Registered: ‎09-22-2009
My Device: Not Specified

Re: ControlledAccessException on addGlobalEventListener

When our application is installed user see the APplication Permissions message. "Would you like to  grant XXXX Trusted Application Status?" and user clicks on "Yes".

 

Inspite of user selecting Yes for application permission we see this Controlled Access Exception sometimes.

 

How can we fix this? Is there any reason why this is happening on some devices and only at certain times?

 

How can we fix this in the code? Do we have to set the ApplicationPermissions explicitily from the code?

 

Do you have any sample code which we can use?

 

Thanks almedia so much for your help.

Developer
Posts: 91
Registered: ‎02-04-2009
My Device: Not Specified

Re: ControlledAccessException on addGlobalEventListener

There are lots of API methods that throw a ControlledAccessException.  You should get the stack trace from the log and figure out what caused it.

 

You can check if a permission has been granted to your application with the ApplicationPermissionManager.  If you determine that you do not have the appropriate permissions, you can invoke a permission request on the manager and pass an ApplicationPermissions object.

 

 

ApplicationPermissionsManager manager = ApplicationPermissionsManager.getInstance();

if (manager.getPermission(ApplicationPermissions.PERMISSION_CHANGE_DEVICE_SETTINGS) != ApplicationPermissions.VALUE_ALLOW) {

ApplicationPermissions permissions = manager.getApplicationPermissions();

permissions.addPermission(ApplicationPermissions.PERMISSION_CHANGE_DEVICE_SETTINGS);

manager.invokePermissionsRequest(permissions);

}

 

 The return value of invokePermissionsRequest tells you if it worked.  You can do addPermission for all the permissions that your application needs and then pass the whole thing to invokePermissionsRequest.  The system will handle prompting the user for the changes.

 

New Developer
Posts: 5
Registered: ‎09-22-2009
My Device: Not Specified

Re: ControlledAccessException on addGlobalEventListener

Thanks for the quick response.

 

We did analyze the stack trace and noticed that it is failing at addGlobalEventListener

 

guid:0x9C3CD62E3320B498 time: Thu Sep 17 17:15:57 2009  severity:1 type:3 app:Java Exception data:
 ControlledAccessException
 No detail message
 net_rim_cldc-16(4A42F4E8)
  ApplicationControlImpl
  assertIPCAllowed
  0x2D1A
 net_rim_cldc-16(4A42F4E8)
  ApplicationControl
  assertIPCAllowed
  0x129B
 net_rim_cldc-6(4A42F4E8)
  Application
  addGlobalEventListener
  0x1852
 ETradeMobileProApp-4(4A5D1D17)
  ETradeMobileProApplication
  doInitialization
  0x1AF
 ETradeMobileProSplash(4A5D1D2A)
  ETradeMobileProStartup$1
  run
  0x412
 net_rim_cldc-1(4A42F4E8)
  Thread
  run
  0xB3F1

Developer
Posts: 91
Registered: ‎02-04-2009
My Device: Not Specified

Re: ControlledAccessException on addGlobalEventListener

Okay, then take the code I posted above and just add a check and request for PERMISSION_INTER_PROCESS_COMMUNUCATION.