summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hillenbrand <codeworkx@cyanogenmod.org>2013-02-08 06:06:18 -0800
committerGerrit Code Review <gerrit@review.cyanogenmod.com>2013-02-08 06:06:18 -0800
commit91c91511c9c3b92e4b3e9b4a66cd03786f267cab (patch)
tree336425a80777b2add57c8321f978812a2c490d65
parentbca85064a57eb20ace6dd073bbe627fcd02fe90d (diff)
parent61ce07c6fabfd53b1a2ee453837ea188fda9d0fe (diff)
downloadframeworks_opt_telephony-91c91511c9c3b92e4b3e9b4a66cd03786f267cab.zip
frameworks_opt_telephony-91c91511c9c3b92e4b3e9b4a66cd03786f267cab.tar.gz
frameworks_opt_telephony-91c91511c9c3b92e4b3e9b4a66cd03786f267cab.tar.bz2
Merge "Update the SMS sending limit instantly (1/2)" into cm-10.1
-rw-r--r--src/java/com/android/internal/telephony/SmsUsageMonitor.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/java/com/android/internal/telephony/SmsUsageMonitor.java b/src/java/com/android/internal/telephony/SmsUsageMonitor.java
index 0032881..5490c13 100644
--- a/src/java/com/android/internal/telephony/SmsUsageMonitor.java
+++ b/src/java/com/android/internal/telephony/SmsUsageMonitor.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.XmlResourceParser;
import android.database.ContentObserver;
+import android.net.Uri;
import android.os.Binder;
import android.os.Handler;
import android.os.Message;
@@ -111,7 +112,7 @@ public class SmsUsageMonitor {
public static final int PREMIUM_SMS_PERMISSION_ALWAYS_ALLOW = 3;
private final int mCheckPeriod;
- private final int mMaxAllowed;
+ private int mMaxAllowed;
private final HashMap<String, ArrayList<Long>> mSmsStamp =
new HashMap<String, ArrayList<Long>>();
@@ -228,30 +229,32 @@ public class SmsUsageMonitor {
/**
* Observe the secure setting for enable flag
*/
- private static class SettingsObserver extends ContentObserver {
- private final Context mContext;
- private final AtomicBoolean mEnabled;
+ private class SettingsObserver extends ContentObserver {
- SettingsObserver(Handler handler, Context context, AtomicBoolean enabled) {
+ SettingsObserver(Handler handler) {
super(handler);
- mContext = context;
- mEnabled = enabled;
- onChange(false);
}
@Override
- public void onChange(boolean selfChange) {
- mEnabled.set(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.SMS_SHORT_CODE_CONFIRMATION, 1) != 0);
+ public void onChange(boolean selfChange, Uri uri) {
+ if (uri.equals(Settings.Global.getUriFor(Settings.Global.SMS_SHORT_CODE_CONFIRMATION))) {
+ mCheckEnabled.set(Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.SMS_SHORT_CODE_CONFIRMATION, 1) != 0);
+ } else if (uri.equals(Settings.Global.getUriFor(Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT))) {
+ mMaxAllowed = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT, DEFAULT_SMS_MAX_COUNT);
+ }
}
}
- private static class SettingsObserverHandler extends Handler {
- SettingsObserverHandler(Context context, AtomicBoolean enabled) {
+ private class SettingsObserverHandler extends Handler {
+ SettingsObserverHandler(Context context) {
ContentResolver resolver = context.getContentResolver();
- ContentObserver globalObserver = new SettingsObserver(this, context, enabled);
+ ContentObserver globalObserver = new SettingsObserver(this);
resolver.registerContentObserver(Settings.Global.getUriFor(
Settings.Global.SMS_SHORT_CODE_CONFIRMATION), false, globalObserver);
+ resolver.registerContentObserver(Settings.Global.getUriFor(
+ Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT), false, globalObserver);
}
}
@@ -271,7 +274,10 @@ public class SmsUsageMonitor {
Settings.Global.SMS_OUTGOING_CHECK_INTERVAL_MS,
DEFAULT_SMS_CHECK_PERIOD);
- mSettingsObserverHandler = new SettingsObserverHandler(mContext, mCheckEnabled);
+ mCheckEnabled.set(Settings.Global.getInt(resolver,
+ Settings.Global.SMS_SHORT_CODE_CONFIRMATION, 1) != 0);
+
+ mSettingsObserverHandler = new SettingsObserverHandler(mContext);
loadPremiumSmsPolicyDb();
}