0

Cache can be cleaned via AIDL, What about forcestop function?

I tried, but failed. Anyone did this before?

add aidl file in my packages:

IActivityManager.aidl
package android.app; 
oneway interface IActivityManager { 
     void forceStopPackage(String packageName);
}

implements IActivityManager, but I can't get its object:

import android.app.IActivityManager;
class ActivityManagerProxy implements IActivityManager
{

    public ActivityManagerProxy(IBinder remote)
    {
        mRemote = remote;
    }

    public IBinder asBinder()
    {
        return mRemote;
    }

    public void forceStopPackage(String packageName) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(descriptor);
        data.writeString(packageName);
        mRemote.transact(FORCE_STOP_PACKAGE_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    private IBinder mRemote;
}
thecr0w
  • 2,148
  • 4
  • 33
  • 59

1 Answers1

1

It's not possible since ActivityManagerService which runs in its own process just checked the permission of the IPC caller. You must hold the FORCE_STOP_PACKAGES permission to call this method.

Oasis Feng
  • 7,490
  • 3
  • 31
  • 44