當前位置: 首頁>>代碼示例>>Java>>正文


Java Process類代碼示例

本文整理匯總了Java中android.os.Process的典型用法代碼示例。如果您正苦於以下問題:Java Process類的具體用法?Java Process怎麽用?Java Process使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Process類屬於android.os包,在下文中一共展示了Process類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateSeed

import android.os.Process; //導入依賴的package包/類
/**
 * Generates a device- and invocation-specific seed to be mixed into the
 * Linux PRNG.
 */
private static byte[] generateSeed() {
    try {
        ByteArrayOutputStream seedBuffer = new ByteArrayOutputStream();
        DataOutputStream seedBufferOut =
                new DataOutputStream(seedBuffer);
        seedBufferOut.writeLong(System.currentTimeMillis());
        seedBufferOut.writeLong(System.nanoTime());
        seedBufferOut.writeInt(Process.myPid());
        seedBufferOut.writeInt(Process.myUid());
        seedBufferOut.write(BUILD_FINGERPRINT_AND_DEVICE_SERIAL);
        seedBufferOut.close();
        return seedBuffer.toByteArray();
    } catch (IOException e) {
        throw new SecurityException("Failed to generate seed", e);
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:21,代碼來源:PRNGFixes.java

示例2: ExoPlayerImplInternal

import android.os.Process; //導入依賴的package包/類
public ExoPlayerImplInternal(Handler eventHandler, boolean playWhenReady,
    int[] selectedTrackIndices, int minBufferMs, int minRebufferMs) {
  this.eventHandler = eventHandler;
  this.playWhenReady = playWhenReady;
  this.minBufferUs = minBufferMs * 1000L;
  this.minRebufferUs = minRebufferMs * 1000L;
  this.selectedTrackIndices = Arrays.copyOf(selectedTrackIndices, selectedTrackIndices.length);
  this.state = ExoPlayer.STATE_IDLE;
  this.durationUs = TrackRenderer.UNKNOWN_TIME_US;
  this.bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US;

  standaloneMediaClock = new StandaloneMediaClock();
  pendingSeekCount = new AtomicInteger();
  enabledRenderers = new ArrayList<>(selectedTrackIndices.length);
  trackFormats = new MediaFormat[selectedTrackIndices.length][];
  // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can
  // not normally change to this priority" is incorrect.
  internalPlaybackThread = new PriorityHandlerThread("ExoPlayerImplInternal:Handler",
      Process.THREAD_PRIORITY_AUDIO);
  internalPlaybackThread.start();
  handler = new Handler(internalPlaybackThread.getLooper(), this);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:23,代碼來源:ExoPlayerImplInternal.java

示例3: run

import android.os.Process; //導入依賴的package包/類
@Override
public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    while (true) {
        try {
            ImageRequest request = mQueue.take();
            if (request.checkTaskNotActual()) {
                continue;
            }
            dealRequest(request);

        } catch (InterruptedException e) {
            // 如果要求退出則退出,否則遇到異常繼續
            if (mQuit) {
                return;
            } else {
                continue;
            }
        }
    }
}
 
開發者ID:shenhuanet,項目名稱:Sendroid,代碼行數:22,代碼來源:Dispatcher.java

示例4: formatUid

import android.os.Process; //導入依賴的package包/類
public static void formatUid(StringBuilder sb, int uid) {
    if (uid < Process.FIRST_APPLICATION_UID) {
        sb.append(uid);
    } else {
        sb.append('u');
        sb.append(getUserId(uid));
        final int appId = getAppId(uid);
        if (appId >= FIRST_ISOLATED_UID && appId <= LAST_ISOLATED_UID) {
            sb.append('i');
            sb.append(appId - FIRST_ISOLATED_UID);
        } else if (appId >= Process.FIRST_APPLICATION_UID) {
            sb.append('a');
            sb.append(appId - Process.FIRST_APPLICATION_UID);
        } else {
            sb.append('s');
            sb.append(appId);
        }
    }
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:20,代碼來源:VUserHandle.java

示例5: onCreate

import android.os.Process; //導入依賴的package包/類
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());

    final PackageInfo packageInfo = application.packageInfo();
    final int versionNameSplit = packageInfo.versionName.indexOf('-');
    final HttpUrl.Builder url = HttpUrl
            .parse(Constants.VERSION_URL
                    + (versionNameSplit >= 0 ? packageInfo.versionName.substring(versionNameSplit) : ""))
            .newBuilder();
    url.addEncodedQueryParameter("package", packageInfo.packageName);
    url.addQueryParameter("current", Integer.toString(packageInfo.versionCode));
    versionUrl = url.build();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:19,代碼來源:AlertDialogsFragment.java

示例6: onClickPendingAppItem

import android.os.Process; //導入依賴的package包/類
private void onClickPendingAppItem(final View v, final String packageName,
        boolean downloadStarted) {
    if (downloadStarted) {
        // If the download has started, simply direct to the market app.
        startMarketIntentForPackage(v, packageName);
        return;
    }
    new AlertDialog.Builder(this)
        .setTitle(R.string.abandoned_promises_title)
        .setMessage(R.string.abandoned_promise_explanation)
        .setPositiveButton(R.string.abandoned_search, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                startMarketIntentForPackage(v, packageName);
            }
        })
        .setNeutralButton(R.string.abandoned_clean_this,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    final UserHandle user = Process.myUserHandle();
                    mWorkspace.removeAbandonedPromise(packageName, user);
                }
            })
        .create().show();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:26,代碼來源:Launcher.java

