Snap for 5251505 from 257f85e424 to qt-release

Change-Id: I1dd3558da30dcc22cf150d22baa7b30a4c27b8cb
This commit is contained in:
android-build-team Robot
2019-01-23 04:12:52 +00:00
10 changed files with 240 additions and 17 deletions

View File

@@ -0,0 +1,28 @@
<!--
Copyright 2019 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="64.0"
android:viewportHeight="64.0">
<path
android:fillColor="#0F9D58"
android:pathData="M32,5.3C17.3,5.3 5.3,17.3 5.3,32s12,26.7 26.7,26.7s26.7,-12 26.7,-26.7S46.7,5.3 32,5.3z"/>
<path
android:fillColor="#FFFFFF"
android:pathData="M49.4,24.3l-20,20c-1,1 -2.7,1 -3.8,0l0,0l-11.1,-11c-1.1,-1 -1.1,-2.7 0,-3.8s2.7,-1.1 3.8,0l0,0l9.2,9.2l18.1,-18.1c1,-1 2.7,-1 3.8,0C50.4,21.6 50.4,23.3 49.4,24.3L49.4,24.3z"/>
</vector>

View File

@@ -0,0 +1,24 @@
<!--
Copyright 2019 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"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M3,6h18L21,4L3,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h4v-2L3,18L3,6zM13,12L9,12v1.78c-0.61,0.55 -1,1.33 -1,2.22 0,0.89 0.39,1.67 1,2.22L9,20h4v-1.78c0.61,-0.55 1,-1.34 1,-2.22s-0.39,-1.67 -1,-2.22L13,12zM11,17.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM22,8h-6c-0.5,0 -1,0.5 -1,1v10c0,0.5 0.5,1 1,1h6c0.5,0 1,-0.5 1,-1L23,9c0,-0.5 -0.5,-1 -1,-1zM21,18h-4v-8h4v8z"/>
</vector>

View File

@@ -174,6 +174,20 @@
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<!-- Enable/Disable CBRS data -->
<Switch android:id="@+id/cbrs_data_switch"
android:textSize="14sp"
android:layout_marginTop="8dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cbrs_data_switch_string" />
<!-- Horizontal Rule -->
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<!-- Ping stats -->
<Button android:id="@+id/ping_test"
android:textSize="14sp"

View File

@@ -63,6 +63,9 @@
<!-- EAB provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
<string name="eab_provisioned_switch_string">EAB/Presence Provisioned</string>
<!-- Cbrs enable disable flag. Only shown in diagnostic screen, so precise translation is not needed -->
<string name="cbrs_data_switch_string">Cbrs Data</string>
<!-- Title for controlling on/off for Mobile phone's radio power. Only shown in diagnostic screen, so precise translation is not needed. -->
<string name="radio_info_radio_power">Mobile Radio Power</string>

View File

@@ -213,6 +213,7 @@ public class RadioInfo extends Activity {
private Switch imsVtProvisionedSwitch;
private Switch imsWfcProvisionedSwitch;
private Switch eabProvisionedSwitch;
private Switch cbrsDataSwitch;
private Spinner preferredNetworkType;
private Spinner cellInfoRefreshRateSpinner;
@@ -450,6 +451,9 @@ public class RadioInfo extends Activity {
imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
@@ -526,6 +530,11 @@ public class RadioInfo extends Activity {
imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
if (isCbrsSupported()) {
cbrsDataSwitch.setChecked(getCbrsDataState());
cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
}
mTelephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_CALL_STATE
//b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
@@ -1483,4 +1492,38 @@ public class RadioInfo extends Activity {
}
};
boolean isCbrsSupported() {
return getResources().getBoolean(
com.android.internal.R.bool.config_cbrs_supported);
}
void updateCbrsDataState(boolean state) {
Log.d(TAG, "setCbrsDataSwitchState() state:" + ((state)? "on":"off"));
if (mTelephonyManager != null) {
QueuedWork.queue(new Runnable() {
public void run() {
mTelephonyManager.setOpportunisticNetworkState(state);
cbrsDataSwitch.setChecked(getCbrsDataState());
}
}, false);
}
}
boolean getCbrsDataState() {
boolean state = false;
if (mTelephonyManager != null) {
state = mTelephonyManager.isOpportunisticNetworkEnabled();
}
Log.d(TAG, "getCbrsDataState() state:" +((state)? "on":"off"));
return state;
}
OnCheckedChangeListener mCbrsDataSwitchChangeListener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateCbrsDataState(isChecked);
}
};
}

View File

@@ -74,18 +74,7 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
}
final int numDevices = mConnectedDevices.size();
if (numDevices == 0) {
// Disable switch entry if there is no connected devices.
mPreference.setVisible(false);
final CharSequence summary = mContext.getText(R.string.media_output_default_summary);
final CharSequence[] defaultMediaOutput = new CharSequence[]{summary};
mSelectedIndex = getDefaultDeviceIndex();
preference.setSummary(summary);
setPreference(defaultMediaOutput, defaultMediaOutput, preference);
return;
}
mPreference.setVisible(true);
mPreference.setVisible((numDevices == 0) ? false : true);
CharSequence[] mediaOutputs = new CharSequence[numDevices + 1];
CharSequence[] mediaValues = new CharSequence[numDevices + 1];

