Snap for 5220519 from f57f490aa6 to qt-release
Change-Id: I193d4aafdc387888f1406524fe0e9f8cf7bcfb23
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
android:id="@+id/dismissal_view"
|
android:id="@+id/dismissal_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/homepage_card_dismissal_background"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -24,12 +24,12 @@
|
|||||||
<ViewFlipper
|
<ViewFlipper
|
||||||
android:id="@+id/view_flipper"
|
android:id="@+id/view_flipper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/content"
|
android:id="@+id/content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:paddingStart="@dimen/homepage_card_padding_start"
|
android:paddingStart="@dimen/homepage_card_padding_start"
|
||||||
android:paddingEnd="@dimen/homepage_card_padding_end"
|
android:paddingEnd="@dimen/homepage_card_padding_end"
|
||||||
android:paddingTop="@dimen/homepage_half_card_padding_top"
|
android:paddingTop="@dimen/homepage_half_card_padding_top"
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ instead of an ImageView -->
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="@style/Preference_TextAppearanceMaterialSubhead"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
android:ellipsize="marquee" />
|
android:ellipsize="marquee" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|||||||
@@ -23,5 +23,6 @@
|
|||||||
<color name="homepage_support_background">#3F5FBD</color>
|
<color name="homepage_support_background">#3F5FBD</color>
|
||||||
<!-- 80% black for status bar of homepage -->
|
<!-- 80% black for status bar of homepage -->
|
||||||
<color name="homepage_status_bar_color">#cc000000</color>
|
<color name="homepage_status_bar_color">#cc000000</color>
|
||||||
|
<color name="homepage_card_dismissal_background">@*android:color/material_grey_800</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,7 @@
|
|||||||
<color name="homepage_about_background">#9FA8DA</color>
|
<color name="homepage_about_background">#9FA8DA</color>
|
||||||
<color name="homepage_privacy_background">#5E97F6</color>
|
<color name="homepage_privacy_background">#5E97F6</color>
|
||||||
<color name="homepage_card_stroke_color">#1f000000</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 -->
|
<!-- End of dashboard/homepage icon background colors -->
|
||||||
|
|
||||||
<color name="switchbar_text_color">@android:color/white</color>
|
<color name="switchbar_text_color">@android:color/white</color>
|
||||||
|
|||||||
@@ -171,4 +171,7 @@
|
|||||||
|
|
||||||
<!-- ComponentName to launch a vendor-specific enrollment activity if available -->
|
<!-- ComponentName to launch a vendor-specific enrollment activity if available -->
|
||||||
<string name="config_face_enroll" translatable="false"></string>
|
<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>
|
</resources>
|
||||||
|
|||||||
@@ -5828,9 +5828,6 @@
|
|||||||
Used in SetupWizard for XLarge screen [CHAR LIMIT=20] -->
|
Used in SetupWizard for XLarge screen [CHAR LIMIT=20] -->
|
||||||
<string name="wifi_setup_detail">Network details</string>
|
<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] -->
|
<!-- Content description of the enabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_sync_enabled">Sync enabled</string>
|
<string name="accessibility_sync_enabled">Sync enabled</string>
|
||||||
<!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
|
<!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
|
android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
|
||||||
android:key="timezone"
|
android:key="timezone"
|
||||||
android:title="@string/date_time_set_timezone"
|
android:title="@string/date_time_set_timezone_title"
|
||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
settings:userRestriction="no_config_date_time" />
|
settings:userRestriction="no_config_date_time" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:key="privacy_dashboard_page"
|
android:key="privacy_dashboard_page"
|
||||||
android:title="@string/privacy_dashboard_title">
|
android:title="@string/privacy_dashboard_title"
|
||||||
|
settings:initialExpandedChildrenCount="3">
|
||||||
|
|
||||||
<!-- App permissions -->
|
<!-- App permissions -->
|
||||||
<Preference
|
<Preference
|
||||||
@@ -30,13 +31,6 @@
|
|||||||
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
|
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
|
||||||
</Preference>
|
</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 -->
|
<!-- Show passwords -->
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="show_password"
|
android:key="show_password"
|
||||||
@@ -44,6 +38,13 @@
|
|||||||
android:summary="@string/show_password_summary"
|
android:summary="@string/show_password_summary"
|
||||||
settings:controller="com.android.settings.security.ShowPasswordPreferenceController"/>
|
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 -->
|
<!-- Privacy Service -->
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="privacy_services"/>
|
android:key="privacy_services"/>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public class FeatureFlagPersistent {
|
|||||||
static {
|
static {
|
||||||
PERSISTENT_FLAGS = new HashSet<>();
|
PERSISTENT_FLAGS = new HashSet<>();
|
||||||
PERSISTENT_FLAGS.add(FeatureFlags.HEARING_AID_SETTINGS);
|
PERSISTENT_FLAGS.add(FeatureFlags.HEARING_AID_SETTINGS);
|
||||||
|
PERSISTENT_FLAGS.add(FeatureFlags.NETWORK_INTERNET_V2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnabled(Context context, String feature) {
|
public static boolean isEnabled(Context context, String feature) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.util.AttributeSet;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.appcompat.app.AlertDialog.Builder;
|
import androidx.appcompat.app.AlertDialog.Builder;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -33,18 +34,18 @@ import com.android.settings.RestrictedListPreference;
|
|||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class TimeoutListPreference extends RestrictedListPreference {
|
public class TimeoutListPreference extends RestrictedListPreference {
|
||||||
private static final String TAG = "TimeoutListPreference";
|
private static final String TAG = "TimeoutListPreference";
|
||||||
private EnforcedAdmin mAdmin;
|
private EnforcedAdmin mAdmin;
|
||||||
private final CharSequence[] mInitialEntries;
|
private CharSequence[] mInitialEntries;
|
||||||
private final CharSequence[] mInitialValues;
|
private CharSequence[] mInitialValues;
|
||||||
|
|
||||||
public TimeoutListPreference(Context context, AttributeSet attrs) {
|
public TimeoutListPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mInitialEntries = getEntries();
|
updateInitialValues();
|
||||||
mInitialValues = getEntryValues();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,13 +66,8 @@ public class TimeoutListPreference extends RestrictedListPreference {
|
|||||||
if (mAdmin != null) {
|
if (mAdmin != null) {
|
||||||
View footerView = dialog.findViewById(R.id.admin_disabled_other_options);
|
View footerView = dialog.findViewById(R.id.admin_disabled_other_options);
|
||||||
footerView.findViewById(R.id.admin_more_details_link).setOnClickListener(
|
footerView.findViewById(R.id.admin_more_details_link).setOnClickListener(
|
||||||
new View.OnClickListener() {
|
view -> RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
|
||||||
@Override
|
getContext(), mAdmin));
|
||||||
public void onClick(View view) {
|
|
||||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
|
|
||||||
getContext(), mAdmin);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,8 +85,8 @@ public class TimeoutListPreference extends RestrictedListPreference {
|
|||||||
maxTimeout = Long.MAX_VALUE;
|
maxTimeout = Long.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
|
final ArrayList<CharSequence> revisedEntries = new ArrayList<>();
|
||||||
ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
|
final ArrayList<CharSequence> revisedValues = new ArrayList<>();
|
||||||
for (int i = 0; i < mInitialValues.length; ++i) {
|
for (int i = 0; i < mInitialValues.length; ++i) {
|
||||||
long timeout = Long.parseLong(mInitialValues[i].toString());
|
long timeout = Long.parseLong(mInitialValues[i].toString());
|
||||||
if (timeout <= maxTimeout) {
|
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
|
// 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.
|
// by admin, otherwise remove the padlock in case it was set earlier.
|
||||||
if (revisedValues.size() == 0) {
|
if (revisedValues.isEmpty()) {
|
||||||
setDisabledByAdmin(admin);
|
setDisabledByAdmin(admin);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -117,7 +113,7 @@ public class TimeoutListPreference extends RestrictedListPreference {
|
|||||||
setValue(String.valueOf(userPreference));
|
setValue(String.valueOf(userPreference));
|
||||||
} else if (revisedValues.size() > 0
|
} else if (revisedValues.size() > 0
|
||||||
&& Long.parseLong(revisedValues.get(revisedValues.size() - 1).toString())
|
&& 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
|
// If the last one happens to be the same as the max timeout, select that
|
||||||
setValue(String.valueOf(maxTimeout));
|
setValue(String.valueOf(maxTimeout));
|
||||||
} else {
|
} 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.display;
|
package com.android.settings.display;
|
||||||
|
|
||||||
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
|
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -60,7 +58,7 @@ public class TimeoutPreferenceController extends AbstractPreferenceController im
|
|||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
final TimeoutListPreference timeoutListPreference = (TimeoutListPreference) preference;
|
final TimeoutListPreference timeoutListPreference = (TimeoutListPreference) preference;
|
||||||
final long currentTimeout = Settings.System.getLong(mContext.getContentResolver(),
|
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));
|
timeoutListPreference.setValue(String.valueOf(currentTimeout));
|
||||||
final DevicePolicyManager dpm =
|
final DevicePolicyManager dpm =
|
||||||
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
@@ -86,7 +84,8 @@ public class TimeoutPreferenceController extends AbstractPreferenceController im
|
|||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
try {
|
try {
|
||||||
int value = Integer.parseInt((String) newValue);
|
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);
|
updateTimeoutPreferenceDescription((TimeoutListPreference) preference, value);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(TAG, "could not persist screen timeout setting", e);
|
Log.e(TAG, "could not persist screen timeout setting", e);
|
||||||
@@ -94,7 +93,7 @@ public class TimeoutPreferenceController extends AbstractPreferenceController im
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CharSequence getTimeoutDescription(
|
private static CharSequence getTimeoutDescription(
|
||||||
long currentTimeout, CharSequence[] entries, CharSequence[] values) {
|
long currentTimeout, CharSequence[] entries, CharSequence[] values) {
|
||||||
if (currentTimeout < 0 || entries == null || values == null
|
if (currentTimeout < 0 || entries == null || values == null
|
||||||
|| values.length != entries.length) {
|
|| values.length != entries.length) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import static com.android.settings.network.MobilePlanPreferenceController
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
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.R;
|
||||||
import com.android.settings.core.FeatureFlags;
|
import com.android.settings.core.FeatureFlags;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.development.featureflags.FeatureFlagPersistent;
|
||||||
import com.android.settings.network.MobilePlanPreferenceController.MobilePlanPreferenceHost;
|
import com.android.settings.network.MobilePlanPreferenceController.MobilePlanPreferenceHost;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.wifi.WifiMasterSwitchPreferenceController;
|
import com.android.settings.wifi.WifiMasterSwitchPreferenceController;
|
||||||
@@ -61,7 +61,7 @@ public class NetworkDashboardFragment extends DashboardFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
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;
|
return R.xml.network_and_internet_v2;
|
||||||
} else {
|
} else {
|
||||||
return R.xml.network_and_internet;
|
return R.xml.network_and_internet;
|
||||||
@@ -72,7 +72,7 @@ public class NetworkDashboardFragment extends DashboardFragment implements
|
|||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(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(MultiNetworkHeaderController.class).init(getSettingsLifecycle());
|
||||||
}
|
}
|
||||||
use(AirplaneModePreferenceController.class).setFragment(this);
|
use(AirplaneModePreferenceController.class).setFragment(this);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
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. */
|
/** Message sent to us to stop scanning wifi and pop up timeout dialog. */
|
||||||
private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
|
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. */
|
/** Spec defines there should be 5 wifi ap on the list at most. */
|
||||||
private static final int MAX_NUMBER_LIST_ITEM = 5;
|
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. */
|
/** Delayed time to stop scanning wifi. */
|
||||||
private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
|
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) {
|
public void onCancel(@NonNull DialogInterface dialog) {
|
||||||
super.onCancel(dialog);
|
super.onCancel(dialog);
|
||||||
// Finishes the activity when user clicks back key or outside of the dialog.
|
// Finishes the activity when user clicks back key or outside of the dialog.
|
||||||
getActivity().finish();
|
if (getActivity() != null) {
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -177,6 +184,8 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
|
mHandler.removeMessages(MESSAGE_FINISH_ACTIVITY);
|
||||||
if (mFilterWifiTracker != null) {
|
if (mFilterWifiTracker != null) {
|
||||||
mFilterWifiTracker.onDestroy();
|
mFilterWifiTracker.onDestroy();
|
||||||
mFilterWifiTracker = null;
|
mFilterWifiTracker = null;
|
||||||
@@ -207,7 +216,10 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MESSAGE_STOP_SCAN_WIFI_LIST:
|
case MESSAGE_STOP_SCAN_WIFI_LIST:
|
||||||
removeMessages(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;
|
break;
|
||||||
default:
|
default:
|
||||||
// Do nothing.
|
// 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.
|
// 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
|
@Override
|
||||||
@@ -284,7 +307,7 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAbort() {
|
public void onAbort() {
|
||||||
stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
|
stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -295,10 +318,13 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMatch(List<ScanResult> scanResults) {
|
public void onMatch(List<ScanResult> scanResults) {
|
||||||
mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
|
// Shouldn't need to renew cached list, since input result is empty.
|
||||||
renewAccessPointList(scanResults);
|
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
|
// Updates internal AccessPoint list from WifiTracker. scanResults are used to update key list
|
||||||
@@ -329,17 +355,24 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
|
public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
|
||||||
// Dismisses current dialog and finishes Activity, since connection is success.
|
// Removes the progress icon.
|
||||||
dismiss();
|
final Dialog dialog = getDialog();
|
||||||
final Activity activity = getActivity();
|
if (dialog != null) {
|
||||||
if (activity != null) {
|
final View view = dialog.findViewById(R.id.network_request_title_progress);
|
||||||
activity.finish();
|
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
|
@Override
|
||||||
public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
|
public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
|
||||||
stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
|
stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class FilterWifiTracker {
|
private final class FilterWifiTracker {
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ package com.android.settings.wifi.dpp;
|
|||||||
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -35,11 +38,42 @@ import com.android.settings.R;
|
|||||||
* to the Wi-Fi network.
|
* to the Wi-Fi network.
|
||||||
*/
|
*/
|
||||||
public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
||||||
|
private static final String TAG = "WifiDppAddDeviceFragment";
|
||||||
|
|
||||||
private ImageView mWifiApPictureView;
|
private ImageView mWifiApPictureView;
|
||||||
private TextView mChooseDifferentNetwork;
|
private TextView mChooseDifferentNetwork;
|
||||||
private Button mButtonLeft;
|
private Button mButtonLeft;
|
||||||
private Button mButtonRight;
|
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
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_CONFIGURATOR;
|
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_CONFIGURATOR;
|
||||||
@@ -86,6 +120,11 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startWifiDppInitiator() {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,11 +66,8 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
|
|||||||
/** The Wi-Fi network which will be configured */
|
/** The Wi-Fi network which will be configured */
|
||||||
private WifiNetworkConfig mWifiNetworkConfig;
|
private WifiNetworkConfig mWifiNetworkConfig;
|
||||||
|
|
||||||
/** The public key from Wi-Fi DPP QR code */
|
/** The uri from Wi-Fi DPP QR code */
|
||||||
private String mPublicKey;
|
private String mDppUri;
|
||||||
|
|
||||||
/** The information from Wi-Fi DPP QR code */
|
|
||||||
private String mInformation;
|
|
||||||
|
|
||||||
/** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_DPP_QR_CODE */
|
/** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_DPP_QR_CODE */
|
||||||
private WifiQrCode mWifiDppQrCode;
|
private WifiQrCode mWifiDppQrCode;
|
||||||
@@ -228,12 +225,8 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
|
|||||||
return mWifiNetworkConfig;
|
return mWifiNetworkConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPublicKey() {
|
public String getDppUri() {
|
||||||
return mPublicKey;
|
return mDppUri;
|
||||||
}
|
|
||||||
|
|
||||||
public String getInformation() {
|
|
||||||
return mInformation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WifiQrCode getWifiDppQrCode() {
|
public WifiQrCode getWifiDppQrCode() {
|
||||||
@@ -270,17 +263,15 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScanWifiDppSuccess(String publicKey, String information) {
|
public void onScanWifiDppSuccess(String uri) {
|
||||||
mPublicKey = publicKey;
|
mDppUri = uri;
|
||||||
mInformation = information;
|
|
||||||
|
|
||||||
showAddDeviceFragment(/* addToBackStack */ true);
|
showAddDeviceFragment(/* addToBackStack */ true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScanZxingWifiFormatSuccess(WifiNetworkConfig wifiNetworkConfig) {
|
public void onScanZxingWifiFormatSuccess(WifiNetworkConfig wifiNetworkConfig) {
|
||||||
mPublicKey = null;
|
mDppUri = null;
|
||||||
mInformation = null;
|
|
||||||
mWifiNetworkConfig = new WifiNetworkConfig(wifiNetworkConfig);
|
mWifiNetworkConfig = new WifiNetworkConfig(wifiNetworkConfig);
|
||||||
|
|
||||||
showAddDeviceFragment(/* addToBackStack */ true);
|
showAddDeviceFragment(/* addToBackStack */ true);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi.dpp;
|
package com.android.settings.wifi.dpp;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
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.core.InstrumentedActivity;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To provision "this" device with specified Wi-Fi network.
|
* To provision "this" device with specified Wi-Fi network.
|
||||||
*
|
*
|
||||||
@@ -49,6 +53,39 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
|
|||||||
|
|
||||||
private FragmentManager mFragmentManager;
|
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
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_ENROLLEE;
|
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_ENROLLEE;
|
||||||
@@ -108,8 +145,9 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScanWifiDppSuccess(String publicKey, String information) {
|
public void onScanWifiDppSuccess(String uri) {
|
||||||
// TODO(b/1023597): starts DPP enrollee handshake here
|
final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||||
|
wifiManager.startDppAsEnrolleeInitiator(uri, /* handler */ null, new DppStatusCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -62,9 +62,8 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
|||||||
private static final long SHOW_ERROR_MESSAGE_INTERVAL = 2000;
|
private static final long SHOW_ERROR_MESSAGE_INTERVAL = 2000;
|
||||||
private static final long SHOW_SUCCESS_SQUARE_INTERVAL = 1000;
|
private static final long SHOW_SUCCESS_SQUARE_INTERVAL = 1000;
|
||||||
|
|
||||||
// Keys for Bundle usage
|
// Key for Bundle usage
|
||||||
private static final String KEY_PUBLIC_KEY = "key_public_key";
|
private static final String KEY_PUBLIC_URI = "key_public_uri";
|
||||||
private static final String KEY_INFORMATION = "key_information";
|
|
||||||
|
|
||||||
private QrCamera mCamera;
|
private QrCamera mCamera;
|
||||||
private TextureView mTextureView;
|
private TextureView mTextureView;
|
||||||
@@ -91,7 +90,7 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
|||||||
|
|
||||||
// Container Activity must implement this interface
|
// Container Activity must implement this interface
|
||||||
public interface OnScanWifiDppSuccessListener {
|
public interface OnScanWifiDppSuccessListener {
|
||||||
public void onScanWifiDppSuccess(String publicKey, String information);
|
public void onScanWifiDppSuccess(String uri);
|
||||||
}
|
}
|
||||||
OnScanWifiDppSuccessListener mScanWifiDppSuccessListener;
|
OnScanWifiDppSuccessListener mScanWifiDppSuccessListener;
|
||||||
|
|
||||||
@@ -269,7 +268,7 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
|||||||
public void handleSuccessfulResult(String qrCode) {
|
public void handleSuccessfulResult(String qrCode) {
|
||||||
switch (mWifiQrCode.getScheme()) {
|
switch (mWifiQrCode.getScheme()) {
|
||||||
case WifiQrCode.SCHEME_DPP:
|
case WifiQrCode.SCHEME_DPP:
|
||||||
handleWifiDpp(mWifiQrCode.getPublicKey(), mWifiQrCode.getInformation());
|
handleWifiDpp(qrCode);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG:
|
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();
|
destroyCamera();
|
||||||
mDecorateView.setFocused(true);
|
mDecorateView.setFocused(true);
|
||||||
|
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putString(KEY_PUBLIC_KEY, publicKey);
|
bundle.putString(KEY_PUBLIC_URI, uri);
|
||||||
bundle.putString(KEY_INFORMATION, information);
|
|
||||||
|
|
||||||
Message message = mHandler.obtainMessage(MESSAGE_SCAN_WIFI_DPP_SUCCESS);
|
Message message = mHandler.obtainMessage(MESSAGE_SCAN_WIFI_DPP_SUCCESS);
|
||||||
message.setData(bundle);
|
message.setData(bundle);
|
||||||
@@ -352,10 +350,9 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Bundle bundle = msg.getData();
|
final Bundle bundle = msg.getData();
|
||||||
final String publicKey = bundle.getString(KEY_PUBLIC_KEY);
|
final String uri = bundle.getString(KEY_PUBLIC_URI);
|
||||||
final String information = bundle.getString(KEY_INFORMATION);
|
|
||||||
|
|
||||||
mScanWifiDppSuccessListener.onScanWifiDppSuccess(publicKey, information);
|
mScanWifiDppSuccessListener.onScanWifiDppSuccess(uri);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:
|
case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ public class WifiDppUtils {
|
|||||||
/** The data corresponding to {@code WifiConfiguration} hiddenSSID */
|
/** The data corresponding to {@code WifiConfiguration} hiddenSSID */
|
||||||
public static final String EXTRA_WIFI_HIDDEN_SSID = "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 */
|
/** @see WifiQrCode */
|
||||||
public static final String EXTRA_QR_CODE = "qrCode";
|
public static final String EXTRA_QR_CODE = "qrCode";
|
||||||
|
|
||||||
@@ -164,6 +167,11 @@ public class WifiDppUtils {
|
|||||||
if (!TextUtils.isEmpty(preSharedKey)) {
|
if (!TextUtils.isEmpty(preSharedKey)) {
|
||||||
intent.putExtra(EXTRA_WIFI_PRE_SHARED_KEY, 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;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,13 +46,15 @@ public class WifiNetworkConfig {
|
|||||||
private String mSsid;
|
private String mSsid;
|
||||||
private String mPreSharedKey;
|
private String mPreSharedKey;
|
||||||
private boolean mHiddenSsid;
|
private boolean mHiddenSsid;
|
||||||
|
private int mNetworkId;
|
||||||
|
|
||||||
private WifiNetworkConfig(String security, String ssid, String preSharedKey,
|
private WifiNetworkConfig(String security, String ssid, String preSharedKey, boolean hiddenSsid,
|
||||||
boolean hiddenSsid) {
|
int networkId) {
|
||||||
mSecurity = security;
|
mSecurity = security;
|
||||||
mSsid = ssid;
|
mSsid = ssid;
|
||||||
mPreSharedKey = preSharedKey;
|
mPreSharedKey = preSharedKey;
|
||||||
mHiddenSsid = hiddenSsid;
|
mHiddenSsid = hiddenSsid;
|
||||||
|
mNetworkId = networkId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WifiNetworkConfig(WifiNetworkConfig config) {
|
public WifiNetworkConfig(WifiNetworkConfig config) {
|
||||||
@@ -60,6 +62,7 @@ public class WifiNetworkConfig {
|
|||||||
mSsid = config.mSsid;
|
mSsid = config.mSsid;
|
||||||
mPreSharedKey = config.mPreSharedKey;
|
mPreSharedKey = config.mPreSharedKey;
|
||||||
mHiddenSsid = config.mHiddenSsid;
|
mHiddenSsid = config.mHiddenSsid;
|
||||||
|
mNetworkId = config.mNetworkId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,17 +85,19 @@ public class WifiNetworkConfig {
|
|||||||
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
|
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
|
||||||
String preSharedKey = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY);
|
String preSharedKey = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY);
|
||||||
boolean hiddenSsid = intent.getBooleanExtra(WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID, false);
|
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,
|
public static WifiNetworkConfig getValidConfigOrNull(String security, String ssid,
|
||||||
String preSharedKey, boolean hiddenSsid) {
|
String preSharedKey, boolean hiddenSsid, int networkId) {
|
||||||
if (!isValidConfig(security, ssid, preSharedKey, hiddenSsid)) {
|
if (!isValidConfig(security, ssid, preSharedKey, hiddenSsid)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid);
|
return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid, networkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidConfig(WifiNetworkConfig config) {
|
public static boolean isValidConfig(WifiNetworkConfig config) {
|
||||||
@@ -184,6 +189,11 @@ public class WifiNetworkConfig {
|
|||||||
return mHiddenSsid;
|
return mHiddenSsid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
|
public int getNetworkId() {
|
||||||
|
return mNetworkId;
|
||||||
|
}
|
||||||
|
|
||||||
public void connect(Context context, WifiManager.ActionListener listener) {
|
public void connect(Context context, WifiManager.ActionListener listener) {
|
||||||
WifiConfiguration wifiConfiguration = getWifiConfigurationOrNull();
|
WifiConfiguration wifiConfiguration = getWifiConfigurationOrNull();
|
||||||
if (wifiConfiguration == null) {
|
if (wifiConfiguration == null) {
|
||||||
@@ -208,6 +218,7 @@ public class WifiNetworkConfig {
|
|||||||
final WifiConfiguration wifiConfiguration = new WifiConfiguration();
|
final WifiConfiguration wifiConfiguration = new WifiConfiguration();
|
||||||
wifiConfiguration.SSID = addQuotationIfNeeded(mSsid);
|
wifiConfiguration.SSID = addQuotationIfNeeded(mSsid);
|
||||||
wifiConfiguration.hiddenSSID = mHiddenSsid;
|
wifiConfiguration.hiddenSSID = mHiddenSsid;
|
||||||
|
wifiConfiguration.networkId = mNetworkId;
|
||||||
|
|
||||||
if (TextUtils.isEmpty(mSecurity) || SECURITY_NO_PASSWORD.equals(mSecurity)) {
|
if (TextUtils.isEmpty(mSecurity) || SECURITY_NO_PASSWORD.equals(mSecurity)) {
|
||||||
wifiConfiguration.allowedKeyManagement.set(KeyMgmt.NONE);
|
wifiConfiguration.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.wifi.dpp;
|
package com.android.settings.wifi.dpp;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.annotation.Keep;
|
import androidx.annotation.Keep;
|
||||||
@@ -135,7 +136,7 @@ public class WifiQrCode {
|
|||||||
password = removeBackSlash(password);
|
password = removeBackSlash(password);
|
||||||
|
|
||||||
mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid, password,
|
mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid, password,
|
||||||
hiddenSsid);
|
hiddenSsid, WifiConfiguration.INVALID_NETWORK_ID);
|
||||||
|
|
||||||
if (mWifiNetworkConfig == null) {
|
if (mWifiNetworkConfig == null) {
|
||||||
throw new IllegalArgumentException("Invalid format");
|
throw new IllegalArgumentException("Invalid format");
|
||||||
|
|||||||
@@ -88,4 +88,7 @@
|
|||||||
|
|
||||||
<!-- Email address for the homepage contextual cards feedback -->
|
<!-- Email address for the homepage contextual cards feedback -->
|
||||||
<string name="config_contextual_card_feedback_email" translatable="false">test@test.test</string>
|
<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>
|
</resources>
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ package com.android.settings.display;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.robolectric.RuntimeEnvironment.application;
|
import static org.robolectric.RuntimeEnvironment.application;
|
||||||
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
|
||||||
@@ -69,4 +69,23 @@ public class TimeoutListPreferenceTest {
|
|||||||
// should set to largest allowed value, which is 5 minute
|
// should set to largest allowed value, which is 5 minute
|
||||||
assertThat(mPreference.getValue()).isEqualTo("300000");
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,14 +111,17 @@ public class NetworkRequestDialogFragmentTest {
|
|||||||
ShadowLooper.getShadowMainLooper().runToEndOfTasks();
|
ShadowLooper.getShadowMainLooper().runToEndOfTasks();
|
||||||
|
|
||||||
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
|
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
|
||||||
|
assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.TIME_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeNetworkRequestDialogFragment extends NetworkRequestDialogFragment {
|
class FakeNetworkRequestDialogFragment extends NetworkRequestDialogFragment {
|
||||||
boolean bCalledStopAndPop = false;
|
boolean bCalledStopAndPop = false;
|
||||||
|
ERROR_DIALOG_TYPE errorType = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
|
public void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
|
||||||
bCalledStopAndPop = true;
|
bCalledStopAndPop = true;
|
||||||
|
errorType = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,22 +153,28 @@ public class NetworkRequestDialogFragmentTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateAccessPointList_onUserSelectionConnectSuccess_shouldCloseTheDialog() {
|
public void updateAccessPointList_onUserSelectionConnectSuccess_shouldCloseTheDialog() {
|
||||||
List<AccessPoint> accessPointList = createAccessPointList();
|
// Assert
|
||||||
when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
|
FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
|
||||||
networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
|
FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
|
||||||
AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
|
||||||
assertThat(alertDialog.isShowing()).isTrue();
|
|
||||||
|
|
||||||
// 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();
|
WifiConfiguration config = new WifiConfiguration();
|
||||||
config.SSID = "Test AP 3";
|
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
|
@Test
|
||||||
public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallTimeoutDialog() {
|
public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallAbortDialog() {
|
||||||
FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
|
FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
|
||||||
FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
|
FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
|
||||||
List<AccessPoint> accessPointList = createAccessPointList();
|
List<AccessPoint> accessPointList = createAccessPointList();
|
||||||
@@ -181,6 +190,7 @@ public class NetworkRequestDialogFragmentTest {
|
|||||||
fakeFragment.onUserSelectionConnectFailure(config);
|
fakeFragment.onUserSelectionConnectFailure(config);
|
||||||
|
|
||||||
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
|
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
|
||||||
|
assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user