Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal] Use monotonic clock to measure time intervals #4289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.os.Build.VERSION_CODES;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseIntArray;
Expand Down Expand Up @@ -1900,7 +1901,7 @@ public boolean tryCaptureView(@NonNull View child, int pointerId) {
return false;
}
}
viewCapturedMillis = System.currentTimeMillis();
viewCapturedMillis = SystemClock.uptimeMillis();
return viewRef != null && viewRef.get() == child;
}

Expand Down Expand Up @@ -1930,7 +1931,7 @@ public void onViewReleased(@NonNull View releasedChild, float xvel, float yvel)
targetState = STATE_EXPANDED;
} else {
int currentTop = releasedChild.getTop();
long dragDurationMillis = System.currentTimeMillis() - viewCapturedMillis;
long dragDurationMillis = SystemClock.uptimeMillis() - viewCapturedMillis;

if (shouldSkipHalfExpandedStateWhenDragging()) {
float yPositionPercentage = currentTop * 100f / parentHeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.util.Property;
import androidx.annotation.FloatRange;
import androidx.annotation.IntRange;
Expand Down Expand Up @@ -463,7 +464,7 @@ float getPhaseFraction() {
? baseSpec.wavelengthDeterminate
: baseSpec.wavelengthIndeterminate;
int cycleInMs = (int) (1000f * wavelength / baseSpec.waveSpeed * durationScale);
phaseFraction = (float) (System.currentTimeMillis() % cycleInMs) / cycleInMs;
phaseFraction = (float) (SystemClock.uptimeMillis() % cycleInMs) / cycleInMs;
if (phaseFraction < 0f) {
phaseFraction = (phaseFraction % 1) + 1f;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.SystemClock;
import android.text.Editable;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -280,7 +281,7 @@ private void setUpDropdownShowHideBehavior() {
}

private boolean isDropdownPopupActive() {
long activeFor = System.currentTimeMillis() - dropdownPopupActivatedAt;
long activeFor = SystemClock.uptimeMillis() - dropdownPopupActivatedAt;
return activeFor < 0 || activeFor > 300;
}

Expand All @@ -297,7 +298,7 @@ private static AutoCompleteTextView castAutoCompleteTextViewOrThrow(EditText edi

private void updateDropdownPopupDirty() {
dropdownPopupDirty = true;
dropdownPopupActivatedAt = System.currentTimeMillis();
dropdownPopupActivatedAt = SystemClock.uptimeMillis();
}

private void setEndIconChecked(boolean checked) {
Expand Down