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


Java Process.myPid方法代码示例

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


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

示例1: init

import android.os.Process; //导入方法依赖的package包/类
/**
 * [HIDE] 外界请不要调用此方法
 */
public static void init(Context context) {
    sCurrentProcess = SysUtils.getCurrentProcessName();
    sCurrentPid = Process.myPid();
    sPackageName = context.getApplicationInfo().packageName;

    // 设置最终的常驻进程名
    String cppn = RePlugin.getConfig().getPersistentName();
    if (!TextUtils.isEmpty(cppn)) {
        if (cppn.startsWith(":")) {
            sPersistentProcessName = sPackageName + cppn;
        } else {
            sPersistentProcessName = cppn;
        }
    }

    sIsUIProcess = sCurrentProcess.equals(sPackageName);
    sIsPersistentProcess = sCurrentProcess.equals(sPersistentProcessName);
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:22,代码来源:IPC.java

示例2: isPrivilegedApp

import android.os.Process; //导入方法依赖的package包/类
static boolean isPrivilegedApp(int callerUid, int callerPid) {
    if (callerUid == Process.SYSTEM_UID || callerUid == 0 ||
            callerPid == Process.myPid() || callerPid == 0) {
        return true;
    }

    IPackageManager pm = AppGlobals.getPackageManager();
    try {
        return (pm.getPrivateFlagsForUid(callerUid) & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED)
                != 0;
    } catch (RemoteException ex) {
        Slog.e(IntentFirewall.TAG, "Remote exception while retrieving uid flags",
                ex);
    }

    return false;
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:18,代码来源:SenderFilter.java

示例3: isMainProcess

import android.os.Process; //导入方法依赖的package包/类
public static boolean isMainProcess(Context c) {
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
        ActivityManager am = ((ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE));
        List<ActivityManager.RunningAppProcessInfo> processInfos = am.getRunningAppProcesses();
        if (processInfos == null) {
            return true;
        }
        String mainProcessName = c.getPackageName();
        int myPid = Process.myPid();
        for (ActivityManager.RunningAppProcessInfo info : processInfos) {
            if (info.pid == myPid && mainProcessName.equals(info.processName)) {
                return true;
            }
        }
        return false;
    } else {
        return !isServiceProcess(c);
    }
}
 
开发者ID:myl2ning,项目名称:fragmentnav,代码行数:20,代码来源:Androids.java

示例4: 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

示例5: getCurrentProcessName

import android.os.Process; //导入方法依赖的package包/类
private static String getCurrentProcessName(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    if (activityManager == null) {
        return null;
    }
    for (ActivityManager.RunningAppProcessInfo processInfo : activityManager.getRunningAppProcesses()) {
        if (processInfo.pid == Process.myPid()) {
            return processInfo.processName;
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:HermesEventBus.java

示例6: getInstance

import android.os.Process; //导入方法依赖的package包/类
/**
 * 获取缓存实例
 * <p>在cacheDir目录</p>
 *
 * @param cacheDir 缓存目录
 * @param maxSize  最大缓存尺寸,单位字节
 * @param maxCount 最大缓存个数
 * @return {@link CacheUtils}
 */
public static CacheUtils getInstance(@NonNull final File cacheDir, final long maxSize, final int maxCount) {
    final String cacheKey = cacheDir.getAbsoluteFile() + "_" + Process.myPid();
    CacheUtils cache = CACHE_MAP.get(cacheKey);
    if (cache == null) {
        cache = new CacheUtils(cacheDir, maxSize, maxCount);
        CACHE_MAP.put(cacheKey, cache);
    }
    return cache;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CacheUtils.java

示例7: insert

import android.os.Process; //导入方法依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues initialValues) {
    createDbIfNotExists();
    SqlArguments args = new SqlArguments(uri);

    // In very limited cases, we support system|signature permission apps to modify the db.
    if (Binder.getCallingPid() != Process.myPid()) {
        if (!initializeExternalAdd(initialValues)) {
            return null;
        }
    }

    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    addModifiedTime(initialValues);
    final long rowId = dbInsertAndCheck(mOpenHelper, db, args.table, null, initialValues);
    if (rowId < 0) return null;

    uri = ContentUris.withAppendedId(uri, rowId);
    notifyListeners();

    if (Utilities.ATLEAST_MARSHMALLOW) {
        reloadLauncherIfExternal();
    } else {
        // Deprecated behavior to support legacy devices which rely on provider callbacks.
        LauncherAppState app = LauncherAppState.getInstanceNoCreate();
        if (app != null && "true".equals(uri.getQueryParameter("isExternalAdd"))) {
            app.reloadWorkspace();
        }

        String notify = uri.getQueryParameter("notify");
        if (notify == null || "true".equals(notify)) {
            getContext().getContentResolver().notifyChange(uri, null);
        }
    }
    return uri;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:37,代码来源:LauncherProvider.java

示例8: insert

import android.os.Process; //导入方法依赖的package包/类
@Override
public Uri insert(@NonNull Uri uri, ContentValues initialValues) {
    createDbIfNotExists();
    SqlArguments args = new SqlArguments(uri);

    // In very limited cases, we support system|signature permission apps to modify the db.
    if (Binder.getCallingPid() != Process.myPid()) {
        if (!initializeExternalAdd(initialValues)) {
            return null;
        }
    }

    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    addModifiedTime(initialValues);
    final long rowId = dbInsertAndCheck(mOpenHelper, db, args.table, null, initialValues);
    if (rowId < 0) return null;

    uri = ContentUris.withAppendedId(uri, rowId);
    notifyListeners();

    if (AndroidVersion.isAtLeastMarshmallow) {
        reloadLauncherIfExternal();
    } else {
        // Deprecated behavior to support legacy devices which rely on provider callbacks.
        LauncherAppState app = LauncherAppState.getInstanceNoCreate();
        if (app != null && "true".equals(uri.getQueryParameter("isExternalAdd"))) {
            app.getModel().forceReload();
        }

        String notify = uri.getQueryParameter("notify");
        if (notify == null || "true".equals(notify)) {
            getContext().getContentResolver().notifyChange(uri, null);
        }
    }
    return uri;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:37,代码来源:LauncherProvider.java

示例9: onGetCallingUid

import android.os.Process; //导入方法依赖的package包/类
public static int onGetCallingUid(int originUid) {
    int callingPid = Binder.getCallingPid();
    if (callingPid == Process.myPid()) {
        return VClientImpl.get().getBaseVUid();
    }
    if (callingPid == VirtualCore.get().getSystemPid()) {
        return Process.SYSTEM_UID;
    }
    int vuid = VActivityManager.get().getUidByPid(callingPid);
    if (vuid != -1) {
        return VUserHandle.getAppId(vuid);
    }
    VLog.d(TAG, "Unknown uid: " + callingPid);
    return VClientImpl.get().getBaseVUid();
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:16,代码来源:NativeEngine.java

示例10: shouldInit

import android.os.Process; //导入方法依赖的package包/类
private boolean shouldInit() {
    ActivityManager am = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
    List<ActivityManager.RunningAppProcessInfo> processInfos = am.getRunningAppProcesses();
    String mainProcessName = getPackageName();
    int myPid = Process.myPid();
    for (ActivityManager.RunningAppProcessInfo info : processInfos) {
        if (info.pid == myPid && mainProcessName.equals(info.processName)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:NicoLiutong,项目名称:miaosou,代码行数:13,代码来源:DemoApplication.java

示例11: getProcessName

import android.os.Process; //导入方法依赖的package包/类
private static @Nullable String getProcessName(final Context context) {
	final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
	final List<ActivityManager.RunningAppProcessInfo> processes;
	try {
		processes = am.getRunningAppProcesses();
	} catch (final SecurityException e) { return null; }	// Isolated process not allowed to call getRunningAppProcesses
	final int pid = Process.myPid();
	if (processes != null) for (final ActivityManager.RunningAppProcessInfo process : processes)
		if (process.pid == pid) return process.processName;
	Log.e(TAG, "Error querying the name of current process.");
	return null;
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:13,代码来源:CondomProcess.java

示例12: getInstance

import android.os.Process; //导入方法依赖的package包/类
/**
 * 获取缓存实例
 * <p>在cacheDir目录</p>
 *
 * @param cacheDir 缓存目录
 * @param maxSize 最大缓存尺寸,单位字节
 * @param maxCount 最大缓存个数
 * @return {@link CacheUtils}
 */
public static CacheUtils getInstance(@NonNull final File cacheDir, final long maxSize, final int maxCount) {
    final String cacheKey = cacheDir.getAbsoluteFile() + "_" + Process.myPid();
    CacheUtils cache = CACHE_MAP.get(cacheKey);
    if (cache == null) {
        cache = new CacheUtils(cacheDir, maxSize, maxCount);
        CACHE_MAP.put(cacheKey, cache);
    }
    return cache;
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:19,代码来源:CacheUtils.java

示例13: getProcessName

import android.os.Process; //导入方法依赖的package包/类
protected String getProcessName() {
    List<RunningAppProcessInfo> runningAppProcesses = ((ActivityManager) this.sAppContext
            .getSystemService(ModelName.ACTIVITY)).getRunningAppProcesses();
    if (runningAppProcesses != null) {
        for (RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
            if (runningAppProcessInfo.pid == Process.myPid()) {
                return runningAppProcessInfo.processName;
            }
        }
    }
    return "com.xiaomi";
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:HostManager.java

示例14: getCurrentProcessName

import android.os.Process; //导入方法依赖的package包/类
/**
 * getCurrentProcessName
 *
 * @param context
 * @return
 */
public static String getCurrentProcessName(Context context) {
    int pid = Process.myPid();
    ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    Iterator i$ = mActivityManager.getRunningAppProcesses().iterator();
    ActivityManager.RunningAppProcessInfo appProcess;
    do {
        if (!i$.hasNext()) {
            return null;
        }
        appProcess = (ActivityManager.RunningAppProcessInfo) i$.next();
    } while (appProcess.pid != pid);
    return appProcess.processName;
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:20,代码来源:ApkProcess.java

示例15: u

import android.os.Process; //导入方法依赖的package包/类
static String u(Context context) {
    try {
        int myPid = Process.myPid();
        for (RunningAppProcessInfo runningAppProcessInfo : ((ActivityManager) context
                .getSystemService(ModelName.ACTIVITY)).getRunningAppProcesses()) {
            if (runningAppProcessInfo.pid == myPid) {
                return runningAppProcessInfo.processName;
            }
        }
    } catch (Throwable th) {
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:k.java


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