Snap for 5220519 from f57f490aa6 to qt-release

Change-Id: I193d4aafdc387888f1406524fe0e9f8cf7bcfb23
This commit is contained in:
android-build-team Robot
2019-01-10 04:05:21 +00:00
24 changed files with 290 additions and 108 deletions

View File

@@ -20,6 +20,7 @@
android:id="@+id/dismissal_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/homepage_card_dismissal_background"
android:orientation="vertical">
<TextView

View File

@@ -24,12 +24,12 @@
<ViewFlipper
android:id="@+id/view_flipper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:paddingStart="@dimen/homepage_card_padding_start"
android:paddingEnd="@dimen/homepage_card_padding_end"
android:paddingTop="@dimen/homepage_half_card_padding_top"

View File

@@ -63,7 +63,7 @@ instead of an ImageView -->
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/Preference_TextAppearanceMaterialSubhead"
android:textAppearance="?android:attr/textAppearanceListItem"
android:ellipsize="marquee" />
<RelativeLayout

View File

@@ -23,5 +23,6 @@
<color name="homepage_support_background">#3F5FBD</color>
<!-- 80% black for status bar of homepage -->
<color name="homepage_status_bar_color">#cc000000</color>
<color name="homepage_card_dismissal_background">@*android:color/material_grey_800</color>
</resources>

View File

@@ -104,6 +104,7 @@
<color name="homepage_about_background">#9FA8DA</color>
<color name="homepage_privacy_background">#5E97F6</color>
<color name="homepage_card_stroke_color">#1f000000</color>
<color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
<!-- End of dashboard/homepage icon background colors -->
<color name="switchbar_text_color">@android:color/white</color>

View File

@@ -171,4 +171,7 @@
<!-- ComponentName to launch a vendor-specific enrollment activity if available -->
<string name="config_face_enroll" translatable="false"></string>
<!-- Max allowed value for screen timeout, in milliseconds -->
<integer name="max_lock_after_timeout_ms">1800000</integer>
</resources>

View File

@@ -5828,9 +5828,6 @@
Used in SetupWizard for XLarge screen [CHAR LIMIT=20] -->
<string name="wifi_setup_detail">Network details</string>
<!-- Do not translate. This is a stub which will be removed soon. -->
<string name="time_zone_auto_stub" translatable="false">Select Time Zone</string>
<!-- Content description of the enabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
<string name="accessibility_sync_enabled">Sync enabled</string>
<!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->

View File

@@ -58,7 +58,7 @@
<com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
android:key="timezone"
android:title="@string/date_time_set_timezone"
android:title="@string/date_time_set_timezone_title"
android:summary="@string/summary_placeholder"
settings:userRestriction="no_config_date_time" />
</PreferenceCategory>

View File

@@ -19,7 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="privacy_dashboard_page"
android:title="@string/privacy_dashboard_title">
android:title="@string/privacy_dashboard_title"
settings:initialExpandedChildrenCount="3">
<!-- App permissions -->
<Preference
@@ -30,13 +31,6 @@
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
</Preference>
<!-- On lock screen notifications -->
<com.android.settings.RestrictedListPreference
android:key="privacy_lock_screen_notifications"
android:title="@string/lock_screen_notifications_title"
android:summary="@string/summary_placeholder"
settings:searchable="false"/>
<!-- Show passwords -->
<SwitchPreference
android:key="show_password"
@@ -44,6 +38,13 @@
android:summary="@string/show_password_summary"
settings:controller="com.android.settings.security.ShowPasswordPreferenceController"/>
<!-- On lock screen notifications -->
<com.android.settings.RestrictedListPreference
android:key="privacy_lock_screen_notifications"
android:title="@string/lock_screen_notifications_title"
android:summary="@string/summary_placeholder"
settings:searchable="false"/>
<!-- Privacy Service -->
<PreferenceCategory
android:key="privacy_services"/>

View File

