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

The following examples show how to use android.os.Trace#traceCounter() . 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 vote down vote up
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;
}
 
Example 2
Source File: InputMethodManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
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 3
Source File: AutomaticBrightnessController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: DisplayPowerState.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: DisplayPowerState.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@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();
}
 
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 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
        }
    }
}
 
Example 7
Source File: DisplayPowerController.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 8
Source File: DisplayPowerController.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void setReportedScreenState(int state) {
    Trace.traceCounter(Trace.TRACE_TAG_POWER, "ReportedScreenStateToPolicy", state);
    mReportedScreenStateToPolicy = state;
}