question

clover912 avatar image
clover912 asked Jeffrey Blattman commented

clover permission clover.permission.POP_CASH_DRAWER not granted

This was working perfectly for me a week or so ago I'm not sure what changed. My current permissions requests looks like this:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="clover.permission.POP_CASH_DRAWER" />
When I try to use the CashDrawers class in the sdk it gives me the exception "Application is not granted permission: clover.permission.POP_CASH_DRAWER". Why would it not grant this permission? It was working before.




Clover Android SDK
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lee Tickett avatar image Lee Tickett commented ·

did you ever resolve this?

0 Likes 0 ·
chanel avatar image
chanel Deactivated answered Lee Tickett commented
This is due to Android no longer allowing apps with different signatures to define the same permissions. We have released a new permission in sandbox that will be released in production in the future. More information can be found here.
6 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lee Tickett avatar image Lee Tickett commented ·

I'm not convinced this is related. I am familiar with that issue and it presents itself in a different manner (prevents the app being installed).

0 Likes 0 ·
justina avatar image justina Lee Tickett commented ·

@Lee Tickett The POP_CASH_DRAWER permission was previously defined in the clover-android-sdk. It was removed in order to account for cases where multiple apps would define the permission through the sdk, which is why the "Application is not granted permission: clover.permission.POP_CASH_DRAWER" exception is thrown.

The fix in the link @Chanel posted details the introduction of a new cash drawer permission that is now defined in a core Clover application rather than within the sdk. This ensures that it will only ever be defined within one application.

<uses-permission android="clover.permission.POP_CASH_DRAWER_NEW"/> should now be used, replacing the original POP_CASH_DRAWER.

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ justina commented ·

Why don't you try the solution and let us know if it works?

0 Likes 0 ·
Show more comments
Jeffrey Blattman avatar image
Jeffrey Blattman answered Jeffrey Blattman commented
@Lee Tickett adding a new answer so as not to write all this in a comment.

You are right, the fix was not properly deployed. We are working to get the SDK updated. In the mean time, can you try this version?
https://drive.google.com/file/d/1ODauMfTy7sKD-vAbs...

No magic. All I did was edit the permission check out of the code (and you can get the source and do the same thing if you want). It'd be better if you could wait for the official fix before going live but not a big deal.

Take a look at this:
https://stackoverflow.com/questions/16682847/how-t...

To see how to add a dependency that's in your file system. I think it'd be something like,
    compile 'com.clover.sdk:clover-android-sdk:191.4.1'
(I called the hacked version 191.4.1).

P.S. I forgot the first rule of answering questions and didn't ask what you are actually trying to do. If you are simply trying to open a cash drawer where the cash drawer is connected through a Clover-supported printer or connected to a Clover hub (such as in Station 2), you can use the CashDrawer class (not the CashDrawer s class, sigh). CashDrawer s is meant as a generalized solution for opening any cash drawer type, although it only supports Clover and APG USB cash drawers now.
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lee Tickett avatar image Lee Tickett commented ·

Cracking- although I couldn't quite figure out the file you attached (it wasn't what i expected).

I looked at your hint at the end which led me to poke around clover-android-sdk-191.4-sources.jar (com\clover\sdk\cashdrawer\StationPrinterCashDrawer.java) from which I then stole a few bits of code and came up with;

com.clover.sdk.v1.printer.CashDrawer.open(this, mAccount, new Printer.Builder().type(Type.SEIKO_USB).category(Category.RECEIPT).build());

I'm guessing I could alternatively have modified CashDrawers.java and tweaked the checkPermission() method to bypass the check?

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ Lee Tickett commented ·

The file I linked is an AAR which is Android's library archive format. It's the same thing that ends up getting downloaded from an external repo (except I modified it). The links I provided are showing you how to reference a local file for the dependency instead of going online to a repository to get it.

Yes, you can use a code snippet like that. I don't think it's quite correct though. You'll need to use `PrinterConnector` to get the printer object. Or you can use the "open any" version of the method with the caveat that it's going to open any connected cash drawer regardless of what device and to which printer it's connected.

Yes, the code mod you mentioned is exactly what I did in the linked file.

0 Likes 0 ·

Welcome to the
Clover Developer Community