Add SIM notification pop-ups.

+ Added a SimDialogActivity so any application can iniate a request to
se tthe default Data, Calls, and SMS.

Bug: 18293625
Change-Id: I60535125b40ece5ebc14542d732e4493bddefbae
This commit is contained in:
PauloftheWest
2014-11-18 07:12:48 -08:00
parent 1dce16a61c
commit ffef98b3a0
5 changed files with 358 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ import com.android.settings.Utils;
import java.util.List;
public class SimBootReceiver extends BroadcastReceiver {
private static final String TAG = "SimBootReceiver";
private static final int SLOT_EMPTY = -1;
private static final int NOTIFICATION_ID = 1;
private static final String SHARED_PREFERENCES_NAME = "sim_state";
@@ -61,6 +62,9 @@ public class SimBootReceiver extends BroadcastReceiver {
private void detectChangeAndNotify() {
final int numSlots = mTelephonyManager.getSimCount();
boolean notificationSent = false;
int numSIMsDetected = 0;
int lastSIMSlotDetected = -1;
// Do not create notifications on single SIM devices.
if (numSlots < 2) {
@@ -82,16 +86,32 @@ public class SimBootReceiver extends BroadcastReceiver {
final int lastSubId = getLastSubId(key);
if (sir != null) {
numSIMsDetected++;
final int currentSubId = sir.getSubscriptionId();
if (lastSubId != currentSubId) {
createNotification(mContext);
setLastSubId(key, currentSubId);
notificationSent = true;
}
lastSIMSlotDetected = i;
} else if (lastSubId != SLOT_EMPTY) {
createNotification(mContext);
setLastSubId(key, SLOT_EMPTY);
notificationSent = true;
}
}
if (notificationSent) {
Intent intent = new Intent(mContext, SimDialogActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (numSIMsDetected == 1) {
intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.PREFERRED_PICK);
intent.putExtra(SimDialogActivity.PREFERRED_SIM, lastSIMSlotDetected);
} else {
intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.DATA_PICK);
}
mContext.startActivity(intent);
}
}
private int getLastSubId(String strSlotId) {
@@ -141,4 +161,5 @@ public class SimBootReceiver extends BroadcastReceiver {
detectChangeAndNotify();
}
};
}