当前位置: 首页>>代码示例>>Java>>正文


Java Binder类代码示例

本文整理汇总了Java中android.os.Binder的典型用法代码示例。如果您正苦于以下问题:Java Binder类的具体用法?Java Binder怎么用?Java Binder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Binder类属于android.os包,在下文中一共展示了Binder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: query

import android.os.Binder; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
        throws Exception {
    List<String> segments = uri.getPathSegments();
    int accountId = Integer.parseInt(segments.get(1));

    /*
     * This method below calls Account.getStats() which uses EmailProvider to do its work.
     * For this to work we need to clear the calling identity. Otherwise accessing
     * EmailProvider will fail because it's not exported so third-party apps can't access it
     * directly.
     */
    long identityToken = Binder.clearCallingIdentity();
    try {
        return getAccountUnread(accountId);
    } finally {
        Binder.restoreCallingIdentity(identityToken);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:MessageProvider.java

示例2: checkOp

import android.os.Binder; //导入依赖的package包/类
@TargetApi(19)
private static boolean checkOp(Context context, int op) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= Build.VERSION_CODES.KITKAT) {
        AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        try {
            Method method = manager.getClass().getDeclaredMethod("checkOp", int.class, int.class, String.class);
            int property = (Integer) method.invoke(manager, op,
                    Binder.getCallingUid(), context.getPackageName());
            return AppOpsManager.MODE_ALLOWED == property;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return false;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:17,代码来源:QMUIDeviceHelper.java

示例3: after

import android.os.Binder; //导入依赖的package包/类
@Override
protected void after(XParam param) throws Throwable {
	String key = (param.args.length > 0 ? (String) param.args[0] : null);
	if (key != null)
		if (mPropertyName.startsWith("%") ? key.contains(mPropertyName.substring(1)) : key.equals(mPropertyName))
			if (mMethod == Methods.get) {
				if (param.getResult() != null && isRestrictedExtra(param, mPropertyName, key))
					param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), mPropertyName));

			} else if (param.args.length > 1) {
				if (isRestrictedExtra(param, mPropertyName, key))
					param.setResult(param.args[1]);

			} else
				Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:17,代码来源:XSystemProperties.java

示例4: checkOp

import android.os.Binder; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 19) {
        AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        try {
            Class clazz = AppOpsManager.class;
            Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
            return AppOpsManager.MODE_ALLOWED == (int)method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
        } catch (Exception e) {
            Log.e(TAG, Log.getStackTraceString(e));
        }
    } else {
        Log.e(TAG, "Below API 19 cannot invoke!");
    }
    return false;
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:18,代码来源:MeizuUtils.java

示例5: queryChildDocuments

import android.os.Binder; //导入依赖的package包/类
@Override
public Cursor queryChildDocuments(String docId, String[] projection, String sortOrder)
        throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));

    // Delegate to real provider
    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
    	Query query = new Query();
    	DownloadManagerUtils.setOnlyIncludeVisibleInDownloadsUi(query);
    	//query.setOnlyIncludeVisibleInDownloadsUi(true);
        query.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL);
    	//query.setFilterByStatus(DownloadManager.STATUS_PENDING | DownloadManager.STATUS_PAUSED | DownloadManager.STATUS_RUNNING | DownloadManager.STATUS_FAILED);
        cursor = mDm.query(query);//.setOnlyIncludeVisibleInDownloadsUi(true)
                //.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL));
        //copyNotificationUri(result, cursor);
        while (cursor.moveToNext()) {
            includeDownloadFromCursor(result, cursor);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:27,代码来源:DownloadStorageProvider.java

示例6: createService

import android.os.Binder; //导入依赖的package包/类
private static void createService(Service service, Intent intent) {
    if (intent.hasExtra(ApkConstant.EXTRA_APK_PATH)) {
        String apkPath = ApkComponentModifier.getPath(intent);
        String className = ApkComponentModifier.getClassName(intent);
        String key = ApkComponentModifier.getKey(intent);
        if (!mRealServices.containsKey(service) || !mRealServices.get(service).containsKey(key)) {
            try {
                Object realToken = new Binder();
                Service rawService = handleCreateService(realToken, service, apkPath, className);
                if (mRealServices.containsKey(service)) {
                    mRealServices.get(service).put(key, rawService);
                } else {
                    Map<String, Service> serviceMap = new HashMap<>();
                    serviceMap.put(key, rawService);
                    mRealServices.put(service, serviceMap);
                }
            } catch (Exception e) {
            }
        }
    }
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:22,代码来源:HookService_Manager.java

示例7: asyncGetService

import android.os.Binder; //导入依赖的package包/类
@Override
public void asyncGetService(String serviceName, IServiceCallback callback)
		throws RemoteException {
	LogControler.info("ServiceManagerServer", "[svcmgr server] asyncGetService name = " + serviceName + " , callingpid = " + Binder.getCallingPid());
	IBinder service = clientServiceContainer.get(serviceName);
	
	if(service == null) {
		service = BinderQuerier.query(serviceName);
	}

	if(service == null){
		asyncClientServiceContainer.put(serviceName, IServiceCallbackProxy.proxy(serviceName,callback));
	} else {
		callback.callback(service);
	}
	
}
 
开发者ID:devyok,项目名称:IPCServiceManager,代码行数:18,代码来源:ServiceManagerServer.java

示例8: checkOp

import android.os.Binder; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 19) {
        AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        try {
            Class clazz = AppOpsManager.class;
            Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
            return AppOpsManager.MODE_ALLOWED == (int)method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
        } catch (Exception e) {
            Log.e(TAG, Log.getStackTraceString(e));
        }
    } else {
        Log.e("", "Below API 19 cannot invoke!");
    }
    return false;
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:18,代码来源:QikuUtils.java

示例9: checkOp

import android.os.Binder; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean checkOp(Context context, int op) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 19) {
        AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        try {
            Class clazz = AppOpsManager.class;
            Method method = clazz.getDeclaredMethod("checkOp", int.class, int.class, String.class);
            return AppOpsManager.MODE_ALLOWED == (int) method.invoke(manager, op, Binder.getCallingUid(), context.getPackageName());
        } catch (Exception e) {
            Log.e(TAG, Log.getStackTraceString(e));
        }
    } else {
        Log.e(TAG, "Below API 19 cannot invoke!");
    }
    return false;
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:18,代码来源:HuaweiUtils.java

