Java Code Examples for android.os.IBinder.getInterfaceDescriptor()

The following are Jave code examples for showing how to use getInterfaceDescriptor() of the android.os.IBinder class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: VirtualHook   File: ProxyServiceFactory.java   Source Code and License Vote up 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 2
Project: springreplugin   File: ServiceWrapper.java   Source Code and License Vote up 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 3
Project: TPlayer   File: ProxyServiceFactory.java   Source Code and License Vote up 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 4
Project: container   File: ProxyServiceFactory.java   Source Code and License Vote up 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 5
Project: XPrivacy   File: XBinder.java   Source Code and License Vote up 5 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);
	}
}