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

Commit 2b15cb21 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Resolve merge conflict for '75f1fdec':



    GPS Provider Service changes

    GPS engine needs to receive network state changes from Android fw.

    Added db query for the current APN, also added a new parameter
    between JNI / HAL to the new method in AGpsRilInterface struct
    for gps engine to receive APN from GPSLocationService

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

Change-Id: I33c45027f1571493d3525324f62d199517c4960c
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parents 7abaecc3 75f1fdec
Loading
Loading
Loading
Loading
+33 −2
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.database.Cursor;
import android.location.Criteria;
import android.location.Criteria;
import android.location.IGpsStatusListener;
import android.location.IGpsStatusListener;
import android.location.IGpsStatusProvider;
import android.location.IGpsStatusProvider;
@@ -32,6 +33,7 @@ import android.location.LocationManager;
import android.location.LocationProvider;
import android.location.LocationProvider;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Binder;
import android.os.Binder;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler;
@@ -45,6 +47,7 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.WorkSource;
import android.os.WorkSource;
import android.provider.Settings;
import android.provider.Settings;
import android.provider.Telephony.Carriers;
import android.provider.Telephony.Sms.Intents;
import android.provider.Telephony.Sms.Intents;
import android.telephony.SmsMessage;
import android.telephony.SmsMessage;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
@@ -489,8 +492,17 @@ public class GpsLocationProvider implements LocationProviderInterface {
        }
        }


        if (info != null) {
        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(),
            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
        if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE_SUPL
@@ -1597,6 +1609,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
    // for GPS SV statistics
    private static final int MAX_SVS = 32;
    private static final int MAX_SVS = 32;
    private static final int EPHEMERIS_MASK = 0;
    private static final int EPHEMERIS_MASK = 0;
@@ -1655,5 +1686,5 @@ public class GpsLocationProvider implements LocationProviderInterface {
    private native void native_agps_set_id(int type, String setid);
    private native void native_agps_set_id(int type, String setid);


    private native void native_update_network_state(boolean connected, int type,
    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 Original line Diff line number Diff line
@@ -543,7 +543,7 @@ static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* e
}
}


static void android_location_GpsLocationProvider_update_network_state(JNIEnv* env, jobject obj,
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) {
    if (sAGpsRilInterface && sAGpsRilInterface->update_network_state) {
@@ -554,6 +554,14 @@ static void android_location_GpsLocationProvider_update_network_state(JNIEnv* en
        } else {
        } else {
            sAGpsRilInterface->update_network_state(connected, type, roaming, NULL);
            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);
        }
    }
    }
}
}


@@ -582,7 +590,7 @@ static JNINativeMethod sMethods[] = {
    {"native_send_ni_response", "(II)V", (void*)android_location_GpsLocationProvider_send_ni_response},
    {"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_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_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)
int register_android_server_location_GpsLocationProvider(JNIEnv* env)