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


Java Binder.getCallingUid方法代码示例

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


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

示例1: validatePostMessageOriginInternal

import android.os.Binder; //导入方法依赖的package包/类
private boolean validatePostMessageOriginInternal(final CustomTabsSessionToken session) {
    if (!mWarmupHasBeenCalled.get()) return false;
    if (!isCallerForegroundOrSelf()) return false;
    final int uid = Binder.getCallingUid();
    ThreadUtils.postOnUiThread(new Runnable() {
        @Override
        public void run() {
            // If the API is not enabled, we don't set the post message origin, which will
            // avoid PostMessageHandler initialization and disallow postMessage calls.
            if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CCT_POST_MESSAGE_API)) return;
            mClientManager.setPostMessageOriginForSession(
                    session, acquireOriginForSession(session, uid));
        }
    });
    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:CustomTabsConnection.java

示例2: call

import android.os.Binder; //导入方法依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    int uid = (int) args[0];
    int callingUid = Binder.getCallingUid();
    if (uid == VirtualCore.get().myUid()) {
        uid = getBaseVUid();
    }
    String[] callingPkgs = VPackageManager.get().getPackagesForUid(callingUid);
    String[] targetPkgs = VPackageManager.get().getPackagesForUid(uid);
    String[] selfPkgs = VPackageManager.get().getPackagesForUid(Process.myUid());

    Set<String> pkgList = new ArraySet<>(2);
    if (callingPkgs != null && callingPkgs.length > 0) {
        pkgList.addAll(Arrays.asList(callingPkgs));
    }
    if (targetPkgs != null && targetPkgs.length > 0) {
        pkgList.addAll(Arrays.asList(targetPkgs));
    }
    if (selfPkgs != null && selfPkgs.length > 0) {
        pkgList.addAll(Arrays.asList(selfPkgs));
    }
    return pkgList.toArray(new String[pkgList.size()]);
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:24,代码来源:MethodProxies.java

示例3: call

import android.os.Binder; //导入方法依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
	int uid = (int) args[0];
	int callingUid = Binder.getCallingUid();
	if (uid == VirtualCore.get().myUid()) {
		uid = getBaseVUid();
	}
	String[] callingPkgs = VPackageManager.get().getPackagesForUid(callingUid);
	String[] targetPkgs = VPackageManager.get().getPackagesForUid(uid);
	String[] selfPkgs = VPackageManager.get().getPackagesForUid(Process.myUid());

	Set<String> pkgList = new ArraySet<>(2);
	if (callingPkgs != null && callingPkgs.length > 0) {
		pkgList.addAll(Arrays.asList(callingPkgs));
	}
	if (targetPkgs != null && targetPkgs.length > 0) {
		pkgList.addAll(Arrays.asList(targetPkgs));
	}
	if (selfPkgs != null && selfPkgs.length > 0) {
		pkgList.addAll(Arrays.asList(selfPkgs));
	}
	return pkgList.toArray(new String[pkgList.size()]);
}
 
开发者ID:codehz,项目名称:container,代码行数:24,代码来源:GetPackagesForUid.java

示例4: after

import android.os.Binder; //导入方法依赖的package包/类
@Override
protected void after(XParam param) throws Throwable {
	int uid = Binder.getCallingUid();
	switch (mMethod) {
	case getAddress:
	case Srv_getAddress:
		if (param.getResult() != null)
			if (isRestricted(param))
				param.setResult(PrivacyManager.getDefacedProp(uid, "MAC"));
		break;

	case Srv_getName:
		if (param.getResult() != null)
			if (isRestricted(param))
				param.setResult(PrivacyManager.getDefacedProp(uid, "BTName"));
		break;

	case getBondedDevices:
		if (param.getResult() != null && isRestricted(param))
			param.setResult(new HashSet<BluetoothDevice>());
		break;
	}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:24,代码来源:XBluetoothAdapter.java

示例5: isPackageAllowed

import android.os.Binder; //导入方法依赖的package包/类
public static boolean isPackageAllowed(int puid, String packageName) {
	int uid = Binder.getCallingUid();
	if (puid == uid)
		return true;

	if (packageName == null) {
		Util.log(null, Log.WARN, "isPackageAllowed uid=" + uid + " package=" + packageName);
		Util.logStack(null, Log.WARN);
		return false;
	}

	boolean allowed = PrivacyManager.getSettingBool(-uid, Meta.cTypeApplication, packageName, false);
	boolean blacklist = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingBlacklist, false);
	if (blacklist)
		allowed = !allowed;
	if (allowed)
		Util.log(null, Log.INFO, "Allowing package=" + packageName);
	return allowed;
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:20,代码来源:XPackageManager.java

示例6: shouldRestrictVisibility

import android.os.Binder; //导入方法依赖的package包/类
/**
 * @return true if we should restrict the columns readable by this caller
 */
private boolean shouldRestrictVisibility() {
    int callingUid = Binder.getCallingUid();
    return Binder.getCallingPid() != Process.myPid() &&
            callingUid != mSystemUid &&
            callingUid != mDefContainerUid;
}
 
开发者ID:redleaf2002,项目名称:downloadmanager,代码行数:10,代码来源:DownloadProvider.java

示例7: mayLaunchUrlInternal

import android.os.Binder; //导入方法依赖的package包/类
private boolean mayLaunchUrlInternal(final CustomTabsSessionToken session, Uri url,
        final Bundle extras, final List<Bundle> otherLikelyBundles) {
    final boolean lowConfidence =
            (url == null || TextUtils.isEmpty(url.toString())) && otherLikelyBundles != null;
    final String urlString = checkAndConvertUri(url);
    if (url != null && urlString == null && !lowConfidence) return false;

    // Things below need the browser process to be initialized.

    // Forbids warmup() from creating a spare renderer, as prerendering wouldn't reuse
    // it. Checking whether prerendering is enabled requires the native library to be loaded,
    // which is not necessarily the case yet.
    if (!warmupInternal(false)) return false; // Also does the foreground check.

    final int uid = Binder.getCallingUid();
    // TODO(lizeb): Also throttle low-confidence mode.
    if (!lowConfidence
            && !mClientManager.updateStatsAndReturnWhetherAllowed(session, uid, urlString)) {
        return false;
    }
    ThreadUtils.postOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (lowConfidence) {
                lowConfidenceMayLaunchUrl(otherLikelyBundles);
            } else {
                highConfidenceMayLaunchUrl(session, uid, urlString, extras, otherLikelyBundles);
            }
        }
    });
    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:33,代码来源:CustomTabsConnection.java

