Merge "Make whole switchable header act as single Switch for AccessibilityService"
diff --git a/res/drawable/ic_add.xml b/res/drawable/ic_add.xml
index 5939c97..e4ced7d 100644
--- a/res/drawable/ic_add.xml
+++ b/res/drawable/ic_add.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="32.0dp"
- android:height="32.0dp"
+ android:width="24.0dp"
+ android:height="24.0dp"
android:viewportWidth="48.0"
android:viewportHeight="48.0">
<path
diff --git a/res/drawable/ic_event.xml b/res/drawable/ic_event.xml
index 2ca958f..6857e2f 100644
--- a/res/drawable/ic_event.xml
+++ b/res/drawable/ic_event.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="32.0dp"
- android:height="32.0dp"
+ android:width="24.0dp"
+ android:height="24.0dp"
android:viewportWidth="48.0"
android:viewportHeight="48.0">
<path
diff --git a/res/drawable/ic_schedule.xml b/res/drawable/ic_schedule.xml
index c77c50e..ed5b2f7 100644
--- a/res/drawable/ic_schedule.xml
+++ b/res/drawable/ic_schedule.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="32.0dp"
- android:height="32.0dp"
+ android:width="24.0dp"
+ android:height="24.0dp"
android:viewportWidth="48.0"
android:viewportHeight="48.0">
<path
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f81b283..ed39fd5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6667,6 +6667,21 @@
<!-- Label for maximum memory use section [CHAR LIMIT=30] -->
<string name="maximum_memory_use">Maximum memory use</string>
+ <!-- Label for app list of memory use [CHAR LIMIT=30] -->
+ <string name="memory_usage">Memory usage</string>
+
+ <!-- Label for app list of memory use [CHAR LIMIT=30] -->
+ <string name="app_list_memory_use">App usage</string>
+
+ <!-- Label for details about an app's memory use [CHAR LIMIT=30] -->
+ <string name="memory_details">Details</string>
+
+ <!-- Summary for how much memory an app has used [CHAR LIMIT=NONE] -->
+ <string name="memory_use_summary"><xliff:g id="size" example="30MB">%1$s</xliff:g> avg memory used in last 3 hours</string>
+
+ <!-- Summary for no memory use for an app [CHAR LIMIT=NONE] -->
+ <string name="no_memory_use_summary">No memory used in last 3 hours</string>
+
<!-- Menu item for Sorting list by average memory use [CHAR LIMIT=NONE]-->
<string name="sort_avg_use">Sort by avg use</string>
diff --git a/res/xml/app_memory_settings.xml b/res/xml/app_memory_settings.xml
index 41de52f..03ce0ff 100644
--- a/res/xml/app_memory_settings.xml
+++ b/res/xml/app_memory_settings.xml
@@ -15,7 +15,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/memory_details_title">
+ android:title="@string/memory_usage">
<PreferenceCategory
android:title="@string/average_memory_use" />
@@ -36,7 +36,8 @@
android:layout="@layout/horizontal_preference"
android:title="@string/memory_maximum_usage" />
- <com.android.settings.applications.SpacePreference
- android:layout_height="15dp" />
+ <PreferenceCategory
+ android:key="processes"
+ android:title="@string/memory_details" />
</PreferenceScreen>
diff --git a/res/xml/installed_app_details.xml b/res/xml/installed_app_details.xml
index deab13b..470e292 100644
--- a/res/xml/installed_app_details.xml
+++ b/res/xml/installed_app_details.xml
@@ -51,4 +51,10 @@
android:title="@string/power_usage_summary_title"
android:selectable="true" />
+ <Preference
+ android:key="memory"
+ android:title="@string/memory_settings_title"
+ android:enabled="false"
+ android:selectable="true" />
+
</PreferenceScreen>
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index b4f19dd..45b4ff1 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -116,7 +116,6 @@
/** If gone bad, should we show encryption failed (false) or corrupt (true)*/
private boolean mCorrupt;
/** A flag to indicate when the back event should be ignored */
- private boolean mIgnoreBack = false;
/** When set, blocks unlocking. Set every COOL_DOWN_ATTEMPTS attempts, only cleared
by power cycling phone. */
private boolean mCooldown = false;
@@ -390,15 +389,11 @@
}
/**
- * Ignore back events after the user has entered the decrypt screen and while the device is
- * encrypting.
+ * Ignore back events from this activity always - there's nowhere to go back
+ * to
*/
@Override
public void onBackPressed() {
- // In the rare case that something pressed back even though we were disabled.
- if (mIgnoreBack)
- return;
- super.onBackPressed();
}
@Override
@@ -516,6 +511,8 @@
passwordEntryInit();
+ findViewById(android.R.id.content).setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
+
if (mLockPatternView != null) {
mLockPatternView.setInStealthMode(!pattern_visible);
}
@@ -694,7 +691,6 @@
* @param isEnabled true if back is enabled, false otherwise.
*/
private final void setBackFunctionality(boolean isEnabled) {
- mIgnoreBack = !isEnabled;
if (isEnabled) {
mStatusBar.disable(sWidgetsToDisable);
} else {
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index ed5de25..744ed3f 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -588,7 +588,7 @@
final MenuItem help = menu.findItem(R.id.data_usage_menu_help);
String helpUrl;
if (!TextUtils.isEmpty(helpUrl = getResources().getString(R.string.help_url_data_usage))) {
- HelpUtils.prepareHelpMenuItem(context, help, helpUrl);
+ HelpUtils.prepareHelpMenuItem(context, help, helpUrl, getClass().getName());
} else {
help.setVisible(false);
}
diff --git a/src/com/android/settings/HelpUtils.java b/src/com/android/settings/HelpUtils.java
index 67e7b53..0e79c6d 100644
--- a/src/com/android/settings/HelpUtils.java
+++ b/src/com/android/settings/HelpUtils.java
@@ -21,9 +21,11 @@
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources.Theme;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
+import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
@@ -49,6 +51,12 @@
*/
private final static String PARAM_VERSION = "version";
+ // Constants for help intents.
+ private static final String EXTRA_CONTEXT = "EXTRA_CONTEXT";
+ private static final String EXTRA_THEME = "EXTRA_THEME";
+ private static final String EXTRA_PRIMARY_COLOR = "EXTRA_PRIMARY_COLOR";
+ private static final String EXTRA_BACKUP_URI = "EXTRA_BACKUP_URI";
+
/**
* Cached version code to prevent repeated calls to the package manager.
*/
@@ -57,29 +65,17 @@
/** Static helper that is not instantiable*/
private HelpUtils() { }
- public static boolean prepareHelpMenuItem(Context context, Menu menu, String helpUri) {
+ public static boolean prepareHelpMenuItem(Context context, Menu menu, String helpUri,
+ String backupContext) {
MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_label);
- return prepareHelpMenuItem(context, helpItem, helpUri);
+ return prepareHelpMenuItem(context, helpItem, helpUri, backupContext);
}
- public static boolean prepareHelpMenuItem(Context context, Menu menu, int helpUriResource) {
+ public static boolean prepareHelpMenuItem(Context context, Menu menu, int helpUriResource,
+ String backupContext) {
MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_label);
- return prepareHelpMenuItem(context, helpItem, context.getString(helpUriResource));
- }
-
- /**
- * Prepares the help menu item by doing the following.
- * - If the string corresponding to the helpUrlResourceId is empty or null, then the help menu
- * item is made invisible.
- * - Otherwise, this makes the help menu item visible and sets the intent for the help menu
- * item to view the URL.
- *
- * @return returns whether the help menu item has been made visible.
- */
- public static boolean prepareHelpMenuItem(Context context, MenuItem helpMenuItem,
- int helpUrlResourceId) {
- String helpUrlString = context.getResources().getString(helpUrlResourceId);
- return prepareHelpMenuItem(context, helpMenuItem, helpUrlString);
+ return prepareHelpMenuItem(context, helpItem, context.getString(helpUriResource),
+ backupContext);
}
/**
@@ -91,7 +87,7 @@
* @return returns whether the help menu item has been made visible.
*/
public static boolean prepareHelpMenuItem(Context context, MenuItem helpMenuItem,
- String helpUriString) {
+ String helpUriString, String backupContext) {
if (TextUtils.isEmpty(helpUriString)) {
// The help url string is empty or null, so set the help menu item to be invisible.
helpMenuItem.setVisible(false);
@@ -99,12 +95,11 @@
// return that the help menu item is not visible (i.e. false)
return false;
} else {
- Intent intent = getHelpIntent(context, helpUriString);
+ Intent intent = getHelpIntent(context, helpUriString, backupContext);
// Set the intent to the help menu item, show the help menu item in the overflow
// menu, and make it visible.
- ComponentName component = intent.resolveActivity(context.getPackageManager());
- if (component != null) {
+ if (intent != null) {
helpMenuItem.setIntent(intent);
helpMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
helpMenuItem.setVisible(true);
@@ -118,11 +113,23 @@
}
}
- public static Intent getHelpIntent(Context context, String helpUriString) {
+ public static Intent getHelpIntent(Context context, String helpUriString,
+ String backupContext) {
// Try to handle as Intent Uri, otherwise just treat as Uri.
try {
- return Intent.parseUri(helpUriString,
+ Intent intent = Intent.parseUri(helpUriString,
Intent.URI_ANDROID_APP_SCHEME | Intent.URI_INTENT_SCHEME);
+ addIntentParameters(context, intent, backupContext);
+ ComponentName component = intent.resolveActivity(context.getPackageManager());
+ if (component != null) {
+ return intent;
+ } else if (intent.hasExtra(EXTRA_BACKUP_URI)) {
+ // This extra contains a backup URI for when the intent isn't available.
+ return getHelpIntent(context, intent.getStringExtra(EXTRA_BACKUP_URI),
+ backupContext);
+ } else {
+ return null;
+ }
} catch (URISyntaxException e) {
}
// The help url string exists, so first add in some extra query parameters.
@@ -136,6 +143,18 @@
return intent;
}
+ private static void addIntentParameters(Context context, Intent intent, String backupContext) {
+ if (!intent.hasExtra(EXTRA_CONTEXT)) {
+ // Insert some context if none exists.
+ intent.putExtra(EXTRA_CONTEXT, backupContext);
+ }
+ intent.putExtra(EXTRA_THEME, 1 /* Light, dark action bar */);
+ Theme theme = context.getTheme();
+ TypedValue typedValue = new TypedValue();
+ theme.resolveAttribute(android.R.attr.colorPrimary, typedValue, true);
+ intent.putExtra(EXTRA_PRIMARY_COLOR, context.getColor(typedValue.resourceId));
+ }
+
/**
* Adds two query parameters into the Uri, namely the language code and the version code
* of the app's package as gotten via the context.
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index 095785b..baf04d4 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -294,7 +294,7 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (mHelpUri != null && getActivity() != null) {
- HelpUtils.prepareHelpMenuItem(getActivity(), menu, mHelpUri);
+ HelpUtils.prepareHelpMenuItem(getActivity(), menu, mHelpUri, getClass().getName());
}
}
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 3ddb6a5..4bd74b0 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -115,6 +115,7 @@
private static final String KEY_DATA = "data_settings";
private static final String KEY_LAUNCH = "preferred_settings";
private static final String KEY_BATTERY = "battery";
+ private static final String KEY_MEMORY = "memory";
private final HashSet<String> mHomePackages = new HashSet<String>();
@@ -130,6 +131,7 @@
private Preference mPermissionsPreference;
private Preference mLaunchPreference;
private Preference mDataPreference;
+ private Preference mMemoryPreference;
private boolean mDisableAfterUninstall;
// Used for updating notification preference.
@@ -143,6 +145,9 @@
private BatteryStatsHelper mBatteryHelper;
private BatterySipper mSipper;
+ protected ProcStatsData mStatsManager;
+ protected ProcStatsPackageEntry mStats;
+
private boolean handleDisableable(Button button) {
boolean disableable = false;
// Try to prevent the user from bricking their phone
@@ -260,6 +265,7 @@
mDataCallbacks);
}
new BatteryUpdater().execute();
+ new MemoryUpdater().execute();
}
@Override
@@ -295,6 +301,8 @@
mBatteryPreference = findPreference(KEY_BATTERY);
mBatteryPreference.setEnabled(false);
mBatteryPreference.setOnPreferenceClickListener(this);
+ mMemoryPreference = findPreference(KEY_MEMORY);
+ mMemoryPreference.setOnPreferenceClickListener(this);
mLaunchPreference = findPreference(KEY_LAUNCH);
if (mAppEntry.info != null) {
@@ -701,6 +709,9 @@
startManagePermissionsActivity();
} else if (preference == mLaunchPreference) {
startAppInfoFragment(AppLaunchSettings.class, mLaunchPreference.getTitle());
+ } else if (preference == mMemoryPreference) {
+ ProcessStatsBase.launchMemoryDetail((SettingsActivity) getActivity(),
+ mStatsManager.getMemInfo(), mStats);
} else if (preference == mDataPreference) {
Bundle args = new Bundle();
args.putString(DataUsageSummary.EXTRA_SHOW_APP_IMMEDIATE_PKG,
@@ -767,6 +778,49 @@
}
}
+ private class MemoryUpdater extends AsyncTask<Void, Void, ProcStatsPackageEntry> {
+
+ @Override
+ protected ProcStatsPackageEntry doInBackground(Void... params) {
+ if (mPackageInfo == null) {
+ return null;
+ }
+ if (mStatsManager == null) {
+ mStatsManager = new ProcStatsData(getActivity(), false);
+ mStatsManager.setDuration(ProcessStatsBase.sDurations[0]);
+ }
+ mStatsManager.refreshStats(true);
+ for (ProcStatsPackageEntry pkgEntry : mStatsManager.getEntries()) {
+ for (ProcStatsEntry entry : pkgEntry.mEntries) {
+ if (entry.mUid == mPackageInfo.applicationInfo.uid) {
+ pkgEntry.updateMetrics();
+ return pkgEntry;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(ProcStatsPackageEntry entry) {
+ if (getActivity() == null) {
+ return;
+ }
+ if (entry != null) {
+ mStats = entry;
+ mMemoryPreference.setEnabled(true);
+ double amount = Math.max(entry.mRunWeight, entry.mBgWeight)
+ * mStatsManager.getMemInfo().weightToRam;
+ mMemoryPreference.setSummary(getString(R.string.memory_use_summary,
+ Formatter.formatShortFileSize(getContext(), (long) amount)));
+ } else {
+ mMemoryPreference.setEnabled(false);
+ mMemoryPreference.setSummary(getString(R.string.no_memory_use_summary));
+ }
+ }
+
+ }
+
private class BatteryUpdater extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
@@ -787,6 +841,9 @@
@Override
protected void onPostExecute(Void result) {
+ if (getActivity() == null) {
+ return;
+ }
refreshUi();
}
}
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index fa95427..18a3f11 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -461,7 +461,7 @@
return;
}
HelpUtils.prepareHelpMenuItem(getActivity(), menu, mListType == LIST_TYPE_MAIN
- ? R.string.help_uri_apps : R.string.help_uri_notifications);
+ ? R.string.help_uri_apps : R.string.help_uri_notifications, getClass().getName());
mOptionsMenu = menu;
inflater.inflate(R.menu.manage_apps, menu);
updateOptionsMenu();
diff --git a/src/com/android/settings/applications/ProcessStatsBase.java b/src/com/android/settings/applications/ProcessStatsBase.java
index c2f96d2..b072ebe 100644
--- a/src/com/android/settings/applications/ProcessStatsBase.java
+++ b/src/com/android/settings/applications/ProcessStatsBase.java
@@ -18,14 +18,16 @@
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.android.internal.app.ProcessStats;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.ProcStatsData.MemInfo;
public abstract class ProcessStatsBase extends SettingsPreferenceFragment
implements OnItemSelectedListener {
@@ -124,4 +126,17 @@
}
public abstract void refreshUi();
+
+ public static void launchMemoryDetail(SettingsActivity activity, MemInfo memInfo,
+ ProcStatsPackageEntry entry) {
+ Bundle args = new Bundle();
+ args.putParcelable(ProcessStatsDetail.EXTRA_PACKAGE_ENTRY, entry);
+ args.putDouble(ProcessStatsDetail.EXTRA_WEIGHT_TO_RAM, memInfo.weightToRam);
+ args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, memInfo.memTotalTime);
+ args.putDouble(ProcessStatsDetail.EXTRA_MAX_MEMORY_USAGE,
+ memInfo.usedWeight * memInfo.weightToRam);
+ args.putDouble(ProcessStatsDetail.EXTRA_TOTAL_SCALE, memInfo.totalScale);
+ activity.startPreferencePanel(ProcessStatsDetail.class.getName(), args,
+ R.string.memory_usage, null, null, 0);
+ }
}
diff --git a/src/com/android/settings/applications/ProcessStatsDetail.java b/src/com/android/settings/applications/ProcessStatsDetail.java
index 1cf5ab4..2037113 100644
--- a/src/com/android/settings/applications/ProcessStatsDetail.java
+++ b/src/com/android/settings/applications/ProcessStatsDetail.java
@@ -74,6 +74,8 @@
private static final String KEY_FREQUENCY = "frequency";
private static final String KEY_MAX_USAGE = "max_usage";
+ private static final String KEY_PROCS = "processes";
+
private final ArrayMap<ComponentName, CancellablePreference> mServiceMap = new ArrayMap<>();
private PackageManager mPm;
@@ -92,6 +94,8 @@
private double mTotalScale;
+ private PreferenceCategory mProcGroup;
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -172,6 +176,7 @@
private void createDetails() {
addPreferencesFromResource(R.xml.app_memory_settings);
+ mProcGroup = (PreferenceCategory) findPreference(KEY_PROCS);
fillProcessesSection();
LayoutPreference headerLayout = (LayoutPreference) findPreference(KEY_DETAILS_HEADER);
@@ -227,6 +232,7 @@
};
private void fillProcessesSection() {
+ mProcGroup.removeAll();
final ArrayList<ProcStatsEntry> entries = new ArrayList<>();
for (int ie = 0; ie < mApp.mEntries.size(); ie++) {
ProcStatsEntry entry = mApp.mEntries.get(ie);
@@ -242,6 +248,7 @@
ProcStatsEntry entry = entries.get(ie);
Preference processPref = new Preference(getActivity());
processPref.setTitle(entry.mLabel);
+ processPref.setSelectable(false);
long duration = Math.max(entry.mRunDuration, entry.mBgDuration);
long memoryUse = Math.max((long) (entry.mRunWeight * mWeightToRam),
@@ -251,7 +258,10 @@
/ (float) mTotalTime, getActivity());
processPref.setSummary(
getString(R.string.memory_use_running_format, memoryString, frequency));
- getPreferenceScreen().addPreference(processPref);
+ mProcGroup.addPreference(processPref);
+ }
+ if (mProcGroup.getPreferenceCount() < 2) {
+ getPreferenceScreen().removePreference(mProcGroup);
}
}
diff --git a/src/com/android/settings/applications/ProcessStatsSummary.java b/src/com/android/settings/applications/ProcessStatsSummary.java
index 068cb43..87dc419 100644
--- a/src/com/android/settings/applications/ProcessStatsSummary.java
+++ b/src/com/android/settings/applications/ProcessStatsSummary.java
@@ -112,7 +112,8 @@
args.putBoolean(ARG_TRANSFER_STATS, true);
args.putInt(ARG_DURATION_INDEX, mDurationIndex);
mStatsManager.xferStats();
- startFragment(this, ProcessStatsUi.class.getName(), R.string.app_memory_use, 0, args);
+ startFragment(this, ProcessStatsUi.class.getName(), R.string.app_list_memory_use, 0,
+ args);
return true;
}
return false;
diff --git a/src/com/android/settings/applications/ProcessStatsUi.java b/src/com/android/settings/applications/ProcessStatsUi.java
index a4ecbdd..e2de91f 100644
--- a/src/com/android/settings/applications/ProcessStatsUi.java
+++ b/src/com/android/settings/applications/ProcessStatsUi.java
@@ -106,19 +106,9 @@
if (!(preference instanceof ProcessStatsPreference)) {
return false;
}
-
ProcessStatsPreference pgp = (ProcessStatsPreference) preference;
- Bundle args = new Bundle();
- args.putParcelable(ProcessStatsDetail.EXTRA_PACKAGE_ENTRY, pgp.getEntry());
MemInfo memInfo = mStatsManager.getMemInfo();
- args.putDouble(ProcessStatsDetail.EXTRA_WEIGHT_TO_RAM,
- memInfo.weightToRam);
- args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, memInfo.memTotalTime);
- args.putDouble(ProcessStatsDetail.EXTRA_MAX_MEMORY_USAGE,
- memInfo.usedWeight * memInfo.weightToRam);
- args.putDouble(ProcessStatsDetail.EXTRA_TOTAL_SCALE, memInfo.totalScale);
- ((SettingsActivity) getActivity()).startPreferencePanel(
- ProcessStatsDetail.class.getName(), args, R.string.details_title, null, null, 0);
+ launchMemoryDetail((SettingsActivity) getActivity(), memInfo, pgp.getEntry());
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@@ -153,6 +143,7 @@
return sb.toString();
}
+ @Override
public void refreshUi() {
mAppListGroup.removeAll();
mAppListGroup.setOrderingAsAdded(false);
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index 31aa0df..6408636 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -87,7 +87,8 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
- HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_uri_dashboard);
+ HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_uri_dashboard,
+ getClass().getName());
}
@Override
diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java
index 0c45cd9..a0ccb24 100644
--- a/src/com/android/settings/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/fingerprint/FingerprintSettings.java
@@ -542,7 +542,7 @@
@Override
public void onClick(View widget) {
Context ctx = widget.getContext();
- Intent intent = HelpUtils.getHelpIntent(ctx, getURL());
+ Intent intent = HelpUtils.getHelpIntent(ctx, getURL(), ctx.getClass().getName());
try {
ctx.startActivity(intent);
} catch (ActivityNotFoundException e) {
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 89a3325..3576ee2 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -135,7 +135,7 @@
String helpUrl;
if (!TextUtils.isEmpty(helpUrl = getResources().getString(R.string.help_url_battery))) {
final MenuItem help = menu.add(0, MENU_HELP, 0, R.string.help_label);
- HelpUtils.prepareHelpMenuItem(getActivity(), help, helpUrl);
+ HelpUtils.prepareHelpMenuItem(getActivity(), help, helpUrl, getClass().getName());
}
}
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java
index a907ea1..f1c8863 100644
--- a/src/com/android/settings/nfc/AndroidBeam.java
+++ b/src/com/android/settings/nfc/AndroidBeam.java
@@ -61,7 +61,8 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
- HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_uri_beam);
+ HelpUtils.prepareHelpMenuItem(getActivity(), menu, R.string.help_uri_beam,
+ getClass().getName());
}
@Override
diff --git a/src/com/android/settings/wifi/AccessPointPreference.java b/src/com/android/settings/wifi/AccessPointPreference.java
index 55d575e..35ef2ef 100644
--- a/src/com/android/settings/wifi/AccessPointPreference.java
+++ b/src/com/android/settings/wifi/AccessPointPreference.java
@@ -19,6 +19,7 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.net.wifi.WifiConfiguration;
+import android.os.Looper;
import android.os.UserHandle;
import android.preference.Preference;
import android.view.View;
@@ -38,9 +39,12 @@
private TextView mTitleView;
private TextView mSummaryView;
- private boolean showSummary = true;
+ private boolean mShowSummary = true;
private boolean mForSavedNetworks = false;
private AccessPoint mAccessPoint;
+ private Drawable mBadge;
+ private int mBadgePadding;
+ private int mLevel;
public AccessPointPreference(AccessPoint accessPoint, Context context,
boolean forSavedNetworks) {
@@ -48,6 +52,7 @@
mAccessPoint = accessPoint;
mForSavedNetworks = forSavedNetworks;
mAccessPoint.setTag(this);
+
refresh();
}
@@ -58,24 +63,29 @@
@Override
protected void onBindView(View view) {
super.onBindView(view);
- updateIcon(mAccessPoint.getLevel(), getContext());
+ Drawable drawable = getIcon();
+ if (drawable != null) {
+ drawable.setLevel(mLevel);
+ }
mTitleView = (TextView) view.findViewById(com.android.internal.R.id.title);
+ if (mTitleView != null) {
+ // Attach to the end of the title view
+ mTitleView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, mBadge, null);
+ mTitleView.setCompoundDrawablePadding(mBadgePadding);
+ }
mSummaryView = (TextView) view.findViewById(com.android.internal.R.id.summary);
- mSummaryView.setVisibility(showSummary ? View.VISIBLE : View.GONE);
+ mSummaryView.setVisibility(mShowSummary ? View.VISIBLE : View.GONE);
updateBadge(getContext());
- notifyChanged();
}
protected void updateIcon(int level, Context context) {
if (level == -1) {
setIcon(null);
} else {
- Drawable drawable = getIcon();
-
- if (drawable == null) {
+ if (getIcon() == null) {
// To avoid a drawing race condition, we first set the state (SECURE/NONE) and then
// set the icon (drawable) to that state's drawable.
StateListDrawable sld = (StateListDrawable) context.getTheme()
@@ -86,7 +96,7 @@
sld.setState((mAccessPoint.getSecurity() != AccessPoint.SECURITY_NONE)
? STATE_SECURED
: STATE_NONE);
- drawable = sld.getCurrent();
+ Drawable drawable = sld.getCurrent();
if (!mForSavedNetworks) {
setIcon(drawable);
} else {
@@ -94,57 +104,39 @@
}
}
}
-
- if (drawable != null) {
- drawable.setLevel(level);
- }
}
}
protected void updateBadge(Context context) {
- if (mTitleView != null) {
- WifiConfiguration config = mAccessPoint.getConfig();
- if (config == null) {
- return;
- }
+ WifiConfiguration config = mAccessPoint.getConfig();
+ if (config != null) {
// Fetch badge (may be null)
UserHandle creatorUser = new UserHandle(UserHandle.getUserId(config.creatorUid));
- Drawable badge =
- context.getPackageManager().getUserBadgeForDensity(creatorUser, 0 /* dpi */);
+ mBadge = context.getPackageManager().getUserBadgeForDensity(creatorUser, 0 /* dpi */);
// Distance from the end of the title at which this AP's user badge should sit.
- final int badgePadding = context.getResources()
+ mBadgePadding = context.getResources()
.getDimensionPixelSize(R.dimen.wifi_preference_badge_padding);
-
- // Attach to the end of the title view
- mTitleView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, badge, null);
- mTitleView.setCompoundDrawablePadding(badgePadding);
}
}
/**
- * Shows or Hides the Summary of an AccessPoint.
- *
- * @param showSummary true will show the summary, false will hide the summary
- */
- public void setShowSummary(boolean showSummary) {
- this.showSummary = showSummary;
- if (mSummaryView != null) {
- mSummaryView.setVisibility(showSummary ? View.VISIBLE : View.GONE);
- } // otherwise, will be handled in onBindView.
- }
-
- /**
* Updates the title and summary; may indirectly call notifyChanged().
*/
public void refresh() {
- if (mForSavedNetworks)
+ if (mForSavedNetworks) {
setTitle(mAccessPoint.getConfigName());
- else
+ } else {
setTitle(mAccessPoint.getSsid());
+ }
final Context context = getContext();
- updateIcon(mAccessPoint.getLevel(), context);
+ int level = mAccessPoint.getLevel();
+ if (level != mLevel) {
+ updateIcon(mLevel, context);
+ mLevel = level;
+ notifyChanged();
+ }
updateBadge(context);
// Force new summary
@@ -153,16 +145,40 @@
String summary = mForSavedNetworks ? mAccessPoint.getSavedNetworkSummary()
: mAccessPoint.getSettingsSummary();
- if (summary.length() > 0) {
+ boolean showSummary = summary.length() > 0;
+ if (showSummary) {
setSummary(summary);
- setShowSummary(true);
+ }
+ if (showSummary != mShowSummary) {
+ mShowSummary = showSummary;
+ notifyChanged();
+ }
+ }
+
+ @Override
+ protected void notifyChanged() {
+ if (Looper.getMainLooper() != Looper.myLooper()) {
+ // Let our BG thread callbacks call setTitle/setSummary.
+ postNotifyChanged();
} else {
- setShowSummary(false);
+ super.notifyChanged();
}
}
public void onLevelChanged() {
- notifyChanged();
+ postNotifyChanged();
}
+ private void postNotifyChanged() {
+ if (mTitleView != null) {
+ mTitleView.post(mNotifyChanged);
+ } // Otherwise we haven't been bound yet, and don't need to update.
+ }
+
+ private final Runnable mNotifyChanged = new Runnable() {
+ @Override
+ public void run() {
+ notifyChanged();
+ }
+ };
}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 916af01..3b5c58d 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -679,10 +679,7 @@
mEapIdentityView.setText(enterpriseConfig.getIdentity());
mEapAnonymousView.setText(enterpriseConfig.getAnonymousIdentity());
} else {
- // Choose a default for a new network and show only appropriate
- // fields
- mEapMethodSpinner.setSelection(Eap.PEAP);
- showEapFieldsByMethod(Eap.PEAP);
+ showEapFieldsByMethod(mEapMethodSpinner.getSelectedItemPosition());
}
} else {
showEapFieldsByMethod(mEapMethodSpinner.getSelectedItemPosition());
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 97612a9..0dee191 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -41,6 +41,8 @@
import android.net.wifi.WpsInfo;
import android.nfc.NfcAdapter;
import android.os.Bundle;
+import android.os.HandlerThread;
+import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
@@ -150,6 +152,8 @@
private WifiTracker mWifiTracker;
private String mOpenSsid;
+ private HandlerThread mBgThread;
+
/* End of "used in Wifi Setup context" */
public WifiSettings() {
@@ -166,10 +170,24 @@
}
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ mBgThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND);
+ mBgThread.start();
+ }
+
+ @Override
+ public void onDestroy() {
+ mBgThread.quit();
+ super.onDestroy();
+ }
+
+ @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- mWifiTracker = new WifiTracker(getActivity(), this, true, true, false);
+ mWifiTracker =
+ new WifiTracker(getActivity(), this, mBgThread.getLooper(), true, true, false);
mWifiManager = mWifiTracker.getManager();
mConnectListener = new WifiManager.ActionListener() {