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

The following examples show how to use android.os.Trace#isTagEnabled() . 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: GraphicsStatsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void saveBuffer(HistoricalBuffer buffer) {
    if (Trace.isTagEnabled(Trace.TRACE_TAG_SYSTEM_SERVER)) {
        Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "saving graphicsstats for " + buffer.mInfo.packageName);
    }
    synchronized (mFileAccessLock) {
        File path = pathForApp(buffer.mInfo);
        File parent = path.getParentFile();
        parent.mkdirs();
        if (!parent.exists()) {
            Log.w(TAG, "Unable to create path: '" + parent.getAbsolutePath() + "'");
            return;
        }
        nSaveBuffer(path.getAbsolutePath(), buffer.mInfo.packageName, buffer.mInfo.versionCode,
                buffer.mInfo.startTime, buffer.mInfo.endTime, buffer.mData);
    }
    Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
}
 
Example 3
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 4
Source File: ValueAnimator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Called internally to start an animation by adding it to the active animations list. Must be
 * called on the UI thread.
 */
private void startAnimation() {
    if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
        Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW, getNameForTrace(),
                System.identityHashCode(this));
    }

    mAnimationEndRequested = false;
    initAnimation();
    mRunning = true;
    if (mSeekFraction >= 0) {
        mOverallFraction = mSeekFraction;
    } else {
        mOverallFraction = 0f;
    }
    if (mListeners != null) {
        notifyStartListeners();
    }
}
 
Example 5
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 6
Source File: BroadcastQueue.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * Don't call this method directly; call enqueueParallelBroadcastLocked or
 * enqueueOrderedBroadcastLocked.
 */
private void enqueueBroadcastHelper(BroadcastRecord r) {
    r.enqueueClockTime = System.currentTimeMillis();

    if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
        Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER,
            createBroadcastTraceTitle(r, BroadcastRecord.DELIVERY_PENDING),
            System.identityHashCode(r));
    }
}
 
Example 7
Source File: BroadcastQueue.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Don't call this method directly; call enqueueParallelBroadcastLocked or
 * enqueueOrderedBroadcastLocked.
 */
private void enqueueBroadcastHelper(BroadcastRecord r) {
    r.enqueueClockTime = System.currentTimeMillis();

    if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
        Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER,
            createBroadcastTraceTitle(r, BroadcastRecord.DELIVERY_PENDING),
            System.identityHashCode(r));
    }
}
 
Example 8
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 9
Source File: WebViewDelegate.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Returns {@code true} if the WebView trace tag is enabled and {@code false} otherwise.
 */
public boolean isTraceTagEnabled() {
    return Trace.isTagEnabled(Trace.TRACE_TAG_WEBVIEW);
}
 
Example 10
Source File: SQLiteConnection.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public int beginOperation(String kind, String sql, Object[] bindArgs) {
    synchronized (mOperations) {
        final int index = (mIndex + 1) % MAX_RECENT_OPERATIONS;
        Operation operation = mOperations[index];
        if (operation == null) {
            operation = new Operation();
            mOperations[index] = operation;
        } else {
            operation.mFinished = false;
            operation.mException = null;
            if (operation.mBindArgs != null) {
                operation.mBindArgs.clear();
            }
        }
        operation.mStartWallTime = System.currentTimeMillis();
        operation.mStartTime = SystemClock.uptimeMillis();
        operation.mKind = kind;
        operation.mSql = sql;
        if (bindArgs != null) {
            if (operation.mBindArgs == null) {
                operation.mBindArgs = new ArrayList<Object>();
            } else {
                operation.mBindArgs.clear();
            }
            for (int i = 0; i < bindArgs.length; i++) {
                final Object arg = bindArgs[i];
                if (arg != null && arg instanceof byte[]) {
                    // Don't hold onto the real byte array longer than necessary.
                    operation.mBindArgs.add(EMPTY_BYTE_ARRAY);
                } else {
                    operation.mBindArgs.add(arg);
                }
            }
        }
        operation.mCookie = newOperationCookieLocked(index);
        if (Trace.isTagEnabled(Trace.TRACE_TAG_DATABASE)) {
            Trace.asyncTraceBegin(Trace.TRACE_TAG_DATABASE, operation.getTraceMethodName(),
                    operation.mCookie);
        }
        mIndex = index;
        return operation.mCookie;
    }
}