• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package android.webkit;
18 
19 import android.annotation.SystemApi;
20 import android.compat.annotation.UnsupportedAppUsage;
21 import android.os.RemoteException;
22 
23 /**
24  * @hide
25  */
26 @SystemApi
27 public final class WebViewUpdateService {
28 
29     @UnsupportedAppUsage
WebViewUpdateService()30     private WebViewUpdateService () {}
31 
32     /**
33      * Fetch all packages that could potentially implement WebView.
34      */
getAllWebViewPackages()35     public static WebViewProviderInfo[] getAllWebViewPackages() {
36         IWebViewUpdateService service = getUpdateService();
37         if (service == null) {
38             return new WebViewProviderInfo[0];
39         }
40         try {
41             return service.getAllWebViewPackages();
42         } catch (RemoteException e) {
43             throw e.rethrowFromSystemServer();
44         }
45     }
46 
47     /**
48      * Fetch all packages that could potentially implement WebView and are currently valid.
49      */
getValidWebViewPackages()50     public static WebViewProviderInfo[] getValidWebViewPackages() {
51         IWebViewUpdateService service = getUpdateService();
52         if (service == null) {
53             return new WebViewProviderInfo[0];
54         }
55         try {
56             return service.getValidWebViewPackages();
57         } catch (RemoteException e) {
58             throw e.rethrowFromSystemServer();
59         }
60     }
61 
62     /**
63      * Used by DevelopmentSetting to get the name of the WebView provider currently in use.
64      */
getCurrentWebViewPackageName()65     public static String getCurrentWebViewPackageName() {
66         IWebViewUpdateService service = getUpdateService();
67         if (service == null) {
68             return null;
69         }
70         try {
71             return service.getCurrentWebViewPackageName();
72         } catch (RemoteException e) {
73             throw e.rethrowFromSystemServer();
74         }
75     }
76 
getUpdateService()77     private static IWebViewUpdateService getUpdateService() {
78         return WebViewFactory.getUpdateService();
79     }
80 }
81