Java Code Examples for android.os.Trace#asyncTraceEnd()

The following examples show how to use android.os.Trace#asyncTraceEnd() . 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: BroadcastQueue.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
private final void addBroadcastToHistoryLocked(BroadcastRecord original) {
    if (original.callingUid < 0) {
        // This was from a registerReceiver() call; ignore it.
        return;
    }
    original.finishTime = SystemClock.uptimeMillis();

    if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
        Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER,
            createBroadcastTraceTitle(original, BroadcastRecord.DELIVERY_DELIVERED),
            System.identityHashCode(original));
    }

    // Note sometimes (only for sticky broadcasts?) we reuse BroadcastRecords,
    // So don't change the incoming record directly.
    final BroadcastRecord historyRecord = original.maybeStripForHistory();

    mBroadcastHistory[mHistoryNext] = historyRecord;
    mHistoryNext = ringAdvance(mHistoryNext, 1, MAX_BROADCAST_HISTORY);

    mBroadcastSummaryHistory[mSummaryHistoryNext] = historyRecord.intent;
    mSummaryHistoryEnqueueTime[mSummaryHistoryNext] = historyRecord.enqueueClockTime;
    mSummaryHistoryDispatchTime[mSummaryHistoryNext] = historyRecord.dispatchClockTime;
    mSummaryHistoryFinishTime[mSummaryHistoryNext] = System.currentTimeMillis();
    mSummaryHistoryNext = ringAdvance(mSummaryHistoryNext, 1, MAX_BROADCAST_SUMMARY_HISTORY);
}
 
Example 2
Source File: VibratorService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
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 4
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: BroadcastQueue.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private final void addBroadcastToHistoryLocked(BroadcastRecord original) {
    if (original.callingUid < 0) {
        // This was from a registerReceiver() call; ignore it.
        return;
    }
    original.finishTime = SystemClock.uptimeMillis();

    if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
        Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER,
            createBroadcastTraceTitle(original, BroadcastRecord.DELIVERY_DELIVERED),
            System.identityHashCode(original));
    }

    // Note sometimes (only for sticky broadcasts?) we reuse BroadcastRecords,
    // So don't change the incoming record directly.
    final BroadcastRecord historyRecord = original.maybeStripForHistory();

    mBroadcastHistory[mHistoryNext] = historyRecord;
    mHistoryNext = ringAdvance(mHistoryNext, 1, MAX_BROADCAST_HISTORY);

    mBroadcastSummaryHistory[mSummaryHistoryNext] = historyRecord.intent;
    mSummaryHistoryEnqueueTime[mSummaryHistoryNext] = historyRecord.enqueueClockTime;
    mSummaryHistoryDispatchTime[mSummaryHistoryNext] = historyRecord.dispatchClockTime;
    mSummaryHistoryFinishTime[mSummaryHistoryNext] = System.currentTimeMillis();
    mSummaryHistoryNext = ringAdvance(mSummaryHistoryNext, 1, MAX_BROADCAST_SUMMARY_HISTORY);
}
 
Example 6
Source File: UserState.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void setState(int newState) {
    if (newState == state) {
        return;
    }
    final int userId = mHandle.getIdentifier();
    if (state != STATE_BOOTING) {
        Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER,
                stateToString(state) + " " + userId, userId);
    }
    if (newState != STATE_SHUTDOWN) {
        Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER,
                stateToString(newState) + " " + userId, userId);
    }
    Slog.i(TAG, "User " + userId + " state changed from "
            + stateToString(state) + " to " + stateToString(newState));
    EventLogTags.writeAmUserStateChanged(userId, newState);
    lastState = state;
    state = newState;
}
 
Example 7
Source File: SQLiteConnection.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private boolean endOperationDeferLogLocked(int cookie) {
    final Operation operation = getOperationLocked(cookie);
    if (operation != null) {
        if (Trace.isTagEnabled(Trace.TRACE_TAG_DATABASE)) {
            Trace.asyncTraceEnd(Trace.TRACE_TAG_DATABASE, operation.getTraceMethodName(),
                    operation.mCookie);
        }
        operation.mEndTime = SystemClock.uptimeMillis();
        operation.mFinished = true;
        final long execTime = operation.mEndTime - operation.mStartTime;
        mPool.onStatementExecuted(execTime);
        return SQLiteDebug.DEBUG_LOG_SLOW_QUERIES && SQLiteDebug.shouldLogSlowQuery(
                execTime);
    }
    return false;
}
 
Example 8
Source File: DisplayPowerController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void unblockScreenOn() {
    if (mPendingScreenOnUnblocker != null) {
        mPendingScreenOnUnblocker = null;
        long delay = SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime;
        Slog.i(TAG, "Unblocked screen on after " + delay + " ms");
        Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, SCREEN_ON_BLOCKED_TRACE_NAME, 0);
    }
}
 
Example 9
Source File: DisplayPowerController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void unblockScreenOff() {
    if (mPendingScreenOffUnblocker != null) {
        mPendingScreenOffUnblocker = null;
        long delay = SystemClock.elapsedRealtime() - mScreenOffBlockStartRealTime;
        Slog.i(TAG, "Unblocked screen off after " + delay + " ms");
        Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, SCREEN_OFF_BLOCKED_TRACE_NAME, 0);
    }
}
 
Example 10
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: ActivityMetricsLogger.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void stopLaunchTrace(WindowingModeTransitionInfo info) {
    if (info == null) {
        return;
    }
    if (info.launchTraceActive) {
        Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching: "
                + info.launchedActivity.packageName, 0);
        info.launchTraceActive = false;
    }
}
 
Example 12
Source File: ValueAnimator.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Called internally to end an animation by removing it from the animations list. Must be
 * called on the UI thread.
 */
private void endAnimation() {
    if (mAnimationEndRequested) {
        return;
    }
    removeAnimationCallback();

    mAnimationEndRequested = true;
    mPaused = false;
    boolean notify = (mStarted || mRunning) && mListeners != null;
    if (notify && !mRunning) {
        // If it's not yet running, then start listeners weren't called. Call them now.
        notifyStartListeners();
    }
    mRunning = false;
    mStarted = false;
    mStartListenersCalled = false;
    mLastFrameTime = -1;
    mFirstFrameTime = -1;
    mStartTime = -1;
    if (notify && mListeners != null) {
        ArrayList<AnimatorListener> tmpListeners =
                (ArrayList<AnimatorListener>) mListeners.clone();
        int numListeners = tmpListeners.size();
        for (int i = 0; i < numListeners; ++i) {
            tmpListeners.get(i).onAnimationEnd(this, mReversing);
        }
    }
    // mReversing needs to be reset *after* notifying the listeners for the end callbacks.
    mReversing = false;
    if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
        Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, getNameForTrace(),
                System.identityHashCode(this));
    }
}
 
Example 13
Source File: ActivityMetricsLogger.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
void stopFullyDrawnTraceIfNeeded() {
    if (mDrawingTraceActive) {
        Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
        mDrawingTraceActive = false;
    }
}