本文整理汇总了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;
}
示例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()]);
}
示例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()]);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例10: enforcePermission
import android.os.Binder; //导入方法依赖的package包/类
private void enforcePermission() throws SecurityException {
if (Binder.getCallingUid() != Process.myUid())
throw new SecurityException();
}
示例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);
}
示例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);
}
示例13: verify
import android.os.Binder; //导入方法依赖的package包/类
@Override
public boolean verify(Context context) throws Exception {
return Process.myUid() == Binder.getCallingUid();
}
示例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;
}
}
示例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);
}