Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f529245 authored by Salvador Martinez's avatar Salvador Martinez
Browse files

Update auto wi-fi to prompt user for permissions

This CL makes it so that auto wi-fi will correctly prompt users
to enable the correct permissions before allowing them to turn
on the setting. Additionally it provides users with important
information regarding each setting.

Bug: 67070896
Test: Robotests
Change-Id: Ieddfa421be6e45ce69f3d6048ae051a7e3ce4c76
parent 861bf935
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2018 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?android:attr/textColorSecondary">
    <path
        android:fillColor="#FF000000"
        android:pathData="M12,17L12,17c0.55,0 1,-0.45 1,-1v-4c0,-0.55 -0.45,-1 -1,-1l0,0c-0.55,0 -1,0.45 -1,1v4C11,16.55 11.45,17 12,17z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M12,2c-5.52,0 -10,4.48 -10,10s4.48,10 10,10s10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8s8,3.59 8,8S16.41,20 12,20z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M12,9.1L12,9.1c0.61,0 1.1,-0.49 1.1,-1.1l0,0c0,-0.61 -0.49,-1.1 -1.1,-1.1l0,0c-0.61,0 -1.1,0.49 -1.1,1.1l0,0C10.9,8.61 11.39,9.1 12,9.1z"/>
</vector>
+57 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2018 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.
-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="24dp"
        android:layout_marginRight="24dp"
        android:layout_marginTop="8dp"
        android:text="@string/wifi_settings_scanning_required_summary"
        style="@style/TextAppearance.AppCompat.Subhead"/>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="top">

        <ImageView
            android:src="@drawable/ic_info_outline_24dp"
            android:maxHeight="24dp"
            android:maxWidth="24dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="2dp"
            android:layout_marginTop="4dp"
            android:layout_marginLeft="24dp"
            android:adjustViewBounds="true"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="8dp"
            android:padding="8dp"
            android:text="@string/wifi_settings_scanning_required_info"
            android:textAppearance="?android:attr/textAppearanceSmall"/>
    </LinearLayout>
</LinearLayout>
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -1916,9 +1916,11 @@
    <!-- Wi-Fi settings dialog. Summary text describing why we need Wi-Fi scanning on. [CHAR LIMIT=NONE]-->
    <string name="wifi_settings_scanning_required_summary">To turn on Wi\u2011Fi automatically, you first need to turn on Wi\u2011Fi scanning.</string>
    <!-- Wi-Fi settings dialog. Informational text describing what Wi-Fi scanning does. [CHAR LIMIT=NONE]-->
    <string name="wifi_settings_scanning_required_info">Wi\2011Fi scanning allows apps and services to scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. This can be used, for example, to improve location\u2011based features and services.</string>
    <string name="wifi_settings_scanning_required_info">Wi\u2011Fi scanning allows apps and services to scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. This can be used, for example, to improve location\u2011based features and services.</string>
    <!-- Wi-Fi settings dialog. Text for the button that takes users to a help article about Wi-Fi scanning. [CHAR LIMIT = 20]-->
    <string name="wifi_settings_scanning_required_turn_on">Turn on</string>
    <!-- Wi-Fi settings dialog. Text to show in toast for when user turns on wifi scanning. [CHAR LIMIT=NONE] -->
    <string name="wifi_settings_scanning_required_enabled">Wi\u2011Fi scanning turned on</string>
    <!-- Dialog for Access Points --> <skip />
    <!-- Label to show/hide advanced options [CHAR LIMIT=40] -->
+11 −4
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public class ConfigureWifiSettings extends DashboardFragment {
    private static final String TAG = "ConfigureWifiSettings";

    public static final String KEY_IP_ADDRESS = "current_ip_address";
    public static final int WIFI_WAKEUP_REQUEST_CODE = 600;

    private WifiWakeupPreferenceController mWifiWakeupPreferenceController;
    private UseOpenWifiPreferenceController mUseOpenWifiPreferenceController;
@@ -71,7 +72,7 @@ public class ConfigureWifiSettings extends DashboardFragment {

    @Override
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        mWifiWakeupPreferenceController = new WifiWakeupPreferenceController(context);
        mWifiWakeupPreferenceController = new WifiWakeupPreferenceController(context, this);
        mUseOpenWifiPreferenceController = new UseOpenWifiPreferenceController(context, this,
                getLifecycle());
        final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
@@ -87,10 +88,16 @@ public class ConfigureWifiSettings extends DashboardFragment {

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (mUseOpenWifiPreferenceController == null ||
                !mUseOpenWifiPreferenceController.onActivityResult(requestCode, resultCode)) {
            super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == WIFI_WAKEUP_REQUEST_CODE && mWifiWakeupPreferenceController != null) {
            mWifiWakeupPreferenceController.onActivityResult(requestCode, resultCode);
            return;
        }
        if (resultCode == UseOpenWifiPreferenceController.REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY
                && mUseOpenWifiPreferenceController == null) {
            mUseOpenWifiPreferenceController.onActivityResult(requestCode, resultCode);
            return;
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+2 −2
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@ import java.util.List;
public class UseOpenWifiPreferenceController extends AbstractPreferenceController
        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
        LifecycleObserver, OnResume, OnPause {
    public static final int REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY = 400;

    private static final String KEY_USE_OPEN_WIFI_AUTOMATICALLY = "use_open_wifi_automatically";
    @VisibleForTesting
    static final int REQUEST_CODE_OPEN_WIFI_AUTOMATICALLY = 400;

    private final ContentResolver mContentResolver;
    private final Fragment mFragment;
Loading