Skip to content

Commit dba6906

Browse files
Robert GreenwaltAndroid (Google) Code Review
authored andcommitted
Merge "Send availability info more reliably" into ics-mr0
2 parents a548b5c + 12e24ae commit dba6906

File tree

5 files changed

+36
-45
lines changed

5 files changed

+36
-45
lines changed

core/java/android/net/MobileDataStateTracker.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ public void onReceive(Context context, Intent intent) {
197197
String apnName = intent.getStringExtra(Phone.DATA_APN_KEY);
198198
mNetworkInfo.setRoaming(intent.getBooleanExtra(Phone.DATA_NETWORK_ROAMING_KEY,
199199
false));
200-
200+
if (VDBG) {
201+
log(mApnType + " setting isAvailable to " +
202+
intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,false));
203+
}
201204
mNetworkInfo.setIsAvailable(!intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,
202205
false));
203206

core/java/android/net/NetworkStateTracker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public interface NetworkStateTracker {
132132
* Returns an indication of whether this network is available for
133133
* connections. A value of {@code false} means that some quasi-permanent
134134
* condition prevents connectivity to this network.
135+
*
136+
* NOTE that this is broken on multi-connection devices. Should be fixed in J release
137+
* TODO - fix on multi-pdp devices
135138
*/
136139
public boolean isAvailable();
137140

telephony/java/com/android/internal/telephony/DataConnectionTracker.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,6 @@ public enum Activity {
254254
/** CID of active data connection */
255255
protected int mCidActive;
256256

257-
/** indication of our availability (preconditions to trysetupData are met) **/
258-
protected boolean mAvailability = false;
259-
260257
// When false we will not auto attach and manually attaching is required.
261258
protected boolean mAutoAttachOnCreation = false;
262259

@@ -755,7 +752,7 @@ protected void notifyDataConnection(String reason) {
755752
mPhone.notifyDataConnection(reason, apnIdToType(id));
756753
}
757754
}
758-
notifyDataAvailability(reason);
755+
notifyOffApnsOfAvailability(reason);
759756
}
760757

761758
// a new APN has gone active and needs to send events to catch up with the
@@ -783,29 +780,15 @@ private void notifyApnIdDisconnected(String reason, int apnId) {
783780
}
784781

