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


Java Process.myUid方法代码示例

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


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

示例1: hasGeolocationPermission

import android.os.Process; //导入方法依赖的package包/类
static boolean hasGeolocationPermission(Context context) {
    int pid = Process.myPid();
    int uid = Process.myUid();
    if (ApiCompatibilityUtils.checkPermission(
            context, Manifest.permission.ACCESS_COARSE_LOCATION, pid, uid)
            != PackageManager.PERMISSION_GRANTED) {
        return false;
    }

    // Work around a bug in OnePlus2 devices running Lollipop, where the NETWORK_PROVIDER
    // incorrectly requires FINE_LOCATION permission (it should only require COARSE_LOCATION
    // permission). http://crbug.com/580733
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            && ApiCompatibilityUtils.checkPermission(
                    context, Manifest.permission.ACCESS_FINE_LOCATION, pid, uid)
                    != PackageManager.PERMISSION_GRANTED) {
        return false;
    }

    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:GeolocationHeader.java

示例2: openFileUri

import android.os.Process; //导入方法依赖的package包/类
private InputStream openFileUri(Uri uri) throws IOException {
  FileInputStream fin   = new FileInputStream(uri.getPath());
  int             owner = FileUtils.getFileDescriptorOwner(fin.getFD());
  
  if (owner == -1 || owner == Process.myUid()) {
    fin.close();
    throw new IOException("File owned by application");
  }

  return fin;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:ShareActivity.java

示例3: afterHookedMethod

import android.os.Process; //导入方法依赖的package包/类
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
	if (!param.hasThrowable())
		try {
			// Do not restrict Zygote
			if (Process.myUid() <= 0)
				return;

			// Pre processing
			XParam xparam = XParam.fromXposed(param);
			xparam.setExtras(param.getObjectExtra("xextra"));

			long start = System.currentTimeMillis();

			// Execute hook
			mHook.after(xparam);

			long ms = System.currentTimeMillis() - start;
			if (ms > PrivacyManager.cWarnHookDelayMs)
				Util.log(mHook, Log.WARN, String.format("%s %d ms", param.method.getName(), ms));

			// Post processing
			if (xparam.hasResult())
				param.setResult(xparam.getResult());
			if (xparam.hasThrowable())
				param.setThrowable(xparam.getThrowable());
		} catch (Throwable ex) {
			Util.bug(null, ex);
		}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:31,代码来源:XPrivacy.java

示例4: beforeHookedMethod

import android.os.Process; //导入方法依赖的package包/类
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
	try {
		// Do not restrict Zygote
		if (Process.myUid() <= 0)
			return;

		// Pre processing
		XParam xparam = XParam.fromXposed(param);

		long start = System.currentTimeMillis();

		// Execute hook
		mHook.before(xparam);

		long ms = System.currentTimeMillis() - start;
		if (ms > PrivacyManager.cWarnHookDelayMs)
			Util.log(mHook, Log.WARN, String.format("%s %d ms", param.method.getName(), ms));

		// Post processing
		if (xparam.hasResult())
			param.setResult(xparam.getResult());
		if (xparam.hasThrowable())
			param.setThrowable(xparam.getThrowable());
		param.setObjectExtra("xextra", xparam.getExtras());
	} catch (Throwable ex) {
		Util.bug(null, ex);
	}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:30,代码来源:XPrivacy.java

示例5: start

import android.os.Process; //导入方法依赖的package包/类
@Override
public int start() {
	uid = Process.myUid();
	if ((trafficRxStart = TrafficStats.getUidRxBytes(uid)) == TrafficStats.UNSUPPORTED) {
		return SERVICE_NOT_SUPPORTED;
	}		
	
	running = true;
	trafficTxStart = TrafficStats.getUidTxBytes(uid);
	return SERVICE_START_OK;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:12,代码来源:TrafficServiceByUidImpl.java

示例6: isCallerForegroundOrSelf

import android.os.Process; //导入方法依赖的package包/类
/**
 * @return true when inside a Binder transaction and the caller is in the
 * foreground or self. Don't use outside a Binder transaction.
 */
private boolean isCallerForegroundOrSelf() {
    int uid = Binder.getCallingUid();
    if (uid == Process.myUid()) return true;
    // Starting with L MR1, AM.getRunningAppProcesses doesn't return all the
    // processes. We use a workaround in this case.
    boolean useWorkaround = true;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
        do {
            ActivityManager am =
                    (ActivityManager) mApplication.getSystemService(Context.ACTIVITY_SERVICE);
            // Extra paranoia here and below, some L 5.0.x devices seem to throw NPE somewhere
            // in this code.
            // See https://crbug.com/654705.
            if (am == null) break;
            List<ActivityManager.RunningAppProcessInfo> running = am.getRunningAppProcesses();
            if (running == null) break;
            for (ActivityManager.RunningAppProcessInfo rpi : running) {
                if (rpi == null) continue;
                boolean matchingUid = rpi.uid == uid;
                boolean isForeground = rpi.importance
                        == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
                useWorkaround &= !matchingUid;
                if (matchingUid && isForeground) return true;
            }
        } while (false);
    }
    return useWorkaround ? !isBackgroundProcess(Binder.getCallingPid()) : false;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:33,代码来源:CustomTabsConnection.java

示例7: getUidByPid

import android.os.Process; //导入方法依赖的package包/类
@Override
public int getUidByPid(int pid) {
    synchronized (mPidsSelfLocked) {
        ProcessRecord r = findProcessLocked(pid);
        if (r != null) {
            return r.vuid;
        }
    }
    return Process.myUid();
}
 
开发者ID:codehz,项目名称:container,代码行数:11,代码来源:VActivityManagerService.java

示例8: beforeCall

import android.os.Process; //导入方法依赖的package包/类
@Override
public boolean beforeCall(Object who, Method method, Object... args) {
    int index = ArrayUtils.indexOfLast(args, Integer.class);
    if (index != -1) {
        int uid = (int) args[index];
        if (uid == Process.myUid()) {
            args[index] = getRealUid();
        }
    }
    return super.beforeCall(who, method, args);
}
 
开发者ID:codehz,项目名称:container,代码行数:12,代码来源:ReplaceLastUidHook.java

示例9: beforeCall

import android.os.Process; //导入方法依赖的package包/类
@Override
public boolean beforeCall(Object who, Method method, Object... args) {
    int uid = (int) args[index];
    if (uid == Process.myUid()) {
        args[index] = getRealUid();
    }
    return super.beforeCall(who, method, args);
}
 
开发者ID:codehz,项目名称:container,代码行数:9,代码来源:ReplaceUidHook.java

示例10: killAllOtherProcess

import android.os.Process; //导入方法依赖的package包/类
public static void killAllOtherProcess(Context context) {
    for (RunningAppProcessInfo ai : ((ActivityManager) context.getSystemService(ModelName
            .ACTIVITY)).getRunningAppProcesses()) {
        if (ai.uid == Process.myUid() && ai.pid != Process.myPid()) {
            Process.killProcess(ai.pid);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:ShareTinkerInternals.java

示例11: getFakeUid

import android.os.Process; //导入方法依赖的package包/类
protected int getFakeUid() {
    return Process.myUid();
}
 
开发者ID:codehz,项目名称:container,代码行数:4,代码来源:FakeIdentityBinder.java

示例12: getPackageResourcePath

import android.os.Process; //导入方法依赖的package包/类
public String getPackageResourcePath() {
    int myUid = Process.myUid();
    ApplicationInfo appInfo = this.mPackage.applicationInfo;
    return appInfo.uid == myUid ? appInfo.sourceDir : appInfo.publicSourceDir;
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:6,代码来源:LoadedPlugin.java

示例13: isCallerAllowed

import android.os.Process; //导入方法依赖的package包/类
/**
 * @return false if the caller is not authorized to get data from this MediaBrowserService
 */
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isCallerAllowed(Context context, String callingPackage, int callingUid) {
    // Always allow calls from the framework, self app or development environment.
    if (Process.SYSTEM_UID == callingUid || Process.myUid() == callingUid) {
        return true;
    }

    if (isPlatformSigned(context, callingPackage)) {
        return true;
    }

    PackageInfo packageInfo = getPackageInfo(context, callingPackage);
    if (packageInfo == null) {
        return false;
    }
    if (packageInfo.signatures.length != 1) {
        Log.w(TAG, "Caller does not have exactly one signature certificate!");
        return false;
    }
    String signature = Base64.encodeToString(
            packageInfo.signatures[0].toByteArray(), Base64.NO_WRAP);

    // Test for known signatures:
    ArrayList<CallerInfo> validCallers = mValidCertificates.get(signature);
    if (validCallers == null) {
        Log.v(TAG, "Signature for caller " + callingPackage  + " is not valid: \n"
                + signature);
        if (mValidCertificates.isEmpty()) {
            Log.w(TAG, "The list of valid certificates is empty. Either your file " +
                    "res/xml/allowed_media_browser_callers.xml is empty or there was an error " +
                    "while reading it. Check previous log messages.");
        }
        return false;
    }

    // Check if the package name is valid for the certificate:
    StringBuffer expectedPackages = new StringBuffer();
    for (CallerInfo info: validCallers) {
        if (callingPackage.equals(info.packageName)) {
            Log.v(TAG, "Valid caller: " + info.name + "  package=" + info.packageName +
                    " release=" + info.release);
            return true;
        }
        expectedPackages.append(info.packageName).append(' ');
    }

    Log.i(TAG, "Caller has a valid certificate, but its package doesn't match any " +
            "expected package for the given certificate. Caller's package is " + callingPackage +
            ". Expected packages as defined in res/xml/allowed_media_browser_callers.xml are (" +
            expectedPackages + "). This caller's certificate is: \n" + signature);

    return false;
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:57,代码来源:PackageValidator.java

示例14: checkPermission

import android.os.Process; //导入方法依赖的package包/类
@Override public int checkPermission(final String permission, final int pid, final int uid) {
	return pid == Process.myPid() && uid == Process.myUid() && mCondom.shouldSpoofPermission(permission) ? PERMISSION_GRANTED
			: super.checkPermission(permission, pid, uid);
}
 
开发者ID:oasisfeng,项目名称:condom,代码行数:5,代码来源:CondomApplication.java

示例15: acquireOriginForSession

import android.os.Process; //导入方法依赖的package包/类
/**
 * Acquire the origin for the client that owns the given session.
 * @param session The session to use for getting client information.
 * @param clientUID The UID for the client controlling the session.
 * @return The validated origin {@link Uri} for the given session's client.
 */
protected Uri acquireOriginForSession(CustomTabsSessionToken session, int clientUID) {
    if (clientUID == Process.myUid()) return Uri.EMPTY;
    return null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:CustomTabsConnection.java


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