• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Settings


コミットメタ情報

リビジョン5f1747a00dd655bcc1f461e5d1edf6c38a88a3ad (tree)
日時2015-03-26 10:49:50
作者Stuart Scott <stuartscott@goog...>
コミッターThe Android Automerger

ログメッセージ

Fix sim notifications.

bug:19705366
Change-Id: I1d1f2dc5cf1d4580ab503c88853b089db0362242

変更サマリ

差分

--- a/src/com/android/settings/sim/SimBootReceiver.java
+++ b/src/com/android/settings/sim/SimBootReceiver.java
@@ -24,8 +24,6 @@ import android.app.PendingIntent;
2424 import android.content.BroadcastReceiver;
2525 import android.content.Context;
2626 import android.content.Intent;
27-import android.content.SharedPreferences;
28-import android.content.SharedPreferences.Editor;
2927 import android.content.res.Resources;
3028 import android.provider.Settings;
3129 import android.support.v4.app.NotificationCompat;
@@ -40,13 +38,8 @@ import java.util.List;
4038
4139 public class SimBootReceiver extends BroadcastReceiver {
4240 private static final String TAG = "SimBootReceiver";
43- private static final int SLOT_EMPTY = -1;
4441 private static final int NOTIFICATION_ID = 1;
45- private static final String SHARED_PREFERENCES_NAME = "sim_state";
46- private static final String SLOT_PREFIX = "sim_slot_";
47- private static final int INVALID_SLOT = -2; // Used when upgrading from K to LMR1
4842
49- private SharedPreferences mSharedPreferences = null;
5043 private TelephonyManager mTelephonyManager;
5144 private Context mContext;
5245 private SubscriptionManager mSubscriptionManager;
@@ -56,9 +49,6 @@ public class SimBootReceiver extends BroadcastReceiver {
5649 mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
5750 mContext = context;
5851 mSubscriptionManager = SubscriptionManager.from(mContext);
59- mSharedPreferences = mContext.getSharedPreferences(SHARED_PREFERENCES_NAME,
60- Context.MODE_PRIVATE);
61-
6252 mSubscriptionManager.addOnSubscriptionsChangedListener(mSubscriptionListener);
6353 }
6454
@@ -75,6 +65,22 @@ public class SimBootReceiver extends BroadcastReceiver {
7565 return;
7666 }
7767
68+ // Cancel any previous notifications
69+ cancelNotification(mContext);
70+
71+ // Clear defaults for any subscriptions which no longer exist
72+ mSubscriptionManager.clearDefaultsForInactiveSubIds();
73+
74+ boolean dataSelected = SubscriptionManager.isUsableSubIdValue(
75+ SubscriptionManager.getDefaultDataSubId());
76+ boolean smsSelected = SubscriptionManager.isUsableSubIdValue(
77+ SubscriptionManager.getDefaultSmsSubId());
78+
79+ // If data and sms defaults are selected, dont show notification (Calls default is optional)
80+ if (dataSelected && smsSelected) {
81+ return;
82+ }
83+
7884 // We wait until SubscriptionManager returns a valid list of Subscription informations
7985 // by checking if the list is empty.
8086 // This is not completely correct, but works for most cases.
@@ -82,57 +88,34 @@ public class SimBootReceiver extends BroadcastReceiver {
8288 List<SubscriptionInfo> sil = mSubscriptionManager.getActiveSubscriptionInfoList();
8389 if (sil == null || sil.size() < 1) {
8490 return;
85- }
86-
87- for (int i = 0; i < numSlots; i++) {
88- final SubscriptionInfo sir = Utils.findRecordBySlotId(mContext, i);
89- final String key = SLOT_PREFIX+i;
90- final int lastSubId = getLastSubId(key);
91-
92- if (sir != null) {
93- numSIMsDetected++;
94- final int currentSubId = sir.getSubscriptionId();
95- if (lastSubId == INVALID_SLOT) {
96- setLastSubId(key, currentSubId);
97- } else if (lastSubId != currentSubId) {
98- createNotification(mContext);
99- setLastSubId(key, currentSubId);
100- notificationSent = true;
101- }
102- lastSIMSlotDetected = i;
103- } else if (lastSubId != SLOT_EMPTY) {
104- createNotification(mContext);
105- setLastSubId(key, SLOT_EMPTY);
106- notificationSent = true;
107- }
108- }
109-
110- if (notificationSent) {
111- Intent intent = new Intent(mContext, SimDialogActivity.class);
112- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
113- if (numSIMsDetected == 1) {
91+ } else {
92+ // Create a notification to tell the user that some defaults are missing
93+ createNotification(mContext);
94+
95+ if (sil.size() == 1) {
96+ // If there is only one subscription, ask if user wants to use if for everything
97+ Intent intent = new Intent(mContext, SimDialogActivity.class);
98+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
11499 intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.PREFERRED_PICK);
115- intent.putExtra(SimDialogActivity.PREFERRED_SIM, lastSIMSlotDetected);
116- } else {
100+ intent.putExtra(SimDialogActivity.PREFERRED_SIM, sil.get(0).getSimSlotIndex());
101+ mContext.startActivity(intent);
102+ } else if (!dataSelected) {
103+ // TODO(sanketpadawe): This should not be shown if the user is looking at the
104+ // SimSettings page - its just annoying
105+ // If there are mulitple, ensure they pick default data
106+ Intent intent = new Intent(mContext, SimDialogActivity.class);
107+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
117108 intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.DATA_PICK);
109+ mContext.startActivity(intent);
118110 }
119- mContext.startActivity(intent);
120111 }
121- }
122-
123- private int getLastSubId(String strSlotId) {
124- return mSharedPreferences.getInt(strSlotId, INVALID_SLOT);
125- }
126112
127- private void setLastSubId(String strSlotId, int value) {
128- Editor editor = mSharedPreferences.edit();
129- editor.putInt(strSlotId, value);
130- editor.commit();
131113 }
132114
133115 private void createNotification(Context context){
134116 final Resources resources = context.getResources();
135117
118+ // TODO(sanketpadawe): This notification should not be dissmissable by the user
136119 NotificationCompat.Builder builder =
137120 new NotificationCompat.Builder(context)
138121 .setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)