本文整理汇总了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);
}
}
示例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);
}
示例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;
}
}
}
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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;
}
}
示例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()]);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
示例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();
}