View File

@@ -55,6 +55,7 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
@Override
public void onConfiguratorSuccess(int code) {
// Update success UI.
mHeaderIcon.setImageResource(R.drawable.ic_check_circle_green);
mTitle.setText(R.string.wifi_dpp_wifi_shared_with_device);
mSummary.setVisibility(View.INVISIBLE);
mWifiApPictureView.setImageResource(R.drawable.wifi_dpp_success);
@@ -109,6 +110,8 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mHeaderIcon.setImageResource(R.drawable.ic_devices_other_opaque_black);
final WifiQrCode wifiQrCode = ((WifiDppConfiguratorActivity) getActivity())
.getWifiDppQrCode();
final String information = wifiQrCode.getInformation();

View File

@@ -19,6 +19,7 @@ package com.android.settings.wifi.dpp;
import android.app.ActionBar;
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -83,9 +84,20 @@ public class WifiDppChooseSavedWifiNetworkFragment extends WifiDppQrCodeBaseFrag
mButtonLeft = view.findViewById(R.id.button_left);
mButtonLeft.setText(R.string.cancel);
mButtonLeft.setOnClickListener(v -> {
Activity activity = getActivity();
activity.setResult(Activity.RESULT_CANCELED);
activity.finish();
String action = null;
final Intent intent = getActivity().getIntent();
if (intent != null) {
action = intent.getAction();
}
if (WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER.equals(action) ||
WifiDppConfiguratorActivity
.ACTION_CONFIGURATOR_QR_CODE_GENERATOR.equals(action)) {
getFragmentManager().popBackStack();
} else {
final Activity activity = getActivity();
activity.setResult(Activity.RESULT_CANCELED);
activity.finish();
}
});
mButtonRight = view.findViewById(R.id.button_right);

View File

@@ -314,8 +314,6 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
@Override
public void onClickChooseDifferentNetwork() {
mWifiNetworkConfig = null;
showChooseSavedWifiNetworkFragment(/* addToBackStack */ true);
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright (C) 2019 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 static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.android.settings.wifi.dpp.WifiDppUtils.TAG_FRAGMENT_ADD_DEVICE;
import static com.android.settings.wifi.dpp.WifiDppUtils.TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK;
import static com.google.common.truth.Truth.assertThat;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import androidx.fragment.app.FragmentManager;
import androidx.test.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class WifiDppChooseSavedWifiNetworkFragmentTest {
// Valid Wi-Fi DPP QR code
private static final String VALID_WIFI_DPP_QR_CODE = "DPP:I:SN=4774LH2b4044;M:010203040506;K:"
+ "MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;";
// Keys used to lookup resources by name (see the resourceId/resourceString helper methods).
private static final String STRING = "string";
private static final String WIFI_DPP_CHOOSE_DIFFERENT_NETWORK =
"wifi_dpp_choose_different_network";
private static final String CANCEL = "cancel";
@Rule
public final ActivityTestRule<WifiDppConfiguratorActivity> mActivityRule =
new ActivityTestRule<>(WifiDppConfiguratorActivity.class, /* initialTouchMode */true,
/* launchActivity */ false);
private Context mContext;
@Before
public void setUp() {
mContext = InstrumentationRegistry.getTargetContext();
}
@Test
public void clickCancelButton_configuratorQrCodeScannerIntent_shouldPopBackStack() {
final Intent intent =
new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
final WifiDppConfiguratorActivity hostActivity = mActivityRule.launchActivity(intent);
// Go to WifiDppChooseSavedWifiNetworkFragment and click the cancel button
final FragmentManager fragmentManager = hostActivity.getSupportFragmentManager();
final WifiQrCode wifiQrCode = new WifiQrCode(VALID_WIFI_DPP_QR_CODE);
hostActivity.runOnUiThread(() ->
((WifiDppConfiguratorActivity)hostActivity).onScanWifiDppSuccess(wifiQrCode)
);
onView(withText(resourceString(WIFI_DPP_CHOOSE_DIFFERENT_NETWORK))).perform(click());
onView(withText(resourceString(CANCEL))).perform(click());
assertThat(fragmentManager.findFragmentByTag(TAG_FRAGMENT_ADD_DEVICE)).isNotNull();
assertThat(fragmentManager.findFragmentByTag(TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK))
.isNull();
}
@Test
public void clickCancelButton_processWifiDppQrCodeIntent_shouldFinish() {
final Intent intent =
new Intent(WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
final WifiDppConfiguratorActivity hostActivity = mActivityRule.launchActivity(intent);
onView(withText(resourceString(CANCEL))).perform(click());
assertThat(hostActivity.isFinishing()).isEqualTo(true);
}
private int resourceId(String type, String name) {
return mContext.getResources().getIdentifier(name, type, mContext.getPackageName());
}
/** Similar to {@link #resourceId}, but for accessing R.string.<name> values. */
private String resourceString(String name) {
return mContext.getResources().getString(resourceId(STRING, name));
}
}