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

Native Development

Reply
Regular Contributor
cmr1990
Posts: 59
Registered: ‎10-16-2013
My Carrier: vodaphone

unable to use SimCardState, permission denied

i need to use the functions in SimCardState, specifically the state of the sim card.

https://developer.blackberry.com/native/reference/cascades/bb__device__simcardinfo.html

as mentioned in the documentation, i have set the 'read_device_identifying_information' permission.

in spite of that, i get an error as :

SimCardInfo - failed to open restricted PPS object:  "Permission denied" 

i'm using native sdk 10.1 (cpp) and using Z10 10.1..

please help!!

Please use plain text.
BlackBerry Development Advisor
mwoolley
Posts: 558
Registered: ‎06-25-2010
My Carrier: Vodafone

Re: unable to use SimCardState, permission denied

Hi

 

I'm seeing the same permission denied error in the console:

 

SimCardInfo - failed to open restricted PPS object:  "Permission denied" 

 

But access to SimCardState seems to be working all the same. If you ignore the message in the log, are you in fact getting a value returned for this property? Here's (most of) my code:

 

import bb.cascades 1.0
import bb.multimedia 1.0

TabbedPane {
    id: main
    objectName: "main"
    showTabsOnActionBar: true

    function simStateName(state) {
        switch (state) {
            case 0:
                return "Not Detected";
                break;
            case 1:
                return "Incompatible";
                break;
            case 2:
                return "Not Provisioned";
                break;
            case 3:
                return "Read Error";
                break;
            case 4:
                return "PIN Required";
                break;
            case 5:
                return "Ready";
                break;
            default:
                return "Unknown";
        }
    }

    Tab {
        id: sim_tab
        imageSource: "asset:///images/sim_card.png"
        title: "SIM Info"
        Page {
            Container {
                layout: StackLayout {
                }
                Label {
                    text: qsTr("SIM Card Info")
                    textStyle.base: SystemDefaults.TextStyles.TitleText
                    verticalAlignment: VerticalAlignment.Center
                    horizontalAlignment: HorizontalAlignment.Center
                }
                Container {
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    Label {
                        id: lbl_mcc
                        text: qsTr("MCC")
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 40
                        }
                    }
                    Label {
                        id: val_mcc
                        text: sim.mobileCountryCode
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 60
                        }
                    }
                }
                Container {
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    Label {
                        id: lbl_mnc
                        text: qsTr("MNC")
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 40
                        }
                    }
                    Label {
                        id: val_mnc
                        text: sim.mobileNetworkCode
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 60
                        }
                    }
                }
                Container {
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    Label {
                        id: lbl_sno
                        text: qsTr("Serial Number")
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 40
                        }
                    }
                    Label {
                        id: val_sno
                        text: sim.serialNumber
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 60
                        }
                    }
                }
                Container {
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    Label {
                        id: lbl_state
                        text: qsTr("State")
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 40
                        }
                    }
                    Label {
                        id: val_state
                        text: simStateName(sim.state)
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                        layoutProperties: StackLayoutProperties {
                            spaceQuota: 60
                        }
                    }
                }
            }
        }
    }
}

 

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        QObject(app)
, _sim(new bb::device::SimCardInfo(this))
{
.......
}

 

class ApplicationUI : public QObject
{
    Q_OBJECT
public:
    ApplicationUI(bb::cascades::Application *app);
    virtual ~ApplicationUI();
    bb::device::SimCardInfo *_sim;

 and a screen shot:

 

IMG_00000013.png

 

 

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.