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