示例8: isGappsCaller

import android.os.Binder; //导入方法依赖的package包/类
public static boolean isGappsCaller(Context context) {
    try {
        int callingUid = Binder.getCallingUid();
        if (callingUid < PackageUtils.FIRST_APPLICATION_UID) {
            return false;
        }
        PackageManager pm = context.getPackageManager();
        return pm.getApplicationInfo(GMS, 0).uid == callingUid || isGapps(pm, callingUid);
    } catch (PackageManager.NameNotFoundException e) {
        CommonLog.v("cannot find gms", e);
    }
    return false;
}
 
开发者ID:brevent,项目名称:prevent,代码行数:14,代码来源:GmsUtils.java

示例9: enforcePermission

import android.os.Binder; //导入方法依赖的package包/类
private void enforcePermission(int uid) {
	if (uid >= 0)
		if (Util.getUserId(uid) != Util.getUserId(Binder.getCallingUid()))
			throw new SecurityException("uid=" + uid + " calling=" + Binder.getCallingUid());

	int callingUid = Util.getAppId(Binder.getCallingUid());
	if (callingUid != getXUid() && callingUid != Process.SYSTEM_UID)
		throw new SecurityException("xuid=" + mXUid + " calling=" + Binder.getCallingUid());
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:10,代码来源:PrivacyService.java

示例10: enforcePermission

import android.os.Binder; //导入方法依赖的package包/类
private void enforcePermission() throws SecurityException {
	if (Binder.getCallingUid() != Process.myUid())
		throw new SecurityException();
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:5,代码来源:PrivacyProvider.java

示例11: isRestrictedExtra

import android.os.Binder; //导入方法依赖的package包/类
protected boolean isRestrictedExtra(XParam param, String extra) throws Throwable {
	int uid = Binder.getCallingUid();
	return PrivacyManager.getRestrictionExtra(this, uid, mRestrictionName, getSpecifier(), extra, mSecret);
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:5,代码来源:XHook.java

示例12: isRestrictedValue

import android.os.Binder; //导入方法依赖的package包/类
protected boolean isRestrictedValue(XParam param, String value) throws Throwable {
	int uid = Binder.getCallingUid();
	return PrivacyManager.getRestrictionExtra(this, uid, mRestrictionName, getSpecifier(), null, value, mSecret);
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:5,代码来源:XHook.java

示例13: verify

import android.os.Binder; //导入方法依赖的package包/类
@Override
public boolean verify(Context context) throws Exception {
    return Process.myUid() == Binder.getCallingUid();
}
 
开发者ID:yjfnypeu,项目名称:Router-RePlugin,代码行数:5,代码来源:RePluginVerification.java

示例14: after

import android.os.Binder; //导入方法依赖的package包/类
@Override
protected void after(XParam param) throws Throwable {
	switch (mMethod) {
	case getCurrentSync:
		if (isRestricted(param))
			param.setResult(null);
		break;

	case getCurrentSyncs:
		if (isRestricted(param))
			param.setResult(new ArrayList<SyncInfo>());
		break;

	case getSyncAdapterTypes:
		if (isRestricted(param))
			param.setResult(new SyncAdapterType[0]);
		break;

	case openAssetFileDescriptor:
	case openFileDescriptor:
	case openInputStream:
	case openOutputStream:
	case openTypedAssetFileDescriptor:
	case openAssetFile:
	case openFile:
		if (param.args.length > 0 && param.args[0] instanceof Uri) {
			String uri = ((Uri) param.args[0]).toString();
			if (isRestrictedExtra(param, uri))
				param.setThrowable(new FileNotFoundException("XPrivacy"));
		}
		break;

	case Srv_call:
		handleCallAfter(param);
		break;

	case query:
	case Srv_query:
		handleUriAfter(param);
		break;

	case Srv_getCurrentSyncs:
	case Srv_getCurrentSyncsAsUser:
		if (param.getResult() != null)
			if (isRestricted(param)) {
				int uid = Binder.getCallingUid();
				@SuppressWarnings("unchecked")
				List<SyncInfo> listSync = (List<SyncInfo>) param.getResult();
				List<SyncInfo> listFiltered = new ArrayList<SyncInfo>();
				for (SyncInfo sync : listSync)
					if (XAccountManager.isAccountAllowed(sync.account, uid))
						listFiltered.add(sync);
				param.setResult(listFiltered);
			}
		break;
	}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:58,代码来源:XContentResolver.java

示例15: isRestricted

import android.os.Binder; //导入方法依赖的package包/类
protected boolean isRestricted(XParam param, String methodName) throws Throwable {
	int uid = Binder.getCallingUid();
	return PrivacyManager.getRestriction(this, uid, mRestrictionName, methodName, mSecret);
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:5,代码来源:XHook.java


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