android.os.Trace Java Examples
The following examples show how to use
android.os.Trace.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InputMethodManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void finishedInputEvent(int seq, boolean handled, boolean timeout) { final PendingEvent p; synchronized (mH) { int index = mPendingEvents.indexOfKey(seq); if (index < 0) { return; // spurious, event already finished or timed out } p = mPendingEvents.valueAt(index); mPendingEvents.removeAt(index); Trace.traceCounter(Trace.TRACE_TAG_INPUT, PENDING_EVENT_COUNTER, mPendingEvents.size()); if (timeout) { Log.w(TAG, "Timeout waiting for IME to handle input event after " + INPUT_METHOD_NOT_RESPONDING_TIMEOUT + " ms: " + p.mInputMethodId); } else { mH.removeMessages(MSG_TIMEOUT_INPUT_EVENT, p); } } invokeFinishedInputEventCallback(p, handled); }
Example #2
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void logScreenOn() { Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, TRACE_SCREEN_ON, 0); final int latencyMs = (int) (SystemClock.uptimeMillis() - mLastWakeTime); LogMaker log = new LogMaker(MetricsEvent.SCREEN); log.setType(MetricsEvent.TYPE_OPEN); log.setSubtype(0); // not user initiated log.setLatency(latencyMs); // How long it took. MetricsLogger.action(log); EventLogTags.writePowerScreenState(1, 0, 0, 0, latencyMs); if (latencyMs >= SCREEN_ON_LATENCY_WARNING_MS) { Slog.w(TAG, "Screen on took " + latencyMs+ " ms"); } }
Example #3
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private boolean reallyGoToSleepNoUpdateLocked(long eventTime, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "reallyGoToSleepNoUpdateLocked: eventTime=" + eventTime + ", uid=" + uid); } if (eventTime < mLastWakeTime || mWakefulness == WAKEFULNESS_ASLEEP || !mBootCompleted || !mSystemReady) { return false; } Trace.traceBegin(Trace.TRACE_TAG_POWER, "reallyGoToSleep"); try { Slog.i(TAG, "Sleeping (uid " + uid +")..."); setWakefulnessLocked(WAKEFULNESS_ASLEEP, PowerManager.GO_TO_SLEEP_REASON_TIMEOUT); } finally { Trace.traceEnd(Trace.TRACE_TAG_POWER); } return true; }
Example #4
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private boolean napNoUpdateLocked(long eventTime, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "napNoUpdateLocked: eventTime=" + eventTime + ", uid=" + uid); } if (eventTime < mLastWakeTime || mWakefulness != WAKEFULNESS_AWAKE || !mBootCompleted || !mSystemReady) { return false; } Trace.traceBegin(Trace.TRACE_TAG_POWER, "nap"); try { Slog.i(TAG, "Nap time (uid " + uid +")..."); mSandmanSummoned = true; setWakefulnessLocked(WAKEFULNESS_DREAMING, 0); } finally { Trace.traceEnd(Trace.TRACE_TAG_POWER); } return true; }
Example #5
Source File: MaterialColorMapUtils.java From droidddle with Apache License 2.0 | 6 votes |
/** * Return primary and secondary colors from the Material color palette that are similar to * {@param color}. */ public MaterialPalette calculatePrimaryAndSecondaryColor(int color) { Trace.beginSection("calculatePrimaryAndSecondaryColor"); final float colorHue = hue(color); float minimumDistance = Float.MAX_VALUE; int indexBestMatch = 0; for (int i = 0; i < sPrimaryColors.length(); i++) { final int primaryColor = sPrimaryColors.getColor(i, 0); final float comparedHue = hue(primaryColor); // No need to be perceptually accurate when calculating color distances since // we are only mapping to 15 colors. Being slightly inaccurate isn't going to change // the mapping very often. final float distance = Math.abs(comparedHue - colorHue); if (distance < minimumDistance) { minimumDistance = distance; indexBestMatch = i; } } Trace.endSection(); return new MaterialPalette(sPrimaryColors.getColor(indexBestMatch, 0), sSecondaryColors.getColor(indexBestMatch, 0)); }
Example #6
Source File: SwitchAccessService.java From talkback with Apache License 2.0 | 6 votes |
/** * Intended to mimic the behavior of onKeyEvent if this were the only service running. It will be * called from onKeyEvent, both from this service and from others in this apk (TalkBack). This * method must not block, since it will block onKeyEvent as well. * * @param keyEvent A key event * @return {@code true} if the event is handled, {@code false} otherwise. */ @Override public boolean onKeyEventShared(KeyEvent keyEvent) { Trace.beginSection("SwitchAccessService#onKeyEventShared"); if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { PerformanceMonitor.getOrCreateInstance() .startNewTimerEvent(KeyPressEvent.UNKNOWN_KEY_ASSIGNMENT); } if (keyboardEventManager.onKeyEvent(keyEvent, analytics, this)) { wakeLock.acquire(); wakeLock.release(); Trace.endSection(); return true; } Trace.endSection(); return false; }
Example #7
Source File: ThreadedRenderer.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void updateRootDisplayList(View view, DrawCallbacks callbacks) { Trace.traceBegin(Trace.TRACE_TAG_VIEW, "Record View#draw()"); updateViewTreeDisplayList(view); if (mRootNodeNeedsUpdate || !mRootNode.isValid()) { DisplayListCanvas canvas = mRootNode.start(mSurfaceWidth, mSurfaceHeight); try { final int saveCount = canvas.save(); canvas.translate(mInsetLeft, mInsetTop); callbacks.onPreDraw(canvas); canvas.insertReorderBarrier(); canvas.drawRenderNode(view.updateDisplayListIfDirty()); canvas.insertInorderBarrier(); callbacks.onPostDraw(canvas); canvas.restoreToCount(saveCount); mRootNodeNeedsUpdate = false; } finally { mRootNode.end(canvas); } } Trace.traceEnd(Trace.TRACE_TAG_VIEW); }
Example #8
Source File: RuntimeInit.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
protected static Runnable applicationInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) { // If the application calls System.exit(), terminate the process // immediately without running any shutdown hooks. It is not possible to // shutdown an Android application gracefully. Among other things, the // Android runtime shutdown hooks close the Binder driver, which can cause // leftover running threads to crash before the process actually exits. nativeSetExitWithoutCleanup(true); // We want to be fairly aggressive about heap utilization, to avoid // holding on to a lot of memory that isn't needed. // //设置虚拟机的内存利用率参数值为 0.75 VMRuntime.getRuntime().setTargetHeapUtilization(0.75f); VMRuntime.getRuntime().setTargetSdkVersion(targetSdkVersion); final Arguments args = new Arguments(argv); // 解析参数 // The end of of the RuntimeInit event (see #zygoteInit). Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); // Remaining arguments are passed to the start class's static main // 寻找 startClass 的 main() 方法。这里的 startClass 是 com.android.server.SystemServer return findStaticMain(args.startClass, args.startArgs, classLoader); }
Example #9
Source File: SwitchAccessNodeCompat.java From talkback with Apache License 2.0 | 6 votes |
private void reduceVisibleRectangleForWindowsAbove(Rect visibleRect) { Trace.beginSection("SwitchAccessNodeCompat#reduceVisibleRectangleForWindowsAbove"); Rect windowBoundsInScreen = new Rect(); int visibleRectWidth = visibleRect.right - visibleRect.left; int visibleRectHeight = visibleRect.bottom - visibleRect.top; for (int i = 0; i < windowsAbove.size(); ++i) { windowsAbove.get(i).getBoundsInScreen(windowBoundsInScreen); windowBoundsInScreen.sort(); Rect intersectingRectangle = new Rect(visibleRect); if (intersectingRectangle.intersect(windowBoundsInScreen)) { // If the rect above occupies less than a fraction of both sides of this rect, don't // adjust this rect's bounds. This prevents things like FABs changing the bounds // of scroll views under them. if (((intersectingRectangle.right - intersectingRectangle.left) < (visibleRectWidth * MIN_INTERSECTION_TO_CROP)) && ((intersectingRectangle.bottom - intersectingRectangle.top) < (visibleRectHeight * MIN_INTERSECTION_TO_CROP))) { Trace.endSection(); return; } adjustRectToAvoidIntersection(visibleRect, windowBoundsInScreen); } } Trace.endSection(); }
Example #10
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void release() { synchronized (this) { mReferenceCount -= 1; if (mReferenceCount == 0) { if (DEBUG_SPEW) { Slog.d(TAG, "Releasing suspend blocker \"" + mName + "\"."); } nativeReleaseSuspendBlocker(mName); Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, mTraceName, 0); } else if (mReferenceCount < 0) { Slog.wtf(TAG, "Suspend blocker \"" + mName + "\" was released without being acquired!", new Throwable()); mReferenceCount = 0; } } }
Example #11
Source File: VibratorService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void doVibratorOff() { Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "doVibratorOff"); try { synchronized (mInputDeviceVibrators) { if (DEBUG) { Slog.d(TAG, "Turning vibrator off."); } noteVibratorOffLocked(); final int vibratorCount = mInputDeviceVibrators.size(); if (vibratorCount != 0) { for (int i = 0; i < vibratorCount; i++) { mInputDeviceVibrators.get(i).cancel(); } } else { vibratorOff(); } } } finally { Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR); } }
Example #12
Source File: VibratorService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@GuardedBy("mLock") private void doCancelVibrateLocked() { Trace.asyncTraceEnd(Trace.TRACE_TAG_VIBRATOR, "vibration", 0); Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "doCancelVibrateLocked"); try { mH.removeCallbacks(mVibrationEndRunnable); if (mThread != null) { mThread.cancel(); mThread = null; } doVibratorOff(); reportFinishVibrationLocked(); } finally { Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR); } }
Example #13
Source File: SwitchAccessNodeCompat.java From talkback with Apache License 2.0 | 6 votes |
@Override public boolean isVisibleToUser() { Trace.beginSection("SwitchAccessNodeCompat#isVisibleToUser"); if (!isOnScreenAndVisibleToUser()) { Trace.endSection(); return false; } // Views are considered visible only if a minimum number of pixels is showing. Rect visibleBounds = new Rect(); getVisibleBoundsInScreen(visibleBounds); int visibleHeight = visibleBounds.height(); int visibleWidth = visibleBounds.width(); boolean isVisible = (visibleHeight >= MIN_VISIBLE_PIXELS) && (visibleWidth >= MIN_VISIBLE_PIXELS); Trace.endSection(); return isVisible; }
Example #14
Source File: AlarmManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void deliverAlarmsLocked(ArrayList<Alarm> triggerList, long nowELAPSED) { mLastAlarmDeliveryTime = nowELAPSED; for (int i=0; i<triggerList.size(); i++) { Alarm alarm = triggerList.get(i); final boolean allowWhileIdle = (alarm.flags&AlarmManager.FLAG_ALLOW_WHILE_IDLE) != 0; if (alarm.wakeup) { Trace.traceBegin(Trace.TRACE_TAG_POWER, "Dispatch wakeup alarm to " + alarm.packageName); } else { Trace.traceBegin(Trace.TRACE_TAG_POWER, "Dispatch non-wakeup alarm to " + alarm.packageName); } try { if (localLOGV) { Slog.v(TAG, "sending alarm " + alarm); } if (RECORD_ALARMS_IN_HISTORY) { ActivityManager.noteAlarmStart(alarm.operation, alarm.workSource, alarm.uid, alarm.statsTag); } mDeliveryTracker.deliverLocked(alarm, nowELAPSED, allowWhileIdle); } catch (RuntimeException e) { Slog.w(TAG, "Failure sending alarm.", e); } Trace.traceEnd(Trace.TRACE_TAG_POWER); } }
Example #15
Source File: WindowTracing.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void traceStateLocked(String where, WindowManagerService service) { if (!isEnabled()) { return; } ProtoOutputStream os = new ProtoOutputStream(); long tokenOuter = os.start(ENTRY); os.write(ELAPSED_REALTIME_NANOS, SystemClock.elapsedRealtimeNanos()); os.write(WHERE, where); Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "writeToProtoLocked"); try { long tokenInner = os.start(WINDOW_MANAGER_SERVICE); service.writeToProtoLocked(os, true /* trim */); os.end(tokenInner); } finally { Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); } os.end(tokenOuter); appendTraceEntry(os); Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); }
Example #16
Source File: ViewPerformanceSampler.java From BlockCanaryEx with Apache License 2.0 | 6 votes |
static void install() { if (!installed) { installed = true; if (isSupported()) { try { Method traceBegin = Trace.class.getDeclaredMethod("traceBegin", long.class, String.class); Method traceEnd = Trace.class.getDeclaredMethod("traceEnd", long.class); Hook.hook(traceBegin, ViewPerformanceSampler.class.getDeclaredMethod("traceBegin", long.class, String.class)); Hook.hook(traceEnd, ViewPerformanceSampler.class.getDeclaredMethod("traceEnd", long.class)); } catch (NoSuchMethodException e) { e.printStackTrace(); } } } }
Example #17
Source File: DebugLogAspect.java From AndroidProject with Apache License 2.0 | 6 votes |
/** * 方法执行前切入 */ private void enterMethod(ProceedingJoinPoint joinPoint, DebugLog debugLog) { if (!AppConfig.isDebug()) { return; } CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); // 方法所在类 String className = codeSignature.getDeclaringType().getName(); // 方法名 String methodName = codeSignature.getName(); // 方法参数名集合 String[] parameterNames = codeSignature.getParameterNames(); // 方法参数集合 Object[] parameterValues = joinPoint.getArgs(); //记录并打印方法的信息 StringBuilder builder = getMethodLogInfo(className, methodName, parameterNames, parameterValues); log(debugLog.value(), builder.toString()); final String section = builder.toString().substring(2); Trace.beginSection(section); }
Example #18
Source File: SystemServiceManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void stopUser(final int userHandle) { Slog.i(TAG, "Calling onStopUser u" + userHandle); final int serviceLen = mServices.size(); for (int i = 0; i < serviceLen; i++) { final SystemService service = mServices.get(i); Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "onStopUser " + service.getClass().getName()); long time = SystemClock.elapsedRealtime(); try { service.onStopUser(userHandle); } catch (Exception ex) { Slog.wtf(TAG, "Failure reporting stop of user " + userHandle + " to service " + service.getClass().getName(), ex); } warnIfTooLong(SystemClock.elapsedRealtime() - time, service, "onStopUser"); Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER); } }
Example #19
Source File: UserController.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void onFinished(int id, Bundle extras) throws RemoteException { long unlockTime = SystemClock.uptimeMillis() - mUnlockStarted; // Report system user unlock time to perf dashboard if (id == UserHandle.USER_SYSTEM) { new TimingsTraceLog("SystemServerTiming", Trace.TRACE_TAG_SYSTEM_SERVER) .logDuration("SystemUserUnlock", unlockTime); } else { Slog.d(TAG, "Unlocking user " + id + " took " + unlockTime + " ms"); } }
Example #20
Source File: AnimationThread.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static void ensureThreadLocked() { if (sInstance == null) { sInstance = new AnimationThread(); sInstance.start(); sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_WINDOW_MANAGER); sHandler = new Handler(sInstance.getLooper()); } }
Example #21
Source File: ZygoteInit.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
static void preload(TimingsTraceLog bootTimingsTraceLog) { Log.d(TAG, "begin preload"); bootTimingsTraceLog.traceBegin("BeginIcuCachePinning"); beginIcuCachePinning(); bootTimingsTraceLog.traceEnd(); // BeginIcuCachePinning bootTimingsTraceLog.traceBegin("PreloadClasses"); preloadClasses(); // 预加载并初始化 /system/etc/preloaded-classes 中的类 bootTimingsTraceLog.traceEnd(); // PreloadClasses bootTimingsTraceLog.traceBegin("PreloadResources"); preloadResources(); // 预加载系统资源 bootTimingsTraceLog.traceEnd(); // PreloadResources Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadAppProcessHALs"); nativePreloadAppProcessHALs(); // HAL? Trace.traceEnd(Trace.TRACE_TAG_DALVIK); Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadOpenGL"); preloadOpenGL(); // 预加载 OpenGL Trace.traceEnd(Trace.TRACE_TAG_DALVIK); preloadSharedLibraries(); // 预加载 共享库,包括 android、compiler_rt、jnigraphics 这三个库 preloadTextResources(); // 预加载文字资源 // Ask the WebViewFactory to do any initialization that must run in the zygote process, // for memory sharing purposes. // WebViewFactory 中一些必须在 zygote 进程中进行的初始化工作,用于共享内存 WebViewFactory.prepareWebViewInZygote(); endIcuCachePinning(); warmUpJcaProviders(); Log.d(TAG, "end preload"); sPreloadComplete = true; }
Example #22
Source File: NewIntentItem.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void execute(ClientTransactionHandler client, IBinder token, PendingTransactionActions pendingActions) { Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "activityNewIntent"); client.handleNewIntent(token, mIntents, mPause); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); }
Example #23
Source File: VibratorService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@GuardedBy("mLock") private void reportFinishVibrationLocked() { Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "reportFinishVibrationLocked"); try { if (mCurrentVibration != null) { mAppOps.finishOp(AppOpsManager.OP_VIBRATE, mCurrentVibration.uid, mCurrentVibration.opPkg); unlinkVibration(mCurrentVibration); mCurrentVibration = null; } } finally { Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR); } }
Example #24
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override protected void finalize() throws Throwable { try { if (mReferenceCount != 0) { Slog.wtf(TAG, "Suspend blocker \"" + mName + "\" was finalized without being released!"); mReferenceCount = 0; nativeReleaseSuspendBlocker(mName); Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, mTraceName, 0); } } finally { super.finalize(); } }
Example #25
Source File: DisplayContent.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** Updates the layer assignment of windows on this display. */ void assignWindowLayers(boolean setLayoutNeeded) { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "assignWindowLayers"); assignChildLayers(getPendingTransaction()); if (setLayoutNeeded) { setLayoutNeeded(); } // We accumlate the layer changes in-to "getPendingTransaction()" but we defer // the application of this transaction until the animation pass triggers // prepareSurfaces. This allows us to synchronize Z-ordering changes with // the hiding and showing of surfaces. scheduleAnimation(); Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); }
Example #26
Source File: PauseActivityItem.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void execute(ClientTransactionHandler client, IBinder token, PendingTransactionActions pendingActions) { Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "activityPause"); // 调用 ActiivtyThread.handlePauseActivity() client.handlePauseActivity(token, mFinished, mUserLeaving, mConfigChanges, pendingActions, "PAUSE_ACTIVITY_ITEM"); Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); }
Example #27
Source File: TimingsTraceLog.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Begin tracing named section * @param name name to appear in trace */ public void traceBegin(String name) { assertSameThread(); Trace.traceBegin(mTraceTag, name); if (DEBUG_BOOT_TIME) { mStartTimes.push(Pair.create(name, SystemClock.elapsedRealtime())); } }
Example #28
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void setHalAutoSuspendModeLocked(boolean enable) { if (enable != mHalAutoSuspendModeEnabled) { if (DEBUG) { Slog.d(TAG, "Setting HAL auto-suspend mode to " + enable); } mHalAutoSuspendModeEnabled = enable; Trace.traceBegin(Trace.TRACE_TAG_POWER, "setHalAutoSuspend(" + enable + ")"); try { nativeSetAutoSuspend(enable); } finally { Trace.traceEnd(Trace.TRACE_TAG_POWER); } } }
Example #29
Source File: MainActivity.java From Girls with Apache License 2.0 | 5 votes |
@Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { super.onSaveInstanceState(outState, outPersistentState); // Necessary to restore the BottomBar's state, otherwise we would // lose the current tab on orientation change. Trace.beginSection("onSaveInstanceState"); mBottomBar.onSaveInstanceState(outState); Trace.endSection(); }
Example #30
Source File: SurfaceAnimationThread.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static void ensureThreadLocked() { if (sInstance == null) { sInstance = new SurfaceAnimationThread(); sInstance.start(); sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_WINDOW_MANAGER); sHandler = new Handler(sInstance.getLooper()); } }