@@ -37,6 +37,7 @@ public class FeatureFlagPersistent {
static {
PERSISTENT_FLAGS = new HashSet<>();
PERSISTENT_FLAGS.add(FeatureFlags.HEARING_AID_SETTINGS);
PERSISTENT_FLAGS.add(FeatureFlags.NETWORK_INTERNET_V2);
}
public static boolean isEnabled(Context context, String feature) {

View File

@@ -26,6 +26,7 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog.Builder;
import com.android.settings.R;
@@ -33,18 +34,18 @@ import com.android.settings.RestrictedListPreference;
import com.android.settingslib.RestrictedLockUtils;
import java.util.ArrayList;
import java.util.List;
public class TimeoutListPreference extends RestrictedListPreference {
private static final String TAG = "TimeoutListPreference";
private EnforcedAdmin mAdmin;
private final CharSequence[] mInitialEntries;
private final CharSequence[] mInitialValues;
private CharSequence[] mInitialEntries;
private CharSequence[] mInitialValues;
public TimeoutListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mInitialEntries = getEntries();
mInitialValues = getEntryValues();
updateInitialValues();
}
@Override
@@ -65,13 +66,8 @@ public class TimeoutListPreference extends RestrictedListPreference {
if (mAdmin != null) {
View footerView = dialog.findViewById(R.id.admin_disabled_other_options);
footerView.findViewById(R.id.admin_more_details_link).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
getContext(), mAdmin);
}
});
view -> RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
getContext(), mAdmin));
}
}
@@ -89,8 +85,8 @@ public class TimeoutListPreference extends RestrictedListPreference {
maxTimeout = Long.MAX_VALUE;
}
ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
final ArrayList<CharSequence> revisedEntries = new ArrayList<>();
final ArrayList<CharSequence> revisedValues = new ArrayList<>();
for (int i = 0; i < mInitialValues.length; ++i) {
long timeout = Long.parseLong(mInitialValues[i].toString());
if (timeout <= maxTimeout) {
@@ -101,7 +97,7 @@ public class TimeoutListPreference extends RestrictedListPreference {
// If there are no possible options for the user, then set this preference as disabled
// by admin, otherwise remove the padlock in case it was set earlier.
if (revisedValues.size() == 0) {
if (revisedValues.isEmpty()) {
setDisabledByAdmin(admin);
return;
} else {
@@ -117,7 +113,7 @@ public class TimeoutListPreference extends RestrictedListPreference {
setValue(String.valueOf(userPreference));
} else if (revisedValues.size() > 0
&& Long.parseLong(revisedValues.get(revisedValues.size() - 1).toString())
== maxTimeout) {
== maxTimeout) {
// If the last one happens to be the same as the max timeout, select that
setValue(String.valueOf(maxTimeout));
} else {
@@ -128,4 +124,36 @@ public class TimeoutListPreference extends RestrictedListPreference {
}
}
}
@VisibleForTesting
void updateInitialValues() {
// Read default list of candidate values.
final CharSequence[] entries = getEntries();
final CharSequence[] values = getEntryValues();
// Filter out values based on config
final List<CharSequence> revisedEntries = new ArrayList<>();
final List<CharSequence> revisedValues = new ArrayList<>();
final long maxTimeout = getContext().getResources().getInteger(
R.integer.max_lock_after_timeout_ms);
if (entries == null || values == null) {
return;
}
Log.d(TAG, "max timeout: " + maxTimeout);
for (int i = 0; i < values.length; ++i) {
long timeout = Long.parseLong(values[i].toString());
if (timeout <= maxTimeout) {
Log.d(TAG, "keeping timeout: " + values[i]);
revisedEntries.add(entries[i]);
revisedValues.add(values[i]);
} else {
Log.d(TAG, "Dropping timeout: " + values[i]);
}
}
// Store final candidates in initial value lists.
mInitialEntries = revisedEntries.toArray(new CharSequence[0]);
setEntries(mInitialEntries);
mInitialValues = revisedValues.toArray(new CharSequence[0]);
setEntryValues(mInitialValues);
}
}

View File

@@ -13,8 +13,6 @@
*/
package com.android.settings.display;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.os.UserHandle;
@@ -60,7 +58,7 @@ public class TimeoutPreferenceController extends AbstractPreferenceController im
public void updateState(Preference preference) {
final TimeoutListPreference timeoutListPreference = (TimeoutListPreference) preference;
final long currentTimeout = Settings.System.getLong(mContext.getContentResolver(),
SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
Settings.System.SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
timeoutListPreference.setValue(String.valueOf(currentTimeout));
final DevicePolicyManager dpm =
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
@@ -86,7 +84,8 @@ public class TimeoutPreferenceController extends AbstractPreferenceController im
public boolean onPreferenceChange(Preference preference, Object newValue) {
try {
int value = Integer.parseInt((String) newValue);
Settings.System.putInt(mContext.getContentResolver(), SCREEN_OFF_TIMEOUT, value);
Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SCREEN_OFF_TIMEOUT, value);
updateTimeoutPreferenceDescription((TimeoutListPreference) preference, value);
} catch (NumberFormatException e) {
Log.e(TAG, "could not persist screen timeout setting", e);
@@ -94,7 +93,7 @@ public class TimeoutPreferenceController extends AbstractPreferenceController im
return true;
}
public static CharSequence getTimeoutDescription(
private static CharSequence getTimeoutDescription(
long currentTimeout, CharSequence[] entries, CharSequence[] values) {
if (currentTimeout < 0 || entries == null || values == null
|| values.length != entries.length) {

View File

@@ -21,7 +21,6 @@ import static com.android.settings.network.MobilePlanPreferenceController
import android.app.Dialog;
import android.content.Context;
import android.provider.SearchIndexableResource;
import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
@@ -31,6 +30,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.network.MobilePlanPreferenceController.MobilePlanPreferenceHost;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.wifi.WifiMasterSwitchPreferenceController;
@@ -61,7 +61,7 @@ public class NetworkDashboardFragment extends DashboardFragment implements
@Override
protected int getPreferenceScreenResId() {
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
return R.xml.network_and_internet_v2;
} else {
return R.xml.network_and_internet;
@@ -72,7 +72,7 @@ public class NetworkDashboardFragment extends DashboardFragment implements
public void onAttach(Context context) {
super.onAttach(context);
if (FeatureFlagUtils.isEnabled(context, FeatureFlags.NETWORK_INTERNET_V2)) {
if (FeatureFlagPersistent.isEnabled(context, FeatureFlags.NETWORK_INTERNET_V2)) {
use(MultiNetworkHeaderController.class).init(getSettingsLifecycle());
}
use(AirplaneModePreferenceController.class).setFragment(this);

View File

@@ -16,7 +16,6 @@
package com.android.settings.wifi;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -67,9 +66,15 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
/** Message sent to us to stop scanning wifi and pop up timeout dialog. */
private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
/** Message sent to us to finish activity. */
private static final int MESSAGE_FINISH_ACTIVITY = 1;
/** Spec defines there should be 5 wifi ap on the list at most. */
private static final int MAX_NUMBER_LIST_ITEM = 5;
/** Holding time to let user be aware that selected wifi ap is connected */
private static final int DELAY_TIME_USER_AWARE_CONNECTED_MS = 1 * 1000;
/** Delayed time to stop scanning wifi. */
private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
@@ -155,7 +160,9 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
public void onCancel(@NonNull DialogInterface dialog) {
super.onCancel(dialog);
// Finishes the activity when user clicks back key or outside of the dialog.
getActivity().finish();
if (getActivity() != null) {
getActivity().finish();
}
}
@Override
@@ -177,6 +184,8 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
@Override
public void onDestroy() {
super.onDestroy();
mHandler.removeMessages(MESSAGE_FINISH_ACTIVITY);
if (mFilterWifiTracker != null) {
mFilterWifiTracker.onDestroy();
mFilterWifiTracker = null;
@@ -207,7 +216,10 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
switch (msg.what) {
case MESSAGE_STOP_SCAN_WIFI_LIST:
removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
break;
case MESSAGE_FINISH_ACTIVITY:
stopScanningAndMaybePopErrorDialog(/* ERROR_DIALOG_TYPE */ null);
break;
default:
// Do nothing.
@@ -216,18 +228,29 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
}
};
protected void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
protected void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
// Dismisses current dialog.
dismiss();
final Dialog dialog = getDialog();
if (dialog != null && dialog.isShowing()) {
dismiss();
}
if (type == null) {
// If no error, finishes activity.
if (getActivity() != null) {
getActivity().finish();
}
} else {
// Throws error dialog.
final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
.newInstance();
final Bundle bundle = new Bundle();
bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, type);
fragment.setArguments(bundle);
fragment.show(getActivity().getSupportFragmentManager(),
NetworkRequestDialogFragment.class.getSimpleName());
}
// Throws new timeout dialog.
final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
.newInstance();
final Bundle bundle = new Bundle();
bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, type);
fragment.setArguments(bundle);
fragment.show(getActivity().getSupportFragmentManager(),
NetworkRequestDialogFragment.class.getSimpleName());
}
@Override
@@ -284,7 +307,7 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
@Override
public void onAbort() {
stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
}
@Override
@@ -295,10 +318,13 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
@Override
public void onMatch(List<ScanResult> scanResults) {
mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
renewAccessPointList(scanResults);
// Shouldn't need to renew cached list, since input result is empty.
if (scanResults != null && scanResults.size() > 0) {
mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
renewAccessPointList(scanResults);
notifyAdapterRefresh();
notifyAdapterRefresh();
}
}
// Updates internal AccessPoint list from WifiTracker. scanResults are used to update key list
@@ -329,17 +355,24 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
@Override
public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
// Dismisses current dialog and finishes Activity, since connection is success.
dismiss();
final Activity activity = getActivity();
if (activity != null) {
activity.finish();
// Removes the progress icon.
final Dialog dialog = getDialog();
if (dialog != null) {
final View view = dialog.findViewById(R.id.network_request_title_progress);
if (view != null) {
view.setVisibility(View.GONE);
}
}
// Posts delay to finish self since connection is success.
mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
mHandler.sendEmptyMessageDelayed(MESSAGE_FINISH_ACTIVITY,
DELAY_TIME_USER_AWARE_CONNECTED_MS);
}
@Override
public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
}
private final class FilterWifiTracker {

View File

@@ -18,7 +18,10 @@ package com.android.settings.wifi.dpp;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -35,11 +38,42 @@ import com.android.settings.R;
* to the Wi-Fi network.
*/
public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
private static final String TAG = "WifiDppAddDeviceFragment";
private ImageView mWifiApPictureView;
private TextView mChooseDifferentNetwork;
private Button mButtonLeft;
private Button mButtonRight;
private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
@Override
public void onEnrolleeSuccess(int newNetworkId) {
// Do nothing
}
@Override
public void onConfiguratorSuccess(int code) {
// Update success UI.
mTitle.setText(R.string.wifi_dpp_wifi_shared_with_device);
mSummary.setVisibility(View.INVISIBLE);
mButtonLeft.setText(R.string.wifi_dpp_add_another_device);
mButtonLeft.setOnClickListener(v -> getFragmentManager().popBackStack());
mButtonRight.setText(R.string.done);
mButtonRight.setOnClickListener(v -> getActivity().finish());
}
@Override
public void onFailure(int code) {
//TODO(b/122429170): Show DPP configuration error state UI
Log.d(TAG, "DppStatusCallback.onFailure " + code);
}
@Override
public void onProgress(int code) {
// Do nothing
}
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_CONFIGURATOR;
@@ -86,6 +120,11 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
}
private void startWifiDppInitiator() {
//TODO(b/122331217): starts Wi-Fi DPP initiator handshake here
final String enrolleeUri = ((WifiDppConfiguratorActivity) getActivity()).getDppUri();
final int networkId =
((WifiDppConfiguratorActivity) getActivity()).getWifiNetworkConfig().getNetworkId();
final WifiManager wifiManager = getContext().getSystemService(WifiManager.class);
wifiManager.startDppAsConfiguratorInitiator(enrolleeUri, networkId,
WifiManager.DPP_NETWORK_ROLE_STA, /* handler */ null, new DppStatusCallback());
}
}

View File

@@ -66,11 +66,8 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
/** The Wi-Fi network which will be configured */
private WifiNetworkConfig mWifiNetworkConfig;
/** The public key from Wi-Fi DPP QR code */
private String mPublicKey;
/** The information from Wi-Fi DPP QR code */
private String mInformation;
/** The uri from Wi-Fi DPP QR code */
private String mDppUri;
/** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_DPP_QR_CODE */
private WifiQrCode mWifiDppQrCode;
@@ -228,12 +225,8 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
return mWifiNetworkConfig;
}
public String getPublicKey() {
return mPublicKey;
}
public String getInformation() {
return mInformation;
public String getDppUri() {
return mDppUri;
}
public WifiQrCode getWifiDppQrCode() {
@@ -270,17 +263,15 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
}
@Override
public void onScanWifiDppSuccess(String publicKey, String information) {
mPublicKey = publicKey;
mInformation = information;
public void onScanWifiDppSuccess(String uri) {
mDppUri = uri;
showAddDeviceFragment(/* addToBackStack */ true);
}
@Override
public void onScanZxingWifiFormatSuccess(WifiNetworkConfig wifiNetworkConfig) {
mPublicKey = null;
mInformation = null;
mDppUri = null;
mWifiNetworkConfig = new WifiNetworkConfig(wifiNetworkConfig);
showAddDeviceFragment(/* addToBackStack */ true);

View File

@@ -16,6 +16,8 @@
package com.android.settings.wifi.dpp;
import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.provider.Settings;
import android.app.ActionBar;
import android.app.Activity;
@@ -32,6 +34,8 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.core.InstrumentedActivity;
import com.android.settings.R;
import java.util.List;
/**
* To provision "this" device with specified Wi-Fi network.
*
@@ -49,6 +53,39 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
private FragmentManager mFragmentManager;
private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
@Override
public void onEnrolleeSuccess(int newNetworkId) {
// Connect to the new network.
final WifiManager wifiManager = getSystemService(WifiManager.class);
final List<WifiConfiguration> wifiConfigs = wifiManager.getPrivilegedConfiguredNetworks();
for (WifiConfiguration wifiConfig : wifiConfigs) {
if (wifiConfig.networkId == newNetworkId) {
wifiManager.connect(wifiConfig, WifiDppEnrolleeActivity.this);
return;
}
}
Log.e(TAG, "Invalid networkId " + newNetworkId);
WifiDppEnrolleeActivity.this.onFailure(WifiManager.ERROR_AUTHENTICATING);
}
@Override
public void onConfiguratorSuccess(int code) {
// Do nothing
}
@Override
public void onFailure(int code) {
//TODO(b/122429170): Show DPP enrollee error state UI
Log.d(TAG, "DppStatusCallback.onFailure " + code);
}
@Override
public void onProgress(int code) {
// Do nothing
}
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_ENROLLEE;
@@ -108,8 +145,9 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
}
@Override
public void onScanWifiDppSuccess(String publicKey, String information) {
// TODO(b/1023597): starts DPP enrollee handshake here
public void onScanWifiDppSuccess(String uri) {
final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiManager.startDppAsEnrolleeInitiator(uri, /* handler */ null, new DppStatusCallback());
}
@Override

View File

@@ -62,9 +62,8 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
private static final long SHOW_ERROR_MESSAGE_INTERVAL = 2000;
private static final long SHOW_SUCCESS_SQUARE_INTERVAL = 1000;
// Keys for Bundle usage
private static final String KEY_PUBLIC_KEY = "key_public_key";
private static final String KEY_INFORMATION = "key_information";
// Key for Bundle usage
private static final String KEY_PUBLIC_URI = "key_public_uri";
private QrCamera mCamera;
private TextureView mTextureView;
@@ -91,7 +90,7 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
// Container Activity must implement this interface
public interface OnScanWifiDppSuccessListener {
public void onScanWifiDppSuccess(String publicKey, String information);
public void onScanWifiDppSuccess(String uri);
}
OnScanWifiDppSuccessListener mScanWifiDppSuccessListener;
@@ -269,7 +268,7 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
public void handleSuccessfulResult(String qrCode) {
switch (mWifiQrCode.getScheme()) {
case WifiQrCode.SCHEME_DPP:
handleWifiDpp(mWifiQrCode.getPublicKey(), mWifiQrCode.getInformation());
handleWifiDpp(qrCode);
break;
case WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG:
@@ -281,13 +280,12 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
}
}
private void handleWifiDpp(String publicKey, String information) {
private void handleWifiDpp(String uri) {
destroyCamera();
mDecorateView.setFocused(true);
final Bundle bundle = new Bundle();
bundle.putString(KEY_PUBLIC_KEY, publicKey);
bundle.putString(KEY_INFORMATION, information);
bundle.putString(KEY_PUBLIC_URI, uri);
Message message = mHandler.obtainMessage(MESSAGE_SCAN_WIFI_DPP_SUCCESS);
message.setData(bundle);
@@ -352,10 +350,9 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
return;
}
final Bundle bundle = msg.getData();
final String publicKey = bundle.getString(KEY_PUBLIC_KEY);
final String information = bundle.getString(KEY_INFORMATION);
final String uri = bundle.getString(KEY_PUBLIC_URI);
mScanWifiDppSuccessListener.onScanWifiDppSuccess(publicKey, information);
mScanWifiDppSuccessListener.onScanWifiDppSuccess(uri);
break;
case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:

View File

@@ -64,6 +64,9 @@ public class WifiDppUtils {
/** The data corresponding to {@code WifiConfiguration} hiddenSSID */
public static final String EXTRA_WIFI_HIDDEN_SSID = "hiddenSsid";
/** The data corresponding to {@code WifiConfiguration} networkId */
public static final String EXTRA_WIFI_NETWORK_ID = "networkId";
/** @see WifiQrCode */
public static final String EXTRA_QR_CODE = "qrCode";
@@ -164,6 +167,11 @@ public class WifiDppUtils {
if (!TextUtils.isEmpty(preSharedKey)) {
intent.putExtra(EXTRA_WIFI_PRE_SHARED_KEY, preSharedKey);
}
if (wifiConfig.networkId == WifiConfiguration.INVALID_NETWORK_ID) {
throw new IllegalArgumentException("Invalid network ID");
} else {
intent.putExtra(EXTRA_WIFI_NETWORK_ID, wifiConfig.networkId);
}
return intent;
}

View File

@@ -46,13 +46,15 @@ public class WifiNetworkConfig {
private String mSsid;
private String mPreSharedKey;
private boolean mHiddenSsid;
private int mNetworkId;
private WifiNetworkConfig(String security, String ssid, String preSharedKey,
boolean hiddenSsid) {
private WifiNetworkConfig(String security, String ssid, String preSharedKey, boolean hiddenSsid,
int networkId) {
mSecurity = security;
mSsid = ssid;
mPreSharedKey = preSharedKey;
mHiddenSsid = hiddenSsid;
mNetworkId = networkId;
}
public WifiNetworkConfig(WifiNetworkConfig config) {
@@ -60,6 +62,7 @@ public class WifiNetworkConfig {
mSsid = config.mSsid;
mPreSharedKey = config.mPreSharedKey;
mHiddenSsid = config.mHiddenSsid;
mNetworkId = config.mNetworkId;
}
/**
@@ -82,17 +85,19 @@ public class WifiNetworkConfig {
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
String preSharedKey = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY);
boolean hiddenSsid = intent.getBooleanExtra(WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID, false);
int networkId = intent.getIntExtra(WifiDppUtils.EXTRA_WIFI_NETWORK_ID,
WifiConfiguration.INVALID_NETWORK_ID);
return getValidConfigOrNull(security, ssid, preSharedKey, hiddenSsid);
return getValidConfigOrNull(security, ssid, preSharedKey, hiddenSsid, networkId);
}
public static WifiNetworkConfig getValidConfigOrNull(String security, String ssid,
String preSharedKey, boolean hiddenSsid) {
String preSharedKey, boolean hiddenSsid, int networkId) {
if (!isValidConfig(security, ssid, preSharedKey, hiddenSsid)) {
return null;
}
return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid);
return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid, networkId);
}
public static boolean isValidConfig(WifiNetworkConfig config) {
@@ -184,6 +189,11 @@ public class WifiNetworkConfig {
return mHiddenSsid;
}
@Keep
public int getNetworkId() {
return mNetworkId;
}
public void connect(Context context, WifiManager.ActionListener listener) {
WifiConfiguration wifiConfiguration = getWifiConfigurationOrNull();
if (wifiConfiguration == null) {
@@ -208,6 +218,7 @@ public class WifiNetworkConfig {
final WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = addQuotationIfNeeded(mSsid);
wifiConfiguration.hiddenSSID = mHiddenSsid;
wifiConfiguration.networkId = mNetworkId;
if (TextUtils.isEmpty(mSecurity) || SECURITY_NO_PASSWORD.equals(mSecurity)) {
wifiConfiguration.allowedKeyManagement.set(KeyMgmt.NONE);

View File

@@ -17,6 +17,7 @@
package com.android.settings.wifi.dpp;
import android.content.Intent;
import android.net.wifi.WifiConfiguration;
import android.text.TextUtils;
import androidx.annotation.Keep;
@@ -135,7 +136,7 @@ public class WifiQrCode {
password = removeBackSlash(password);
mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid, password,
hiddenSsid);
hiddenSsid, WifiConfiguration.INVALID_NETWORK_ID);
if (mWifiNetworkConfig == null) {
throw new IllegalArgumentException("Invalid format");

View File

@@ -88,4 +88,7 @@
<!-- Email address for the homepage contextual cards feedback -->
<string name="config_contextual_card_feedback_email" translatable="false">test@test.test</string>
<!-- Max allowed value for screen timeout, in milliseconds -->
<integer name="max_lock_after_timeout_ms">1700000</integer>
</resources>

View File

@@ -17,11 +17,11 @@ package com.android.settings.display;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.robolectric.RuntimeEnvironment.application;
import android.util.AttributeSet;
import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.RestrictedLockUtils;
@@ -69,4 +69,23 @@ public class TimeoutListPreferenceTest {
// should set to largest allowed value, which is 5 minute
assertThat(mPreference.getValue()).isEqualTo("300000");
}
@Test
@Config(qualifiers = "mcc999")
public void newInstance_hasLowTimeoutConfig_shouldRemoveLongTimeouts() {
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
final TimeoutListPreference pref = new TimeoutListPreference(application, attributeSet);
final long maxTimeout = application.getResources().getInteger(
R.integer.max_lock_after_timeout_ms);
pref.setEntries(R.array.screen_timeout_entries);
pref.setEntryValues(R.array.screen_timeout_values);
pref.updateInitialValues();
final CharSequence[] values = pref.getEntryValues();
for (CharSequence value : values) {
long timeout = Long.parseLong(value.toString());
assertThat(timeout).isAtMost(maxTimeout);
}
}
}

View File

@@ -111,14 +111,17 @@ public class NetworkRequestDialogFragmentTest {
ShadowLooper.getShadowMainLooper().runToEndOfTasks();
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.TIME_OUT);
}
class FakeNetworkRequestDialogFragment extends NetworkRequestDialogFragment {
boolean bCalledStopAndPop = false;
ERROR_DIALOG_TYPE errorType = null;
@Override
public void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
public void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
bCalledStopAndPop = true;
errorType = type;
}
}
@@ -150,22 +153,28 @@ public class NetworkRequestDialogFragmentTest {
@Test
public void updateAccessPointList_onUserSelectionConnectSuccess_shouldCloseTheDialog() {
List<AccessPoint> accessPointList = createAccessPointList();
when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(alertDialog.isShowing()).isTrue();
// Assert
FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
// Test if config would update list.
List<AccessPoint> accessPointList = createAccessPointList();
when(spyFakeFragment.getAccessPointList()).thenReturn(accessPointList);
spyFakeFragment.show(mActivity.getSupportFragmentManager(), null);
// Action
WifiConfiguration config = new WifiConfiguration();
config.SSID = "Test AP 3";
networkRequestDialogFragment.onUserSelectionConnectSuccess(config);
spyFakeFragment.onUserSelectionConnectSuccess(config);
assertThat(alertDialog.isShowing()).isFalse();
// Check
ShadowLooper.getShadowMainLooper().runToEndOfTasks();
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
assertThat(fakeFragment.errorType).isNull();
}
@Test
public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallTimeoutDialog() {
public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallAbortDialog() {
FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
List<AccessPoint> accessPointList = createAccessPointList();
@@ -181,6 +190,7 @@ public class NetworkRequestDialogFragmentTest {
fakeFragment.onUserSelectionConnectFailure(config);
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.ABORT);
}
@Test