Block the disable option for WebView Default package
Test: atest ApplicationFeatureProviderImplTest Bug: 308907090 Change-Id: I21785975b965b04895849d2df71fa2f2b4cb4b2d
This commit is contained in:
@@ -22,11 +22,14 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.webkit.IWebViewUpdateService;
|
||||
import android.webkit.UserPackage;
|
||||
import android.webkit.WebViewFactory;
|
||||
import android.webkit.WebViewProviderInfo;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -104,5 +107,24 @@ public class WebViewUpdateServiceWrapper {
|
||||
toast.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the package name of the default WebView provider.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDefaultWebViewPackageName() {
|
||||
try {
|
||||
IWebViewUpdateService service = WebViewFactory.getUpdateService();
|
||||
if (service != null) {
|
||||
WebViewProviderInfo provider = service.getDefaultWebViewPackage();
|
||||
if (provider != null) {
|
||||
return provider.packageName;
|
||||
}
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException when trying to fetch default WebView package Name", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static final int PACKAGE_FLAGS = PackageManager.MATCH_ANY_USER;
|
||||
}
|
||||
|
Reference in New Issue
Block a user