</intent-filter>
</activity>
+ <activity
+ android:name=".wifi.dpp.WifiDppEnrolleeActivity">
+ <intent-filter>
+ <action android:name="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ </activity>
+
<activity android:name=".homepage.contextualcards.ContextualCardFeedbackDialog"
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
<!-- This is the longest AndroidManifest.xml ever. -->
android:layout_height="wrap_content"
android:layout_gravity="center"/>
- <include layout="@layout/wifi_dpp_fragment_footer"
- android:gravity="center|bottom"/>
-
</LinearLayout>
<string name="wifi_dpp_add_device_to_network">Add a device to this network</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=120] -->
<string name="wifi_dpp_center_qr_code">Center the device\u2019s QR code below to add device to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
+ <!-- Title for the fragment to scan QR code [CHAR LIMIT=50] -->
+ <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>
+ <!-- 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] -->
+ <string name="wifi_dpp_scan_qr_code_with_another_device">Scan this QR code with another device to join \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
<!-- Label for the check box to share a network with other users on the same device -->
<string name="wifi_shared">Share with other device users</string>
<!-- Hint for unchanged fields -->
import com.android.settings.core.InstrumentedActivity;
import com.android.settings.R;
+/**
+ * To provision "other" device with specified Wi-Fi network.
+ *
+ * Uses different intents to specify different provisioning ways.
+ *
+ * For intent action {@code ACTION_CONFIGURATOR_QR_CODE_SCANNER} and
+ * {@code android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR}, specify the Wi-Fi network to be
+ * provisioned in:
+ *
+ * {@code WifiDppUtils.EXTRA_WIFI_SECURITY}
+ * {@code WifiDppUtils.EXTRA_WIFI_SSID}
+ * {@code WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY}
+ * {@code WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID}
+ *
+ * For intent action {@code ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK}, specify Wi-Fi (DPP)
+ * QR code in {@code WifiDppUtils.EXTRA_QR_CODE}
+ */
public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
- WifiNetworkConfig.Retriever {
+ WifiNetworkConfig.Retriever,
+ WifiDppQrCodeGeneratorFragment.OnQrCodeGeneratorFragmentAddButtonClickedListener {
private static final String TAG = "WifiDppConfiguratorActivity";
public static final String ACTION_CONFIGURATOR_QR_CODE_SCANNER =
"android.settings.WIFI_DPP_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK";
private FragmentManager mFragmentManager;
- private FragmentTransaction mFragmentTransaction;
/** The Wi-Fi network which will be configured */
private WifiNetworkConfig mWifiNetworkConfig;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.wifi_dpp_activity);
+ setContentView(R.layout.wifi_dpp_activity);
mFragmentManager = getSupportFragmentManager();
- mFragmentTransaction = getSupportFragmentManager().beginTransaction();
- Intent intent = getIntent();
+ handleIntent(getIntent());
+
+ ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setElevation(0);
+ actionBar.setDisplayShowTitleEnabled(false);
+ }
+ }
+
+ private void handleIntent(Intent intent) {
boolean cancelActivity = false;
WifiNetworkConfig config;
switch (intent.getAction()) {
cancelActivity = true;
} else {
mWifiNetworkConfig = config;
- addQrCodeScannerFragment(/* addToBackStack= */ false);
+ showQrCodeScannerFragment(/* addToBackStack= */ false);
}
break;
case ACTION_CONFIGURATOR_QR_CODE_GENERATOR:
cancelActivity = true;
} else {
mWifiNetworkConfig = config;
- addQrCodeGeneratorFragment();
+ showQrCodeGeneratorFragment();
}
break;
case ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK:
- addChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
+ showChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
break;
default:
cancelActivity = true;
}
}
- private void addQrCodeScannerFragment(boolean addToBackStack) {
+ private void showQrCodeScannerFragment(boolean addToBackStack) {
+ // Avoid to replace the same fragment during configuration change
+ if (mFragmentManager.findFragmentByTag(WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER) != null) {
+ return;
+ }
+
WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment();
- mFragmentTransaction.add(R.id.fragment_container, fragment);
+ FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
+
+ fragmentTransaction.replace(R.id.fragment_container, fragment,
+ WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
if (addToBackStack) {
- mFragmentTransaction.addToBackStack(/* name */ null);
+ fragmentTransaction.addToBackStack(/* name */ null);
}
- mFragmentTransaction.commit();
+ fragmentTransaction.commit();
}
- private void addQrCodeGeneratorFragment() {
+ private void showQrCodeGeneratorFragment() {
+ // Avoid to replace the same fragment during configuration change
+ if (mFragmentManager.findFragmentByTag(
+ WifiDppUtils.TAG_FRAGMENT_QR_CODE_GENERATOR) != null) {
+ return;
+ }
+
WifiDppQrCodeGeneratorFragment fragment = new WifiDppQrCodeGeneratorFragment();
- mFragmentTransaction.add(R.id.fragment_container, fragment);
- mFragmentTransaction.commit();
+ FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
+
+ fragmentTransaction.replace(R.id.fragment_container, fragment,
+ WifiDppUtils.TAG_FRAGMENT_QR_CODE_GENERATOR);
+ fragmentTransaction.commit();
}
- private void addChooseSavedWifiNetworkFragment(boolean addToBackStack) {
- ActionBar action = getActionBar();
- if (action != null) {
- action.hide();
+ private void showChooseSavedWifiNetworkFragment(boolean addToBackStack) {
+ // Avoid to replace the same fragment during configuration change
+ if (mFragmentManager.findFragmentByTag(
+ WifiDppUtils.TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK) != null) {
+ return;
}
WifiDppChooseSavedWifiNetworkFragment fragment =
new WifiDppChooseSavedWifiNetworkFragment();
- mFragmentTransaction.add(R.id.fragment_container, fragment);
- if (addToBackStack) {
- mFragmentTransaction.addToBackStack(/* name */ null);
- }
- mFragmentTransaction.commit();
- }
+ FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
- @Override
- protected void onStop() {
- Fragment fragment = mFragmentManager.findFragmentById(R.id.fragment_container);
- if (fragment != null) {
- // Remove it to prevent stacking multiple fragments after screen rotated.
- mFragmentManager.beginTransaction().remove(fragment).commit();
+ fragmentTransaction.replace(R.id.fragment_container, fragment,
+ WifiDppUtils.TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK);
+ if (addToBackStack) {
+ fragmentTransaction.addToBackStack(/* name */ null);
}
-
- super.onStop();
+ fragmentTransaction.commit();
}
@Override
return true;
}
}
+
+ @Override
+ public boolean onNavigateUp(){
+ Fragment fragment = mFragmentManager.findFragmentById(R.id.fragment_container);
+ if (fragment instanceof WifiDppQrCodeGeneratorFragment) {
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ return true;
+ } else if (fragment instanceof WifiDppQrCodeScannerFragment) {
+ mFragmentManager.popBackStackImmediate();
+ }
+
+ return false;
+ }
+
+ @Override public void onQrCodeGeneratorFragmentAddButtonClicked() {
+ showQrCodeScannerFragment(/* addToBackStack */ true);
+ }
}
--- /dev/null
+/*
+ * 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.
+ */
+
+package com.android.settings.wifi.dpp;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+
+import com.android.internal.logging.nano.MetricsProto;
+
+import com.android.settings.core.InstrumentedActivity;
+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}.
+ */
+public class WifiDppEnrolleeActivity extends InstrumentedActivity {
+ private static final String TAG = "WifiDppEnrolleeActivity";
+
+ public static final String ACTION_ENROLLEE_QR_CODE_SCANNER =
+ "android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER";
+
+ private FragmentManager mFragmentManager;
+
+ @Override
+ public int getMetricsCategory() {
+ //TODO:Should we use a new metrics category for Wi-Fi DPP?
+ return MetricsProto.MetricsEvent.WIFI_NETWORK_DETAILS;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.wifi_dpp_activity);
+ mFragmentManager = getSupportFragmentManager();
+
+ handleIntent(getIntent());
+
+ ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setElevation(0);
+ actionBar.setDisplayShowTitleEnabled(false);
+ }
+ }
+
+ private void handleIntent(Intent intent) {
+ switch (intent.getAction()) {
+ case ACTION_ENROLLEE_QR_CODE_SCANNER:
+ String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
+ showQrCodeScannerFragment(/* addToBackStack */ false, ssid);
+ break;
+ default:
+ Log.e(TAG, "Launch with an invalid action");
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ }
+ }
+
+ private void showQrCodeScannerFragment(boolean addToBackStack, String ssid) {
+ // Avoid to replace the same fragment during configuration change
+ if (mFragmentManager.findFragmentByTag(WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER) != null) {
+ return;
+ }
+
+ WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment(ssid);
+ FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
+
+ fragmentTransaction.replace(R.id.fragment_container, fragment,
+ WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
+ if (addToBackStack) {
+ fragmentTransaction.addToBackStack(/* name */ null);
+ }
+ fragmentTransaction.commit();
+ }
+
+ @Override
+ public boolean onNavigateUp(){
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ return true;
+ }
+}
import com.android.settings.R;
/**
+ * TODO: Should refine code to only initiate UI component in each child fragment.
+ */
+
+/**
* There are below 4 fragments for Wi-Fi DPP UI flow, to reduce redundant code of UI components,
* this parent fragment instantiates all UI components and provides setting APIs for them.
*
private ImageView mWifiApPictureView; //optional, for WifiDppAddDeviceFragment
private TextView mChooseDifferentNetwork;//optional, for WifiDppAddDeviceFragment
- private Button mButtonLeft; //optional, for WifiDppQrCodeScannerFragment,
- // WifiDppChooseSavedWifiNetworkFragment,
+ private Button mButtonLeft; //optional, for WifiDppChooseSavedWifiNetworkFragment,
// WifiDppAddDeviceFragment
- private Button mButtonRight; //optional, for WifiDppQrCodeScannerFragment,
- // WifiDppChooseSavedWifiNetworkFragment,
+ private Button mButtonRight; //optional, for WifiDppChooseSavedWifiNetworkFragment,
// WifiDppAddDeviceFragment
abstract protected int getLayout();
}
/**
- * optional, for WifiDppQrCodeScannerFragment,
- * WifiDppChooseSavedWifiNetworkFragment,
+ * optional, for WifiDppChooseSavedWifiNetworkFragment,
* WifiDppAddDeviceFragment
*/
protected void setLeftButtonText(String text) {
}
/**
- * optional, for WifiDppQrCodeScannerFragment,
- * WifiDppChooseSavedWifiNetworkFragment,
+ * optional, for WifiDppChooseSavedWifiNetworkFragment,
* WifiDppAddDeviceFragment
*/
protected void setRightButtonText(String text) {
}
/**
- * optional, for WifiDppQrCodeScannerFragment,
- * WifiDppChooseSavedWifiNetworkFragment,
+ * optional, for WifiDppChooseSavedWifiNetworkFragment,
* WifiDppAddDeviceFragment
*/
protected void hideLeftButton() {
}
/**
- * optional, for WifiDppQrCodeScannerFragment,
- * WifiDppChooseSavedWifiNetworkFragment,
+ * optional, for WifiDppChooseSavedWifiNetworkFragment,
* WifiDppAddDeviceFragment
*/
protected void hideRightButton() {
}
/**
- * optional, for WifiDppQrCodeScannerFragment,
- * WifiDppChooseSavedWifiNetworkFragment,
+ * optional, for WifiDppChooseSavedWifiNetworkFragment,
* WifiDppAddDeviceFragment
*/
protected void setLeftButtonOnClickListener(View.OnClickListener listener) {
}
/**
- * optional, for WifiDppQrCodeScannerFragment,
- * WifiDppChooseSavedWifiNetworkFragment,
+ * optional, for WifiDppChooseSavedWifiNetworkFragment,
* WifiDppAddDeviceFragment
*/
protected void setRightButtonOnClickListener(View.OnClickListener listener) {
package com.android.settings.wifi.dpp;
+import android.app.ActionBar;
+import android.content.Context;
import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import com.android.settings.R;
return R.layout.wifi_dpp_qrcode_generator_fragment;
}
+ // Container Activity must implement this interface
+ public interface OnQrCodeGeneratorFragmentAddButtonClickedListener {
+ public void onQrCodeGeneratorFragmentAddButtonClicked();
+ }
+ OnQrCodeGeneratorFragmentAddButtonClickedListener mListener;
+
@Override
- public void onActivityCreated (Bundle savedInstanceState) {
+ public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
+
+ WifiNetworkConfig wifiNetworkConfig = ((WifiNetworkConfig.Retriever) getActivity())
+ .getWifiNetworkConfig();
+ if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
+ throw new IllegalArgumentException("Invalid Wi-Fi network for configuring");
+ }
+ setTitle(getString(R.string.wifi_dpp_share_wifi));
+ setDescription(getString(R.string.wifi_dpp_scan_qr_code_with_another_device,
+ wifiNetworkConfig.getSsid()));
+
+ setHasOptionsMenu(true);
+ ActionBar actionBar = getActivity().getActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.show();
+ }
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ mListener = (OnQrCodeGeneratorFragmentAddButtonClickedListener) context;
+ }
+
+ @Override
+ public void onDetach() {
+ mListener = null;
+
+ super.onDetach();
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ MenuItem item = menu.add(0, Menu.FIRST, 0, R.string.next_label);
+ item.setIcon(R.drawable.ic_menu_add);
+ item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem menuItem) {
+ switch (menuItem.getItemId()) {
+ case Menu.FIRST:
+ mListener.onQrCodeGeneratorFragmentAddButtonClicked();
+ return true;
+ default:
+ return super.onOptionsItemSelected(menuItem);
+ }
}
}
package com.android.settings.wifi.dpp;
import android.annotation.Nullable;
+import android.app.ActionBar;
import android.app.Activity;
+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;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
private SurfaceView mSurfaceView;
private QrDecorateView mDecorateView;
+ /** true if the fragment working for configurator, false enrollee*/
+ private final boolean mConfiguratorMode;
+
+ /** The SSID of the Wi-Fi network which the user specify to enroll */
+ private String mSsid;
+
@Override
protected int getLayout() {
return R.layout.wifi_dpp_qrcode_scanner_fragment;
}
+ /**
+ * Configurator container activity of the fragment should create instance with this constructor.
+ */
+ public WifiDppQrCodeScannerFragment() {
+ super();
+
+ mConfiguratorMode = true;
+ }
+
+ /**
+ * Enrollee container activity of the fragment should create instance with this constructor and
+ * specify the SSID string of the WI-Fi network to be provisioned.
+ */
+ public WifiDppQrCodeScannerFragment(String ssid) {
+ super();
+
+ mConfiguratorMode = false;
+ mSsid = ssid;
+ }
+
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- setTitle(getString(R.string.wifi_dpp_add_device_to_network));
+ if (mConfiguratorMode) {
+ setTitle(getString(R.string.wifi_dpp_add_device_to_network));
- WifiNetworkConfig wifiNetworkConfig = ((WifiNetworkConfig.Retriever) getActivity())
+ WifiNetworkConfig wifiNetworkConfig = ((WifiNetworkConfig.Retriever) getActivity())
.getWifiNetworkConfig();
- if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
- throw new IllegalArgumentException("Invalid Wi-Fi network for configuring");
+ if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
+ throw new IllegalArgumentException("Invalid Wi-Fi network for configuring");
+ }
+ 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));
}
- setDescription(getString(R.string.wifi_dpp_center_qr_code, wifiNetworkConfig.getSsid()));
-
- hideRightButton();
-
- setLeftButtonText(getString(android.R.string.cancel));
- setLeftButtonOnClickListener((view) -> {
- getActivity().setResult(Activity.RESULT_CANCELED);
- getActivity().finish();
- });
+ ActionBar actionBar = getActivity().getActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.show();
+ }
}
@Override
}
@Override
+ public void onDestroyView() {
+ SurfaceHolder surfaceHolder = mSurfaceView.getHolder();
+ surfaceHolder.removeCallback(this);
+
+ super.onDestroyView();
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ menu.removeItem(Menu.FIRST);
+
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
public void surfaceCreated(final SurfaceHolder holder) {
initCamera(holder);
}
* Here are the items shared by both WifiDppConfiguratorActivity & WifiDppEnrolleeActivity
*/
public class WifiDppUtils {
+ /**
+ * The fragment tag specified to FragmentManager for container activities to manage fragments.
+ */
+ public static final String TAG_FRAGMENT_QR_CODE_SCANNER = "qr_code_scanner_fragment";
+
+ /**
+ * @see #TAG_FRAGMENT_QR_CODE_SCANNER
+ */
+ public static final String TAG_FRAGMENT_QR_CODE_GENERATOR = "qr_code_generator_fragment";
+
+ /**
+ * @see #TAG_FRAGMENT_QR_CODE_SCANNER
+ */
+ public static final String TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK =
+ "choose_saved_wifi_network_fragment";
+
+ /**
+ * @see #TAG_FRAGMENT_QR_CODE_SCANNER
+ */
+ public static final String TAG_FRAGMENT_ADD_DEVICE = "add_device_fragment";
+
/** The data is from {@code com.android.settingslib.wifi.AccessPoint.securityToString} */
public static final String EXTRA_WIFI_SECURITY = "security";
assertThat(activity instanceof WifiNetworkConfig.Retriever).isEqualTo(true);
}
+
+ @Test
+ public void testActivity_shouldImplementsQrCodeGeneratorFragmentCallback() {
+ WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
+
+ assertThat(activity instanceof WifiDppQrCodeGeneratorFragment
+ .OnQrCodeGeneratorFragmentAddButtonClickedListener).isEqualTo(true);
+ }
}
--- /dev/null
+/*
+ * 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.
+ */
+
+package com.android.settings.wifi.dpp;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class WifiDppQrCodeGeneratorFragmentTest {
+ @Rule
+ public final ActivityTestRule<WifiDppConfiguratorActivity> mActivityRule =
+ new ActivityTestRule<>(WifiDppConfiguratorActivity.class, true);
+
+ @Before
+ public void setUp() {
+ Intent intent =
+ new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
+ mActivityRule.launchActivity(intent);
+ }
+
+ @Test
+ public void rotateScreen_shouldNotCrash() {
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ }
+}
package com.android.settings.wifi.dpp;
-import static android.support.test.espresso.action.ViewActions.click;
-import static android.support.test.espresso.matcher.ViewMatchers.withText;
-import static android.support.test.espresso.Espresso.onView;
-
-import static com.google.common.truth.Truth.assertThat;
-
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;