Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1eb3820d authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Dump the entire state of WebViewUpdateService on demand.

It is especially useful to know which is the current WebView package but
we also add some other state to be able to debug WebViewUpdateService.

Bug: 32307028
Test: Run 'adb shell dumpsys webviewupdate' and inspect printed
contents.
Test: Take bug report and inspect the 'webviewupdate' dump section.
Change-Id: I79c2cda87ea7633a915eae5de3c3015b18ed6d7c
parent 67387af7
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.webkit.WebViewProviderResponse;
import com.android.server.SystemService;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Arrays;

/**
@@ -259,5 +260,18 @@ public class WebViewUpdateService extends SystemService {
                Binder.restoreCallingIdentity(callingId);
            }
        }

        @Override
        protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                    != PackageManager.PERMISSION_GRANTED) {

                pw.println("Permission Denial: can't dump webviewupdate service from pid="
                        + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
                return;
            }

            WebViewUpdateService.this.mImpl.dumpState(pw);
        }
    }
}
+32 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.webkit.WebViewFactory;
import android.webkit.WebViewProviderInfo;
import android.webkit.WebViewProviderResponse;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -673,6 +674,27 @@ public class WebViewUpdateServiceImpl {
            mMinimumVersionCode = minimumVersionCode;
            return mMinimumVersionCode;
        }

        public void dumpState(PrintWriter pw) {
            synchronized (mLock) {
                if (mCurrentWebViewPackage == null) {
                    pw.println("  Current WebView package is null");
                } else {
                    pw.println(String.format("  Current WebView package (name, version): (%s, %s)",
                            mCurrentWebViewPackage.packageName,
                            mCurrentWebViewPackage.versionName));
                }
                pw.println(String.format("  Minimum WebView version code: %d",
                      mMinimumVersionCode));
                pw.println(String.format("  Number of relros started: %d",
                        mNumRelroCreationsStarted));
                pw.println(String.format("  Number of relros finished: %d",
                            mNumRelroCreationsFinished));
                pw.println(String.format("  WebView package dirty: %b", mWebViewPackageDirty));
                pw.println(String.format("  Any WebView package installed: %b",
                        mAnyWebViewInstalled));
            }
        }
    }

    private static boolean providerHasValidSignature(WebViewProviderInfo provider,
@@ -741,4 +763,14 @@ public class WebViewUpdateServiceImpl {
            mSystemInterface.setMultiProcessEnabledFromContext(mContext);
        }
    }

    /**
     * Dump the state of this Service.
     */
    void dumpState(PrintWriter pw) {
        pw.println("Current WebView Update Service state");
        pw.println(String.format("  Fallback logic enabled: %b",
                mSystemInterface.isFallbackLogicEnabled()));
        mWebViewUpdater.dumpState(pw);
    }
}