android.os.Trace#traceCounter ( )源码实例Demo

下面列出了android.os.Trace#traceCounter ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: InputMethodManager.java
int sendInputEventOnMainLooperLocked(PendingEvent p) {
    if (mCurChannel != null) {
        if (mCurSender == null) {
            mCurSender = new ImeInputEventSender(mCurChannel, mH.getLooper());
        }

        final InputEvent event = p.mEvent;
        final int seq = event.getSequenceNumber();
        if (mCurSender.sendInputEvent(seq, event)) {
            mPendingEvents.put(seq, p);
            Trace.traceCounter(Trace.TRACE_TAG_INPUT, PENDING_EVENT_COUNTER,
                    mPendingEvents.size());

            Message msg = mH.obtainMessage(MSG_TIMEOUT_INPUT_EVENT, seq, 0, p);
            msg.setAsynchronous(true);
            mH.sendMessageDelayed(msg, INPUT_METHOD_NOT_RESPONDING_TIMEOUT);
            return DISPATCH_IN_PROGRESS;
        }

        Log.w(TAG, "Unable to send input event to IME: "
                + mCurId + " dropping: " + event);
    }
    return DISPATCH_NOT_HANDLED;
}
 
源代码2 项目: android_9.0.0_r45   文件: InputMethodManager.java
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);
}
 
private void handleLightSensorEvent(long time, float lux) {
    Trace.traceCounter(Trace.TRACE_TAG_POWER, "ALS", (int) lux);
    mHandler.removeMessages(MSG_UPDATE_AMBIENT_LUX);

    if (mAmbientLightRingBuffer.size() == 0) {
        // switch to using the steady-state sample rate after grabbing the initial light sample
        adjustLightSensorRate(mNormalLightSensorRate);
    }
    applyLightSensorMeasurement(time, lux);
    updateAmbientLux(time);
}
 
源代码4 项目: android_9.0.0_r45   文件: DisplayPowerState.java
/**
 * Dismisses the color fade surface.
 */
public void dismissColorFade() {
    Trace.traceCounter(Trace.TRACE_TAG_POWER, COUNTER_COLOR_FADE, 100);
    if (mColorFade != null) mColorFade.dismiss();
    mColorFadePrepared = false;
    mColorFadeReady = true;
}
 
源代码5 项目: android_9.0.0_r45   文件: DisplayPowerState.java
@Override
public void run() {
    mColorFadeDrawPending = false;

    if (mColorFadePrepared) {
        mColorFade.draw(mColorFadeLevel);
        Trace.traceCounter(Trace.TRACE_TAG_POWER,
                COUNTER_COLOR_FADE, Math.round(mColorFadeLevel * 100));
    }

    mColorFadeReady = true;
    invokeCleanListenerIfNeeded();
}
 
private void animateScreenBrightness(int target, int rate) {
    if (DEBUG) {
        Slog.d(TAG, "Animating brightness: target=" + target +", rate=" + rate);
    }
    if (mScreenBrightnessRampAnimator.animateTo(target, rate)) {
        Trace.traceCounter(Trace.TRACE_TAG_POWER, "TargetScreenBrightness", target);
        try {
            mBatteryStats.noteScreenBrightness(target);
        } catch (RemoteException ex) {
            // same process
        }
    }
}
 
private boolean setScreenState(int state, boolean reportOnly) {
    final boolean isOff = (state == Display.STATE_OFF);
    if (mPowerState.getScreenState() != state) {

        // If we are trying to turn screen off, give policy a chance to do something before we
        // actually turn the screen off.
        if (isOff && !mScreenOffBecauseOfProximity) {
            if (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_ON) {
                setReportedScreenState(REPORTED_TO_POLICY_SCREEN_TURNING_OFF);
                blockScreenOff();
                mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker);
                unblockScreenOff();
            } else if (mPendingScreenOffUnblocker != null) {
                // Abort doing the state change until screen off is unblocked.
                return false;
            }
        }

        if (!reportOnly) {
            Trace.traceCounter(Trace.TRACE_TAG_POWER, "ScreenState", state);
            mPowerState.setScreenState(state);
            // Tell battery stats about the transition.
            try {
                mBatteryStats.noteScreenState(state);
            } catch (RemoteException ex) {
                // same process
            }
        }
    }

    // Tell the window manager policy when the screen is turned off or on unless it's due
    // to the proximity sensor.  We temporarily block turning the screen on until the
    // window manager is ready by leaving a black surface covering the screen.
    // This surface is essentially the final state of the color fade animation and
    // it is only removed once the window manager tells us that the activity has
    // finished drawing underneath.
    if (isOff && mReportedScreenStateToPolicy != REPORTED_TO_POLICY_SCREEN_OFF
            && !mScreenOffBecauseOfProximity) {
        setReportedScreenState(REPORTED_TO_POLICY_SCREEN_OFF);
        unblockScreenOn();
        mWindowManagerPolicy.screenTurnedOff();
    } else if (!isOff
            && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_TURNING_OFF) {

        // We told policy already that screen was turning off, but now we changed our minds.
        // Complete the full state transition on -> turningOff -> off.
        unblockScreenOff();
        mWindowManagerPolicy.screenTurnedOff();
        setReportedScreenState(REPORTED_TO_POLICY_SCREEN_OFF);
    }
    if (!isOff && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_OFF) {
        setReportedScreenState(REPORTED_TO_POLICY_SCREEN_TURNING_ON);
        if (mPowerState.getColorFadeLevel() == 0.0f) {
            blockScreenOn();
        } else {
            unblockScreenOn();
        }
        mWindowManagerPolicy.screenTurningOn(mPendingScreenOnUnblocker);
    }

    // Return true if the screen isn't blocked.
    return mPendingScreenOnUnblocker == null;
}
 
private void setReportedScreenState(int state) {
    Trace.traceCounter(Trace.TRACE_TAG_POWER, "ReportedScreenStateToPolicy", state);
    mReportedScreenStateToPolicy = state;
}