示例7: getApplicationInfo

import android.os.Process; //導入依賴的package包/類
@Override
public ApplicationInfo getApplicationInfo(String packageName, int flags, UserHandle user) {
    final boolean isPrimaryUser = Process.myUserHandle().equals(user);
    if (!isPrimaryUser && (flags == 0)) {
        // We are looking for an installed app on a secondary profile. Prior to O, the only
        // entry point for work profiles is through the LauncherActivity.
        List<LauncherActivityInfo> activityList =
                mLauncherApps.getActivityList(packageName, user);
        return activityList.size() > 0 ? activityList.get(0).getApplicationInfo() : null;
    }
    try {
        ApplicationInfo info =
                mContext.getPackageManager().getApplicationInfo(packageName, flags);
        // There is no way to check if the app is installed for managed profile. But for
        // primary profile, we can still have this check.
        if (isPrimaryUser && ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0)
                || !info.enabled) {
            return null;
        }
        return info;
    } catch (PackageManager.NameNotFoundException e) {
        // Package not found
        return null;
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:26,代碼來源:LauncherAppsCompatVL.java

示例8: call

import android.os.Process; //導入依賴的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

示例9: testCanRecordEvent

import android.os.Process; //導入依賴的package包/類
@SmallTest
@Feature({"Android-AppBase"})
public void testCanRecordEvent() {
    EarlyTraceEvent.enable();
    long myThreadId = Process.myTid();
    long beforeMs = SystemClock.elapsedRealtime();
    EarlyTraceEvent.begin(EVENT_NAME);
    EarlyTraceEvent.end(EVENT_NAME);
    long afterMs = SystemClock.elapsedRealtime();

    assertEquals(1, EarlyTraceEvent.sCompletedEvents.size());
    assertTrue(EarlyTraceEvent.sPendingEvents.isEmpty());
    EarlyTraceEvent.Event event = EarlyTraceEvent.sCompletedEvents.get(0);
    assertEquals(EVENT_NAME, event.mName);
    assertEquals(myThreadId, event.mThreadId);
    assertTrue(beforeMs <= event.mBeginTimeMs && event.mBeginTimeMs <= afterMs);
    assertTrue(event.mBeginTimeMs <= event.mEndTimeMs);
    assertTrue(beforeMs <= event.mEndTimeMs && event.mEndTimeMs <= afterMs);
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:20,代碼來源:EarlyTraceEventTest.java

示例10: onDestroy

import android.os.Process; //導入依賴的package包/類
public void onDestroy() {
    super.onDestroy();
    new StringBuilder(z[55]).append(Process.myPid());
    z.b();
    e.l = false;
    if (this.i != null) {
        this.i.removeCallbacksAndMessages(null);
    }
    cn.jpush.android.util.a.p(getApplicationContext());
    if (this.f != null) {
        n nVar = this.f;
        if (VERSION.SDK_INT >= 18) {
            nVar.quitSafely();
        } else {
            nVar.quit();
        }
    }
    if (!(this.h == null || k.a.get() == 0)) {
        this.h.a();
    }
    if (this.g != null && !this.g.isShutdown()) {
        a(this.g);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:25,代碼來源:PushService.java

示例11: generateSeed

import android.os.Process; //導入依賴的package包/類
/**
 * Generates a device- and invocation-specific seed to be mixed into the
 * Linux PRNG.
 */
private static byte[] generateSeed() {
  try {
    ByteArrayOutputStream seedBuffer = new ByteArrayOutputStream();
    DataOutputStream seedBufferOut =
        new DataOutputStream(seedBuffer);
    seedBufferOut.writeLong(System.currentTimeMillis());
    seedBufferOut.writeLong(System.nanoTime());
    seedBufferOut.writeInt(Process.myPid());
    seedBufferOut.writeInt(Process.myUid());
    seedBufferOut.write(BUILD_FINGERPRINT_AND_DEVICE_SERIAL);
    seedBufferOut.close();
    return seedBuffer.toByteArray();
  } catch (IOException e) {
    throw new SecurityException("Failed to generate seed", e);
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:21,代碼來源:PRNGFixes.java

示例12: newThread

import android.os.Process; //導入依賴的package包/類
@Override
public Thread newThread(final Runnable r) {
    Runnable wrapper = new Runnable() {
        @Override
        public void run() {
            try {
                // compression of the thread priority is 0.
                Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
            } catch (Throwable t) {
                t.printStackTrace();
            }
            r.run();
        }
    };

    String workThreadName = COMPRESS_THREAD_PREFIX_NAME + "-" + mThreadNumber.getAndIncrement();

    Thread thread = new Thread(wrapper, workThreadName);
    if (thread.isDaemon())
        thread.setDaemon(false);

    return thread;
}
 
開發者ID:ghnor,項目名稱:Flora,代碼行數:24,代碼來源:CompressThreadFactory.java

示例13: createShortcutInfo

import android.os.Process; //導入依賴的package包/類
private static ShortcutInfo createShortcutInfo(Intent data, LauncherAppState app) {
    Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
    Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);

    if (intent == null) {
        // If the intent is null, we can't construct a valid ShortcutInfo, so we return null
        return null;
    }

    final ShortcutInfo info = new ShortcutInfo();

    // Only support intents for current user for now. Intents sent from other
    // users wouldn't get here without intent forwarding anyway.
    info.user = Process.myUserHandle();

    if (bitmap instanceof Bitmap) {
        info.iconBitmap = LauncherIcons.createIconBitmap((Bitmap) bitmap, app.getContext());
    } else {
        Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
        if (extra instanceof Intent.ShortcutIconResource) {
            info.iconResource = (Intent.ShortcutIconResource) extra;
            info.iconBitmap = LauncherIcons.createIconBitmap(info.iconResource, app.getContext());
        }
    }
    if (info.iconBitmap == null) {
        info.iconBitmap = app.getIconCache().getDefaultIcon(info.user);
    }

    info.title = Utilities.trim(name);
    info.contentDescription = UserManagerCompat.getInstance(app.getContext())
            .getBadgedLabelForUser(info.title, info.user);
    info.intent = intent;
    return info;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:36,代碼來源:InstallShortcutReceiver.java

示例14: run

import android.os.Process; //導入依賴的package包/類
public void run() {
    Process.setThreadPriority(10);
    while (!this.d) {
        try {
            Request request = (Request) this.c.take();
            if (!request.h()) {
                a(request);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
            if (this.d) {
                return;
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:r.java

示例15: optionTutorial

import android.os.Process; //導入依賴的package包/類
private void optionTutorial() {
	((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
	((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
	int userId = Util.getUserId(Process.myUid());
	PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialMain, Boolean.FALSE.toString());

	Dialog dlgUsage = new Dialog(this);
	dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON);
	dlgUsage.setTitle(R.string.title_usage_header);
	dlgUsage.setContentView(R.layout.usage);
	dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
	dlgUsage.setCancelable(true);
	dlgUsage.show();
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:15,代碼來源:ActivityMain.java


注:本文中的android.os.Process類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。