Skip to content

Commit 1e6329d

Browse files
author
Wink Saville
committed
Use new preferredAPN URI avoiding onApnChanged() call with self-change
Solving the issue that setting preferred APN from GDCT triggers back APN change event and force unnecessary data call disconnects and setups. The new URI is added in Telephony Provider so ContentObserver callback (results in onApnChanged) will not be triggered. Bug:5448858 Change-Id: I4c0bcf32cec69cf1d0a0430f7a27495b89e93625
1 parent bd9d9d3 commit 1e6329d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ public void putRecoveryAction(int action) {
136136
private static final String INTENT_DATA_STALL_ALARM =
137137
"com.android.internal.telephony.gprs-data-stall";
138138

139-
static final Uri PREFERAPN_URI = Uri.parse("content://telephony/carriers/preferapn");
139+
static final Uri PREFERAPN_NO_UPDATE_URI =
140+
Uri.parse("content://telephony/carriers/preferapn_no_update");
140141
static final String APN_ID = "apn_id";
141142
private boolean canSetPreferApn = false;
142143

@@ -2342,26 +2343,30 @@ private void startDelayedRetry(GsmDataConnection.FailCause cause,
23422343

23432344
private void setPreferredApn(int pos) {
23442345
if (!canSetPreferApn) {
2346+
log("setPreferredApn: X !canSEtPreferApn");
23452347
return;
23462348
}
23472349

2350+
log("setPreferredApn: delete");
23482351
ContentResolver resolver = mPhone.getContext().getContentResolver();
2349-
resolver.delete(PREFERAPN_URI, null, null);
2352+
resolver.delete(PREFERAPN_NO_UPDATE_URI, null, null);
23502353

23512354
if (pos >= 0) {
2355+
log("setPreferredApn: insert");
23522356
ContentValues values = new ContentValues();
23532357
values.put(APN_ID, pos);
2354-
resolver.insert(PREFERAPN_URI, values);
2358+
resolver.insert(PREFERAPN_NO_UPDATE_URI, values);
23552359
}
23562360
}
23572361

23582362
private ApnSetting getPreferredApn() {
23592363
if (mAllApns.isEmpty()) {
2364+
log("getPreferredApn: X not found mAllApns.isEmpty");
23602365
return null;
23612366
}
23622367

23632368
Cursor cursor = mPhone.getContext().getContentResolver().query(
2364-
PREFERAPN_URI, new String[] { "_id", "name", "apn" },
2369+
PREFERAPN_NO_UPDATE_URI, new String[] { "_id", "name", "apn" },
23652370
null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
23662371

23672372
if (cursor != null) {
@@ -2376,6 +2381,7 @@ private ApnSetting getPreferredApn() {
23762381
pos = cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID));
23772382
for(ApnSetting p:mAllApns) {
23782383
if (p.id == pos && p.canHandleType(mRequestedApnType)) {
2384+
log("getPreferredApn: X found apnSetting" + p);
23792385
cursor.close();
23802386
return p;
23812387
}
@@ -2386,6 +2392,7 @@ private ApnSetting getPreferredApn() {
23862392
cursor.close();
23872393
}
23882394

2395+
log("getPreferredApn: X not found");
23892396
return null;
23902397
}
23912398

0 commit comments

Comments
 (0)