WebViewUpdateService.java revision 08cfaf672604422dd355d6703aec78f3aa5ee74e
1/* 2 * Copyright (C) 2012 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 com.android.server.webkit; 18 19import android.os.Binder; 20import android.os.Process; 21import android.util.Log; 22import android.webkit.IWebViewUpdateService; 23 24/** 25 * Private service to wait for the updatable WebView to be ready for use. 26 * @hide 27 */ 28public class WebViewUpdateService extends IWebViewUpdateService.Stub { 29 30 private static final String TAG = "WebViewUpdateService"; 31 32 private boolean mRelroReady32Bit = false; 33 private boolean mRelroReady64Bit = false; 34 35 public WebViewUpdateService() { 36 } 37 38 /** 39 * The shared relro process calls this to notify us that it's done trying to create a relro 40 * file. 41 */ 42 public void notifyRelroCreationCompleted(boolean is64Bit, boolean success) { 43 // Verify that the caller is the shared relro process. 44 if (Binder.getCallingUid() != Process.SHARED_RELRO_UID) { 45 return; 46 } 47 48 synchronized (this) { 49 if (is64Bit) { 50 mRelroReady64Bit = true; 51 } else { 52 mRelroReady32Bit = true; 53 } 54 this.notifyAll(); 55 } 56 } 57 58 /** 59 * WebViewFactory calls this to block WebView loading until the relro file is created. 60 */ 61 public void waitForRelroCreationCompleted(boolean is64Bit) { 62 synchronized (this) { 63 if (is64Bit) { 64 while (!mRelroReady64Bit) { 65 try { 66 this.wait(); 67 } catch (InterruptedException e) {} 68 } 69 } else { 70 while (!mRelroReady32Bit) { 71 try { 72 this.wait(); 73 } catch (InterruptedException e) {} 74 } 75 } 76 } 77 } 78} 79