Merge "Wifi p2p fix?" into nyc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3f8cbb9..357b138 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5985,9 +5985,6 @@
<!-- [CHAR LIMIT=180] Notification importance summary -->
<string name="show_silently_summary">Don\'t make sound, vibrate, or peek these notifications into view on the current screen.</string>
- <!-- Default Apps > Default notification assistant -->
- <string name="default_notification_assistant">Notification assistant</string>
-
<!-- Sound & notification > Advanced section: Title for managing notification listeners option. [CHAR LIMIT=30] -->
<string name="manage_notification_access_title">Notification access</string>
diff --git a/res/xml/advanced_apps.xml b/res/xml/advanced_apps.xml
index 99e81a6..99da745 100644
--- a/res/xml/advanced_apps.xml
+++ b/res/xml/advanced_apps.xml
@@ -66,11 +66,6 @@
android:title="@string/sms_application_title"
settings:keywords="@string/keywords_more_default_sms_app" />
- <com.android.settings.applications.DefaultNotificationAssistantPreference
- android:key="default_notification_asst_app"
- android:title="@string/default_notification_assistant" />
-
-
</PreferenceCategory>
<com.android.settings.WorkOnlyCategory
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index 4dde340..8847321 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -611,12 +611,26 @@
private void removeAllFingerprintTemplatesAndFinish() {
if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()
- && mFingerprintManager.getEnrolledFingerprints().size() > 0) {
+ && mFingerprintManager.hasEnrolledFingerprints(mUserId)) {
+ mFingerprintManager.setActiveUser(mUserId);
mFingerprintManager.remove(
- new Fingerprint(null, 0, 0, 0), mUserId, mRemovalCallback);
- } else {
- finish();
+ new Fingerprint(null, mUserId, 0, 0), mUserId,
+ new RemovalCallback() {
+ @Override
+ public void onRemovalError(Fingerprint fp, int errMsgId,
+ CharSequence errString) {
+ mRemovalCallback.onRemovalError(fp, errMsgId, errString);
+ mFingerprintManager.setActiveUser(UserHandle.myUserId());
+ }
+
+ @Override
+ public void onRemovalSucceeded(Fingerprint fingerprint) {
+ mRemovalCallback.onRemovalSucceeded(fingerprint);
+ mFingerprintManager.setActiveUser(UserHandle.myUserId());
+ }
+ });
}
+ finish();
}
@Override
@@ -636,7 +650,7 @@
}
private int getResIdForFactoryResetProtectionWarningMessage() {
- boolean hasFingerprints = mFingerprintManager.hasEnrolledFingerprints();
+ boolean hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(mUserId);
boolean isProfile = Utils.isManagedProfile(UserManager.get(getActivity()), mUserId);
switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 8966974..eb781e4 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -702,7 +702,12 @@
dialog.show(getChildFragmentManager(), TAG_UNIFICATION_DIALOG);
} else {
mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, true);
- createPreferenceHierarchy();
+ Bundle extras = new Bundle();
+ extras.putInt(Intent.EXTRA_USER_ID, mProfileChallengeUserId);
+ startFragment(this,
+ "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
+ R.string.lock_settings_picker_title_profile,
+ SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE, extras);
}
} else if (KEY_SHOW_PASSWORD.equals(key)) {
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
diff --git a/src/com/android/settings/applications/DefaultNotificationAssistantPreference.java b/src/com/android/settings/applications/DefaultNotificationAssistantPreference.java
deleted file mode 100644
index 53fc391..0000000
--- a/src/com/android/settings/applications/DefaultNotificationAssistantPreference.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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.app.ActivityManager;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-import android.provider.Settings;
-import android.service.notification.NotificationAssistantService;
-import android.util.AttributeSet;
-import android.util.Slog;
-import com.android.settings.AppListPreference;
-import com.android.settings.R;
-import com.android.settings.notification.ManagedServiceSettings;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DefaultNotificationAssistantPreference extends AppListPreference {
- private static final String TAG = "DefaultNotiAssist";
-
- private PackageManager mPm;
- private final ManagedServiceSettings.Config mConfig;
- private final Context mContext;
-
- public DefaultNotificationAssistantPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- mContext = context;
- mPm = context.getPackageManager();
- mConfig = getConfig();
- setShowItemNone(true);
- updateList(getServices());
- }
-
- @Override
- protected boolean persistString(String value) {
- Settings.Secure.putString(mContext.getContentResolver(), mConfig.setting, value);
- setSummary(getEntry());
- return true;
- }
-
- private void updateList(List<ServiceInfo> services) {
- final ComponentName[] assistants = new ComponentName[services.size()];
- for (int i = 0; i < services.size(); i++) {
- assistants[i] = new ComponentName(services.get(i).packageName, services.get(i).name);
- }
- final String assistant =
- Settings.Secure.getString(mContext.getContentResolver(), mConfig.setting);
- setComponentNames(assistants, assistant == null ? null
- : ComponentName.unflattenFromString(assistant));
- }
-
- private List<ServiceInfo> getServices() {
- List<ServiceInfo> services = new ArrayList<>();
- final int user = ActivityManager.getCurrentUser();
-
- List<ResolveInfo> installedServices = mPm.queryIntentServicesAsUser(
- new Intent(mConfig.intentAction),
- PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
- user);
-
- for (int i = 0, count = installedServices.size(); i < count; i++) {
- ResolveInfo resolveInfo = installedServices.get(i);
- ServiceInfo info = resolveInfo.serviceInfo;
-
- if (!mConfig.permission.equals(info.permission)) {
- Slog.w(mConfig.tag, "Skipping " + mConfig.noun + " service "
- + info.packageName + "/" + info.name
- + ": it does not require the permission "
- + mConfig.permission);
- continue;
- }
- services.add(info);
- }
- return services;
- }
-
- private ManagedServiceSettings.Config getConfig() {
- final ManagedServiceSettings.Config c = new ManagedServiceSettings.Config();
- c.tag = TAG;
- c.setting = Settings.Secure.ENABLED_NOTIFICATION_ASSISTANT;
- c.intentAction = NotificationAssistantService.SERVICE_INTERFACE;
- c.permission = android.Manifest.permission.BIND_NOTIFICATION_ASSISTANT_SERVICE;
- c.noun = "notification assistant";
- c.warningDialogTitle = R.string.notification_listener_security_warning_title;
- c.warningDialogSummary = R.string.notification_listener_security_warning_summary;
- c.emptyText = R.string.no_notification_listeners;
- return c;
- }
-}
diff --git a/src/com/android/settings/dashboard/SuggestionsChecks.java b/src/com/android/settings/dashboard/SuggestionsChecks.java
index 7d617b7..3ea815c 100644
--- a/src/com/android/settings/dashboard/SuggestionsChecks.java
+++ b/src/com/android/settings/dashboard/SuggestionsChecks.java
@@ -37,7 +37,7 @@
import com.android.settings.Settings.ZenModeAutomationSuggestionActivity;
import com.android.settingslib.drawer.Tile;
-import java.util.List;
+import java.util.Collection;
/**
* The Home of all stupidly dynamic Settings Suggestions checks.
@@ -86,10 +86,10 @@
}
private boolean hasEnabledZenAutoRules() {
- List<AutomaticZenRule> zenRules = NotificationManager.from(mContext).getAutomaticZenRules();
- final int N = zenRules.size();
- for (int i = 0; i < N; i++) {
- if (zenRules.get(i).isEnabled()) {
+ Collection<AutomaticZenRule> zenRules =
+ NotificationManager.from(mContext).getAutomaticZenRules().values();
+ for (AutomaticZenRule rule : zenRules) {
+ if (rule.isEnabled()) {
return true;
}
}
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index b871848..75acdc3 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -87,7 +87,7 @@
}
};
- private NotificationListenerService mListener = new NotificationListenerService() {
+ private final NotificationListenerService mListener = new NotificationListenerService() {
@Override
public void onNotificationPosted(StatusBarNotification sbn, RankingMap ranking) {
logd("onNotificationPosted: %s", sbn.getNotification());
@@ -135,22 +135,16 @@
mPm = mContext.getPackageManager();
mNoMan = INotificationManager.Stub.asInterface(
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
- try {
- mListener.registerAsSystemService(mContext, new ComponentName(mContext.getPackageName(),
- this.getClass().getCanonicalName()), ActivityManager.getCurrentUser());
- } catch (RemoteException e) {
- Log.e(TAG, "Cannot register listener", e);
- }
}
@Override
- public void onDetach() {
+ public void onPause() {
try {
mListener.unregisterAsSystemService();
} catch (RemoteException e) {
Log.e(TAG, "Cannot unregister listener", e);
}
- super.onDetach();
+ super.onPause();
}
@Override
@@ -171,6 +165,12 @@
public void onResume() {
logd("onResume()");
super.onResume();
+ try {
+ mListener.registerAsSystemService(mContext, new ComponentName(mContext.getPackageName(),
+ this.getClass().getCanonicalName()), ActivityManager.getCurrentUser());
+ } catch (RemoteException e) {
+ Log.e(TAG, "Cannot register listener", e);
+ }
refreshList();
}
@@ -205,17 +205,17 @@
}
private static String getTitleString(Notification n) {
- String title = null;
+ CharSequence title = null;
if (n.extras != null) {
- title = n.extras.getString(Notification.EXTRA_TITLE);
+ title = n.extras.getCharSequence(Notification.EXTRA_TITLE);
if (TextUtils.isEmpty(title)) {
- title = n.extras.getString(Notification.EXTRA_TEXT);
+ title = n.extras.getCharSequence(Notification.EXTRA_TEXT);
}
}
if (TextUtils.isEmpty(title) && !TextUtils.isEmpty(n.tickerText)) {
- title = n.tickerText.toString();
+ title = n.tickerText;
}
- return title;
+ return String.valueOf(title);
}
private static String formatPendingIntent(PendingIntent pi) {
diff --git a/src/com/android/settings/notification/ZenModeAutomationSettings.java b/src/com/android/settings/notification/ZenModeAutomationSettings.java
index df19c60..f1546aa 100644
--- a/src/com/android/settings/notification/ZenModeAutomationSettings.java
+++ b/src/com/android/settings/notification/ZenModeAutomationSettings.java
@@ -46,7 +46,9 @@
import java.lang.ref.WeakReference;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Comparator;
+import java.util.Map;
public class ZenModeAutomationSettings extends ZenModeSettingsBase {
@@ -111,15 +113,15 @@
AutomaticZenRule rule = new AutomaticZenRule(ruleName, ri.serviceComponent,
ri.defaultConditionId, NotificationManager.INTERRUPTION_FILTER_PRIORITY,
true);
- AutomaticZenRule savedRule = addZenRule(rule);
- if (savedRule != null) {
- startActivity(getRuleIntent(ri.settingsAction, null, savedRule.getId()));
+ String savedRuleId = addZenRule(rule);
+ if (savedRuleId != null) {
+ startActivity(getRuleIntent(ri.settingsAction, null, savedRuleId));
}
}
}.show();
}
- private void showDeleteRuleDialog(final String ruleId, final String ruleName) {
+ private void showDeleteRuleDialog(final String ruleId, final CharSequence ruleName) {
new AlertDialog.Builder(mContext)
.setMessage(getString(R.string.zen_mode_delete_rule_confirmation, ruleName))
.setNegativeButton(R.string.cancel, null)
@@ -147,8 +149,9 @@
return intent;
}
- private AutomaticZenRule[] sortedRules() {
- final AutomaticZenRule[] rt = mRules.toArray(new AutomaticZenRule[mRules.size()]);
+ private Map.Entry<String,AutomaticZenRule>[] sortedRules() {
+ final Map.Entry<String,AutomaticZenRule>[] rt =
+ mRules.toArray(new Map.Entry[mRules.size()]);
Arrays.sort(rt, RULE_COMPARATOR);
return rt;
}
@@ -156,8 +159,8 @@
private void updateControls() {
final PreferenceScreen root = getPreferenceScreen();
root.removeAll();
- final AutomaticZenRule[] sortedRules = sortedRules();
- for (AutomaticZenRule sortedRule : sortedRules) {
+ final Map.Entry<String,AutomaticZenRule>[] sortedRules = sortedRules();
+ for (Map.Entry<String,AutomaticZenRule> sortedRule : sortedRules) {
ZenRulePreference pref = new ZenRulePreference(getPrefContext(), sortedRule);
if (pref.appExists) {
root.addPreference(pref);
@@ -247,15 +250,17 @@
return null;
}
- private static final Comparator<AutomaticZenRule> RULE_COMPARATOR =
- new Comparator<AutomaticZenRule>() {
+ private static final Comparator<Map.Entry<String,AutomaticZenRule>> RULE_COMPARATOR =
+ new Comparator<Map.Entry<String,AutomaticZenRule>>() {
@Override
- public int compare(AutomaticZenRule lhs, AutomaticZenRule rhs) {
- int byDate = Long.compare(lhs.getCreationTime(), rhs.getCreationTime());
+ public int compare(Map.Entry<String,AutomaticZenRule> lhs,
+ Map.Entry<String,AutomaticZenRule> rhs) {
+ int byDate = Long.compare(lhs.getValue().getCreationTime(),
+ rhs.getValue().getCreationTime());
if (byDate != 0) {
return byDate;
} else {
- return key(lhs).compareTo(key(rhs));
+ return key(lhs.getValue()).compareTo(key(rhs.getValue()));
}
}
@@ -263,20 +268,22 @@
final int type = ZenModeConfig.isValidScheduleConditionId(rule.getConditionId()) ? 1
: ZenModeConfig.isValidEventConditionId(rule.getConditionId()) ? 2
: 3;
- return type + rule.getName();
+ return type + rule.getName().toString();
}
};
private class ZenRulePreference extends Preference {
- final String mName;
+ final CharSequence mName;
final String mId;
final boolean appExists;
- public ZenRulePreference(Context context, final AutomaticZenRule rule) {
+ public ZenRulePreference(Context context,
+ final Map.Entry<String, AutomaticZenRule> ruleEntry) {
super(context);
+ final AutomaticZenRule rule = ruleEntry.getValue();
mName = rule.getName();
- mId = rule.getId();
+ mId = ruleEntry.getKey();
final boolean isSchedule = ZenModeConfig.isValidScheduleConditionId(
rule.getConditionId());
diff --git a/src/com/android/settings/notification/ZenModeRuleSettingsBase.java b/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
index 501a260..d251580 100644
--- a/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
+++ b/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
@@ -123,7 +123,7 @@
if (zenMode == mRule.getInterruptionFilter()) return false;
if (DEBUG) Log.d(TAG, "onPrefChange zenMode=" + zenMode);
mRule.setInterruptionFilter(zenMode);
- setZenRule(mRule);
+ setZenRule(mId, mRule);
return true;
}
});
@@ -166,7 +166,7 @@
MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ENABLE_RULE, enabled);
if (DEBUG) Log.d(TAG, "onSwitchChanged enabled=" + enabled);
mRule.setEnabled(enabled);
- setZenRule(mRule);
+ setZenRule(mId, mRule);
if (enabled) {
final int toastText = getEnabledToastText();
if (toastText != 0) {
@@ -182,7 +182,7 @@
protected void updateRule(Uri newConditionId) {
mRule.setConditionId(newConditionId);
- setZenRule(mRule);
+ setZenRule(mId, mRule);
}
@Override
@@ -219,7 +219,7 @@
@Override
public void onOk(String ruleName) {
mRule.setName(ruleName);
- setZenRule(mRule);
+ setZenRule(mId, mRule);
}
}.show();
}
@@ -243,7 +243,7 @@
public void onClick(DialogInterface dialog, int which) {
MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_DELETE_RULE_OK);
mDeleting = true;
- removeZenRule(mRule.getId());
+ removeZenRule(mId);
}
})
.show();
diff --git a/src/com/android/settings/notification/ZenModeSettingsBase.java b/src/com/android/settings/notification/ZenModeSettingsBase.java
index ec1426d..7864244 100644
--- a/src/com/android/settings/notification/ZenModeSettingsBase.java
+++ b/src/com/android/settings/notification/ZenModeSettingsBase.java
@@ -31,7 +31,10 @@
import com.android.settings.RestrictedSettingsFragment;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
abstract public class ZenModeSettingsBase extends RestrictedSettingsFragment {
protected static final String TAG = "ZenModeSettings";
@@ -41,7 +44,7 @@
private final SettingsObserver mSettingsObserver = new SettingsObserver();
protected Context mContext;
- protected List<AutomaticZenRule> mRules;
+ protected Set<Map.Entry<String, AutomaticZenRule>> mRules;
protected int mZenMode;
abstract protected void onZenModeChanged();
@@ -92,16 +95,17 @@
}
}
- protected AutomaticZenRule addZenRule(AutomaticZenRule rule) {
+ protected String addZenRule(AutomaticZenRule rule) {
+ String id = NotificationManager.from(mContext).addAutomaticZenRule(rule);
final AutomaticZenRule savedRule =
- NotificationManager.from(mContext).addAutomaticZenRule(rule);
+ NotificationManager.from(mContext).getAutomaticZenRule(id);
maybeRefreshRules(savedRule != null, true);
- return savedRule;
+ return id;
}
- protected boolean setZenRule(AutomaticZenRule rule) {
+ protected boolean setZenRule(String id, AutomaticZenRule rule) {
final boolean success =
- NotificationManager.from(mContext).updateAutomaticZenRule(rule);
+ NotificationManager.from(mContext).updateAutomaticZenRule(id, rule);
maybeRefreshRules(success, true);
return success;
}
@@ -127,8 +131,10 @@
NotificationManager.from(mContext).setZenMode(zenMode, conditionId, TAG);
}
- private List<AutomaticZenRule> getZenModeRules() {
- return NotificationManager.from(mContext).getAutomaticZenRules();
+ private Set<Map.Entry<String, AutomaticZenRule>> getZenModeRules() {
+ Map<String, AutomaticZenRule> ruleMap
+ = NotificationManager.from(mContext).getAutomaticZenRules();
+ return ruleMap.entrySet();
}
private final class SettingsObserver extends ContentObserver {
diff --git a/src/com/android/settings/notification/ZenRuleNameDialog.java b/src/com/android/settings/notification/ZenRuleNameDialog.java
index 2c0ee42..f69198b 100644
--- a/src/com/android/settings/notification/ZenRuleNameDialog.java
+++ b/src/com/android/settings/notification/ZenRuleNameDialog.java
@@ -31,10 +31,10 @@
private final AlertDialog mDialog;
private final EditText mEditText;
- private final String mOriginalRuleName;
+ private final CharSequence mOriginalRuleName;
private final boolean mIsNew;
- public ZenRuleNameDialog(Context context, String ruleName) {
+ public ZenRuleNameDialog(Context context, CharSequence ruleName) {
mIsNew = ruleName == null;
mOriginalRuleName = ruleName;
final View v = LayoutInflater.from(context).inflate(R.layout.zen_rule_name, null, false);
@@ -52,7 +52,7 @@
public void onClick(DialogInterface dialog, int which) {
final String newName = trimmedText();
if (!mIsNew && mOriginalRuleName != null
- && mOriginalRuleName.equalsIgnoreCase(newName)) {
+ && mOriginalRuleName.equals(newName)) {
return; // no change to an existing rule, just dismiss
}
onOk(newName);