Merge "Import translations. DO NOT MERGE"
diff --git a/res/layout/screen_zoom_preview_settings.xml b/res/layout/screen_zoom_preview_settings.xml
index f93adc2..a635612 100644
--- a/res/layout/screen_zoom_preview_settings.xml
+++ b/res/layout/screen_zoom_preview_settings.xml
@@ -140,7 +140,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/display_summary_on"
+ android:text="@string/display_summary_example"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
diff --git a/res/layout/trusted_credential.xml b/res/layout/trusted_credential.xml
index cc146f8..acef60b 100644
--- a/res/layout/trusted_credential.xml
+++ b/res/layout/trusted_credential.xml
@@ -21,14 +21,15 @@
android:background="?android:attr/selectableItemBackground"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="15dip"
- android:paddingBottom="15dip"
+ android:descendantFocusability="blocksDescendants"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
+ android:paddingTop="15dip"
+ android:paddingBottom="15dip"
android:orientation="vertical">
<TextView
@@ -53,8 +54,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
- android:clickable="false"
- android:focusable="false"
+ android:padding="8dp"
android:layout_weight="0" />
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d2212f2..ef9c3dd 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1659,6 +1659,10 @@
<!-- Dialog for Access Points --> <skip />
<!-- Label to show/hide advanced options [CHAR LIMIT=40] -->
<string name="wifi_show_advanced">Advanced options</string>
+ <!-- Message for talkback to say when Advanced Options expanded [CHAR LIMIT=NONE] -->
+ <string name="wifi_advanced_toggle_description_expanded">Drop down list Advanced Options. Double-tap to collapse.</string>
+ <!-- Message for talkback to say when Advanced Options is collapsed [CHAR LIMIT=NONE] -->
+ <string name="wifi_advanced_toggle_description_collapsed">Drop down list Advanced Options. Double-tap to expand.</string>
<!-- Title for the WPS setup dialog [CHAR LIMIT=50] -->
<string name="wifi_wps_setup_title">Wi\u2011Fi Protected Setup</string>
<!-- Message in WPS dialog at start up [CHAR LIMIT=150] -->
@@ -6260,13 +6264,14 @@
</string>
<!-- Title for what display preferences are applied when device is in VR mode -->
- <string name="display_vr_pref_title">When device is in VR mode</string>
+ <string name="display_vr_pref_title">When device is in VR</string>
<!-- [CHAR LIMIT=70] Put display into low-persistence mode, this decreases motion blur. -->
- <string name="display_vr_pref_low_persistence">Use low motion blur settings</string>
+ <string name="display_vr_pref_low_persistence">Reduce blur (recommended)</string>
- <!-- [CHAR LIMIT=70] Do not change display settings. -->
- <string name="display_vr_pref_off">Do nothing</string>
+ <!-- [CHAR LIMIT=70] Do not change default display settings, this may reduce perceived screen
+ flicker while in VR mode. -->
+ <string name="display_vr_pref_off">Reduce flicker</string>
<!-- Sound & notification > Advanced section: Title for managing Do Not Disturb access option. [CHAR LIMIT=40] -->
<string name="manage_zen_access_title">Do Not Disturb access</string>
@@ -7273,6 +7278,8 @@
<!-- Summary of display with screen sleep timeout [CHAR LIMIT=NONE] -->
<string name="display_summary">Sleep after <xliff:g id="timeout_description" example="10 minutes">%1$s</xliff:g> of inactivity</string>
+ <!-- Example summary of display used in Setup Wizard preview screen [CHAR LIMIT=NONE] -->
+ <string name="display_summary_example">Sleep after 10 minutes of inactivity</string>
<!-- Summary of memory screen [CHAR LIMIT=NONE] -->
<string name="memory_summary">Avg <xliff:g id="used_memory" example="1.7GB">%1$s</xliff:g> of <xliff:g id="total_memory" example="2GB">%2$s</xliff:g> memory used</string>
@@ -7820,25 +7827,29 @@
<!-- Summary text for double twist for camera mode [CHAR LIMIT=160]-->
<string name="double_twist_for_camera_mode_summary"></string>
- <!-- Title text for ambient display double tap [CHAR LIMIT=60]-->
- <string name="ambient_display_title">Quick screen check - Double Tap</string>
+ <!-- Title text for ambient display double tap (phone) [CHAR LIMIT=60]-->
+ <string name="ambient_display_title" product="default">Double-tap to check phone</string>
+ <!-- Title text for ambient display double tap (tablet) [CHAR LIMIT=60]-->
+ <string name="ambient_display_title" product="tablet">Double-tap to check tablet</string>
+ <!-- Title text for ambient display double tap (device) [CHAR LIMIT=60]-->
+ <string name="ambient_display_title" product="device">Double-tap to check device</string>
- <!-- Summary text for ambient display double tap (phone) [CHAR LIMIT=160]-->
- <string name="ambient_display_summary" product="default">To check your phone without waking it up fully, double-tap it</string>
- <!-- Summary text for ambient display double tap (tablet) [CHAR LIMIT=160]-->
- <string name="ambient_display_summary" product="tablet">To check your tablet without waking it up fully, double-tap it</string>
- <!-- Summary text for ambient display double tap (device) [CHAR LIMIT=160]-->
- <string name="ambient_display_summary" product="device">To check your device without waking it up fully, double-tap it</string>
+ <!-- Summary text for ambient display double tap [CHAR LIMIT=160]-->
+ <string name="ambient_display_summary">To quickly check your notifications, double-tap your screen</string>
- <!-- Title text for ambient display pick up [CHAR LIMIT=60]-->
- <string name="ambient_display_pickup_title">Quick screen check - Pickup notifications</string>
+ <!-- Title text for ambient display pick up (phone) [CHAR LIMIT=60]-->
+ <string name="ambient_display_pickup_title" product="default">Lift to check phone</string>
+ <!-- Title text for ambient display pick up (tablet) [CHAR LIMIT=60]-->
+ <string name="ambient_display_pickup_title" product="tablet">Lift to check tablet</string>
+ <!-- Title text for ambient display pick up (device) [CHAR LIMIT=60]-->
+ <string name="ambient_display_pickup_title" product="device">Lift to check device</string>
<!-- Summary text for ambient display (phone) [CHAR LIMIT=160]-->
- <string name="ambient_display_pickup_summary" product="default">To check your phone without waking it up fully, pick it up</string>
+ <string name="ambient_display_pickup_summary" product="default">To quickly check your notifications, pick up your phone</string>
<!-- Summary text for ambient display (tablet) [CHAR LIMIT=160]-->
- <string name="ambient_display_pickup_summary" product="tablet">To check your tablet without waking it up fully, pick it up</string>
+ <string name="ambient_display_pickup_summary" product="tablet">To quickly check your notifications, pick up your tablet</string>
<!-- Summary text for ambient display (device) [CHAR LIMIT=160]-->
- <string name="ambient_display_pickup_summary" product="device">To check your device without waking it up fully, pick it up</string>
+ <string name="ambient_display_pickup_summary" product="device">To quickly check your notifications, pick up your device</string>
<!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=60]-->
<string name="fingerprint_swipe_for_notifications_title">Swipe for notifications</string>
diff --git a/src/com/android/settings/TrustedCredentialsDialogBuilder.java b/src/com/android/settings/TrustedCredentialsDialogBuilder.java
index 31042cb..03414bd 100644
--- a/src/com/android/settings/TrustedCredentialsDialogBuilder.java
+++ b/src/com/android/settings/TrustedCredentialsDialogBuilder.java
@@ -138,7 +138,7 @@
onClickOk();
}
} else if (view == mNegativeButton) {
- onClickRemove();
+ onClickEnableOrDisable();
}
}
@@ -155,21 +155,26 @@
}
}
- private void onClickRemove() {
+ private void onClickEnableOrDisable() {
final CertHolder certHolder = getCurrentCertInfo();
- new AlertDialog.Builder(mActivity)
- .setMessage(getButtonConfirmation(certHolder))
- .setPositiveButton(android.R.string.yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- mDelegate.removeOrInstallCert(certHolder);
- dialog.dismiss();
- nextOrDismiss();
- }
- })
- .setNegativeButton(android.R.string.no, null)
- .show();
+ DialogInterface.OnClickListener onConfirm = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ mDelegate.removeOrInstallCert(certHolder);
+ nextOrDismiss();
+ }
+ };
+ if (certHolder.isSystemCert()) {
+ // Removing system certs is reversible, so skip confirmation.
+ onConfirm.onClick(null, -1);
+ } else {
+ new AlertDialog.Builder(mActivity)
+ .setMessage(R.string.trusted_credentials_remove_confirmation)
+ .setPositiveButton(android.R.string.yes, onConfirm)
+ .setNegativeButton(android.R.string.no, null)
+ .show();
+
+ }
}
private void onCredentialConfirmed(int userId) {
@@ -314,13 +319,6 @@
return certLayout;
}
- private static int getButtonConfirmation(CertHolder certHolder) {
- return certHolder.isSystemCert() ? ( certHolder.isDeleted()
- ? R.string.trusted_credentials_enable_confirmation
- : R.string.trusted_credentials_disable_confirmation )
- : R.string.trusted_credentials_remove_confirmation;
- }
-
private static int getButtonLabel(CertHolder certHolder) {
return certHolder.isSystemCert() ? ( certHolder.isDeleted()
? R.string.trusted_credentials_enable_label
diff --git a/src/com/android/settings/TrustedCredentialsSettings.java b/src/com/android/settings/TrustedCredentialsSettings.java
index 4cefc74..bae0a92 100644
--- a/src/com/android/settings/TrustedCredentialsSettings.java
+++ b/src/com/android/settings/TrustedCredentialsSettings.java
@@ -318,7 +318,8 @@
* whereas children correspond to certificates.
*/
private class GroupAdapter extends BaseExpandableListAdapter implements
- ExpandableListView.OnGroupClickListener, ExpandableListView.OnChildClickListener {
+ ExpandableListView.OnGroupClickListener, ExpandableListView.OnChildClickListener,
+ View.OnClickListener {
private final AdapterData mData;
private GroupAdapter(Tab tab) {
@@ -402,6 +403,16 @@
return true;
}
+ /**
+ * Called when the switch on a system certificate is clicked. This will toggle whether it
+ * is trusted as a credential.
+ */
+ @Override
+ public void onClick(View view) {
+ CertHolder holder = (CertHolder) view.getTag();
+ removeOrInstallCert(holder);
+ }
+
@Override
public boolean onGroupClick(ExpandableListView expandableListView, View view,
int groupPosition, long id) {
@@ -459,16 +470,17 @@
ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
+ holder = new ViewHolder();
LayoutInflater inflater = LayoutInflater.from(getActivity());
convertView = inflater.inflate(R.layout.trusted_credential, parent, false);
- holder = new ViewHolder();
+ convertView.setTag(holder);
holder.mSubjectPrimaryView = (TextView)
convertView.findViewById(R.id.trusted_credential_subject_primary);
holder.mSubjectSecondaryView = (TextView)
convertView.findViewById(R.id.trusted_credential_subject_secondary);
holder.mSwitch = (Switch) convertView.findViewById(
R.id.trusted_credential_status);
- convertView.setTag(holder);
+ holder.mSwitch.setOnClickListener(this);
} else {
holder = (ViewHolder) convertView.getTag();
}
@@ -480,6 +492,7 @@
UserManager.DISALLOW_CONFIG_CREDENTIALS,
new UserHandle(certHolder.mProfileId)));
holder.mSwitch.setVisibility(View.VISIBLE);
+ holder.mSwitch.setTag(certHolder);
}
return convertView;
}
@@ -576,6 +589,7 @@
mListView = (ListView) mContainerView.findViewById(R.id.cert_list);
mListView.setAdapter(this);
mListView.setOnItemClickListener(this);
+ mListView.setItemsCanFocus(true);
mHeaderView = (ViewGroup) mContainerView.findViewById(R.id.header_view);
mHeaderView.setOnClickListener(this);
diff --git a/src/com/android/settings/applications/AppStateOverlayBridge.java b/src/com/android/settings/applications/AppStateOverlayBridge.java
index af51984..838ee42 100644
--- a/src/com/android/settings/applications/AppStateOverlayBridge.java
+++ b/src/com/android/settings/applications/AppStateOverlayBridge.java
@@ -23,6 +23,9 @@
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
+import java.util.ArrayList;
+import java.util.List;
+
/*
* Connects info of apps that draw overlay to the ApplicationsState. Wraps around the generic
* AppStateAppOpsBridge class to tailor to the semantics of SYSTEM_ALERT_WINDOW. Also provides app
@@ -62,6 +65,13 @@
}
public static class OverlayState extends AppStateAppOpsBridge.PermissionState {
+ public final boolean controlEnabled;
+
+ private static final List<String> DISABLE_PACKAGE_LIST = new ArrayList<>();
+
+ static {
+ DISABLE_PACKAGE_LIST.add("com.android.systemui");
+ }
public OverlayState(PermissionState permissionState) {
super(permissionState.packageName, permissionState.userHandle);
@@ -69,6 +79,7 @@
this.appOpMode = permissionState.appOpMode;
this.permissionDeclared = permissionState.permissionDeclared;
this.staticPermissionGranted = permissionState.staticPermissionGranted;
+ controlEnabled = !DISABLE_PACKAGE_LIST.contains(permissionState.packageName);
}
}
diff --git a/src/com/android/settings/applications/DrawOverlayDetails.java b/src/com/android/settings/applications/DrawOverlayDetails.java
index ade2923..335bb16 100644
--- a/src/com/android/settings/applications/DrawOverlayDetails.java
+++ b/src/com/android/settings/applications/DrawOverlayDetails.java
@@ -144,7 +144,7 @@
boolean isAllowed = mOverlayState.isPermissible();
mSwitchPref.setChecked(isAllowed);
// you cannot ask a user to grant you a permission you did not have!
- mSwitchPref.setEnabled(mOverlayState.permissionDeclared);
+ mSwitchPref.setEnabled(mOverlayState.permissionDeclared && mOverlayState.controlEnabled);
mOverlayPrefs.setEnabled(isAllowed);
getPreferenceScreen().removePreference(mOverlayPrefs);
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index 0c35b69..f9b507d 100755
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -102,7 +102,7 @@
deviceName.setText(mCachedDevice.getName(), TextView.BufferType.EDITABLE);
return new AlertDialog.Builder(getContext())
.setView(mRootView)
- .setNegativeButton(R.string.forget, this)
+ .setNeutralButton(R.string.forget, this)
.setPositiveButton(R.string.okay, this)
.setTitle(R.string.bluetooth_preference_paired_devices)
.create();
diff --git a/src/com/android/settings/datausage/UnrestrictedDataAccess.java b/src/com/android/settings/datausage/UnrestrictedDataAccess.java
index 2977eea..df238b9 100644
--- a/src/com/android/settings/datausage/UnrestrictedDataAccess.java
+++ b/src/com/android/settings/datausage/UnrestrictedDataAccess.java
@@ -17,6 +17,8 @@
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
+import android.os.UserHandle;
+import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
@@ -26,11 +28,8 @@
import android.view.View;
import com.android.internal.logging.MetricsProto.MetricsEvent;
-import com.android.settings.AppHeader;
import com.android.settings.R;
-import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.applications.AppInfoBase;
import com.android.settings.applications.AppStateBaseBridge;
import com.android.settings.applications.InstalledAppDetails;
import com.android.settings.datausage.AppStateDataUsageBridge.DataUsageState;
@@ -162,6 +161,9 @@
final int N = apps.size();
for (int i = 0; i < N; i++) {
AppEntry entry = apps.get(i);
+ if (!shouldAddPreference(entry)) {
+ continue;
+ }
String key = entry.info.packageName + "|" + entry.info.uid;
AccessPreference preference = (AccessPreference) getCachedPreference(key);
if (preference == null) {
@@ -221,6 +223,11 @@
return false;
}
+ @VisibleForTesting
+ boolean shouldAddPreference(AppEntry app) {
+ return app != null && UserHandle.isApp(app.info.uid);
+ }
+
private class AccessPreference extends SwitchPreference implements DataSaverBackend.Listener {
private final AppEntry mEntry;
private final DataUsageState mState;
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index 88ff8d5..d9e02e8 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -54,6 +54,8 @@
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.deviceinfo.PrivateStorageInfo;
+import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
import com.android.settingslib.drawer.SettingsDrawerActivity;
import java.io.File;
@@ -168,7 +170,8 @@
for (VolumeInfo vol : volumes) {
if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
- final long volumeTotalBytes = getTotalSize(vol);
+ final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol,
+ sTotalInternalStorage);
final int color = COLOR_PRIVATE[privateCount++ % COLOR_PRIVATE.length];
mInternalCategory.addPreference(
new StorageVolumePreference(context, vol, color, volumeTotalBytes));
@@ -277,7 +280,8 @@
if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
final Bundle args = new Bundle();
args.putString(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
- PrivateVolumeSettings.setVolumeSize(args, getTotalSize(vol));
+ PrivateVolumeSettings.setVolumeSize(args, PrivateStorageInfo.getTotalSize(vol,
+ sTotalInternalStorage));
startFragment(this, PrivateVolumeSettings.class.getCanonicalName(),
-1, 0, args);
return true;
@@ -517,47 +521,15 @@
private void updateSummary() {
// TODO: Register listener.
final StorageManager storageManager = mContext.getSystemService(StorageManager.class);
- if (sTotalInternalStorage <= 0) {
- sTotalInternalStorage = storageManager.getPrimaryStorageSize();
- }
- final List<VolumeInfo> volumes = storageManager.getVolumes();
- long privateFreeBytes = 0;
- long privateTotalBytes = 0;
- for (VolumeInfo info : volumes) {
- final File path = info.getPath();
- if (info.getType() != VolumeInfo.TYPE_PRIVATE || path == null) {
- continue;
- }
- privateTotalBytes += getTotalSize(info);
- privateFreeBytes += path.getFreeSpace();
- }
- long privateUsedBytes = privateTotalBytes - privateFreeBytes;
+ PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(
+ new StorageManagerVolumeProvider(storageManager));
+ long privateUsedBytes = info.totalBytes - info.freeBytes;
mLoader.setSummary(this, mContext.getString(R.string.storage_summary,
Formatter.formatFileSize(mContext, privateUsedBytes),
- Formatter.formatFileSize(mContext, privateTotalBytes)));
+ Formatter.formatFileSize(mContext, info.totalBytes)));
}
}
- private static long getTotalSize(VolumeInfo info) {
- // Device could have more than one primary storage, which could be located in the
- // internal flash (UUID_PRIVATE_INTERNAL) or in an external disk.
- // If it's internal, try to get its total size from StorageManager first
- // (sTotalInternalStorage), since that size is more precise because it accounts for
- // the system partition.
- if (info.getType() == VolumeInfo.TYPE_PRIVATE
- && Objects.equals(info.getFsUuid(), StorageManager.UUID_PRIVATE_INTERNAL)
- && sTotalInternalStorage > 0) {
- return sTotalInternalStorage;
- } else {
- final File path = info.getPath();
- if (path == null) {
- // Should not happen, caller should have checked.
- Log.e(TAG, "info's path is null on getTotalSize(): " + info);
- return 0;
- }
- return path.getTotalSpace();
- }
- }
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
= new SummaryLoader.SummaryProviderFactory() {
diff --git a/tests/app/src/com/android/settings/tests/DrawOverlayDetailsTest.java b/tests/app/src/com/android/settings/tests/DrawOverlayDetailsTest.java
new file mode 100644
index 0000000..234f8e6
--- /dev/null
+++ b/tests/app/src/com/android/settings/tests/DrawOverlayDetailsTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016 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.tests;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.support.test.InstrumentationRegistry;
+import org.junit.runner.RunWith;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import org.junit.Test;
+import com.android.settings.R;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static org.hamcrest.core.IsNot.not;
+import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class DrawOverlayDetailsTest {
+ private final static String PACKAGE_SYSTEM_UI = "com.android.systemui";
+
+ @Test
+ public void testSystemUiDrawOverlayDetails_Disabled() throws Exception{
+ Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
+ instrumentation.startActivitySync(new Intent(android.provider.Settings
+ .ACTION_MANAGE_OVERLAY_PERMISSION));
+
+ final Context targetContext = instrumentation.getTargetContext();
+
+ final PackageManager packageManager = targetContext.getPackageManager();
+ final String appName = (String) packageManager.getApplicationLabel(packageManager
+ .getApplicationInfo(PACKAGE_SYSTEM_UI, PackageManager.GET_META_DATA));
+
+ openActionBarOverflowOrOptionsMenu(targetContext);
+ onView(withText(targetContext.getString(R.string.menu_show_system))).perform(click());
+ onView(withText(appName)).perform(click());
+ onView(withText(targetContext.getString(R.string.permit_draw_overlay))).check(matches
+ (not(isEnabled())));
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java b/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
new file mode 100644
index 0000000..a04861d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2016 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.datausage;
+
+import android.content.pm.ApplicationInfo;
+import android.os.Process;
+
+import com.android.settings.TestConfig;
+import com.android.settingslib.applications.ApplicationsState;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class UnrestrictedDataAccessTest {
+
+ @Mock
+ private ApplicationsState.AppEntry mAppEntry;
+ private UnrestrictedDataAccess mFragment;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mFragment = new UnrestrictedDataAccess();
+ }
+
+ @Test
+ public void testShouldAddPreferenceForApps() {
+ mAppEntry.info = new ApplicationInfo();
+ mAppEntry.info.uid = Process.FIRST_APPLICATION_UID + 10;
+
+ assertThat(mFragment.shouldAddPreference(mAppEntry)).isTrue();
+ }
+
+ @Test
+ public void testShouldNotAddPreferenceForNonApps() {
+ mAppEntry.info = new ApplicationInfo();
+ mAppEntry.info.uid = Process.FIRST_APPLICATION_UID - 10;
+
+ assertThat(mFragment.shouldAddPreference(mAppEntry)).isFalse();
+ }
+
+}