Hi, my current problem is to access my own service. The thing is I have 2 interfaces for my service and want to restrict one of them to applications that have a special permission.
I have a service and an activity in one package. The application has that special permission but I always get a security exception: I've tried the to following things: 1) put the check inside the onBind() method: @Override public IBinder onBind(Intent intent) { if(intent.getAction() != null && intent.getAction().equals(ACTION_SERVICE_MANAGEMENT)) { // check permission if(checkCallingPermission(PERMISSION_MANAGEMENT) == PackageManager.PERMISSION_DENIED) { Log.d(TAG, "Checked for permission: " + PERMISSION_MANAGEMENT + "\nresult: " + checkCallingPermission(PERMISSION_MANAGEMENT)); throw new SecurityException(); } // return management binder return mManagementBinder; } if(_DEBUG) Log.d(TAG, "onBind finished"); // call was not local so return public binder return mBinder; } 2) ptu the check inside a method of the binder it self: private IServiceManagement.Stub mManagementBinder = new IServiceManagement.Stub() { public String[] getRoles() throws RemoteException { return PDPService.this.getRoles(); } public void updatePolicy(String policyuri) { // check permission if(checkCallingPermission(PERMISSION_MANAGEMENT) == PackageManager.PERMISSION_DENIED) { Log.d(TAG, "Checked for permission: " + PERMISSION_MANAGEMENT + "\nresult: " + checkCallingPermission(PERMISSION_MANAGEMENT)); throw new SecurityException(); } Uri uri = Uri.parse(policyuri); Service.this.updateFile(uri, Service.POLICY_FILE); } } both cases end with a security exception (the one I throw). The result of checkCallingPermission is always -1 (PackageManager.PERMISSION_DENIED). I have doublechecked that the name of the permission in code is the same as the one specified in the manifest file. What am I doing wrong? Thanks for help --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---