Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 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 | |
| 17 | package com.android.server.webkit; |
| 18 | |
Ben Murdoch | dc00a84 | 2014-07-17 14:55:00 +0100 | [diff] [blame] | 19 | import android.content.BroadcastReceiver; |
| 20 | import android.content.Context; |
| 21 | import android.content.Intent; |
| 22 | import android.content.IntentFilter; |
Gustav Sennton | bf683e0 | 2016-09-15 14:42:50 +0100 | [diff] [blame] | 23 | import android.content.pm.PackageInfo; |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 24 | import android.content.pm.PackageManager; |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 25 | import android.os.Binder; |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 26 | import android.os.PatternMatcher; |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 27 | import android.os.Process; |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 28 | import android.os.ResultReceiver; |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 29 | import android.os.ShellCallback; |
Gustav Sennton | 23875b2 | 2016-02-09 14:11:33 +0000 | [diff] [blame] | 30 | import android.os.UserHandle; |
Primiano Tucci | 810c052 | 2014-07-25 18:03:16 +0100 | [diff] [blame] | 31 | import android.util.Slog; |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 32 | import android.webkit.IWebViewUpdateService; |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 33 | import android.webkit.WebViewProviderInfo; |
| 34 | import android.webkit.WebViewProviderResponse; |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 35 | |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 36 | import com.android.server.SystemService; |
| 37 | |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 38 | import java.io.FileDescriptor; |
Gustav Sennton | 1eb3820 | 2016-10-21 13:40:10 +0100 | [diff] [blame] | 39 | import java.io.PrintWriter; |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 40 | import java.util.Arrays; |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 41 | |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 42 | /** |
| 43 | * Private service to wait for the updatable WebView to be ready for use. |
| 44 | * @hide |
| 45 | */ |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 46 | public class WebViewUpdateService extends SystemService { |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 47 | |
| 48 | private static final String TAG = "WebViewUpdateService"; |
Gustav Sennton | 6ce92c9 | 2015-10-23 11:10:39 +0100 | [diff] [blame] | 49 | |
Ben Murdoch | dc00a84 | 2014-07-17 14:55:00 +0100 | [diff] [blame] | 50 | private BroadcastReceiver mWebViewUpdatedReceiver; |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 51 | private WebViewUpdateServiceImpl mImpl; |
Ben Murdoch | dc00a84 | 2014-07-17 14:55:00 +0100 | [diff] [blame] | 52 | |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 53 | static final int PACKAGE_CHANGED = 0; |
| 54 | static final int PACKAGE_ADDED = 1; |
| 55 | static final int PACKAGE_ADDED_REPLACED = 2; |
| 56 | static final int PACKAGE_REMOVED = 3; |
| 57 | |
Ben Murdoch | dc00a84 | 2014-07-17 14:55:00 +0100 | [diff] [blame] | 58 | public WebViewUpdateService(Context context) { |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 59 | super(context); |
Hui Shu | 9455bd0 | 2016-04-08 13:25:26 -0700 | [diff] [blame] | 60 | mImpl = new WebViewUpdateServiceImpl(context, SystemImpl.getInstance()); |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public void onStart() { |
Ben Murdoch | dc00a84 | 2014-07-17 14:55:00 +0100 | [diff] [blame] | 65 | mWebViewUpdatedReceiver = new BroadcastReceiver() { |
| 66 | @Override |
| 67 | public void onReceive(Context context, Intent intent) { |
Gustav Sennton | 0df2c55 | 2016-06-14 15:32:19 +0100 | [diff] [blame] | 68 | int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 69 | switch (intent.getAction()) { |
| 70 | case Intent.ACTION_PACKAGE_REMOVED: |
| 71 | // When a package is replaced we will receive two intents, one |
| 72 | // representing the removal of the old package and one representing the |
| 73 | // addition of the new package. |
| 74 | // In the case where we receive an intent to remove the old version of |
| 75 | // the package that is being replaced we early-out here so that we don't |
| 76 | // run the update-logic twice. |
| 77 | if (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)) return; |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 78 | mImpl.packageStateChanged(packageNameFromIntent(intent), |
Gustav Sennton | 0df2c55 | 2016-06-14 15:32:19 +0100 | [diff] [blame] | 79 | PACKAGE_REMOVED, userId); |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 80 | break; |
| 81 | case Intent.ACTION_PACKAGE_CHANGED: |
| 82 | // Ensure that we only heed PACKAGE_CHANGED intents if they change an |
| 83 | // entire package, not just a component |
| 84 | if (entirePackageChanged(intent)) { |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 85 | mImpl.packageStateChanged(packageNameFromIntent(intent), |
Gustav Sennton | 0df2c55 | 2016-06-14 15:32:19 +0100 | [diff] [blame] | 86 | PACKAGE_CHANGED, userId); |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 87 | } |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 88 | break; |
| 89 | case Intent.ACTION_PACKAGE_ADDED: |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 90 | mImpl.packageStateChanged(packageNameFromIntent(intent), |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 91 | (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING) |
Gustav Sennton | 0df2c55 | 2016-06-14 15:32:19 +0100 | [diff] [blame] | 92 | ? PACKAGE_ADDED_REPLACED : PACKAGE_ADDED), userId); |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 93 | break; |
| 94 | case Intent.ACTION_USER_ADDED: |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 95 | mImpl.handleNewUser(userId); |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 96 | break; |
Gustav Sennton | 364e160 | 2016-12-14 09:10:50 +0000 | [diff] [blame^] | 97 | case Intent.ACTION_USER_REMOVED: |
| 98 | mImpl.handleUserRemoved(userId); |
| 99 | break; |
Ben Murdoch | dc00a84 | 2014-07-17 14:55:00 +0100 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | }; |
| 103 | IntentFilter filter = new IntentFilter(); |
Gustav Sennton | 3098cf2 | 2015-11-10 03:33:09 +0000 | [diff] [blame] | 104 | filter.addAction(Intent.ACTION_PACKAGE_ADDED); |
| 105 | filter.addAction(Intent.ACTION_PACKAGE_REMOVED); |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 106 | filter.addAction(Intent.ACTION_PACKAGE_CHANGED); |
Ben Murdoch | dc00a84 | 2014-07-17 14:55:00 +0100 | [diff] [blame] | 107 | filter.addDataScheme("package"); |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 108 | // Make sure we only receive intents for WebView packages from our config file. |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 109 | for (WebViewProviderInfo provider : mImpl.getWebViewPackages()) { |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 110 | filter.addDataSchemeSpecificPart(provider.packageName, PatternMatcher.PATTERN_LITERAL); |
| 111 | } |
Gustav Sennton | 0df2c55 | 2016-06-14 15:32:19 +0100 | [diff] [blame] | 112 | |
| 113 | getContext().registerReceiverAsUser(mWebViewUpdatedReceiver, UserHandle.ALL, filter, |
| 114 | null /* broadcast permission */, null /* handler */); |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 115 | |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 116 | IntentFilter userAddedFilter = new IntentFilter(); |
| 117 | userAddedFilter.addAction(Intent.ACTION_USER_ADDED); |
Gustav Sennton | 364e160 | 2016-12-14 09:10:50 +0000 | [diff] [blame^] | 118 | userAddedFilter.addAction(Intent.ACTION_USER_REMOVED); |
Gustav Sennton | 0df2c55 | 2016-06-14 15:32:19 +0100 | [diff] [blame] | 119 | getContext().registerReceiverAsUser(mWebViewUpdatedReceiver, UserHandle.ALL, |
| 120 | userAddedFilter, null /* broadcast permission */, null /* handler */); |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 121 | |
Torne (Richard Coles) | fc19b0a | 2016-02-01 16:16:57 +0000 | [diff] [blame] | 122 | publishBinderService("webviewupdate", new BinderService(), true /*allowIsolated*/); |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 123 | } |
Ben Murdoch | dc00a84 | 2014-07-17 14:55:00 +0100 | [diff] [blame] | 124 | |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 125 | public void prepareWebViewInSystemServer() { |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 126 | mImpl.prepareWebViewInSystemServer(); |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | private static String packageNameFromIntent(Intent intent) { |
| 130 | return intent.getDataString().substring("package:".length()); |
| 131 | } |
| 132 | |
Gustav Sennton | 065b7e6 | 2016-04-01 15:11:43 +0100 | [diff] [blame] | 133 | /** |
| 134 | * Returns whether the entire package from an ACTION_PACKAGE_CHANGED intent was changed (rather |
| 135 | * than just one of its components). |
| 136 | * @hide |
| 137 | */ |
| 138 | public static boolean entirePackageChanged(Intent intent) { |
| 139 | String[] componentList = |
| 140 | intent.getStringArrayExtra(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST); |
| 141 | return Arrays.asList(componentList).contains( |
| 142 | intent.getDataString().substring("package:".length())); |
Gustav Sennton | dbf5eb0 | 2016-03-30 14:53:03 +0100 | [diff] [blame] | 143 | } |
| 144 | |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 145 | private class BinderService extends IWebViewUpdateService.Stub { |
| 146 | |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 147 | @Override |
| 148 | public void onShellCommand(FileDescriptor in, FileDescriptor out, |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 149 | FileDescriptor err, String[] args, ShellCallback callback, |
| 150 | ResultReceiver resultReceiver) { |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 151 | (new WebViewUpdateServiceShellCommand(this)).exec( |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 152 | this, in, out, err, args, callback, resultReceiver); |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 156 | /** |
| 157 | * The shared relro process calls this to notify us that it's done trying to create a relro |
| 158 | * file. This method gets called even if the relro creation has failed or the process |
| 159 | * crashed. |
| 160 | */ |
| 161 | @Override // Binder call |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 162 | public void notifyRelroCreationCompleted() { |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 163 | // Verify that the caller is either the shared relro process (nominal case) or the |
| 164 | // system server (only in the case the relro process crashes and we get here via the |
| 165 | // crashHandler). |
| 166 | if (Binder.getCallingUid() != Process.SHARED_RELRO_UID && |
| 167 | Binder.getCallingUid() != Process.SYSTEM_UID) { |
| 168 | return; |
| 169 | } |
| 170 | |
Gustav Sennton | 275d13c | 2016-02-24 10:58:09 +0000 | [diff] [blame] | 171 | long callingId = Binder.clearCallingIdentity(); |
| 172 | try { |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 173 | WebViewUpdateService.this.mImpl.notifyRelroCreationCompleted(); |
Gustav Sennton | 275d13c | 2016-02-24 10:58:09 +0000 | [diff] [blame] | 174 | } finally { |
| 175 | Binder.restoreCallingIdentity(callingId); |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 176 | } |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * WebViewFactory calls this to block WebView loading until the relro file is created. |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 181 | * Returns the WebView provider for which we create relro files. |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 182 | */ |
| 183 | @Override // Binder call |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 184 | public WebViewProviderResponse waitForAndGetProvider() { |
Primiano Tucci | e76e81a | 2014-07-29 16:38:33 +0100 | [diff] [blame] | 185 | // The WebViewUpdateService depends on the prepareWebViewInSystemServer call, which |
| 186 | // happens later (during the PHASE_ACTIVITY_MANAGER_READY) in SystemServer.java. If |
| 187 | // another service there tries to bring up a WebView in the between, the wait below |
| 188 | // would deadlock without the check below. |
| 189 | if (Binder.getCallingPid() == Process.myPid()) { |
| 190 | throw new IllegalStateException("Cannot create a WebView from the SystemServer"); |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 191 | } |
| 192 | |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 193 | return WebViewUpdateService.this.mImpl.waitForAndGetProvider(); |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | /** |
| 197 | * This is called from DeveloperSettings when the user changes WebView provider. |
| 198 | */ |
| 199 | @Override // Binder call |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 200 | public String changeProviderAndSetting(String newProvider) { |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 201 | if (getContext().checkCallingPermission( |
| 202 | android.Manifest.permission.WRITE_SECURE_SETTINGS) |
| 203 | != PackageManager.PERMISSION_GRANTED) { |
| 204 | String msg = "Permission Denial: changeProviderAndSetting() from pid=" |
| 205 | + Binder.getCallingPid() |
| 206 | + ", uid=" + Binder.getCallingUid() |
| 207 | + " requires " + android.Manifest.permission.WRITE_SECURE_SETTINGS; |
| 208 | Slog.w(TAG, msg); |
| 209 | throw new SecurityException(msg); |
| 210 | } |
| 211 | |
Gustav Sennton | ab3b6b1 | 2016-03-16 17:38:42 +0000 | [diff] [blame] | 212 | long callingId = Binder.clearCallingIdentity(); |
| 213 | try { |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 214 | return WebViewUpdateService.this.mImpl.changeProviderAndSetting( |
Gustav Sennton | 3a6e6b2 | 2016-04-05 14:09:09 +0100 | [diff] [blame] | 215 | newProvider); |
Gustav Sennton | ab3b6b1 | 2016-03-16 17:38:42 +0000 | [diff] [blame] | 216 | } finally { |
| 217 | Binder.restoreCallingIdentity(callingId); |
| 218 | } |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | @Override // Binder call |
| 222 | public WebViewProviderInfo[] getValidWebViewPackages() { |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 223 | return WebViewUpdateService.this.mImpl.getValidWebViewPackages(); |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | @Override // Binder call |
Gustav Sennton | 8b17926 | 2016-03-14 11:31:14 +0000 | [diff] [blame] | 227 | public WebViewProviderInfo[] getAllWebViewPackages() { |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 228 | return WebViewUpdateService.this.mImpl.getWebViewPackages(); |
Gustav Sennton | 8b17926 | 2016-03-14 11:31:14 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | @Override // Binder call |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 232 | public String getCurrentWebViewPackageName() { |
Gustav Sennton | bf683e0 | 2016-09-15 14:42:50 +0100 | [diff] [blame] | 233 | PackageInfo pi = WebViewUpdateService.this.mImpl.getCurrentWebViewPackage(); |
| 234 | return pi == null ? null : pi.packageName; |
| 235 | } |
| 236 | |
| 237 | @Override // Binder call |
| 238 | public PackageInfo getCurrentWebViewPackage() { |
| 239 | return WebViewUpdateService.this.mImpl.getCurrentWebViewPackage(); |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 240 | } |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 241 | |
| 242 | @Override // Binder call |
| 243 | public boolean isFallbackPackage(String packageName) { |
Gustav Sennton | 79fea48 | 2016-04-07 14:22:56 +0100 | [diff] [blame] | 244 | return WebViewUpdateService.this.mImpl.isFallbackPackage(packageName); |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | @Override // Binder call |
| 248 | public void enableFallbackLogic(boolean enable) { |
| 249 | if (getContext().checkCallingPermission( |
| 250 | android.Manifest.permission.WRITE_SECURE_SETTINGS) |
| 251 | != PackageManager.PERMISSION_GRANTED) { |
| 252 | String msg = "Permission Denial: enableFallbackLogic() from pid=" |
| 253 | + Binder.getCallingPid() |
| 254 | + ", uid=" + Binder.getCallingUid() |
| 255 | + " requires " + android.Manifest.permission.WRITE_SECURE_SETTINGS; |
| 256 | Slog.w(TAG, msg); |
| 257 | throw new SecurityException(msg); |
| 258 | } |
| 259 | |
Gustav Sennton | 6824c7c | 2016-04-04 14:07:23 +0100 | [diff] [blame] | 260 | long callingId = Binder.clearCallingIdentity(); |
| 261 | try { |
| 262 | WebViewUpdateService.this.mImpl.enableFallbackLogic(enable); |
| 263 | } finally { |
| 264 | Binder.restoreCallingIdentity(callingId); |
| 265 | } |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 266 | } |
Gustav Sennton | 1eb3820 | 2016-10-21 13:40:10 +0100 | [diff] [blame] | 267 | |
Torne (Richard Coles) | 1a4c4e3 | 2017-01-10 15:57:41 +0000 | [diff] [blame] | 268 | @Override // Binder call |
| 269 | public boolean isMultiProcessEnabled() { |
| 270 | return WebViewUpdateService.this.mImpl.isMultiProcessEnabled(); |
| 271 | } |
| 272 | |
| 273 | @Override // Binder call |
| 274 | public void enableMultiProcess(boolean enable) { |
| 275 | if (getContext().checkCallingPermission( |
| 276 | android.Manifest.permission.WRITE_SECURE_SETTINGS) |
| 277 | != PackageManager.PERMISSION_GRANTED) { |
| 278 | String msg = "Permission Denial: enableMultiProcess() from pid=" |
| 279 | + Binder.getCallingPid() |
| 280 | + ", uid=" + Binder.getCallingUid() |
| 281 | + " requires " + android.Manifest.permission.WRITE_SECURE_SETTINGS; |
| 282 | Slog.w(TAG, msg); |
| 283 | throw new SecurityException(msg); |
| 284 | } |
| 285 | |
| 286 | long callingId = Binder.clearCallingIdentity(); |
| 287 | try { |
| 288 | WebViewUpdateService.this.mImpl.enableMultiProcess(enable); |
| 289 | } finally { |
| 290 | Binder.restoreCallingIdentity(callingId); |
| 291 | } |
| 292 | } |
| 293 | |
Gustav Sennton | 1eb3820 | 2016-10-21 13:40:10 +0100 | [diff] [blame] | 294 | @Override |
| 295 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 296 | if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 297 | != PackageManager.PERMISSION_GRANTED) { |
| 298 | |
| 299 | pw.println("Permission Denial: can't dump webviewupdate service from pid=" |
| 300 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); |
| 301 | return; |
| 302 | } |
| 303 | |
| 304 | WebViewUpdateService.this.mImpl.dumpState(pw); |
| 305 | } |
Torne (Richard Coles) | 4dbeb35 | 2014-07-29 19:14:24 +0100 | [diff] [blame] | 306 | } |
Torne (Richard Coles) | 08cfaf6 | 2014-05-08 16:07:05 +0100 | [diff] [blame] | 307 | } |