Java Code Examples for android.os.IBinder#getInterfaceDescriptor()
The following examples show how to use
android.os.IBinder#getInterfaceDescriptor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceWrapper.java From springreplugin with Apache License 2.0 | 6 votes |
public static IBinder factory(Context context, String name, IBinder binder) { String descriptor = null; try { descriptor = binder.getInterfaceDescriptor(); } catch (RemoteException e) { if (DEBUG) { Log.d(TAG, "getInterfaceDescriptor()", e); } } android.os.IInterface iin = binder.queryLocalInterface(descriptor); if (iin != null) { /** * If the requested interface has local implementation, meaning that * it's living in the same process as the one who requests for it, * return the binder directly since in such cases our wrapper does * not help in any way. */ return binder; } return new ServiceWrapper(context, name, binder); }
Example 2
Source File: ProxyServiceFactory.java From container with GNU General Public License v3.0 | 6 votes |
public static IBinder getProxyService(Context context, ComponentName component, IBinder binder) { if (context == null || binder == null) { return null; } try { String description = binder.getInterfaceDescriptor(); ServiceFetcher fetcher = sHookSecondaryServiceMap.get(description); if (fetcher != null) { IBinder res = fetcher.getService(context, context.getClassLoader(), binder); if (res != null) { return res; } } } catch (Throwable e) { e.printStackTrace(); } return null; }
Example 3
Source File: RemoteHandler.java From AppOpsX with MIT License | 6 votes |
private void findFromService(SystemServiceCaller caller) { try { IBinder service = ServiceManager.getService(caller.getServiceName()); String aidl = service.getInterfaceDescriptor(); Class aClass = sClassCache.get(aidl); if (aClass == null) { aClass = Class.forName(aidl + "$Stub", false, null); sClassCache.put(aidl, aClass); } Object asInterface = MethodUtils.invokeStaticMethod(aClass, "asInterface", new Object[]{service}, new Class[]{IBinder.class}); Method method = MethodUtils.getAccessibleMethod(aClass, caller.getMethodName(), caller.getParamsType()); if (method != null && asInterface != null) { sFindValue.recycle(); sFindValue.put(asInterface, method); } } catch (Throwable e) { e.printStackTrace(); FLog.log(e); } }
Example 4
Source File: XBinder.java From XPrivacy with GNU General Public License v3.0 | 4 votes |
private void markIPC(XParam param) throws Throwable { // Allow management transactions int code = (Integer) param.args[0]; if (isManagementTransaction(code)) return; // Only for applications int uid = Binder.getCallingUid(); if (!PrivacyManager.isApplication(uid)) return; // Check interface name IBinder binder = (IBinder) param.thisObject; String descriptor = (binder == null ? null : binder.getInterfaceDescriptor()); if (!cServiceDescriptor.contains(descriptor)) return; // Search this object in call stack boolean ok = false; boolean found = false; StackTraceElement[] ste = Thread.currentThread().getStackTrace(); for (int i = 0; i < ste.length; i++) if (ste[i].getClassName().equals(param.thisObject.getClass().getName())) { found = true; // Check if caller class in user space String callerClassName = (i + 2 < ste.length ? ste[i + 2].getClassName() : null); if (callerClassName != null && !callerClassName.startsWith("java.lang.reflect.")) synchronized (mMapClassSystem) { if (!mMapClassSystem.containsKey(callerClassName)) try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?> clazz = Class.forName(callerClassName, false, loader); boolean boot = Context.class.getClassLoader().equals(clazz.getClassLoader()); mMapClassSystem.put(callerClassName, boot); } catch (ClassNotFoundException ignored) { mMapClassSystem.put(callerClassName, true); } ok = mMapClassSystem.get(callerClassName); } break; } // Conditionally mark if (ok) { int flags = (Integer) param.args[3]; if ((flags & ~FLAG_ALL) != 0) Util.log(this, Log.ERROR, "Unknown flags=" + Integer.toHexString(flags) + " descriptor=" + descriptor + " code=" + code + " uid=" + Binder.getCallingUid()); flags |= (mToken << BITS_TOKEN); param.args[3] = flags; } else { int level = (found ? Log.WARN : Log.ERROR); Util.log(this, level, "Unmarked descriptor=" + descriptor + " found=" + found + " code=" + code + " uid=" + Binder.getCallingUid()); Util.logStack(this, level, true); } }