OSDN Git Service

Implement receiver flow of WiFi sharing feature II
authorArc Wang <arcwang@google.com>
Thu, 13 Dec 2018 09:02:19 +0000 (17:02 +0800)
committerArc Wang <arcwang@google.com>
Fri, 14 Dec 2018 06:50:26 +0000 (06:50 +0000)
Bug: 120630683
Test: atest RunSettingsRoboTests
Change-Id: Iabe56205ff9274382adbe5bba59a60d833a57214

res/values/strings.xml
src/com/android/settings/wifi/AddNetworkFragment.java
src/com/android/settings/wifi/WifiDialog.java
src/com/android/settings/wifi/WifiSettings.java
src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
src/com/android/settings/wifi/dpp/WifiDppUtils.java

index 188ba6e..3a538c6 100644 (file)
     <string name="wifi_dpp_scan_qr_code">Scan QR code</string>
     <!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
     <string name="wifi_dpp_scan_qr_code_join_network">Join \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d by scanning a QR code</string>
+    <!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
+    <string name="wifi_dpp_scan_qr_code_join_unknown_network">Join Wi\u2011Fi by scanning a QR code</string>
     <!-- Title for the fragment to share Wi-Fi [CHAR LIMIT=50]  -->
     <string name="wifi_dpp_share_wifi">Share Wi\u2011Fi</string>
     <!-- Hint for the user to use another device to scan QR code on screen to join Wi-Fi [CHAR LIMIT=NONE] -->
index 72d878b..cd8f76e 100644 (file)
@@ -73,7 +73,7 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf
                 scannerButton.setOnClickListener((View v) -> {
                     // Launch QR code scanner to join a network.
                     getContext().startActivity(
-                            WifiDppUtils.getConfiguratorQRCodeScannerIntent(/* ssid */ null));
+                            WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
                 });
             }
         }
index 0e2ca60..0bee671 100644 (file)
@@ -86,9 +86,13 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
             if (scannerButton != null) {
                 scannerButton.setVisibility(View.VISIBLE);
                 scannerButton.setOnClickListener((View v) -> {
+                    String ssid = null;
+                    if (mAccessPoint != null) {
+                        ssid = mAccessPoint.getSsidStr();
+                    }
                     // Launch QR code scanner to join a network.
                     getContext().startActivity(
-                            WifiDppUtils.getConfiguratorQRCodeScannerIntent(/* ssid */ null));
+                            WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid));
                 });
             }
         }
index 54de28d..95e912d 100644 (file)
@@ -244,7 +244,7 @@ public class WifiSettings extends RestrictedSettingsFragment
             mAddPreference.setButtonOnClickListener((View v) -> {
                 // Launch QR code scanner to join a network.
                 getContext().startActivity(
-                        WifiDppUtils.getConfiguratorQRCodeScannerIntent(/* ssid */ null));
+                        WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
             });
         }
         mStatusMessagePreference = (LinkablePreference) findPreference(PREF_KEY_STATUS_MESSAGE);
index e1179f8..f3e8fc1 100644 (file)
@@ -549,11 +549,8 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
      * Show QR code to share the network represented by this preference.
      */
     public void launchQRCodeGenerator() {
-        final Intent intent = new Intent(
-                WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
-        intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY,
+        Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntent(mAccessPoint.getSsidStr(),
                 mAccessPoint.getSecurityString(/* concise */ false));
-        intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, mAccessPoint.getSsidStr());
         mContext.startActivity(intent);
     }
 
index 7c58fd5..39d993f 100644 (file)
@@ -35,7 +35,7 @@ import com.android.settings.R;
  * To provision "this" device with specified Wi-Fi network.
  *
  * To use intent action {@code ACTION_ENROLLEE_QR_CODE_SCANNER}, specify the SSID string of the
- * Wi-Fi network to be provisioned in {@code WifiDppUtils.EXTRA_QR_CODE}.
+ * Wi-Fi network to be provisioned in {@code WifiDppUtils.EXTRA_WIFI_SSID}.
  */
 public class WifiDppEnrolleeActivity extends InstrumentedActivity {
     private static final String TAG = "WifiDppEnrolleeActivity";
index cddd55c..e6427d9 100644 (file)
@@ -34,7 +34,7 @@ import com.android.settings.wifi.qrcode.QrDecorateView;
 import com.android.settings.R;
 
 /**
- * TODO: Should refine code to only initiate UI component in each child fragment.
+ * TODO: b/120645817 should refine code to only initiate UI component in each child fragment.
  */
 
 /**
index 5689c56..342e693 100644 (file)
@@ -23,6 +23,7 @@ import android.content.Context;
 import android.content.Intent;
 import android.graphics.Rect;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.util.Size;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -87,7 +88,14 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
             setDescription(getString(R.string.wifi_dpp_center_qr_code, wifiNetworkConfig.getSsid()));
         } else {
             setTitle(getString(R.string.wifi_dpp_scan_qr_code));
-            setDescription(getString(R.string.wifi_dpp_scan_qr_code_join_network, mSsid));
+
+            String description;
+            if (TextUtils.isEmpty(mSsid)) {
+                description = getString(R.string.wifi_dpp_scan_qr_code_join_unknown_network, mSsid);
+            } else {
+                description = getString(R.string.wifi_dpp_scan_qr_code_join_network, mSsid);
+            }
+            setDescription(description);
         }
 
         ActionBar actionBar = getActivity().getActionBar();
index dc0ff84..3275695 100644 (file)
@@ -88,14 +88,14 @@ public class WifiDppUtils {
     }
 
     /**
-     * Returns an intent to launch QR code scanner.
+     * Returns an intent to launch QR code scanner for Wi-Fi DPP enrollee.
      *
      * @param ssid The data corresponding to {@code WifiConfiguration} SSID
      * @return Intent for launching QR code scanner
      */
-    public static Intent getConfiguratorQRCodeScannerIntent(String ssid) {
+    public static Intent getEnrolleeQrCodeScannerIntent(String ssid) {
         final Intent intent = new Intent(
-                WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
+                WifiDppEnrolleeActivity.ACTION_ENROLLEE_QR_CODE_SCANNER);
         if (!TextUtils.isEmpty(ssid)) {
             intent.putExtra(EXTRA_WIFI_SSID, ssid);
         }
@@ -109,7 +109,8 @@ public class WifiDppUtils {
      * @param Security The data is from {@code AccessPoint.securityToString}
      * @return Intent for launching QR code generator
      */
-    public static Intent getConfiguratorQRCodeGeneratorIntent(String ssid, String Security) {
+    public static Intent getConfiguratorQrCodeGeneratorIntent(String ssid, String Security) {
+        //TODO: b/118794858#comment6 should put password & hideSsid in intent extra
         final Intent intent = new Intent(
                 WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
         if (!TextUtils.isEmpty(ssid)) {