當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。