diff options
author | Adnan <adnan@cyngn.com> | 2014-12-08 10:39:37 -0800 |
---|---|---|
committer | Casey Kelso <ckelso@cyngn.com> | 2014-12-09 03:18:07 +0000 |
commit | 6ff09a47a5f29a4efc47c988fbd05b8dc16ac9ae (patch) | |
tree | cfbb91614afba050e36798da05e9ad6ec1783656 | |
parent | f135e2748c2f5af92240fadef51d12bae316443a (diff) | |
download | android_frameworks_opt_telephony-shipping/cm-11.0.tar.gz android_frameworks_opt_telephony-shipping/cm-11.0.tar.bz2 android_frameworks_opt_telephony-shipping/cm-11.0.zip |
Telephony: Always allow ignored sms packages for premium sms.cm-11.0-XNPH05Q-tomato-9828f8e9ccstable/cm-11.0-XNF8Yshipping/cm-11.0
Also clean up redundant code by creating a new method (resolvePackageName).
Change-Id: I14eafe2c1ae007c1a8d9c1270a832a2c92f3a04e
(cherry picked from commit 9e7b80a78a156b729e6fe92636494d900404d138)
-rw-r--r-- | src/java/com/android/internal/telephony/SMSDispatcher.java | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/java/com/android/internal/telephony/SMSDispatcher.java b/src/java/com/android/internal/telephony/SMSDispatcher.java index 3ae3de5e2..70aa7e97c 100644 --- a/src/java/com/android/internal/telephony/SMSDispatcher.java +++ b/src/java/com/android/internal/telephony/SMSDispatcher.java @@ -64,7 +64,9 @@ import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails; import com.android.internal.telephony.ImsSMSDispatcher; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; @@ -364,13 +366,7 @@ public abstract class SMSDispatcher extends Handler { if (ar.exception == null) { if (DBG) Rlog.d(TAG, "SMS send complete. Broadcasting intent: " + sentIntent); - String packageName = tracker.mAppInfo.applicationInfo.packageName; - // System UID maps to multiple packages. Try to narrow it - // down to an actual sender if possible - if (isSystemUid(mContext, packageName) && sentIntent != null && - sentIntent.getCreatorPackage() != null) { - packageName = sentIntent.getCreatorPackage(); - } + String packageName = resolvePackageName(tracker); if (SmsApplication.shouldWriteMessageForPackage( packageName, mContext)) { @@ -820,6 +816,15 @@ public abstract class SMSDispatcher extends Handler { * @return true if the destination is approved; false if user confirmation event was sent */ boolean checkDestination(SmsTracker tracker) { + List<String> ignorePackages = Arrays.asList( + mContext.getResources().getStringArray(R.array.config_ignored_sms_packages)); + + String packageName = resolvePackageName(tracker); + + if (ignorePackages.contains(packageName)) { + return true; + } + if (mContext.checkCallingOrSelfPermission(SEND_SMS_NO_CONFIRMATION_PERMISSION) == PackageManager.PERMISSION_GRANTED) { return true; // app is pre-approved to send to short codes @@ -923,6 +928,25 @@ public abstract class SMSDispatcher extends Handler { } /** + * Returns the package name from the original creator of the sms, even + * if the package is mapped with others in a specific UID (like System UID) + * + * @param tracker + * @return the package name that created the original sms + */ + private String resolvePackageName(SmsTracker tracker) { + PendingIntent sentIntent = tracker.mSentIntent; + String packageName = tracker.mAppInfo.applicationInfo.packageName; + // System UID maps to multiple packages. Try to narrow it + // down to an actual sender if possible + if (isSystemUid(mContext, packageName) && sentIntent != null && + sentIntent.getCreatorPackage() != null) { + packageName = sentIntent.getCreatorPackage(); + } + return packageName; + } + + /** * Post an alert when SMS needs confirmation due to excessive usage. * @param tracker an SmsTracker for the current message. */ |