Loading src/java/com/android/internal/telephony/SmsApplication.java +75 −19 Original line number Diff line number Diff line Loading @@ -85,37 +85,42 @@ public final class SmsApplication { /** * The class name of the SMS_DELIVER_ACTION receiver in this app. */ public String mSmsReceiverClass; private String mSmsReceiverClass; /** * The class name of the WAP_PUSH_DELIVER_ACTION receiver in this app. */ public String mMmsReceiverClass; private String mMmsReceiverClass; /** * The class name of the ACTION_RESPOND_VIA_MESSAGE intent in this app. */ public String mRespondViaMessageClass; private String mRespondViaMessageClass; /** * The class name of the ACTION_SENDTO intent in this app. */ public String mSendToClass; private String mSendToClass; /** * The class name of the ACTION_DEFAULT_SMS_PACKAGE_CHANGED receiver in this app. */ public String mSmsAppChangedReceiverClass; private String mSmsAppChangedReceiverClass; /** * The class name of the ACTION_EXTERNAL_PROVIDER_CHANGE receiver in this app. */ public String mProviderChangedReceiverClass; private String mProviderChangedReceiverClass; /** * The class name of the SIM_FULL_ACTION receiver in this app. */ private String mSimFullReceiverClass; /** * The user-id for this application */ public int mUid; private int mUid; /** * Returns true if this SmsApplicationData is complete (all intents handled). Loading Loading @@ -151,14 +156,15 @@ public final class SmsApplication { @Override public String toString() { return " mPackageName: " + mPackageName + " mSmsReceiverClass: " + mSmsReceiverClass + " mMmsReceiverClass: " + mMmsReceiverClass + " mRespondViaMessageClass: " + mRespondViaMessageClass + " mSendToClass: " + mSendToClass + " mSmsAppChangedClass: " + mSmsAppChangedReceiverClass + " mProviderChangedReceiverClass: " + mProviderChangedReceiverClass + " mUid: " + mUid; return " mPackageName: " + mPackageName + " mSmsReceiverClass: " + mSmsReceiverClass + " mMmsReceiverClass: " + mMmsReceiverClass + " mRespondViaMessageClass: " + mRespondViaMessageClass + " mSendToClass: " + mSendToClass + " mSmsAppChangedClass: " + mSmsAppChangedReceiverClass + " mProviderChangedReceiverClass: " + mProviderChangedReceiverClass + " mSimFullReceiverClass: " + mSimFullReceiverClass + " mUid: " + mUid; } } Loading Loading @@ -300,8 +306,8 @@ public final class SmsApplication { // Update any existing entries with the default sms changed handler. intent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); List<ResolveInfo> smsAppChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); List<ResolveInfo> smsAppChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "getApplicationCollectionInternal smsAppChangedActivities=" + smsAppChangedReceivers); Loading @@ -325,8 +331,8 @@ public final class SmsApplication { // Update any existing entries with the external provider changed handler. intent = new Intent(Telephony.Sms.Intents.ACTION_EXTERNAL_PROVIDER_CHANGE); List<ResolveInfo> providerChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); List<ResolveInfo> providerChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "getApplicationCollectionInternal providerChangedActivities=" + providerChangedReceivers); Loading @@ -348,6 +354,31 @@ public final class SmsApplication { } } // Update any existing entries with the sim full handler. intent = new Intent(Intents.SIM_FULL_ACTION); List<ResolveInfo> simFullReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "getApplicationCollectionInternal simFullReceivers=" + simFullReceivers); } for (ResolveInfo resolveInfo : simFullReceivers) { final ActivityInfo activityInfo = resolveInfo.activityInfo; if (activityInfo == null) { continue; } final String packageName = activityInfo.packageName; final SmsApplicationData smsApplicationData = receivers.get(packageName); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "getApplicationCollectionInternal packageName=" + packageName + " smsApplicationData: " + smsApplicationData + " activityInfo.name: " + activityInfo.name); } if (smsApplicationData != null) { smsApplicationData.mSimFullReceiverClass = activityInfo.name; } } // Remove any entries for which we did not find all required intents. for (ResolveInfo resolveInfo : smsReceivers) { final ActivityInfo activityInfo = resolveInfo.activityInfo; Loading Loading @@ -883,6 +914,31 @@ public final class SmsApplication { } } /** * Gets the default application that handles sim full event. * @param context context from the calling app * @param updateIfNeeded update the default app if there is no valid default app configured. * @return component name of the app and class to deliver change intents to */ public static ComponentName getDefaultSimFullApplication( Context context, boolean updateIfNeeded) { int userId = getIncomingUserId(context); final long token = Binder.clearCallingIdentity(); try { ComponentName component = null; SmsApplicationData smsApplicationData = getApplication(context, updateIfNeeded, userId); if (smsApplicationData != null && smsApplicationData.mSimFullReceiverClass != null) { component = new ComponentName(smsApplicationData.mPackageName, smsApplicationData.mSimFullReceiverClass); } return component; } finally { Binder.restoreCallingIdentity(token); } } /** * Returns whether need to write the SMS message to SMS database for this package. * <p> Loading src/java/com/android/internal/telephony/SmsStorageMonitor.java +3 −2 Original line number Diff line number Diff line Loading @@ -137,12 +137,13 @@ public class SmsStorageMonitor extends Handler { } /** * Called when SIM_FULL message is received from the RIL. Notifies interested * parties that SIM storage for SMS messages is full. * Called when SIM_FULL message is received from the RIL. Notifies the default SMS application * that SIM storage for SMS messages is full. */ private void handleIccFull() { // broadcast SIM_FULL intent Intent intent = new Intent(Intents.SIM_FULL_ACTION); intent.setComponent(SmsApplication.getDefaultSimFullApplication(mContext, false)); mWakeLock.acquire(WAKE_LOCK_TIMEOUT); SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId()); mContext.sendBroadcast(intent, android.Manifest.permission.RECEIVE_SMS); Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +1 −3 Original line number Diff line number Diff line Loading @@ -43,13 +43,12 @@ import android.os.RegistrantList; import android.os.ServiceManager; import android.provider.BlockedNumberContract; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.test.mock.MockContentProvider; import android.test.mock.MockContentResolver; import android.util.Log; import android.util.Singleton; import android.util.SparseArray; import com.android.ims.ImsCall; import com.android.ims.ImsCallProfile; Loading @@ -61,7 +60,6 @@ import com.android.internal.telephony.dataconnection.DcTracker; import com.android.internal.telephony.imsphone.ImsExternalCallTracker; import com.android.internal.telephony.imsphone.ImsPhone; import com.android.internal.telephony.imsphone.ImsPhoneCallTracker; import com.android.internal.telephony.mocks.TelephonyRegistryMock; import com.android.internal.telephony.test.SimulatedCommands; import com.android.internal.telephony.test.SimulatedCommandsVerifier; import com.android.internal.telephony.uicc.IccCardProxy; Loading tests/telephonytests/src/com/android/internal/telephony/gsm/GsmCellBroadcastHandlerTest.java +9 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package com.android.internal.telephony.gsm; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import android.content.Intent; import android.os.HandlerThread; import android.provider.Telephony; Loading @@ -31,12 +37,6 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; public class GsmCellBroadcastHandlerTest extends TelephonyTest { @Mock private SmsStorageMonitor mSmsStorageMonitor; Loading Loading @@ -85,6 +85,9 @@ public class GsmCellBroadcastHandlerTest extends TelephonyTest { @Test @SmallTest public void testBroadcastSms() { mContextFixture.putResource( com.android.internal.R.string.config_defaultCellBroadcastReceiverComponent, "fake.cellbroadcastreceiver.component"); mSimulatedCommands.notifyGsmBroadcastSms(new byte[] { (byte)0xc0, //geographical scope (byte)0x01, //serial number Loading Loading
src/java/com/android/internal/telephony/SmsApplication.java +75 −19 Original line number Diff line number Diff line Loading @@ -85,37 +85,42 @@ public final class SmsApplication { /** * The class name of the SMS_DELIVER_ACTION receiver in this app. */ public String mSmsReceiverClass; private String mSmsReceiverClass; /** * The class name of the WAP_PUSH_DELIVER_ACTION receiver in this app. */ public String mMmsReceiverClass; private String mMmsReceiverClass; /** * The class name of the ACTION_RESPOND_VIA_MESSAGE intent in this app. */ public String mRespondViaMessageClass; private String mRespondViaMessageClass; /** * The class name of the ACTION_SENDTO intent in this app. */ public String mSendToClass; private String mSendToClass; /** * The class name of the ACTION_DEFAULT_SMS_PACKAGE_CHANGED receiver in this app. */ public String mSmsAppChangedReceiverClass; private String mSmsAppChangedReceiverClass; /** * The class name of the ACTION_EXTERNAL_PROVIDER_CHANGE receiver in this app. */ public String mProviderChangedReceiverClass; private String mProviderChangedReceiverClass; /** * The class name of the SIM_FULL_ACTION receiver in this app. */ private String mSimFullReceiverClass; /** * The user-id for this application */ public int mUid; private int mUid; /** * Returns true if this SmsApplicationData is complete (all intents handled). Loading Loading @@ -151,14 +156,15 @@ public final class SmsApplication { @Override public String toString() { return " mPackageName: " + mPackageName + " mSmsReceiverClass: " + mSmsReceiverClass + " mMmsReceiverClass: " + mMmsReceiverClass + " mRespondViaMessageClass: " + mRespondViaMessageClass + " mSendToClass: " + mSendToClass + " mSmsAppChangedClass: " + mSmsAppChangedReceiverClass + " mProviderChangedReceiverClass: " + mProviderChangedReceiverClass + " mUid: " + mUid; return " mPackageName: " + mPackageName + " mSmsReceiverClass: " + mSmsReceiverClass + " mMmsReceiverClass: " + mMmsReceiverClass + " mRespondViaMessageClass: " + mRespondViaMessageClass + " mSendToClass: " + mSendToClass + " mSmsAppChangedClass: " + mSmsAppChangedReceiverClass + " mProviderChangedReceiverClass: " + mProviderChangedReceiverClass + " mSimFullReceiverClass: " + mSimFullReceiverClass + " mUid: " + mUid; } } Loading Loading @@ -300,8 +306,8 @@ public final class SmsApplication { // Update any existing entries with the default sms changed handler. intent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); List<ResolveInfo> smsAppChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); List<ResolveInfo> smsAppChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "getApplicationCollectionInternal smsAppChangedActivities=" + smsAppChangedReceivers); Loading @@ -325,8 +331,8 @@ public final class SmsApplication { // Update any existing entries with the external provider changed handler. intent = new Intent(Telephony.Sms.Intents.ACTION_EXTERNAL_PROVIDER_CHANGE); List<ResolveInfo> providerChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); List<ResolveInfo> providerChangedReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "getApplicationCollectionInternal providerChangedActivities=" + providerChangedReceivers); Loading @@ -348,6 +354,31 @@ public final class SmsApplication { } } // Update any existing entries with the sim full handler. intent = new Intent(Intents.SIM_FULL_ACTION); List<ResolveInfo> simFullReceivers = packageManager.queryBroadcastReceiversAsUser(intent, 0, userId); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "getApplicationCollectionInternal simFullReceivers=" + simFullReceivers); } for (ResolveInfo resolveInfo : simFullReceivers) { final ActivityInfo activityInfo = resolveInfo.activityInfo; if (activityInfo == null) { continue; } final String packageName = activityInfo.packageName; final SmsApplicationData smsApplicationData = receivers.get(packageName); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "getApplicationCollectionInternal packageName=" + packageName + " smsApplicationData: " + smsApplicationData + " activityInfo.name: " + activityInfo.name); } if (smsApplicationData != null) { smsApplicationData.mSimFullReceiverClass = activityInfo.name; } } // Remove any entries for which we did not find all required intents. for (ResolveInfo resolveInfo : smsReceivers) { final ActivityInfo activityInfo = resolveInfo.activityInfo; Loading Loading @@ -883,6 +914,31 @@ public final class SmsApplication { } } /** * Gets the default application that handles sim full event. * @param context context from the calling app * @param updateIfNeeded update the default app if there is no valid default app configured. * @return component name of the app and class to deliver change intents to */ public static ComponentName getDefaultSimFullApplication( Context context, boolean updateIfNeeded) { int userId = getIncomingUserId(context); final long token = Binder.clearCallingIdentity(); try { ComponentName component = null; SmsApplicationData smsApplicationData = getApplication(context, updateIfNeeded, userId); if (smsApplicationData != null && smsApplicationData.mSimFullReceiverClass != null) { component = new ComponentName(smsApplicationData.mPackageName, smsApplicationData.mSimFullReceiverClass); } return component; } finally { Binder.restoreCallingIdentity(token); } } /** * Returns whether need to write the SMS message to SMS database for this package. * <p> Loading
src/java/com/android/internal/telephony/SmsStorageMonitor.java +3 −2 Original line number Diff line number Diff line Loading @@ -137,12 +137,13 @@ public class SmsStorageMonitor extends Handler { } /** * Called when SIM_FULL message is received from the RIL. Notifies interested * parties that SIM storage for SMS messages is full. * Called when SIM_FULL message is received from the RIL. Notifies the default SMS application * that SIM storage for SMS messages is full. */ private void handleIccFull() { // broadcast SIM_FULL intent Intent intent = new Intent(Intents.SIM_FULL_ACTION); intent.setComponent(SmsApplication.getDefaultSimFullApplication(mContext, false)); mWakeLock.acquire(WAKE_LOCK_TIMEOUT); SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId()); mContext.sendBroadcast(intent, android.Manifest.permission.RECEIVE_SMS); Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +1 −3 Original line number Diff line number Diff line Loading @@ -43,13 +43,12 @@ import android.os.RegistrantList; import android.os.ServiceManager; import android.provider.BlockedNumberContract; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.test.mock.MockContentProvider; import android.test.mock.MockContentResolver; import android.util.Log; import android.util.Singleton; import android.util.SparseArray; import com.android.ims.ImsCall; import com.android.ims.ImsCallProfile; Loading @@ -61,7 +60,6 @@ import com.android.internal.telephony.dataconnection.DcTracker; import com.android.internal.telephony.imsphone.ImsExternalCallTracker; import com.android.internal.telephony.imsphone.ImsPhone; import com.android.internal.telephony.imsphone.ImsPhoneCallTracker; import com.android.internal.telephony.mocks.TelephonyRegistryMock; import com.android.internal.telephony.test.SimulatedCommands; import com.android.internal.telephony.test.SimulatedCommandsVerifier; import com.android.internal.telephony.uicc.IccCardProxy; Loading
tests/telephonytests/src/com/android/internal/telephony/gsm/GsmCellBroadcastHandlerTest.java +9 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package com.android.internal.telephony.gsm; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import android.content.Intent; import android.os.HandlerThread; import android.provider.Telephony; Loading @@ -31,12 +37,6 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; public class GsmCellBroadcastHandlerTest extends TelephonyTest { @Mock private SmsStorageMonitor mSmsStorageMonitor; Loading Loading @@ -85,6 +85,9 @@ public class GsmCellBroadcastHandlerTest extends TelephonyTest { @Test @SmallTest public void testBroadcastSms() { mContextFixture.putResource( com.android.internal.R.string.config_defaultCellBroadcastReceiverComponent, "fake.cellbroadcastreceiver.component"); mSimulatedCommands.notifyGsmBroadcastSms(new byte[] { (byte)0xc0, //geographical scope (byte)0x01, //serial number Loading