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
jdesmedt
Posts: 118
Registered: ‎06-24-2009
My Device: Not Specified
Accepted Solution

Permissions

Hello,

 

I want to set my application permissions at startup, but I can't find which permissions to set...

These are the permissions I need:

- Connection (Bluetooth, wifi)

- Inject events

- read/write files

 

Can someone tell me which permissions I have to check? Or where I can find the info I need? The API's don't give any information on the meaning of the properties...

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Permissions

You want to take a look at "net.rim.device.api.applicationcontrol", take a look at the classes and interface.

 

I have one application that sets permissions at startup, the main function creates and pushes a screen. In the screen's constructor I call super(); followed by a call to setupPermissions();

 

private void setupPermissions()
{
    ApplicationPermissionsManager man = ApplicationPermissionsManager.getInstance();
    int[] requiredPerms = new int[] { ApplicationPermissions.PERMISSION_MEDIA, ApplicationPermissions.PERMISSION_RECORDING, ApplicationPermissions.PERMISSION_FILE_API };
    ApplicationPermissions perms = man.getApplicationPermissions();
    boolean change = false;
    for(int i = 0; i < requiredPerms.length; i++)
    {
        if(perms.containsPermissionKey(requiredPerms[i]))
        {
            if(perms.getPermission(requiredPerms[i]) != ApplicationPermissions.VALUE_ALLOW)
            {
                change = true;
                perms.addPermission(requiredPerms[i]);
            }
        }
        else
        {
            change = true;
            perms.addPermission(requiredPerms[i]);
        }
    }
    if(change)
    {
        man.invokePermissionsRequest(perms);
    }
}

 Though I don't have it implemented I would like to implement ReasonProvider because it drives me nuts when a application requires a permission for something that seems totally unrelated to the application (such as a calculator that requires BlueTooth access. Why?).

 

As for what you need:

  • Connection->PERMISSION_WIFI and PERMISSION_BLUETOOTH
  • Inject events->PERMISSION_INPUT_SIMULATION
  • read/write files->PERMISSION_FILE_API

 

 

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
jeffsims
Posts: 37
Registered: ‎04-03-2009
My Device: Not Specified

Re: Permissions

You can look at this link for the API reference 4.6.1

 

4.6.1 API Reference

 

Then look at the API call ApplicationPermissions

 

You need these :

 

PERMISSION_BLUETOOTH 

PERMISSION_INPUT_SIMULATION

PERMISSION_INTERNET 

PERMISSION_WIFI 

PERMISSION_FILE_API 



 

Developer
jdesmedt
Posts: 118
Registered: ‎06-24-2009
My Device: Not Specified

Re: Permissions

When I invoke the permissions request, I get the following Dialog:

"Application downloads or admin changes require device to reboot for approx 2 minutes. Device inoperable for voice, data and 911 while rebooting. Notice 1 of 5." REBOOT NOW / REBOOT LATER

 

Why do I get this and how can it be avoided...

Developer
jdesmedt
Posts: 118
Registered: ‎06-24-2009
My Device: Not Specified

Re: Permissions

I have another problem: my application has all permissions set to allow and still DeviceInfo.canResetSecurityTimer() returns false...

I have set my application properties manually in Options > Advanced options > Application permissions

Could the above problem be related to the fact that my app is not visible in the application list (but it is available when I press Menu > Modules)?

 

Thanks in advance

Developer
jdesmedt
Posts: 118
Registered: ‎06-24-2009
My Device: Not Specified

Re: Permissions

Anyone?

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Permissions

The device needs to reboot if you have system listeners (I think). Just an educated guess: When you apply for permission changes to be applied the COD module must be "reloaded" but because you have a system listener or your app is a dependency for another app (those are the reasons why a BlackBerry would need to restart) the module cannot just be reloaded it needs the device to restart to prevent breaks in functionality. I don't know how to avoid this when doing application permissions at run time instead of install time (you know, you install an application and before it even downloads it asks you to accept a set of permissions).

 

As for the "canResetSecurityTimer" I don't see that in my documentation. Just from the name you would need to set the PERMISSION_IDLE_TIMER permission. Wait, "Idle Timer", I have that. If that is what you are trying to do then check the documentation because it explains the logic for determining if it returns true or false.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
jdesmedt
Posts: 118
Registered: ‎06-24-2009
My Device: Not Specified

Re: Permissions

The method is indeed DeviceInfo.canResetIdleTime() (sorry for the mistake)

 

How can you set permissions at install time?

Developer
jeffsims
Posts: 37
Registered: ‎04-03-2009
My Device: Not Specified

Re: Permissions

[ Edited ]

Not sure if this is the best way.  You could have an alternate entrty point into your app that runs on startup and just have it check the permiissions and then exit.  This may get run at install time.

 

Developer
jdesmedt
Posts: 118
Registered: ‎06-24-2009
My Device: Not Specified

Re: Permissions

The reason why I need to reset the Security timer is because my app is a video-playing app. If I want to show videos that are longer then the lock-timout, I need to be able to reset the timer (or the lock screen is showed while the video is playing).

 

Am I correct when I say that on BB devices that have ALLOW_RESET_IDLE_TIMER false in their IT Policy, it is not possible the prevent the lock screen from showing?