From 6995fee9aa2b92f2707df7e83dfb19559af35b79 Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Thu, 14 May 2015 14:20:45 -0700 Subject: [PATCH 1/5] Fix bug #21025020 Stability: JCs in Settings: Caused by: java.lang.NullPointerException - prevent the NPE Change-Id: Ief5a618e789e50eebcaa4386bd9ecec2192b4565 --- .../settings/applications/InstalledAppDetails.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index 5b510ebc2ed..c3645853ac4 100755 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -284,12 +284,15 @@ public class InstalledAppDetails extends AppInfoBase mBatteryPreference.setOnPreferenceClickListener(this); mLaunchPreference = findPreference(KEY_LAUNCH); - if ((mAppEntry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0) { - mLaunchPreference.setEnabled(false); - } else if (!mAppEntry.info.enabled) { - mLaunchPreference.setEnabled(false); + if (mAppEntry.info != null) { + if ((mAppEntry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0 || + !mAppEntry.info.enabled) { + mLaunchPreference.setEnabled(false); + } else { + mLaunchPreference.setOnPreferenceClickListener(this); + } } else { - mLaunchPreference.setOnPreferenceClickListener(this); + mLaunchPreference.setEnabled(false); } } From c3fb482ffe7afa224aa01d7990d27dbe5a4ed514 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 13 May 2015 14:14:05 -0700 Subject: [PATCH 2/5] Fix crash when removing fingerprint Also fix a strings in fingerprint enrollment. Bug: 21030545 Change-Id: I2d250b51a01f02bee014d4bc8e192d11199113e3 --- res/values/strings.xml | 4 ++-- src/com/android/settings/fingerprint/FingerprintSettings.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 6e8fba43902..0ffaf582549 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -761,7 +761,7 @@ To use your fingerprint to unlock your screen or confirm purchases, you\u2019ll need to: - Setup your backup screen lock method + Set up your backup screen lock method Add your fingerprint @@ -791,7 +791,7 @@ Whenever you see this icon, you can use your fingerprint for identification or to authorize a purchase. - Setup screen lock + Set up screen lock Done diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java index 5a69147236b..56f3ff6b35a 100644 --- a/src/com/android/settings/fingerprint/FingerprintSettings.java +++ b/src/com/android/settings/fingerprint/FingerprintSettings.java @@ -259,9 +259,9 @@ public class FingerprintSettings extends SubSettings { protected void removeFingerprintPreference(int fingerprintId) { String name = genKey(fingerprintId); - Preference prefToRemove = mManageCategory.findPreference(name); + Preference prefToRemove = findPreference(name); if (prefToRemove != null) { - if (!mManageCategory.removePreference(prefToRemove)) { + if (!getPreferenceScreen().removePreference(prefToRemove)) { Log.w(TAG, "Failed to remove preference with key " + name); } } else { From 874c97a35cb7f771791351c9d398641a10bfe6b3 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Fri, 15 May 2015 11:35:45 -0400 Subject: [PATCH 3/5] Banish the memory page to Apps > Advanced Bug: 21129029 Change-Id: I5ea6c88505e553a4340e9c60377952af7e802a44 --- res/xml/advanced_apps.xml | 4 ++++ res/xml/dashboard_categories.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/res/xml/advanced_apps.xml b/res/xml/advanced_apps.xml index 1bb9c586719..323dca19b02 100644 --- a/res/xml/advanced_apps.xml +++ b/res/xml/advanced_apps.xml @@ -50,4 +50,8 @@ android:value="com.android.settings.Settings$HighPowerApplicationsActivity" /> + + diff --git a/res/xml/dashboard_categories.xml b/res/xml/dashboard_categories.xml index cdc1166fa89..14a4db62316 100644 --- a/res/xml/dashboard_categories.xml +++ b/res/xml/dashboard_categories.xml @@ -134,13 +134,13 @@ android:icon="@drawable/ic_settings_multiuser" /> - + Date: Fri, 15 May 2015 13:05:46 -0400 Subject: [PATCH 4/5] Try not to crash while AppInfo is finishing Bug: 21025020 Change-Id: Iebb9e6b24ca503f87b5648f0aaf02dde01903488 --- src/com/android/settings/applications/AppInfoBase.java | 4 ++++ .../settings/applications/InstalledAppDetails.java | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/applications/AppInfoBase.java b/src/com/android/settings/applications/AppInfoBase.java index 442b1d8bff2..ef90fd96aa8 100644 --- a/src/com/android/settings/applications/AppInfoBase.java +++ b/src/com/android/settings/applications/AppInfoBase.java @@ -69,9 +69,12 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment // Dialog identifiers used in showDialog protected static final int DLG_BASE = 0; + protected boolean mFinishing; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + mFinishing = false; mState = ApplicationsState.getInstance(getActivity().getApplication()); mSession = mState.newSession(this); @@ -147,6 +150,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment intent.putExtra(ManageApplications.APP_CHG, appChanged); SettingsActivity sa = (SettingsActivity)getActivity(); sa.finishPreferencePanel(this, Activity.RESULT_OK, intent); + mFinishing = true; } protected void showDialogInner(int id, int moveErrorCode) { diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index c3645853ac4..4eb86a90791 100755 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -244,14 +244,15 @@ public class InstalledAppDetails extends AppInfoBase @Override public void onResume() { super.onResume(); + if (mFinishing) { + return; + } AppItem app = new AppItem(mAppEntry.info.uid); app.addUid(mAppEntry.info.uid); getLoaderManager().restartLoader(LOADER_CHART_DATA, ChartDataLoader.buildArgs(getTemplate(getContext()), app), mDataCallbacks); - if (mPackageInfo != null) { - new BatteryUpdater().execute(); - } + new BatteryUpdater().execute(); } @Override @@ -269,6 +270,9 @@ public class InstalledAppDetails extends AppInfoBase public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + if (mFinishing) { + return; + } handleHeader(); mNotificationPreference = findPreference(KEY_NOTIFICATION); From bc38a9a0ab57be09d9159489d8802250abd7a6e6 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Mon, 18 May 2015 17:36:50 -0700 Subject: [PATCH 5/5] Add setting to disable assist data (2/2). Bug: 20944446 Change-Id: I3c518176cab88ce9b5031a0241bee30240e6f896 --- res/layout/manage_assist_footer.xml | 31 ++++++++ res/values/strings.xml | 14 ++++ res/xml/default_apps.xml | 6 ++ res/xml/manage_assist.xml | 27 +++++++ .../settings/applications/ManageAssist.java | 76 +++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 res/layout/manage_assist_footer.xml create mode 100644 res/xml/manage_assist.xml create mode 100644 src/com/android/settings/applications/ManageAssist.java diff --git a/res/layout/manage_assist_footer.xml b/res/layout/manage_assist_footer.xml new file mode 100644 index 00000000000..8e10d62f988 --- /dev/null +++ b/res/layout/manage_assist_footer.xml @@ -0,0 +1,31 @@ + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 3bea360617f..e6c9bce641f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6508,6 +6508,12 @@ Default Apps + + Assist + + + No default Assist + Browser app @@ -6635,4 +6641,12 @@ Active. Touch to toggle. + + Use current context + + + When you open the assist app, let it see what you\'ve been doing on your screen + + + Assist apps help you identify and act on useful information without having to ask. Some apps support both launcher and voice input services to give you integrated assistance. diff --git a/res/xml/default_apps.xml b/res/xml/default_apps.xml index 7fc32fd4e67..ab65ac84ae1 100644 --- a/res/xml/default_apps.xml +++ b/res/xml/default_apps.xml @@ -19,6 +19,12 @@ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" android:key="default_apps"> + + + + + + + + diff --git a/src/com/android/settings/applications/ManageAssist.java b/src/com/android/settings/applications/ManageAssist.java new file mode 100644 index 00000000000..e222e1ca454 --- /dev/null +++ b/src/com/android/settings/applications/ManageAssist.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2015 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.applications; + +import android.annotation.Nullable; +import android.os.Bundle; +import android.preference.Preference; +import android.preference.SwitchPreference; +import android.provider.Settings; +import android.text.method.LinkMovementMethod; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import com.android.internal.logging.MetricsLogger; +import com.android.settings.InstrumentedFragment; +import com.android.settings.R; +import com.android.settings.SettingsPreferenceFragment; + +/** + * Settings screen to manage everything about assist. + */ +public class ManageAssist extends SettingsPreferenceFragment + implements Preference.OnPreferenceChangeListener { + + private static final String KEY_CONTEXT = "context"; + + private SwitchPreference mContextPref; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + addPreferencesFromResource(R.xml.manage_assist); + mContextPref = (SwitchPreference) findPreference(KEY_CONTEXT); + mContextPref.setChecked(Settings.Secure.getInt(getContentResolver(), + Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1) != 0); + mContextPref.setOnPreferenceChangeListener(this); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + TextView v = (TextView) LayoutInflater.from(view.getContext()).inflate( + R.layout.manage_assist_footer, null); + getListView().addFooterView(v); + } + + @Override + protected int getMetricsCategory() { + return MetricsLogger.APPLICATIONS_MANAGE_ASSIST; + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + if (preference == mContextPref) { + Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED, + (boolean) newValue ? 1 : 0); + return true; + } + return false; + } +}