Skip to content

Commit a82ee49

Browse files
Mike LockwoodAndroid Git Automerger
authored andcommitted
am 8f5dd9a: Merge "GPS Provider Service changes"
* commit '8f5dd9ad3f98d97d2862b57ba8cd961d2201e40c': GPS Provider Service changes
2 parents 98c531d + 8f5dd9a commit a82ee49

2 files changed

Lines changed: 43 additions & 4 deletions

File tree

services/java/com/android/server/location/GpsLocationProvider.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.content.Context;
2323
import android.content.Intent;
2424
import android.content.IntentFilter;
25+
import android.database.Cursor;
2526
import android.location.Criteria;
2627
import android.location.IGpsStatusListener;
2728
import android.location.IGpsStatusProvider;
@@ -33,6 +34,7 @@
3334
import android.net.ConnectivityManager;
3435
import android.net.NetworkInfo;
3536
import android.net.SntpClient;
37+
import android.net.Uri;
3638
import android.os.Binder;
3739
import android.os.Bundle;
3840
import android.os.Handler;
@@ -46,6 +48,7 @@
4648
import android.os.SystemClock;
4749
import android.os.WorkSource;
4850
import android.provider.Settings;
51+
import android.provider.Telephony.Carriers;
4952
import android.provider.Telephony.Sms.Intents;
5053
import android.telephony.SmsMessage;
5154
import android.telephony.TelephonyManager;
@@ -490,8 +493,17 @@ private void handleUpdateNetworkState(int state, NetworkInfo info) {
490493
}
491494

492495
if (info != null) {
496+
boolean dataEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
497+
Settings.Secure.MOBILE_DATA, 1) == 1;
498+
boolean networkAvailable = info.isAvailable() && dataEnabled;
499+
String defaultApn = getSelectedApn();
500+
if (defaultApn == null) {
501+
defaultApn = "dummy-apn";
502+
}
503+
493504
native_update_network_state(info.isConnected(), info.getType(),
494-
info.isRoaming(), info.getExtraInfo());
505+
info.isRoaming(), networkAvailable,
506+
info.getExtraInfo(), defaultApn);
495507
}
496508

497509
if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE_SUPL
@@ -1578,6 +1590,25 @@ public void run() {
15781590
}
15791591
}
15801592

1593+
private String getSelectedApn() {
1594+
Uri uri = Uri.parse("content://telephony/carriers/preferapn");
1595+
String apn = null;
1596+
1597+
Cursor cursor = mContext.getContentResolver().query(uri, new String[] {"apn"},
1598+
null, null, Carriers.DEFAULT_SORT_ORDER);
1599+
1600+
if (null != cursor) {
1601+
try {
1602+
if (cursor.moveToFirst()) {
1603+
apn = cursor.getString(0);
1604+
}
1605+
} finally {
1606+
cursor.close();
1607+
}
1608+
}
1609+
return apn;
1610+
}
1611+
15811612
// for GPS SV statistics
15821613
private static final int MAX_SVS = 32;
15831614
private static final int EPHEMERIS_MASK = 0;
@@ -1636,5 +1667,5 @@ private native void native_agps_set_ref_location_cellid(int type, int mcc, int m
16361667
private native void native_agps_set_id(int type, String setid);
16371668

16381669
private native void native_update_network_state(boolean connected, int type,
1639-
boolean roaming, String extraInfo);
1670+
boolean roaming, boolean available, String extraInfo, String defaultAPN);
16401671
}

services/jni/com_android_server_location_GpsLocationProvider.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* e
533533
}
534534

535535
static void android_location_GpsLocationProvider_update_network_state(JNIEnv* env, jobject obj,
536-
jboolean connected, int type, jboolean roaming, jstring extraInfo)
536+
jboolean connected, int type, jboolean roaming, jboolean available, jstring extraInfo, jstring apn)
537537
{
538538

539539
if (sAGpsRilInterface && sAGpsRilInterface->update_network_state) {
@@ -544,6 +544,14 @@ static void android_location_GpsLocationProvider_update_network_state(JNIEnv* en
544544
} else {
545545
sAGpsRilInterface->update_network_state(connected, type, roaming, NULL);
546546
}
547+
548+
// update_network_availability callback was not included in original AGpsRilInterface
549+
if (sAGpsRilInterface->size >= sizeof(AGpsRilInterface)
550+
&& sAGpsRilInterface->update_network_availability) {
551+
const char *c_apn = env->GetStringUTFChars(apn, NULL);
552+
sAGpsRilInterface->update_network_availability(available, c_apn);
553+
env->ReleaseStringUTFChars(apn, c_apn);
554+
}
547555
}
548556
}
549557

@@ -572,7 +580,7 @@ static JNINativeMethod sMethods[] = {
572580
{"native_send_ni_response", "(II)V", (void*)android_location_GpsLocationProvider_send_ni_response},
573581
{"native_agps_ni_message", "([BI)V", (void *)android_location_GpsLocationProvider_agps_send_ni_message},
574582
{"native_get_internal_state", "()Ljava/lang/String;", (void*)android_location_GpsLocationProvider_get_internal_state},
575-
{"native_update_network_state", "(ZIZLjava/lang/String;)V", (void*)android_location_GpsLocationProvider_update_network_state },
583+
{"native_update_network_state", "(ZIZZLjava/lang/String;Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_update_network_state },
576584
};
577585

578586
int register_android_server_location_GpsLocationProvider(JNIEnv* env)

0 commit comments

Comments
 (0)