Merge "Make GLIF v2 available to OEMs"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c9492a3..9444285 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -765,6 +765,8 @@
<string name="security_status_title">Security status</string>
<!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="security_dashboard_summary">Location, fingerprint</string>
+ <!-- Summary for Security settings when fingerprint is not supported [CHAR LIMIT=NONE]-->
+ <string name="security_dashboard_summary_no_fingerprint">Location</string>
<!-- Fingerprint enrollment and settings --><skip />
<!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_preference_title">Fingerprint</string>
@@ -1640,13 +1642,20 @@
<string name="use_open_wifi_automatically_summary">Automatically connect to high\u2011quality public networks</string>
<!-- Preference title for option to install certificates -->
<string name="wifi_install_credentials">Install certificates</string>
- <!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off. The
- place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring
- the user to "scanning settings" screen. -->
+ <!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off and Wi-Fi
+ scanning is on. The place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They
+ mark a link to bring the user to "scanning settings" screen. -->
<string name="wifi_scan_notify_text">To improve location accuracy, system apps and services can
still scan for Wi\u2011Fi networks. You can change this in
<xliff:g id="link_begin">LINK_BEGIN</xliff:g>scanning
settings<xliff:g id="link_end">LINK_END</xliff:g>.</string>
+ <!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off and Wi-Fi
+ scanning is also off. The place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated.
+ They mark a link to bring the user to "scanning settings" screen. -->
+ <string name="wifi_scan_notify_text_scanning_off">To improve location accuracy,
+ turn on Wi-Fi scanning in
+ <xliff:g id="link_begin">LINK_BEGIN</xliff:g>scanning
+ settings<xliff:g id="link_end">LINK_END</xliff:g>.</string>
<!-- Wifi scan always mode checkbox text -->
<string name="wifi_scan_notify_remember_choice">Don\u2019t show again</string>
<!-- Setting title for setting the wifi sleep policy. Do we keep Wi-Fi active when the screen turns off? -->
@@ -8413,14 +8422,16 @@
<string name="automatic_storage_manager_freed_bytes"><xliff:g id="size" example="3.25MB">%1$s</xliff:g> total made available\n\nLast ran on <xliff:g id="date" example="Jan 12">%2$s</xliff:g></string>
<!-- Title text for enabling web actions. [CHAR_LIMIT=60] -->
- <string name="web_action_enable_title">Open links in apps</string>
+ <string name="web_action_enable_title">Instant apps</string>
<!-- Summary text for enabling web actions. [CHAR_LIMIT=250] -->
- <string name="web_action_enable_summary">Open links in supported apps, even if the
- apps aren’t installed on your device</string>
+ <string name="web_action_enable_summary">Open links in apps, even if they’re not installed</string>
<!-- Section title for the Web Action preference [CHAR LIMIT=60] -->
- <string name="web_action_section_title">Apps not installed</string>
+ <string name="web_action_section_title">Instant apps</string>
+
+ <!-- Preference label for an tappable preference that will open the account chooser for instant apps. [CHAR LIMIT=60] -->
+ <string name="instant_apps_account">Instant apps account</string>
<!-- Section title for the Domain URL app preference list [CHAR LIMIT=60]-->
<string name="domain_url_section_title">Installed apps</string>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 71825b1..9d4acb4 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -27,6 +27,19 @@
<intent android:action="com.android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
</Preference>
+ <com.android.settings.display.NightDisplayPreference
+ android:key="night_display"
+ android:title="@string/night_display_title"
+ android:fragment="com.android.settings.display.NightDisplaySettings"
+ settings:widgetLayout="@null"
+ settings:keywords="@string/keywords_display_night_display" />
+
+ <SwitchPreference
+ android:key="auto_brightness"
+ android:title="@string/auto_brightness_title"
+ settings:keywords="@string/keywords_display_auto_brightness"
+ android:summary="@string/auto_brightness_summary" />
+
<com.android.settingslib.RestrictedPreference
android:key="wallpaper"
android:title="@string/wallpaper_settings_title"
@@ -37,13 +50,6 @@
android:targetClass="@string/config_wallpaper_picker_class" />
</com.android.settingslib.RestrictedPreference>
- <com.android.settings.display.NightDisplayPreference
- android:key="night_display"
- android:title="@string/night_display_title"
- android:fragment="com.android.settings.display.NightDisplaySettings"
- settings:widgetLayout="@null"
- settings:keywords="@string/keywords_display_night_display" />
-
<com.android.settings.TimeoutListPreference
android:key="screen_timeout"
android:title="@string/screen_timeout"
@@ -56,12 +62,6 @@
android:summary="%s"
android:title="@string/display_auto_rotate_title" />
- <SwitchPreference
- android:key="auto_brightness"
- android:title="@string/auto_brightness_title"
- settings:keywords="@string/keywords_display_auto_brightness"
- android:summary="@string/auto_brightness_summary" />
-
<Preference
android:key="font_size"
android:title="@string/title_font_size"
diff --git a/src/com/android/settings/applications/DrawOverlayDetails.java b/src/com/android/settings/applications/DrawOverlayDetails.java
index 39b8919..72564bc 100644
--- a/src/com/android/settings/applications/DrawOverlayDetails.java
+++ b/src/com/android/settings/applications/DrawOverlayDetails.java
@@ -36,6 +36,7 @@
import com.android.settings.R;
import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
import com.android.settings.applications.AppStateOverlayBridge.OverlayState;
+import com.android.settings.core.TouchOverlayManager;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
@@ -61,6 +62,8 @@
private Intent mSettingsIntent;
private OverlayState mOverlayState;
+ private TouchOverlayManager mTouchOverlayManager;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -68,6 +71,7 @@
Context context = getActivity();
mOverlayBridge = new AppStateOverlayBridge(context, mState, null);
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
+ mTouchOverlayManager = new TouchOverlayManager(context);
// find preferences
addPreferencesFromResource(R.xml.app_ops_permissions_details);
@@ -90,6 +94,20 @@
}
@Override
+ public void onStart() {
+ super.onStart();
+
+ mTouchOverlayManager.setOverlayAllowed(false);
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+
+ mTouchOverlayManager.setOverlayAllowed(true);
+ }
+
+ @Override
public void onDestroy() {
super.onDestroy();
mOverlayBridge.release();
diff --git a/src/com/android/settings/applications/ManageDomainUrls.java b/src/com/android/settings/applications/ManageDomainUrls.java
index b09a089..bdc9932 100644
--- a/src/com/android/settings/applications/ManageDomainUrls.java
+++ b/src/com/android/settings/applications/ManageDomainUrls.java
@@ -15,7 +15,9 @@
package com.android.settings.applications;
import android.app.Application;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.UserHandle;
@@ -55,6 +57,7 @@
private ApplicationsState.Session mSession;
private PreferenceGroup mDomainAppList;
private SwitchPreference mWebAction;
+ private Preference mInstantAppAccountPreference;
@Override
public void onCreate(Bundle icicle) {
@@ -126,6 +129,26 @@
mWebAction.setOnPreferenceChangeListener(this);
webActionCategory.addPreference(mWebAction);
+ // Determine whether we should show the instant apps account chooser setting
+ ComponentName instantAppSettingsComponent = getActivity().getPackageManager()
+ .getInstantAppResolverSettingsComponent();
+ Intent instantAppSettingsIntent = null;
+ if (instantAppSettingsComponent != null) {
+ instantAppSettingsIntent =
+ new Intent().setComponent(instantAppSettingsComponent);
+ }
+ if (instantAppSettingsIntent != null) {
+ final Intent launchIntent = instantAppSettingsIntent;
+ // TODO: Make this button actually launch the account chooser.
+ mInstantAppAccountPreference = new Preference(getPrefContext());
+ mInstantAppAccountPreference.setTitle(R.string.instant_apps_account);
+ mInstantAppAccountPreference.setOnPreferenceClickListener(pref -> {
+ startActivity(launchIntent);
+ return true;
+ });
+ webActionCategory.addPreference(mInstantAppAccountPreference);
+ }
+
// list to manage link handling per app
mDomainAppList = new PreferenceCategory(getPrefContext());
mDomainAppList.setTitle(R.string.domain_url_section_title);
@@ -138,9 +161,11 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mWebAction) {
- final int enabled = (boolean) newValue ? 1 : 0;
+ boolean checked = (boolean) newValue;
Settings.Secure.putInt(
- getContentResolver(), Settings.Secure.WEB_ACTION_ENABLED, enabled);
+ getContentResolver(),
+ Settings.Secure.WEB_ACTION_ENABLED, checked ? 1 : 0);
+ mWebAction.setChecked(checked);
return true;
}
return false;
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
index ce9344f..d943de7 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPicker.java
@@ -22,7 +22,6 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.provider.Settings;
-import android.service.autofill.AutoFillService;
import android.service.autofill.AutofillService;
import android.service.autofill.AutofillServiceInfo;
import android.text.TextUtils;
@@ -36,8 +35,6 @@
public class DefaultAutofillPicker extends DefaultAppPickerFragment {
static final String SETTING = Settings.Secure.AUTOFILL_SERVICE;
- // TODO(b/35956626): remove once clients migrated
- static final Intent OLD_AUTO_FILL_PROBE = new Intent(AutoFillService.OLD_SERVICE_INTERFACE);
static final Intent AUTOFILL_PROBE = new Intent(AutofillService.SERVICE_INTERFACE);
@Override
@@ -59,12 +56,6 @@
candidates.add(new DefaultAppInfo(mPm, mUserId, new ComponentName(
info.serviceInfo.packageName, info.serviceInfo.name)));
}
- final List<ResolveInfo> oldResolveInfos = mPm.getPackageManager()
- .queryIntentServices(OLD_AUTO_FILL_PROBE, PackageManager.GET_META_DATA);
- for (ResolveInfo info : oldResolveInfos) {
- candidates.add(new DefaultAppInfo(mPm, mUserId, new ComponentName(
- info.serviceInfo.packageName, info.serviceInfo.name)));
- }
return candidates;
}
@@ -122,24 +113,6 @@
}
}
- final List<ResolveInfo> oldResolveInfos = mPackageManager.queryIntentServices(
- OLD_AUTO_FILL_PROBE, PackageManager.GET_META_DATA);
-
- for (ResolveInfo resolveInfo : oldResolveInfos) {
- final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
- final String flattenKey = new ComponentName(
- serviceInfo.packageName, serviceInfo.name).flattenToString();
- if (TextUtils.equals(mSelectedKey, flattenKey)) {
- final String settingsActivity = new AutofillServiceInfo(
- mPackageManager, serviceInfo)
- .getSettingsActivity();
- if (TextUtils.isEmpty(settingsActivity)) {
- return null;
- }
- return new Intent(Intent.ACTION_MAIN).setComponent(
- new ComponentName(serviceInfo.packageName, settingsActivity));
- }
- }
return null;
}
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java
index 5dfd283..41a5cce 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingService.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java
@@ -65,6 +65,7 @@
return pairingIntent;
}
+ private boolean mRegistered = false;
private final BroadcastReceiver mCancelReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -130,6 +131,7 @@
filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
filter.addAction(BluetoothDevice.ACTION_PAIRING_CANCEL);
registerReceiver(mCancelReceiver, filter);
+ mRegistered = true;
startForeground(NOTIFICATION_ID, builder.getNotification());
return START_REDELIVER_INTENT;
@@ -137,7 +139,10 @@
@Override
public void onDestroy() {
- unregisterReceiver(mCancelReceiver);
+ if (mRegistered) {
+ unregisterReceiver(mCancelReceiver);
+ mRegistered = false;
+ }
stopForeground(true);
}
diff --git a/src/com/android/settings/core/TouchOverlayManager.java b/src/com/android/settings/core/TouchOverlayManager.java
new file mode 100644
index 0000000..f69d1bf
--- /dev/null
+++ b/src/com/android/settings/core/TouchOverlayManager.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 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.core;
+
+import android.app.AppOpsManager;
+import android.content.Context;
+import android.os.Binder;
+import android.os.IBinder;
+
+public class TouchOverlayManager {
+
+ private final Context mContext;
+ private final IBinder mToken = new Binder();
+
+ public TouchOverlayManager(Context context) {
+ mContext = context;
+ }
+
+ public void setOverlayAllowed(boolean allowed) {
+ final AppOpsManager aom = mContext.getSystemService(AppOpsManager.class);
+ if (aom != null) {
+ aom.setUserRestriction(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, !allowed, mToken);
+ aom.setUserRestriction(AppOpsManager.OP_TOAST_WINDOW, !allowed, mToken);
+ }
+ }
+}
diff --git a/src/com/android/settings/datausage/AppDataUsagePreference.java b/src/com/android/settings/datausage/AppDataUsagePreference.java
index 04e2b6d..6770e9e 100644
--- a/src/com/android/settings/datausage/AppDataUsagePreference.java
+++ b/src/com/android/settings/datausage/AppDataUsagePreference.java
@@ -90,8 +90,7 @@
if (cachedDetail != null) {
bindView(cachedDetail, target);
} else {
- new UidDetailTask(provider, item, target).executeOnExecutor(
- AsyncTask.THREAD_POOL_EXECUTOR);
+ new UidDetailTask(provider, item, target).execute();
}
}
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index 07495ee..1a60256 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -66,6 +66,18 @@
}
};
+ private final WifiManager.ActionListener mForgetListener = new WifiManager.ActionListener() {
+ @Override
+ public void onSuccess() {
+ initPreferences();
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ initPreferences();
+ }
+ };
+
private WifiDialog mDialog;
private WifiManager mWifiManager;
private AccessPoint mDlgAccessPoint;
@@ -229,11 +241,12 @@
Log.e(TAG, "Failed to remove Passpoint configuration for "
+ mSelectedAccessPoint.getConfigName());
}
+ initPreferences();
} else {
- mWifiManager.forget(mSelectedAccessPoint.getConfig().networkId, null);
+ // mForgetListener will call initPreferences upon completion
+ mWifiManager.forget(mSelectedAccessPoint.getConfig().networkId, mForgetListener);
}
mSelectedAccessPoint = null;
- initPreferences();
}
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 8784d09..38f5a43 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -516,7 +516,10 @@
if (mSelectedAccessPoint.isActive()) {
return super.onPreferenceTreeClick(preference);
}
- /** Bypass dialog and connect to unsecured or previously connected saved networks. */
+ /**
+ * Bypass dialog and connect to unsecured networks, or previously connected saved
+ * networks, or Passpoint provided networks.
+ */
WifiConfiguration config = mSelectedAccessPoint.getConfig();
if (mSelectedAccessPoint.getSecurity() == AccessPoint.SECURITY_NONE) {
mSelectedAccessPoint.generateOpenNetworkConfig();
@@ -525,6 +528,10 @@
&& config.getNetworkSelectionStatus() != null
&& config.getNetworkSelectionStatus().getHasEverConnected()) {
connect(config, true /* isSavedNetwork */);
+ } else if (mSelectedAccessPoint.isPasspoint()) {
+ // Access point provided by an installed Passpoint provider, connect using
+ // the associated config.
+ connect(config, true /* isSavedNetwork */);
} else {
showDialog(mSelectedAccessPoint, WifiConfigUiBase.MODE_CONNECT);
}
@@ -836,32 +843,24 @@
}
private void setOffMessage() {
- final CharSequence briefText = getText(R.string.wifi_empty_list_wifi_off);
-
+ final CharSequence title = getText(R.string.wifi_empty_list_wifi_off);
// Don't use WifiManager.isScanAlwaysAvailable() to check the Wi-Fi scanning mode. Instead,
// read the system settings directly. Because when the device is in Airplane mode, even if
// Wi-Fi scanning mode is on, WifiManager.isScanAlwaysAvailable() still returns "off".
- final ContentResolver resolver = getActivity().getContentResolver();
- final boolean wifiScanningMode = Settings.Global.getInt(
- resolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
-
- if (!wifiScanningMode) {
- // Show only the brief text if the user is not allowed to configure scanning settings,
- // or the scanning mode has been turned off.
- mStatusMessagePreference.setTitle(briefText);
- } else {
- LinkifyUtils.OnClickListener clickListener = new LinkifyUtils.OnClickListener() {
- @Override
- public void onClick() {
- final SettingsActivity activity = (SettingsActivity) getActivity();
- activity.startPreferencePanel(WifiSettings.this,
- ScanningSettings.class.getName(),
- null, R.string.location_scanning_screen_title, null, null, 0);
- }
- };
- mStatusMessagePreference.setText(
- briefText, getText(R.string.wifi_scan_notify_text), clickListener);
- }
+ final boolean wifiScanningMode = Settings.Global.getInt(getActivity().getContentResolver(),
+ Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
+ final CharSequence description = wifiScanningMode ? getText(R.string.wifi_scan_notify_text)
+ : getText(R.string.wifi_scan_notify_text_scanning_off);
+ final LinkifyUtils.OnClickListener clickListener = new LinkifyUtils.OnClickListener() {
+ @Override
+ public void onClick() {
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+ activity.startPreferencePanel(WifiSettings.this,
+ ScanningSettings.class.getName(),
+ null, R.string.location_scanning_screen_title, null, null, 0);
+ }
+ };
+ mStatusMessagePreference.setText(title, description, clickListener);
removeConnectedAccessPointPreference();
mAccessPointsPreferenceCategory.removeAll();
mAccessPointsPreferenceCategory.addPreference(mStatusMessagePreference);
diff --git a/src/com/android/settings/wifi/WifiSummaryUpdater.java b/src/com/android/settings/wifi/WifiSummaryUpdater.java
index c0d4468..2c56d08 100644
--- a/src/com/android/settings/wifi/WifiSummaryUpdater.java
+++ b/src/com/android/settings/wifi/WifiSummaryUpdater.java
@@ -75,7 +75,7 @@
@Override
public String getSummary() {
if (!mWifiTracker.enabled) {
- return mContext.getString(R.string.wifi_disabled_generic);
+ return mContext.getString(R.string.switch_off_text);
}
if (!mWifiTracker.connected) {
return mContext.getString(R.string.disconnected);
diff --git a/tests/app/src/com/android/settings/wifi/WifiSettingsUiTest.java b/tests/app/src/com/android/settings/wifi/WifiSettingsUiTest.java
new file mode 100644
index 0000000..11a49fc
--- /dev/null
+++ b/tests/app/src/com/android/settings/wifi/WifiSettingsUiTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2017 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;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+
+import com.android.settings.R;
+import com.android.settings.Settings.WifiSettingsActivity;
+import com.android.settingslib.wifi.WifiTracker;
+import com.android.settingslib.wifi.WifiTrackerFactory;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class WifiSettingsUiTest {
+
+ // TODO(sghuman): Investigate why resource ids are not resolving correctly in the test apk,
+ // then remove this manual string entry
+ private static final String WIFI_PREFERENCES = "Wi\\u2011Fi preferences";
+
+ @Mock private WifiTracker mockWifiTracker;
+
+ @Rule
+ public ActivityTestRule<WifiSettingsActivity> mActivityRule =
+ new ActivityTestRule<>(WifiSettingsActivity.class, true);
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ WifiTrackerFactory.setTestingWifiTracker(mockWifiTracker);
+ }
+
+ private void launchActivity() {
+ mActivityRule.launchActivity(new Intent("android.settings.WIFI_SETTINGS"));
+ }
+
+ @Test
+ public void launchActivityShouldSucceed() {
+ launchActivity();
+ }
+
+ @Test
+ public void shouldShowWifiPreferences() {
+ launchActivity();
+ onView(withText(WIFI_PREFERENCES)).perform(click());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java b/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
index a5306a2..ef6351a 100644
--- a/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
@@ -19,10 +19,11 @@
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.internal.telephony.SmsUsageMonitor;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.core.TouchOverlayManager;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.shadow.ShadowPreferenceFragment;
import org.junit.Before;
import org.junit.Test;
@@ -32,6 +33,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
@@ -47,17 +49,22 @@
private FakeFeatureFactory mFeatureFactory;
private DrawOverlayDetails mFragment;
+ @Mock
+ private TouchOverlayManager mTouchOverlayManager;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+
mFragment = new DrawOverlayDetails();
- mFragment.onAttach(ShadowApplication.getInstance().getApplicationContext());
+ ReflectionHelpers.setField(mFragment, "mTouchOverlayManager", mTouchOverlayManager);
}
@Test
public void logSpecialPermissionChange() {
+ mFragment.onAttach(ShadowApplication.getInstance().getApplicationContext());
mFragment.logSpecialPermissionChange(true, "app");
verify(mFeatureFactory.metricsFeatureProvider).action(any(Context.class),
eq(MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_APPDRAW_ALLOW), eq("app"));
@@ -66,4 +73,18 @@
verify(mFeatureFactory.metricsFeatureProvider).action(any(Context.class),
eq(MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_APPDRAW_DENY), eq("app"));
}
+
+ @Test
+ @Config(shadows = ShadowPreferenceFragment.class)
+ public void onStart_disableOverlay() {
+ mFragment.onStart();
+ verify(mTouchOverlayManager).setOverlayAllowed(false);
+ }
+
+ @Test
+ @Config(shadows = ShadowPreferenceFragment.class)
+ public void onStop_enableOverlay() {
+ mFragment.onStop();
+ verify(mTouchOverlayManager).setOverlayAllowed(true);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
index 84d3b98..95f9fbe 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java
@@ -18,6 +18,7 @@
import android.app.Activity;
+import android.app.usage.StorageStatsManager;
import android.icu.text.NumberFormat;
import android.os.storage.VolumeInfo;
import android.text.format.Formatter;
@@ -40,6 +41,7 @@
import java.util.ArrayList;
import java.util.List;
+import static org.mockito.Matchers.any;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -73,9 +75,14 @@
final SummaryLoader.SummaryProvider provider =
StorageSettings.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(mActivity, loader);
final VolumeInfo volumeInfo = mVolumes.get(0);
+ when(volumeInfo.isMountedReadable()).thenReturn(true);
when(volumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
- when(volumeInfo.getPath().getTotalSpace()).thenReturn(500L);
- when(volumeInfo.getPath().getFreeSpace()).thenReturn(0L);
+ when(mStorageManagerVolumeProvider.getTotalBytes(
+ any(StorageStatsManager.class), any(VolumeInfo.class)))
+ .thenReturn(500L);
+ when(mStorageManagerVolumeProvider.getFreeBytes(
+ any(StorageStatsManager.class), any(VolumeInfo.class)))
+ .thenReturn(0L);
ReflectionHelpers.setField(
provider, "mStorageManagerVolumeProvider", mStorageManagerVolumeProvider);
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPreferenceFragment.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPreferenceFragment.java
new file mode 100644
index 0000000..cfd0ce9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPreferenceFragment.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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.testutils.shadow;
+
+import android.support.v14.preference.PreferenceFragment;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@Implements(PreferenceFragment.class)
+public class ShadowPreferenceFragment {
+
+ @Implementation
+ public void onStart() {
+ // No-op.
+ }
+
+ @Implementation
+ public void onStop() {
+ // No-op.
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSummaryUpdaterTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSummaryUpdaterTest.java
index df290b3..967da08 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSummaryUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSummaryUpdaterTest.java
@@ -103,7 +103,7 @@
mWifiTracker.enabled = false;
assertThat(mSummaryUpdater.getSummary()).isEqualTo(
- mContext.getString(R.string.wifi_disabled_generic));
+ mContext.getString(R.string.switch_off_text));
}
@Test