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

The following examples show how to use android.os.Trace#asyncTraceBegin() . 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: ActivityMetricsLogger.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Starts traces for app launch and draw times. We stop the fully drawn trace if its already
 * active since the app may not have reported fully drawn in the previous launch.
 *
 * See {@link android.app.Activity#reportFullyDrawn()}
 *
 * @param info
 * */
private void startTraces(WindowingModeTransitionInfo info) {
    if (info == null) {
        return;
    }
    stopFullyDrawnTraceIfNeeded();
    int transitionType = getTransitionType(info);
    if (!info.launchTraceActive && transitionType == TYPE_TRANSITION_WARM_LAUNCH
            || transitionType == TYPE_TRANSITION_COLD_LAUNCH) {
        Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching: "
                + info.launchedActivity.packageName, 0);
        Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
        mDrawingTraceActive = true;
        info.launchTraceActive = true;
    }
}
 
Example 2
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 3
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 4
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 5
Source File: DisplayPowerController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void blockScreenOn() {
    if (mPendingScreenOnUnblocker == null) {
        Trace.asyncTraceBegin(Trace.TRACE_TAG_POWER, SCREEN_ON_BLOCKED_TRACE_NAME, 0);
        mPendingScreenOnUnblocker = new ScreenOnUnblocker();
        mScreenOnBlockStartRealTime = SystemClock.elapsedRealtime();
        Slog.i(TAG, "Blocking screen on until initial contents have been drawn.");
    }
}
 
Example 6
Source File: DisplayPowerController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void blockScreenOff() {
    if (mPendingScreenOffUnblocker == null) {
        Trace.asyncTraceBegin(Trace.TRACE_TAG_POWER, SCREEN_OFF_BLOCKED_TRACE_NAME, 0);
        mPendingScreenOffUnblocker = new ScreenOffUnblocker();
        mScreenOffBlockStartRealTime = SystemClock.elapsedRealtime();
        Slog.i(TAG, "Blocking screen off");
    }
}
 
Example 7
Source File: VibratorService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@GuardedBy("mLock")
private void startVibrationInnerLocked(Vibration vib) {
    Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "startVibrationInnerLocked");
    try {
        mCurrentVibration = vib;
        if (vib.effect instanceof VibrationEffect.OneShot) {
            Trace.asyncTraceBegin(Trace.TRACE_TAG_VIBRATOR, "vibration", 0);
            VibrationEffect.OneShot oneShot = (VibrationEffect.OneShot) vib.effect;
            doVibratorOn(oneShot.getDuration(), oneShot.getAmplitude(), vib.uid, vib.usageHint);
            mH.postDelayed(mVibrationEndRunnable, oneShot.getDuration());
        } else if (vib.effect instanceof VibrationEffect.Waveform) {
            // mThread better be null here. doCancelVibrate should always be
            // called before startNextVibrationLocked or startVibrationLocked.
            Trace.asyncTraceBegin(Trace.TRACE_TAG_VIBRATOR, "vibration", 0);
            VibrationEffect.Waveform waveform = (VibrationEffect.Waveform) vib.effect;
            mThread = new VibrateThread(waveform, vib.uid, vib.usageHint);
            mThread.start();
        } else if (vib.effect instanceof VibrationEffect.Prebaked) {
            Trace.asyncTraceBegin(Trace.TRACE_TAG_VIBRATOR, "vibration", 0);
            long timeout = doVibratorPrebakedEffectLocked(vib);
            if (timeout > 0) {
                mH.postDelayed(mVibrationEndRunnable, timeout);
            }
        } else {
            Slog.e(TAG, "Unknown vibration type, ignoring");
        }
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR);
    }
}
 
Example 8
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void acquire() {
    synchronized (this) {
        mReferenceCount += 1;
        if (mReferenceCount == 1) {
            if (DEBUG_SPEW) {
                Slog.d(TAG, "Acquiring suspend blocker \"" + mName + "\".");
            }
            Trace.asyncTraceBegin(Trace.TRACE_TAG_POWER, mTraceName, 0);
            nativeAcquireSuspendBlocker(mName);
        }
    }
}
 
Example 9
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 10
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private boolean wakeUpNoUpdateLocked(long eventTime, String reason, int reasonUid,
        String opPackageName, int opUid) {
    if (DEBUG_SPEW) {
        Slog.d(TAG, "wakeUpNoUpdateLocked: eventTime=" + eventTime + ", uid=" + reasonUid);
    }

    if (eventTime < mLastSleepTime || mWakefulness == WAKEFULNESS_AWAKE
            || !mBootCompleted || !mSystemReady) {
        return false;
    }

    Trace.asyncTraceBegin(Trace.TRACE_TAG_POWER, TRACE_SCREEN_ON, 0);

    Trace.traceBegin(Trace.TRACE_TAG_POWER, "wakeUp");
    try {
        switch (mWakefulness) {
            case WAKEFULNESS_ASLEEP:
                Slog.i(TAG, "Waking up from sleep (uid=" + reasonUid + " reason=" + reason
                        + ")...");
                break;
            case WAKEFULNESS_DREAMING:
                Slog.i(TAG, "Waking up from dream (uid=" + reasonUid + " reason=" + reason
                        + ")...");
                break;
            case WAKEFULNESS_DOZING:
                Slog.i(TAG, "Waking up from dozing (uid=" + reasonUid + " reason=" + reason
                        + ")...");
                break;
        }

        mLastWakeTime = eventTime;
        setWakefulnessLocked(WAKEFULNESS_AWAKE, 0);

        mNotifier.onWakeUp(reason, reasonUid, opPackageName, opUid);
        userActivityNoUpdateLocked(
                eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, reasonUid);
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_POWER);
    }
    return true;
}
 
Example 11
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;
    }
}