示例10: openDocument

import android.os.Binder; //导入依赖的package包/类
@Override
public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
        throws FileNotFoundException {

    if (!"r".equals(mode)) {
        throw new IllegalArgumentException("Media is read-only");
    }

    final Uri target = getUriForDocumentId(docId);

    // Delegate to real provider
    final long token = Binder.clearCallingIdentity();
    try {
        return getContext().getContentResolver().openFileDescriptor(target, mode);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:19,代码来源:NonMediaDocumentsProvider.java

示例11: addService

import android.os.Binder; //导入依赖的package包/类
@Override
public void addService(String serviceName, IBinder service)
		throws RemoteException {

	LogControler.info("ServiceManagerServer", "[svcmgr server] addService name = " + serviceName + " , service = " + service+ " , callingpid = " + Binder.getCallingPid());

	service.linkToDeath(new BinderServiceDeathRecipient(serviceName),0);
	clientServiceContainer.put(serviceName, service);

	//查看是否有listen这个服务的
	IServiceCallbackProxy serviceCallback = asyncClientServiceContainer.get(serviceName);

	if(serviceCallback!=null){
		try {
			LogControler.info("ServiceManagerServer", "[svcmgr server] addService onReady");
			serviceCallback.callback(service);
		} catch(Exception e){
			e.printStackTrace();
		}
	} else {
		LogControler.info("ServiceManagerServer", "[svcmgr server] addService serviceCallback not found");
	}
}
 
开发者ID:devyok,项目名称:IPCServiceManager,代码行数:24,代码来源:ServiceManagerServer.java

示例12: after

import android.os.Binder; //导入依赖的package包/类
@Override
protected void after(XParam param) throws Throwable {
	if (mMethod == Methods.getDetailedState) {
		if (param.getResult() != null && isRestricted(param))
			param.setResult(NetworkInfo.DetailedState.DISCONNECTED);

	} else if (mMethod == Methods.getExtraInfo) {
		if (param.getResult() != null && isRestricted(param))
			param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "ExtraInfo"));

	} else if (mMethod == Methods.getState) {
		if (param.getResult() != null && isRestricted(param))
			param.setResult(NetworkInfo.State.DISCONNECTED);

	} else if (mMethod == Methods.isConnected || mMethod == Methods.isConnectedOrConnecting) {
		if (isRestricted(param))
			param.setResult(false);

	} else
		Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:22,代码来源:XNetworkInfo.java

示例13: deleteDocument

import android.os.Binder; //导入依赖的package包/类
@Override
public void deleteDocument(String docId) throws FileNotFoundException {
	final String packageName = getPackageForDocId(docId);
    final long token = Binder.clearCallingIdentity();
    try {
    	if (docId.startsWith(ROOT_ID_USER_APP)) {
PackageManagerUtils.uninstallApp(getContext(), packageName);
    	}
    	else if(docId.startsWith(ROOT_ID_PROCESS)) {
    		activityManager.killBackgroundProcesses(getPackageForDocId(docId));
    	}
    	notifyDocumentsChanged(docId);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:17,代码来源:AppsProvider.java

示例14: queryChildDocumentsForManage

import android.os.Binder; //导入依赖的package包/类
@Override
public Cursor queryChildDocumentsForManage(
        String parentDocumentId, String[] projection, String sortOrder)
        throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));

    // Delegate to real provider
    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        cursor = mDm.query(
                new DownloadManager.Query());//.setOnlyIncludeVisibleInDownloadsUi(true));
        //copyNotificationUri(result, cursor);
        while (cursor.moveToNext()) {
            includeDownloadFromCursor(result, cursor);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:23,代码来源:DownloadStorageProvider.java

示例15: queryChildDocuments

import android.os.Binder; //导入依赖的package包/类
@Override
public Cursor queryChildDocuments(String docId, String[] projection, String sortOrder)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    final Ident ident = getIdentForDocId(docId);

    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        if (TYPE_DOCUMENT_ROOT.equals(ident.type)) {
            queryFile(resolver, cursor, result, DOCUMENT_MIMES, "text");
        } else if (TYPE_ARCHIVE_ROOT.equals(ident.type)) {
            queryFile(resolver, cursor, result, ARCHIVE_MIMES);
        } else if (TYPE_APK_ROOT.equals(ident.type)) {
            queryFile(resolver, cursor, result, APK_MIMES);
        } else {
            throw new UnsupportedOperationException("Unsupported document " + docId);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:26,代码来源:NonMediaDocumentsProvider.java


注:本文中的android.os.Binder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。