Re: [android-developers] Custom Service Permission

2010-08-30 Thread Alvin Tsai
Hi KilicBeg,

Have you managed to figure it out? I have the same problem.

My problem simply is adding a custom permission like
android.permission.CAMERA to allow user use some custom
hardware feature. I've added one in platform.xml but failed in
checkCallingPermission(String16(android.permission.MY_PERMISSION))
when client connect to service.

So my question is
1. is it possible to add custom permission in android?
2. how to do it if it is feasible?

BTW, i know that my question may better post into android-post because it
derives from custom hardware,
but i post it here because i do not think this problem is
hardware-independent and hoping for more help.

Cheers,
- rookie

On Tue, Mar 9, 2010 at 6:55 AM, KilicBeg  wrote:

> Hi,
>
> I am unable to access my custom service after setting permission.
> 03-08 16:38:15.730: WARN/ActivityManager(53): Permission Denial:
> Accessing service ComponentInfo{com.kilic.service/
> com.kilic.service.AdditionService} from pid=235, uid=10026 requires
> com.kilic.service.permission.MY_FIRST_SERVICE
> 03-08 16:41:53.141: INFO/System.out(314): Not allowed to bind to
> service Intent { act=com.kilic.service.IAdditionService }
>
> If I remove the permission everything works fine. Is there anything
> special I need to do in the client manifest other than  permission> ?
>
> Here is my code snippet for the service:
>
> package com.kilic.service;
>
> import android.app.Service;
> import android.content.Intent;
> import android.content.pm.PackageManager;
> import android.os.IBinder;
> import android.util.Log;
>
> /**
>  * This class exposes the remote service to the client
>  */
> public class AdditionService extends Service {
>  private static final String TAG = "AdditionService";
>
>
>  private final IAdditionService.Stub binder=new
> IAdditionService.Stub() {
>public int add(int value1, int value2) {
>  Log.d(TAG, String.format("AdditionService.add(%d,
> %d)",value1, value2));
>return toppla(value1, value2);
>}
>  };
>
>  @Override
>  public void onCreate() {
>super.onCreate();
>Log.d(TAG, "onCreate()");
>  }
>
>  @Override
>  public IBinder onBind(Intent intent)
>  {
>  //if(intent.getAction() != null &&
> intent.getAction().equals(ACTION_SERVICE_MANAGEMENT)) {
>  // check permission
>  System.out.println("intent.getAction() = " + intent.getAction());
>
>
> if(this.checkCallingPermission("com.kilic.service.permission.MY_FIRST_SERVICE")
> == PackageManager.PERMISSION_DENIED) {
> //  Log.d(TAG, "Checked for permission:
> " + PERMISSION_MANAGEMENT
> + "\nresult: " + checkCallingPermission(PERMISSION_MANAGEMENT));
>  Log.d(TAG, "Checked for
> permission: \nresult: " +
> checkCallingPermission("com.kilic.service.permission.MY_FIRST_SERVICE"));
>  throw new SecurityException();
>}
>  // return management binder
>//return (binder);
>  //}
>
>  Log.d(TAG, "onBind finished");
>  // call was not local so return public binder
>  return (binder);
>  }
>
>  /*
>  @Override
>  public IBinder onBind(Intent intent) {
>
>return (binder);
>
>  } */
>
> /**
>  * Implementation of the add() method
>  */
>  private int toppla(int value1, int value2) {
>  Log.d(TAG, String.format("AdditionService.toppla(%d,
> %d)",value1, value2));
>  return value1 + value2;
>  }
>
>
>  @Override
>  public void onDestroy() {
>super.onDestroy();
>Log.d(TAG, "onDestroy()");
>  }
> }
>
> --
> 
> http://schemas.android.com/apk/res/android";
>  package="com.kilic.service"
>  android:versionCode="1"
>  android:versionName="1.0">
>
>
> android:permission="com.kilic.service.permission.MY_FIRST_SERVICE"
> android:process=":remote"
> android:enabled="true"
> android:exported="true">
>
>
> android:name="com.kilic.service.IAdditionService" />
>
>
>
>
>  android:name="com.kilic.service.permission.MY_FIRST_SERVICE"> permission>
>
> 
>
> ===
> And this is the client code:
>
> package com.kilic.service.client;
>
> import com.kilic.service.client.R;
> import android.app.Activity;
> import android.content.ComponentName;
> import android.content.Context;
> import android.content.Intent;
> import android.content.ServiceConnection;
> import android.os.Bundle;
> import android.os.IBinder;
> import android.os.RemoteException;
> import android.util.Log;
> import android.view.View;
> import android.view.View.OnClickListener;
> import android.widget.Button;
> import android.

Re: [android-developers] Re: how to overcome "permission denied" error when SystemProperties.set

2010-03-11 Thread Alvin Tsai
Thanks Makas, yes, I am customizing the Android platform, I'll also redirect
it to android-platform mail-list.

However, I think my problem is also related to android permission rule that
developer may encounter.
because not only the property I create can not be set, but also the
traditional system property like debug.egl.hw can not
be set via SystemProperties.set().

BTW, I met this problem on android donut.

Thanks
- superrookie

On Fri, Mar 12, 2010 at 6:16 AM, Makas Tzavellas
wrote:

> SystemProperties is not a publicly available class. Are you
> customizing the Android platform? If you are then you are probably
> better off asking in the android-platform group. Otherwise that
> basically means you cannot set the property as you are not even
> suppose to have access to the class via the public api.
>
> On Mar 11, 2:48 pm, superrookie  wrote:
> > Hi All,
> >
> > I have a system property named "my.sys.property", and able to get its
> > value by SystemProperties.get(),
> > but when I set it using SystemProperties.set("my.sys.property",
> > "value"), i got error saying that
> >
> > > init: sys_prop: permission denied uid:10003  name:my.sys.property
> >
> > I've search same problem and try to make some effort to overcome it,
> > including:
> > 1. modify android:sharedUserId="android.uid." in
> > AndroidManifest.xml
> > 2. add some write-related uses-permission in AndroidManifest.xml
> > 3. add property_perms in system/core/init/property_service.c because i
> > find error comes from there
> >
> > but the problem still occur: (
> > Does anybody here have idea about how to fix this problem?
> >
> > Thanks
> > - superrookie
>
> --
> 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
>

-- 
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