From 03da2f00aac04e6565a02cf5a9bf6bb1ec926930 Mon Sep 17 00:00:00 2001 From: Tom Taylor Date: Mon, 7 Nov 2011 14:16:44 -0800 Subject: [PATCH] Add new secure setting for controlling Messaging notifications Bug 5552615 We're adding a new intent to allow 3rd party apps to disable the Messaging app's notification. We want any app to be able to query the setting of whether sms notifications are on or off, but only allow system apps, particularly the Messaging app, to change that setting. Other apps can change the setting by firing off an intent which brings up a dialog activity in the Messaging app that'll let them turn off Messaging notifications. Change-Id: I4d2721191b86010efb383a24c28d911496440657 --- api/current.txt | 1 + core/java/android/provider/Settings.java | 10 +++++++++- core/java/android/provider/Telephony.java | 10 ++++++++++ packages/SettingsProvider/res/values/defaults.xml | 4 ++++ .../com/android/providers/settings/DatabaseHelper.java | 4 ++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/api/current.txt b/api/current.txt index 4e41c29943a91..95072f7ceb12a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -17363,6 +17363,7 @@ package android.provider { field public static final java.lang.String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled"; field public static final java.lang.String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern"; field public static final deprecated java.lang.String LOGGING_ID = "logging_id"; + field public static final java.lang.String MESSAGING_APP_NOTIFICATIONS = "messaging_app_notifications"; field public static final java.lang.String NETWORK_PREFERENCE = "network_preference"; field public static final java.lang.String PARENTAL_CONTROL_ENABLED = "parental_control_enabled"; field public static final java.lang.String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update"; diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index a0652f7c20d02..63b3664a811cf 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4067,6 +4067,13 @@ public final class Settings { public static final String CONTACTS_PREAUTH_URI_EXPIRATION = "contacts_preauth_uri_expiration"; + /** + * Whether the Messaging app posts notifications. + * 0=disabled. 1=enabled. + */ + public static final String MESSAGING_APP_NOTIFICATIONS = "messaging_app_notifications"; + + /** * This are the settings to be backed up. * @@ -4104,7 +4111,8 @@ public final class Settings { MOUNT_UMS_NOTIFY_ENABLED, UI_NIGHT_MODE, LOCK_SCREEN_OWNER_INFO, - LOCK_SCREEN_OWNER_INFO_ENABLED + LOCK_SCREEN_OWNER_INFO_ENABLED, + MESSAGING_APP_NOTIFICATIONS }; /** diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 0e6d07d8dd18a..8eb9da13d3fd5 100755 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -1838,5 +1838,15 @@ public final class Telephony { public static final String EXTRA_PLMN = "plmn"; public static final String EXTRA_SHOW_SPN = "showSpn"; public static final String EXTRA_SPN = "spn"; + + /** + * Activity Action: Shows a dialog to turn off Messaging app notification. + *

Input: Nothing. + *

Output: Nothing. + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_MESSAGING_APP_NOTIFICATIONS = + "android.provider.Telephony.MESSAGING_APP_NOTIFICATIONS"; + } } diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index 3920257a7c433..03d5bd21e84d0 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -133,4 +133,8 @@ true true + + + true + diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 5495d0840477f..44194f033f484 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -1472,6 +1472,10 @@ public class DatabaseHelper extends SQLiteOpenHelper { loadBooleanSetting(stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED, R.bool.def_touch_exploration_enabled); + + loadBooleanSetting(stmt, Settings.Secure.MESSAGING_APP_NOTIFICATIONS, + R.bool.def_messaging_app_notifications_on); + } finally { if (stmt != null) stmt.close(); }