Update WebView implementation Dev Setting - new looks + descriptions.
Now that we are changing the WebView package mechanism so that a package can only be used as WebView implementation if that package is enabled for all users of the device we need to tell the user why a package can't be chosen as WebView implementation. With this CL we do so in the 'Set WebView Implementation' Developer Setting. We code for the WebView implementation Developer Setting is now based on the same code as that of the Debug App Developer Setting. Bug: 32894154 Test: Ensure WebView Implementation setting shows correct packages. Test: Ensure WebView Implementation setting shows correct descriptions for why a package is not usable - including the case where packages are disabled/uninstalled for a second user. Test: Ensure the summary for the WebView Implmentation setting is updated after changing WebView package. Test: Ensure the WebView package Activity (Settings.ACTION_WEBVIEW_SETTINGS) is similar to the Dev Setting. Test: ensure non-admin user cannot start WV-picker activity through 'adb shell am start -n com.android.settings/.WebViewImplementation' Change-Id: Ia6e6e9e12ce8f8f45ec539807cd0c6479acb8ecb
This commit is contained in:
95
src/com/android/settings/webview/WebViewAppPicker.java
Normal file
95
src/com/android/settings/webview/WebViewAppPicker.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.webview;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.WebViewFactory;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.core.instrumentation.Instrumentable;
|
||||
import com.android.settings.core.instrumentation.VisibilityLoggerMixin;
|
||||
|
||||
public class WebViewAppPicker extends ListActivity implements Instrumentable {
|
||||
private static final String TAG = WebViewAppPicker.class.getSimpleName();
|
||||
private WebViewAppListAdapter mAdapter;
|
||||
private WebViewUpdateServiceWrapper mWebViewUpdateServiceWrapper;
|
||||
|
||||
private final VisibilityLoggerMixin mVisibilityLoggerMixin =
|
||||
new VisibilityLoggerMixin(getMetricsCategory());
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
if (mWebViewUpdateServiceWrapper == null) {
|
||||
setWebViewUpdateServiceWrapper(createDefaultWebViewUpdateServiceWrapper());
|
||||
}
|
||||
mAdapter = new WebViewAppListAdapter(this, mWebViewUpdateServiceWrapper);
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
mVisibilityLoggerMixin.onAttach(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
WebViewApplicationInfo app = mAdapter.getItem(position);
|
||||
|
||||
if (mWebViewUpdateServiceWrapper.setWebViewProvider(app.info.packageName)) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(app.info.packageName);
|
||||
setResult(RESULT_OK, intent);
|
||||
} else {
|
||||
mWebViewUpdateServiceWrapper.showInvalidChoiceToast(this);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private WebViewUpdateServiceWrapper createDefaultWebViewUpdateServiceWrapper() {
|
||||
return new WebViewUpdateServiceWrapper();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setWebViewUpdateServiceWrapper(WebViewUpdateServiceWrapper wvusWrapper) {
|
||||
mWebViewUpdateServiceWrapper = wvusWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mVisibilityLoggerMixin.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mVisibilityLoggerMixin.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.WEBVIEW_IMPLEMENTATION;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user