blob: 12d3221fb7b5ca94c81071c9d0323dcec81af11c [file] [log] [blame]
Gustav Sennton1c177d82016-03-29 20:43:11 +01001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.webkit;
18
19import android.annotation.SystemApi;
Mathew Inwood42afea22018-08-16 19:18:28 +010020import android.annotation.UnsupportedAppUsage;
Gustav Sennton1c177d82016-03-29 20:43:11 +010021import android.os.RemoteException;
22
23/**
24 * @hide
25 */
26@SystemApi
27public final class WebViewUpdateService {
28
Mathew Inwood42afea22018-08-16 19:18:28 +010029 @UnsupportedAppUsage
Gustav Sennton1c177d82016-03-29 20:43:11 +010030 private WebViewUpdateService () {}
31
32 /**
33 * Fetch all packages that could potentially implement WebView.
34 */
35 public static WebViewProviderInfo[] getAllWebViewPackages() {
Torne (Richard Coles)ff937ac2017-10-02 17:09:32 -040036 IWebViewUpdateService service = getUpdateService();
37 if (service == null) {
38 return new WebViewProviderInfo[0];
39 }
Gustav Sennton1c177d82016-03-29 20:43:11 +010040 try {
Torne (Richard Coles)ff937ac2017-10-02 17:09:32 -040041 return service.getAllWebViewPackages();
Gustav Sennton1c177d82016-03-29 20:43:11 +010042 } catch (RemoteException e) {
Gustav Sennton17757f82016-05-04 15:25:46 +010043 throw e.rethrowFromSystemServer();
Gustav Sennton1c177d82016-03-29 20:43:11 +010044 }
45 }
46
47 /**
48 * Fetch all packages that could potentially implement WebView and are currently valid.
49 */
50 public static WebViewProviderInfo[] getValidWebViewPackages() {
Torne (Richard Coles)ff937ac2017-10-02 17:09:32 -040051 IWebViewUpdateService service = getUpdateService();
52 if (service == null) {
53 return new WebViewProviderInfo[0];
54 }
Gustav Sennton1c177d82016-03-29 20:43:11 +010055 try {
Torne (Richard Coles)ff937ac2017-10-02 17:09:32 -040056 return service.getValidWebViewPackages();
Gustav Sennton1c177d82016-03-29 20:43:11 +010057 } catch (RemoteException e) {
Gustav Sennton17757f82016-05-04 15:25:46 +010058 throw e.rethrowFromSystemServer();
Gustav Sennton1c177d82016-03-29 20:43:11 +010059 }
60 }
61
62 /**
63 * Used by DevelopmentSetting to get the name of the WebView provider currently in use.
64 */
65 public static String getCurrentWebViewPackageName() {
Torne (Richard Coles)ff937ac2017-10-02 17:09:32 -040066 IWebViewUpdateService service = getUpdateService();
67 if (service == null) {
68 return null;
69 }
Gustav Sennton1c177d82016-03-29 20:43:11 +010070 try {
Torne (Richard Coles)ff937ac2017-10-02 17:09:32 -040071 return service.getCurrentWebViewPackageName();
Gustav Sennton1c177d82016-03-29 20:43:11 +010072 } catch (RemoteException e) {
Gustav Sennton17757f82016-05-04 15:25:46 +010073 throw e.rethrowFromSystemServer();
Gustav Sennton1c177d82016-03-29 20:43:11 +010074 }
75 }
76
77 private static IWebViewUpdateService getUpdateService() {
78 return WebViewFactory.getUpdateService();
79 }
80}