Loading AndroidManifest.xml +12 −0 Original line number Diff line number Diff line Loading @@ -2888,6 +2888,18 @@ android:value="true" /> </activity> <activity android:name=".WebViewImplementation" android:exported="true" android:excludeFromRecents="true" android:theme="@*android:style/Theme.Material.Light.Dialog.Alert"> <intent-filter> <action android:name="android.settings.WEBVIEW_SETTINGS" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED" android:value="true" /> </activity> <service android:name=".SettingsDumpService" android:exported="true" Loading src/com/android/settings/DevelopmentSettings.java +1 −10 Original line number Diff line number Diff line Loading @@ -749,7 +749,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ArrayList<String> options = new ArrayList<String>(); ArrayList<String> values = new ArrayList<String>(); for(int n = 0; n < providers.length; n++) { if (isPackageEnabled(providers[n].packageName)) { if (Utils.isPackageEnabled(getActivity(), providers[n].packageName)) { options.add(providers[n].description); values.add(providers[n].packageName); } Loading Loading @@ -1929,15 +1929,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment requestCode, resources.getString(R.string.oem_unlock_enable)); } private boolean isPackageEnabled(String packageName) { try { return getActivity().getPackageManager().getApplicationInfo(packageName, 0).enabled; } catch (NameNotFoundException e) { // Thrown by PackageManager.getApplicationInfo if the package does not exist } return false; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (HDCP_CHECKING_KEY.equals(preference.getKey())) { Loading src/com/android/settings/Utils.java +10 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.IntentFilterVerificationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.content.res.Resources; Loading Loading @@ -87,7 +88,6 @@ import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.ListView; import android.widget.TabWidget; import com.android.internal.app.UnlaunchableAppActivity; import com.android.internal.util.UserIcons; Loading Loading @@ -1137,5 +1137,14 @@ public final class Utils extends com.android.settingslib.Utils { } return null; } public static boolean isPackageEnabled(Context context, String packageName) { try { return context.getPackageManager().getApplicationInfo(packageName, 0).enabled; } catch (NameNotFoundException e) { // Thrown by PackageManager.getApplicationInfo if the package does not exist } return false; } } src/com/android/settings/WebViewImplementation.java 0 → 100644 +113 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.settings; import android.annotation.Nullable; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnDismissListener; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserManager; import android.util.Log; import android.webkit.IWebViewUpdateService; import android.webkit.WebViewProviderInfo; import com.android.internal.logging.MetricsProto.MetricsEvent; import java.util.ArrayList; public class WebViewImplementation extends InstrumentedActivity implements OnCancelListener, OnDismissListener { private static final String TAG = "WebViewImplementation"; private IWebViewUpdateService mWebViewUpdateService; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!UserManager.get(this).isAdminUser()) { finish(); return; } mWebViewUpdateService = IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate")); try { WebViewProviderInfo[] providers = mWebViewUpdateService.getValidWebViewPackages(); if (providers == null) { Log.e(TAG, "No WebView providers available"); finish(); return; } String currentValue = mWebViewUpdateService.getCurrentWebViewPackageName(); if (currentValue == null) { currentValue = ""; } int currentIndex = -1; ArrayList<String> options = new ArrayList<>(); final ArrayList<String> values = new ArrayList<>(); for (WebViewProviderInfo provider : providers) { if (Utils.isPackageEnabled(this, provider.packageName)) { options.add(provider.description); values.add(provider.packageName); if (currentValue.contentEquals(provider.packageName)) { currentIndex = values.size() - 1; } } } new AlertDialog.Builder(this) .setTitle(R.string.select_webview_provider_dialog_title) .setSingleChoiceItems(options.toArray(new String[0]), currentIndex, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { mWebViewUpdateService.changeProviderAndSetting(values.get(which)); } catch (RemoteException e) { Log.w(TAG, "Problem reaching webviewupdate service", e); } finish(); } }).setNegativeButton(android.R.string.cancel, null) .setOnCancelListener(this) .setOnDismissListener(this) .show(); } catch (RemoteException e) { Log.w(TAG, "Problem reaching webviewupdate service", e); finish(); } } @Override protected int getMetricsCategory() { return MetricsEvent.WEBVIEW_IMPLEMENTATION; } @Override public void onCancel(DialogInterface dialog) { finish(); } @Override public void onDismiss(DialogInterface dialog) { finish(); } } Loading
AndroidManifest.xml +12 −0 Original line number Diff line number Diff line Loading @@ -2888,6 +2888,18 @@ android:value="true" /> </activity> <activity android:name=".WebViewImplementation" android:exported="true" android:excludeFromRecents="true" android:theme="@*android:style/Theme.Material.Light.Dialog.Alert"> <intent-filter> <action android:name="android.settings.WEBVIEW_SETTINGS" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED" android:value="true" /> </activity> <service android:name=".SettingsDumpService" android:exported="true" Loading
src/com/android/settings/DevelopmentSettings.java +1 −10 Original line number Diff line number Diff line Loading @@ -749,7 +749,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment ArrayList<String> options = new ArrayList<String>(); ArrayList<String> values = new ArrayList<String>(); for(int n = 0; n < providers.length; n++) { if (isPackageEnabled(providers[n].packageName)) { if (Utils.isPackageEnabled(getActivity(), providers[n].packageName)) { options.add(providers[n].description); values.add(providers[n].packageName); } Loading Loading @@ -1929,15 +1929,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment requestCode, resources.getString(R.string.oem_unlock_enable)); } private boolean isPackageEnabled(String packageName) { try { return getActivity().getPackageManager().getApplicationInfo(packageName, 0).enabled; } catch (NameNotFoundException e) { // Thrown by PackageManager.getApplicationInfo if the package does not exist } return false; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (HDCP_CHECKING_KEY.equals(preference.getKey())) { Loading
src/com/android/settings/Utils.java +10 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.IntentFilterVerificationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.content.res.Resources; Loading Loading @@ -87,7 +88,6 @@ import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.ListView; import android.widget.TabWidget; import com.android.internal.app.UnlaunchableAppActivity; import com.android.internal.util.UserIcons; Loading Loading @@ -1137,5 +1137,14 @@ public final class Utils extends com.android.settingslib.Utils { } return null; } public static boolean isPackageEnabled(Context context, String packageName) { try { return context.getPackageManager().getApplicationInfo(packageName, 0).enabled; } catch (NameNotFoundException e) { // Thrown by PackageManager.getApplicationInfo if the package does not exist } return false; } }
src/com/android/settings/WebViewImplementation.java 0 → 100644 +113 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.settings; import android.annotation.Nullable; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnDismissListener; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserManager; import android.util.Log; import android.webkit.IWebViewUpdateService; import android.webkit.WebViewProviderInfo; import com.android.internal.logging.MetricsProto.MetricsEvent; import java.util.ArrayList; public class WebViewImplementation extends InstrumentedActivity implements OnCancelListener, OnDismissListener { private static final String TAG = "WebViewImplementation"; private IWebViewUpdateService mWebViewUpdateService; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!UserManager.get(this).isAdminUser()) { finish(); return; } mWebViewUpdateService = IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate")); try { WebViewProviderInfo[] providers = mWebViewUpdateService.getValidWebViewPackages(); if (providers == null) { Log.e(TAG, "No WebView providers available"); finish(); return; } String currentValue = mWebViewUpdateService.getCurrentWebViewPackageName(); if (currentValue == null) { currentValue = ""; } int currentIndex = -1; ArrayList<String> options = new ArrayList<>(); final ArrayList<String> values = new ArrayList<>(); for (WebViewProviderInfo provider : providers) { if (Utils.isPackageEnabled(this, provider.packageName)) { options.add(provider.description); values.add(provider.packageName); if (currentValue.contentEquals(provider.packageName)) { currentIndex = values.size() - 1; } } } new AlertDialog.Builder(this) .setTitle(R.string.select_webview_provider_dialog_title) .setSingleChoiceItems(options.toArray(new String[0]), currentIndex, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { mWebViewUpdateService.changeProviderAndSetting(values.get(which)); } catch (RemoteException e) { Log.w(TAG, "Problem reaching webviewupdate service", e); } finish(); } }).setNegativeButton(android.R.string.cancel, null) .setOnCancelListener(this) .setOnDismissListener(this) .show(); } catch (RemoteException e) { Log.w(TAG, "Problem reaching webviewupdate service", e); finish(); } } @Override protected int getMetricsCategory() { return MetricsEvent.WEBVIEW_IMPLEMENTATION; } @Override public void onCancel(DialogInterface dialog) { finish(); } @Override public void onDismiss(DialogInterface dialog) { finish(); } }