重写Binder的onTransact方法
|
|||
|
The description of
Binder#onTransact mentions unmarshalling transactions. Is it safe to use it just for checking permissions and returning false when the permissions are not okay, and returning the default implementation when all is well? – Daniel Feb 11 at 15:36 |
||
|
i think so, but the docs do not say what is returned boolean for (try to return
false and see what happens) or you would try to throw RemoteException saying "dear client, nonono, you have no permissions to call me" – pskink Feb 11 at 16:03 |
||
|
I did try it. When I return
false from onTransact , the function call on the client returns null . – Daniel |
拿到caller的包名
String pkg = getPackageManager().getNameForUid(getCallingUid());
Binder#onTransact
method, this is a good place for any remote checks – pskink Feb 10 at 17:58