well ok i understand the risk..and i will change the architecture
but anyway i have a problem to bind to a service of another apk even
if its attribute is exported=true
i wonder if i do someting wrong in my procedure:

in the remote apk i generate an interface from an aidl file and make a
service and with an anonymous class in it
that extends MyInterface.Stub.

In the client package i have an activity that has an object of type
MyInterface (that is the mservice object of type IGps in the example
above ) that i use it in order to call the methods exposed by my
remote service.However i don't have visibility of that interface since
it is in a remote package so i copy/paste the aidl from the remote
package into my client package and generate the interface as well ( i
also change the package name in the aidl file to that of my client
package) so now i have visibility of the ineterface..but this does not
seem to work ..do i make any mistake?

On 13 Φεβ, 22:07, Dianne Hackborn <[email protected]> wrote:
> If you haven't declared an <intent-filter> in your manifest, then the
> component will be private to that .apk.  You can make it public with either
> android:exported="true" or defining an intent-filter.
>
> HOWEVER..  PLEASE be super careful about doing this.  Did you realize that
> you are in the process of creating a nice big security hole, where you let
> any application get the user's current location without needing permission?
>
> Why are you doing this?  The location APIs let applications get the current
> location.  Why are you republishing that information in your own service?
>  And why does this need to be in a separate .apk?
>
> My first instinct is for you to just not do this.  Please.  If you really
> think you need to do it, you need to seriously think about what you are
> doing with security.  You would be very much best off putting all of this
> stuff in one .apk so you don't leak information to others.  If for some
> reason you really think you need to have this separate (and take the
> overhead of multiple processes and all that), then you need to step back and
> take serious consideration of security and applying permissions to enforce
> it, how your .apks are signed, install ordering issues with granting
> permissions, etc.
>
> 2010/2/13 dane131 <[email protected]>
>
>
>
>
>
> > anybody help?
>
> > On 13 Φεβ, 00:44, dane131 <[email protected]> wrote:
> > > hallo i have aservicethat provides gps coordinates.Here is the
> > > code :
>
> > > package app.suite.gps;
>
> > > import android.app.Service;
> > > import android.content.Context;
> > > import android.content.Intent;
> > > import android.location.Location;
> > > import android.location.LocationListener;
> > > import android.location.LocationManager;
> > > import android.os.Bundle;
> > > import android.os.IBinder;
> > > import android.os.RemoteException;
> > > import app.suite.gps.IGps;
>
> > > public class Service_impl extendsServiceimplements LocationListener{
>
> > >         double lat=37.96568 ;
> > >         double lng=23.71382;
>
> > >         @Override
> > >         public IBinder onBind(Intent arg0) {
> > >                 // TODO Auto-generated method stub
> > >                 LocationManager lm =
> > > (LocationManager)getSystemService(Context.LOCATION_SERVICE);
> > >             lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,
> > 1000L,
> > > 500.0f, this);
> > >             return mBinder;
> > >         }
>
> > > private final IGps.Stub mBinder = new IGps.Stub() {
>
> > >                 @Override
> > >                 public double getLat() throws RemoteException {
>
> > >                         return lat;
> > >                 }
>
> > >                 @Override
> > >                 public double getLng() throws RemoteException {
>
> > >                         return lng;
> > >                 }
> > >     };
>
> > >         public void onLocationChanged(Location location) {
> > >                 if (location != null)
> > >                 {
> > >                         lat = location.getLatitude(); ;
> > >                         lng = location.getLongitude();
> > >                 }
>
> > >         }
>
> > >         @Override
> > >         public void onProviderDisabled(String arg0) {
> > >                 // TODO Auto-generated method stub
>
> > >         }
>
> > >         @Override
> > >         public void onProviderEnabled(String arg0) {
> > >                 // TODO Auto-generated method stub
>
> > >         }
>
> > >         @Override
> > >         public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
> > >                 // TODO Auto-generated method stub
>
> > >         }
>
> > > }
>
> > > i want tobindto thisservicefrom another application which uses the
> > > following piece of code :
>
> > > package app.suite.client;
>
> > > import android.app.Activity;
> > > import android.content.ComponentName;
> > > 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.widget.Button;
> > > import android.widget.TextView;
> > > public class Client extends Activity
> > > {
> > >     IGps mservice=null;
>
> > >     ServiceConnection conn=new ServiceConnection() {
>
> > >                 @Override
> > >                 public void onServiceDisconnected(ComponentName name) {
> > >                         Log.e("TAG","DISCONNECTED");
>
> > >                 }
>
> > >                 @Override
> > >                 public void onServiceConnected(ComponentName name,
> > IBinderservice)
> > > {
>
> > >                 mservice=IGps.Stub.asInterface(service);
> > >                         try
> > >                         {
> > >                         double a=mservice.getLat();
> > >                         String a_str=Double.toString(a);
> > >                         Log.e("TAG",a_str);
> > >                         }
> > >                         catch(RemoteException e)
> > >                         {
>
> > >                         }
>
> > >                 }
> > >         };
> > >      public void onCreate(Bundle icicle)
> > >      {
> > >           super.onCreate(icicle);
> > >           setContentView(R.layout.main);
>
> > >         Intentservice= new Intent();
> > >        service.setComponent(new
> > > ComponentName("app.suite.gps","app.suite.gps.Service_impl"));
> > >         bindService(service, conn, BIND_AUTO_CREATE);
>
> > > }
> > > }
>
> > > When i run the code i get the security exception "unabletobindtoservice"
>
> > > (I have included the IGps.aidl file in both applications and generated
> > > the interfaces)
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%2Bunsubs 
> > [email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to