Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a82ee49a authored by Mike Lockwood's avatar Mike Lockwood Committed by Android Git Automerger
Browse files

am 8f5dd9ad: Merge "GPS Provider Service changes"

* commit '8f5dd9ad':
  GPS Provider Service changes
parents 98c531dc 8f5dd9ad
Loading
Loading
Loading
Loading
+33 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.location.Criteria;
import android.location.IGpsStatusListener;
import android.location.IGpsStatusProvider;
@@ -33,6 +34,7 @@ import android.location.LocationProvider;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.SntpClient;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
@@ -46,6 +48,7 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.WorkSource;
import android.provider.Settings;
import android.provider.Telephony.Carriers;
import android.provider.Telephony.Sms.Intents;
import android.telephony.SmsMessage;
import android.telephony.TelephonyManager;
@@ -490,8 +493,17 @@ public class GpsLocationProvider implements LocationProviderInterface {
        }

        if (info != null) {
            boolean dataEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
                                                         Settings.Secure.MOBILE_DATA, 1) == 1;
            boolean networkAvailable = info.isAvailable() && dataEnabled;
            String defaultApn = getSelectedApn();
            if (defaultApn == null) {
                defaultApn = "dummy-apn";
            }

            native_update_network_state(info.isConnected(), info.getType(),
                    info.isRoaming(), info.getExtraInfo());
                                        info.isRoaming(), networkAvailable,
                                        info.getExtraInfo(), defaultApn);
        }

        if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE_SUPL
@@ -1578,6 +1590,25 @@ public class GpsLocationProvider implements LocationProviderInterface {
        }
    }

    private String getSelectedApn() {
        Uri uri = Uri.parse("content://telephony/carriers/preferapn");
        String apn = null;

        Cursor cursor = mContext.getContentResolver().query(uri, new String[] {"apn"},
                null, null, Carriers.DEFAULT_SORT_ORDER);

        if (null != cursor) {
            try {
                if (cursor.moveToFirst()) {
                    apn = cursor.getString(0);
                }
            } finally {
                cursor.close();
            }
        }
        return apn;
    }

    // for GPS SV statistics
    private static final int MAX_SVS = 32;
    private static final int EPHEMERIS_MASK = 0;
@@ -1636,5 +1667,5 @@ public class GpsLocationProvider implements LocationProviderInterface {
    private native void native_agps_set_id(int type, String setid);

    private native void native_update_network_state(boolean connected, int type,
            boolean roaming, String extraInfo);
            boolean roaming, boolean available, String extraInfo, String defaultAPN);
}
+10 −2
Original line number Diff line number Diff line
@@ -533,7 +533,7 @@ static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* e
}

static void android_location_GpsLocationProvider_update_network_state(JNIEnv* env, jobject obj,
        jboolean connected, int type, jboolean roaming, jstring extraInfo)
        jboolean connected, int type, jboolean roaming, jboolean available, jstring extraInfo, jstring apn)
{

    if (sAGpsRilInterface && sAGpsRilInterface->update_network_state) {
@@ -544,6 +544,14 @@ static void android_location_GpsLocationProvider_update_network_state(JNIEnv* en
        } else {
            sAGpsRilInterface->update_network_state(connected, type, roaming, NULL);
        }

        // update_network_availability callback was not included in original AGpsRilInterface
        if (sAGpsRilInterface->size >= sizeof(AGpsRilInterface)
                && sAGpsRilInterface->update_network_availability) {
            const char *c_apn = env->GetStringUTFChars(apn, NULL);
            sAGpsRilInterface->update_network_availability(available, c_apn);
            env->ReleaseStringUTFChars(apn, c_apn);
        }
    }
}

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

int register_android_server_location_GpsLocationProvider(JNIEnv* env)