webview: switch timestamps to uptimeMillis().

We should use uptimeMillis for the startup timestamps since it doesn't
count time in device sleep.

Fixes: 184786485
Test: n/a
Change-Id: I4073e73de9b76d50398b820879c4fcf7b8f614e8
This commit is contained in:
Torne (Richard Coles)
2021-04-29 15:13:14 -04:00
parent 41a4d6741e
commit d35469d86b
2 changed files with 10 additions and 10 deletions

View File

@@ -16,10 +16,10 @@
package android.webkit;
import android.annotation.ElapsedRealtimeLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.UptimeMillisLong;
import android.app.ActivityThread;
import android.app.Application;
import android.app.ResourcesManager;
@@ -227,7 +227,7 @@ public final class WebViewDelegate {
* WebViewChromiumFactoryProvider#create method was invoked.
*/
@NonNull
@ElapsedRealtimeLong
@UptimeMillisLong
public long[] getTimestamps() {
return WebViewFactory.getTimestamps();
}

View File

@@ -273,7 +273,7 @@ public final class WebViewFactory {
// us honest and minimize usage of WebView internals when binding the proxy.
if (sProviderInstance != null) return sProviderInstance;
sTimestamps[WEBVIEW_LOAD_START] = SystemClock.elapsedRealtime();
sTimestamps[WEBVIEW_LOAD_START] = SystemClock.uptimeMillis();
final int uid = android.os.Process.myUid();
if (uid == android.os.Process.ROOT_UID || uid == android.os.Process.SYSTEM_UID
|| uid == android.os.Process.PHONE_UID || uid == android.os.Process.NFC_UID
@@ -413,7 +413,7 @@ public final class WebViewFactory {
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW,
"initialApplication.createApplicationContext");
sTimestamps[CREATE_CONTEXT_START] = SystemClock.elapsedRealtime();
sTimestamps[CREATE_CONTEXT_START] = SystemClock.uptimeMillis();
try {
// Construct an app context to load the Java code into the current app.
Context webViewContext = initialApplication.createApplicationContext(
@@ -422,7 +422,7 @@ public final class WebViewFactory {
sPackageInfo = newPackageInfo;
return webViewContext;
} finally {
sTimestamps[CREATE_CONTEXT_END] = SystemClock.elapsedRealtime();
sTimestamps[CREATE_CONTEXT_END] = SystemClock.uptimeMillis();
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
}
} catch (RemoteException | PackageManager.NameNotFoundException e) {
@@ -448,26 +448,26 @@ public final class WebViewFactory {
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getChromiumProviderClass()");
try {
sTimestamps[ADD_ASSETS_START] = SystemClock.elapsedRealtime();
sTimestamps[ADD_ASSETS_START] = SystemClock.uptimeMillis();
for (String newAssetPath : webViewContext.getApplicationInfo().getAllApkPaths()) {
initialApplication.getAssets().addAssetPathAsSharedLibrary(newAssetPath);
}
sTimestamps[ADD_ASSETS_END] = sTimestamps[GET_CLASS_LOADER_START] =
SystemClock.elapsedRealtime();
SystemClock.uptimeMillis();
ClassLoader clazzLoader = webViewContext.getClassLoader();
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()");
sTimestamps[GET_CLASS_LOADER_END] = sTimestamps[NATIVE_LOAD_START] =
SystemClock.elapsedRealtime();
SystemClock.uptimeMillis();
WebViewLibraryLoader.loadNativeLibrary(clazzLoader,
getWebViewLibrary(sPackageInfo.applicationInfo));
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()");
sTimestamps[NATIVE_LOAD_END] = sTimestamps[PROVIDER_CLASS_FOR_NAME_START] =
SystemClock.elapsedRealtime();
SystemClock.uptimeMillis();
try {
return getWebViewProviderClass(clazzLoader);
} finally {
sTimestamps[PROVIDER_CLASS_FOR_NAME_END] = SystemClock.elapsedRealtime();
sTimestamps[PROVIDER_CLASS_FOR_NAME_END] = SystemClock.uptimeMillis();
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
}
} catch (ClassNotFoundException e) {