785782
// disabled apn's still need avail/unavail notificiations - send them out
786-
protected void notifyOffApnsOfAvailability(String reason, boolean availability) {
787-
if (mAvailability == availability) {
788-
if (DBG) {
789-
log("notifyOffApnsOfAvailability: no change in availability, " +
790-
"not nofitying about reason='" + reason + "' availability=" + availability);
791-
}
792-
return;
793-
}
794-
mAvailability = availability;
783+
protected void notifyOffApnsOfAvailability(String reason) {
784+
if (DBG) log("notifyOffApnsOfAvailability - reason= " + reason);
795785
for (int id = 0; id < APN_NUM_TYPES; id++) {
796786
if (!isApnIdEnabled(id)) {
797787
notifyApnIdDisconnected(reason, id);
798788
}
799789
}
800790
}
801791

802-
// we had an availability change - tell the listeners
803-
protected void notifyDataAvailability(String reason) {
804-
// note that we either just turned all off because we lost availability
805-
// or all were off and could now go on, so only have off apns to worry about
806-
notifyOffApnsOfAvailability(reason, isDataPossible(Phone.APN_TYPE_DEFAULT));
807-
}
808-
809792
public boolean isApnTypeEnabled(String apnType) {
810793
if (apnType == null) {
811794
return false;

telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private boolean trySetupData(String reason) {
237237
// FIXME this can be improved
238238
setState(State.CONNECTED);
239239
notifyDataConnection(reason);
240-
notifyOffApnsOfAvailability(reason, true);
240+
notifyOffApnsOfAvailability(reason);
241241

242242
log("(fix?) We're on the simulator; assuming data is connected");
243243
return true;
@@ -250,10 +250,10 @@ private boolean trySetupData(String reason) {
250250
if ((mState == State.IDLE || mState == State.SCANNING) &&
251251
isDataAllowed() && getAnyDataEnabled()) {
252252
boolean retValue = setupData(reason);
253-
notifyOffApnsOfAvailability(reason, retValue);
253+
notifyOffApnsOfAvailability(reason);
254254
return retValue;
255255
} else {
256-
notifyOffApnsOfAvailability(reason, false);
256+
notifyOffApnsOfAvailability(reason);
257257
return false;
258258
}
259259
}
@@ -276,7 +276,7 @@ private void cleanUpConnection(boolean tearDown, String reason) {
276276
}
277277

278278
setState(State.DISCONNECTING);
279-
notifyDataAvailability(reason);
279+
notifyOffApnsOfAvailability(reason);
280280

281281
boolean notificationDeferred = false;
282282
for (DataConnection conn : mDataConnections.values()) {
@@ -536,7 +536,7 @@ private void startAlarmForReconnect(int delay, String reason) {
536536

537537
private void notifyNoData(FailCause lastFailCauseCode) {
538538
setState(State.FAILED);
539-
notifyDataAvailability(null);
539+
notifyOffApnsOfAvailability(null);
540540
}
541541

542542
protected void gotoIdleAndNotifyDataConnection(String reason) {
@@ -583,7 +583,7 @@ protected boolean onTrySetupData(String reason) {
583583
@Override
584584
protected void onRoamingOff() {
585585
if (getDataOnRoamingEnabled() == false) {
586-
notifyDataAvailability(Phone.REASON_ROAMING_OFF);
586+
notifyOffApnsOfAvailability(Phone.REASON_ROAMING_OFF);
587587
trySetupData(Phone.REASON_ROAMING_OFF);
588588
} else {
589589
notifyDataConnection(Phone.REASON_ROAMING_OFF);
@@ -601,7 +601,7 @@ protected void onRoamingOn() {
601601
} else {
602602
if (DBG) log("Tear down data connection on roaming.");
603603
cleanUpAllConnections(null);
604-
notifyDataAvailability(Phone.REASON_ROAMING_ON);
604+
notifyOffApnsOfAvailability(Phone.REASON_ROAMING_ON);
605605
}
606606
}
607607

@@ -619,7 +619,7 @@ protected void onRadioAvailable() {
619619
log("We're on the simulator; assuming data is connected");
620620
}
621621

622-
notifyDataAvailability(null);
622+
notifyOffApnsOfAvailability(null);
623623

624624
if (mState != State.IDLE) {
625625
cleanUpAllConnections(null);
@@ -710,7 +710,7 @@ protected void onVoiceCallStarted() {
710710
if (mState == State.CONNECTED && !mCdmaPhone.mSST.isConcurrentVoiceAndDataAllowed()) {
711711
stopNetStatPoll();
712712
notifyDataConnection(Phone.REASON_VOICE_CALL_STARTED);
713-
notifyDataAvailability(Phone.REASON_VOICE_CALL_STARTED);
713+
notifyOffApnsOfAvailability(Phone.REASON_VOICE_CALL_STARTED);
714714
}
715715
}
716716

@@ -727,7 +727,7 @@ protected void onVoiceCallEnded() {
727727
// clean slate after call end.
728728
resetPollStats();
729729
}
730-
notifyDataAvailability(Phone.REASON_VOICE_CALL_ENDED);
730+
notifyOffApnsOfAvailability(Phone.REASON_VOICE_CALL_ENDED);
731731
} else {
732732
mDataConnections.get(0).resetRetryCount();
733733
// in case data setup was attempted when we were on a voice call

telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ private void onDataConnectionAttached() {
556556
notifyDataConnection(Phone.REASON_DATA_ATTACHED);
557557
} else {
558558
// update APN availability so that APN can be enabled.
559-
notifyDataAvailability(Phone.REASON_DATA_ATTACHED);
559+
notifyOffApnsOfAvailability(Phone.REASON_DATA_ATTACHED);
560560
}
561561

562562
setupDataOnReadyApns(Phone.REASON_DATA_ATTACHED);
@@ -693,7 +693,7 @@ private boolean trySetupData(ApnContext apnContext) {
693693
if (waitingApns.isEmpty()) {
694694
if (DBG) log("trySetupData: No APN found");
695695
notifyNoData(GsmDataConnection.FailCause.MISSING_UNKNOWN_APN, apnContext);
696-
notifyOffApnsOfAvailability(apnContext.getReason(), false);
696+
notifyOffApnsOfAvailability(apnContext.getReason());
697697
return false;
698698
} else {
699699
apnContext.setWaitingApns(waitingApns);
@@ -708,31 +708,33 @@ private boolean trySetupData(ApnContext apnContext) {
708708
}
709709
// apnContext.setReason(apnContext.getReason());
710710
boolean retValue = setupData(apnContext);
711-
notifyOffApnsOfAvailability(apnContext.getReason(), retValue);
711+
notifyOffApnsOfAvailability(apnContext.getReason());
712712
return retValue;
713713
} else {
714714
// TODO: check the condition.
715715
if (!apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)
716716
&& (apnContext.getState() == State.IDLE
717717
|| apnContext.getState() == State.SCANNING))
718718
mPhone.notifyDataConnectionFailed(apnContext.getReason(), apnContext.getApnType());
719-
notifyOffApnsOfAvailability(apnContext.getReason(), false);
719+
notifyOffApnsOfAvailability(apnContext.getReason());
720720
return false;
721721
}
722722
}
723723

724724
@Override
725725
// Disabled apn's still need avail/unavail notificiations - send them out
726-
protected void notifyOffApnsOfAvailability(String reason, boolean availability) {
727-
if (mAvailability == availability) return;
728-
mAvailability = availability;
729-
726+
protected void notifyOffApnsOfAvailability(String reason) {
730727
for (ApnContext apnContext : mApnContexts.values()) {
731728
if (!apnContext.isReady()) {
732729
if (DBG) log("notifyOffApnOfAvailability type:" + apnContext.getApnType());
733730
mPhone.notifyDataConnection(reason != null ? reason : apnContext.getReason(),
734731
apnContext.getApnType(),
735732
Phone.DataState.DISCONNECTED);
733+
} else {
734+
if (DBG) {
735+
log("notifyOffApnsOfAvailability skipped apn due to isReady==false: " +
736+
apnContext.toString());
737+
}
736738
}
737739
}
738740
}
@@ -1572,7 +1574,7 @@ private void onRecordsLoaded() {
15721574
createAllApnList();
15731575
if (mPhone.mCM.getRadioState().isOn()) {
15741576
if (DBG) log("onRecordsLoaded: notifying data availability");
1575-
notifyDataAvailability(Phone.REASON_SIM_LOADED);
1577+
notifyOffApnsOfAvailability(Phone.REASON_SIM_LOADED);
15761578
}
15771579
setupDataOnReadyApns(Phone.REASON_SIM_LOADED);
15781580
}
@@ -1681,7 +1683,7 @@ protected void onRoamingOff() {
16811683
if (DBG) log("onRoamingOff");
16821684

16831685
if (getDataOnRoamingEnabled() == false) {
1684-
notifyDataAvailability(Phone.REASON_ROAMING_OFF);
1686+
notifyOffApnsOfAvailability(Phone.REASON_ROAMING_OFF);
16851687
setupDataOnReadyApns(Phone.REASON_ROAMING_OFF);
16861688
} else {
16871689
notifyDataConnection(Phone.REASON_ROAMING_OFF);
@@ -1697,7 +1699,7 @@ protected void onRoamingOn() {
16971699
} else {
16981700
if (DBG) log("onRoamingOn: Tear down data connection on roaming.");
16991701
cleanUpAllConnections(true, Phone.REASON_ROAMING_ON);
1700-
notifyDataAvailability(Phone.REASON_ROAMING_ON);
1702+
notifyOffApnsOfAvailability(Phone.REASON_ROAMING_ON);
17011703
}
17021704
}
17031705

@@ -1714,7 +1716,7 @@ protected void onRadioAvailable() {
17141716
}
17151717

17161718
if (mPhone.mIccRecords.getRecordsLoaded()) {
1717-
notifyDataAvailability(null);
1719+
notifyOffApnsOfAvailability(null);
17181720
}
17191721

17201722
if (getOverallState() != State.IDLE) {
@@ -1740,7 +1742,7 @@ protected void onRadioOffOrNotAvailable() {
17401742
if (DBG) log("onRadioOffOrNotAvailable: is off and clean up all connections");
17411743
cleanUpAllConnections(false, Phone.REASON_RADIO_TURNED_OFF);
17421744
}
1743-
notifyDataAvailability(null);
1745+
notifyOffApnsOfAvailability(null);
17441746
}
17451747

17461748
@Override
@@ -1985,7 +1987,7 @@ protected void notifyDataConnection(String reason) {
19851987
apnContext.getApnType());
19861988
}
19871989
}
1988-
notifyDataAvailability(reason);
1990+
notifyOffApnsOfAvailability(reason);
19891991
}
19901992

19911993
/**

0 commit comments

Comments
 (0)