Merge "Show setting tiles for secondary users"
diff --git a/res/layout/system_info_list_item.xml b/res/layout/system_info_list_item.xml
new file mode 100644
index 0000000..37806bd
--- /dev/null
+++ b/res/layout/system_info_list_item.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:orientation="vertical"
+ android:paddingStart="?android:attr/dialogPreferredPadding"
+ android:paddingEnd="?android:attr/dialogPreferredPadding"
+ android:paddingTop="8dp"
+ android:paddingBottom="8dp">
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal"/>
+ <TextView
+ android:id="@+id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/title"
+ android:layout_alignStart="@id/title"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"
+ android:maxLines="4"/>
+</LinearLayout>
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index ad3fac1..0ddd366 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -311,7 +311,10 @@
preferenceGroup.setContentDescription(
mContext.getString(R.string.accessibility_category_personal));
}
- mParent.getPreferenceScreen().addPreference(preferenceGroup);
+ final PreferenceScreen screen = mParent.getPreferenceScreen();
+ if (screen != null) {
+ screen.addPreference(preferenceGroup);
+ }
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {
profileData.authenticatorHelper = new AuthenticatorHelper(context,
@@ -367,6 +370,9 @@
void cleanUpPreferences() {
PreferenceScreen screen = mParent.getPreferenceScreen();
+ if (screen == null) {
+ return;
+ }
for (int i = 0; i < mProfiles.size(); i++) {
final PreferenceGroup preferenceGroup = mProfiles.valueAt(i).preferenceGroup;
screen.removePreference(preferenceGroup);
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index d689ee4..b5f0e76 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -324,7 +324,12 @@
? R.xml.installed_app_details_ia
: R.xml.installed_app_details);
addDynamicPrefs();
-
+ if (mDashboardFeatureProvider.isEnabled()) {
+ mFooter = new LayoutPreference(getPrefContext(), R.layout.app_action_buttons);
+ mFooter.setOrder(10000);
+ mFooter.setKey(KEY_FOOTER);
+ getPreferenceScreen().addPreference(mFooter);
+ }
if (Utils.isBandwidthControlEnabled()) {
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
@@ -964,12 +969,6 @@
}
addAppInstallerInfoPref(screen);
- if (mDashboardFeatureProvider.isEnabled()) {
- mFooter = new LayoutPreference(screen.getContext(), R.layout.app_action_buttons);
- mFooter.setOrder(10000);
- mFooter.setKey(KEY_FOOTER);
- screen.addPreference(mFooter);
- }
}
private void addAppInstallerInfoPref(PreferenceScreen screen) {
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index e63a1df..b0a9902 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -636,12 +636,11 @@
final long usedSize = mTotalSize - details.availSize;
final long unaccountedSize = usedSize - accountedSize;
final long otherSize = totalMiscSize + totalDownloadsSize + unaccountedSize;
- if (LOGV)
- Log.v(TAG, "Other items: \n\tmTotalSize: " + mTotalSize + " availSize: "
- + details.availSize + " usedSize: " + usedSize + "\n\taccountedSize: "
- + accountedSize + " unaccountedSize size: " + unaccountedSize
- + "\n\ttotalMiscSize: " + totalMiscSize + " totalDownloadsSize: "
- + totalDownloadsSize + "\n\tdetails: " + details);
+ Log.v(TAG, "Other items: \n\tmTotalSize: " + mTotalSize + " availSize: "
+ + details.availSize + " usedSize: " + usedSize + "\n\taccountedSize: "
+ + accountedSize + " unaccountedSize size: " + unaccountedSize
+ + "\n\ttotalMiscSize: " + totalMiscSize + " totalDownloadsSize: "
+ + totalDownloadsSize + "\n\tdetails: " + details);
updatePreference(otherItem, otherSize);
}
}
diff --git a/src/com/android/settings/wifi/AdvancedWifiSettings.java b/src/com/android/settings/wifi/AdvancedWifiSettings.java
index f7cc772..4727428 100644
--- a/src/com/android/settings/wifi/AdvancedWifiSettings.java
+++ b/src/com/android/settings/wifi/AdvancedWifiSettings.java
@@ -18,8 +18,11 @@
import android.app.Dialog;
import android.app.DialogFragment;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.wifi.WifiManager;
import android.net.wifi.WpsInfo;
import android.os.Bundle;
import android.os.UserManager;
@@ -44,6 +47,13 @@
private boolean mUnavailable;
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ initPreferences();
+ }
+ };
+
public AdvancedWifiSettings() {
super(UserManager.DISALLOW_CONFIG_WIFI);
}
@@ -74,13 +84,23 @@
}
@Override
- public void onResume() {
- super.onResume();
+ public void onStart() {
+ super.onStart();
if (!mUnavailable) {
+ getActivity().registerReceiver(mReceiver,
+ new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION));
initPreferences();
}
}
+ @Override
+ public void onStop() {
+ super.onStop();
+ if (!mUnavailable) {
+ getActivity().unregisterReceiver(mReceiver);
+ }
+ }
+
private void initPreferences() {
final Context context = getActivity();
Intent intent = new Intent(Credentials.INSTALL_AS_USER_ACTION);
@@ -90,11 +110,13 @@
Preference pref = findPreference(KEY_INSTALL_CREDENTIALS);
pref.setIntent(intent);
-
+ final WifiManager wifiManager =
+ (WifiManager)getActivity().getSystemService(Context.WIFI_SERVICE);
Intent wifiDirectIntent = new Intent(context,
com.android.settings.Settings.WifiP2pSettingsActivity.class);
Preference wifiDirectPref = findPreference(KEY_WIFI_DIRECT);
wifiDirectPref.setIntent(wifiDirectIntent);
+ wifiDirectPref.setEnabled(wifiManager.isWifiEnabled());
// WpsDialog: Create the dialog like WifiSettings does.
Preference wpsPushPref = findPreference(KEY_WPS_PUSH);
@@ -105,6 +127,7 @@
return true;
}
});
+ wpsPushPref.setEnabled(wifiManager.isWifiEnabled());
// WpsDialog: Create the dialog like WifiSettings does.
Preference wpsPinPref = findPreference(KEY_WPS_PIN);
@@ -115,6 +138,7 @@
return true;
}
});
+ wpsPinPref.setEnabled(wifiManager.isWifiEnabled());
}
/* Wrapper class for the WPS dialog to properly handle life cycle events like rotation. */
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index 552c689..398e9c5 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -190,6 +190,24 @@
}
@Test
+ @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
+ public void onResume_noPreferenceScreen_shouldNotCrash() {
+ final List<UserInfo> infos = new ArrayList<>();
+ infos.add(new UserInfo(1, "user 1", 0));
+ when(mUserManager.isManagedProfile()).thenReturn(false);
+ when(mUserManager.isLinkedUser()).thenReturn(false);
+ when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
+
+ AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
+ when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class))).thenReturn(
+ preferenceGroup);
+
+ mController.onResume();
+
+ // Should not crash
+ }
+
+ @Test
public void updateRawDataToIndex_ManagedProfile_shouldNotUpdate() {
final List<SearchIndexableRaw> data = new ArrayList<>();
when(mUserManager.isManagedProfile()).thenReturn(true);