Loading src/java/com/android/internal/telephony/SmsUsageMonitor.java +12 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import android.app.role.RoleManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.ContentResolver; import android.content.Context; Loading Loading @@ -51,6 +52,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; Loading Loading @@ -125,6 +127,8 @@ public class SmsUsageMonitor { /** Last modified time for pattern file */ private long mPatternFileLastModified = 0; private RoleManager mRoleManager; /** Directory for per-app SMS permission XML file. */ private static final String SMS_POLICY_FILE_DIRECTORY = "/data/misc/sms"; Loading Loading @@ -248,6 +252,7 @@ public class SmsUsageMonitor { public SmsUsageMonitor(Context context) { mContext = context; ContentResolver resolver = context.getContentResolver(); mRoleManager = (RoleManager) mContext.getSystemService(Context.ROLE_SERVICE); mMaxAllowed = Settings.Global.getInt(resolver, Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT, Loading Loading @@ -345,7 +350,7 @@ public class SmsUsageMonitor { /** * Check to see if an application is allowed to send new SMS messages, and confirm with * user if the send limit was reached or if a non-system app is potentially sending to a * premium SMS short code or number. * premium SMS short code or number. If the app is the default SMS app, there's no send limit. * * @param appName the package name of the app requesting to send an SMS * @param smsWaiting the number of new messages desired to send Loading @@ -363,9 +368,14 @@ public class SmsUsageMonitor { mSmsStamp.put(appName, sentList); } List<String> defaultApp = mRoleManager.getRoleHolders(RoleManager.ROLE_SMS); if (defaultApp.contains(appName)) { return true; } else { return isUnderLimit(sentList, smsWaiting); } } } /** * Check if the destination is a possible premium short code. Loading Loading
src/java/com/android/internal/telephony/SmsUsageMonitor.java +12 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import android.app.role.RoleManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.ContentResolver; import android.content.Context; Loading Loading @@ -51,6 +52,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; Loading Loading @@ -125,6 +127,8 @@ public class SmsUsageMonitor { /** Last modified time for pattern file */ private long mPatternFileLastModified = 0; private RoleManager mRoleManager; /** Directory for per-app SMS permission XML file. */ private static final String SMS_POLICY_FILE_DIRECTORY = "/data/misc/sms"; Loading Loading @@ -248,6 +252,7 @@ public class SmsUsageMonitor { public SmsUsageMonitor(Context context) { mContext = context; ContentResolver resolver = context.getContentResolver(); mRoleManager = (RoleManager) mContext.getSystemService(Context.ROLE_SERVICE); mMaxAllowed = Settings.Global.getInt(resolver, Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT, Loading Loading @@ -345,7 +350,7 @@ public class SmsUsageMonitor { /** * Check to see if an application is allowed to send new SMS messages, and confirm with * user if the send limit was reached or if a non-system app is potentially sending to a * premium SMS short code or number. * premium SMS short code or number. If the app is the default SMS app, there's no send limit. * * @param appName the package name of the app requesting to send an SMS * @param smsWaiting the number of new messages desired to send Loading @@ -363,9 +368,14 @@ public class SmsUsageMonitor { mSmsStamp.put(appName, sentList); } List<String> defaultApp = mRoleManager.getRoleHolders(RoleManager.ROLE_SMS); if (defaultApp.contains(appName)) { return true; } else { return isUnderLimit(sentList, smsWaiting); } } } /** * Check if the destination is a possible premium short code. Loading