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

Commit 3c8fbdf5 authored by Fred Fettinger's avatar Fred Fettinger Committed by Mike Lockwood
Browse files

location: dump LocationProvider internal state



For each location provider, call getInternalState() to see if it has any
state information to include in a bugreport. If the returned string is not
null, then print a header with the provided name followed by the returned
string.

Change-Id: I0a388d7fba14ac8cadcb80eda0a0ceb95032410b
Signed-off-by: default avatarFred Fettinger <fred.fettinger@motorola.com>
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 83835359
Loading
Loading
Loading
Loading
+27 −7
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ static const GpsInterface* sGpsInterface = NULL;
static const GpsXtraInterface* sGpsXtraInterface = NULL;
static const AGpsInterface* sAGpsInterface = NULL;
static const GpsNiInterface* sGpsNiInterface = NULL;
static const GpsDebugInterface* sGpsDebugInterface = NULL;

// data written to by GPS callbacks
static GpsLocation  sGpsLocation;
@@ -57,7 +58,7 @@ struct NmeaSentence {
    GpsUtcTime  timestamp;
    char        nmea[NMEA_SENTENCE_LENGTH];
};
static NmeaSentence sNmeaBuffer[NMEA_SENTENCE_LENGTH];
static NmeaSentence sNmeaBuffer[NMEA_SENTENCE_COUNT];
static int mNmeaSentenceCount = 0;

// a copy of the data shared by android_location_GpsLocationProvider_wait_for_event
@@ -66,7 +67,7 @@ static GpsLocation sGpsLocationCopy;
static GpsStatus    sGpsStatusCopy;
static GpsSvStatus  sGpsSvStatusCopy;
static AGpsStatus   sAGpsStatusCopy;
static NmeaSentence sNmeaBufferCopy[NMEA_SENTENCE_LENGTH];
static NmeaSentence sNmeaBufferCopy[NMEA_SENTENCE_COUNT];
static GpsNiNotification  sGpsNiNotificationCopy;

enum CallbackType {
@@ -226,6 +227,9 @@ static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject o
    if (sGpsNiInterface)
       sGpsNiInterface->init(&sGpsNiCallbacks);

    if (!sGpsDebugInterface)
       sGpsDebugInterface = (const GpsDebugInterface*)sGpsInterface->get_extension(GPS_DEBUG_INTERFACE);

    return true;
}

@@ -472,13 +476,28 @@ static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jo
static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* env, jobject obj,
      jint notifId, jint response)
{
   if (!sGpsNiInterface)
    if (!sGpsNiInterface) {
        sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
    }
    if (sGpsNiInterface) {
        sGpsNiInterface->respond(notifId, response);
    }
}

static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* env, jobject obj)
{
    jstring result = NULL;
    if (sGpsDebugInterface) {
        const size_t maxLength = 2047;
        char buffer[maxLength+1];
        size_t length = sGpsDebugInterface->get_internal_state(buffer, maxLength);
        if (length > maxLength) length = maxLength;
        buffer[length] = 0;
        result = env->NewStringUTF(buffer);
    }
    return result;
}

static JNINativeMethod sMethods[] = {
     /* name, signature, funcPtr */
    {"class_init_native", "()V", (void *)android_location_GpsLocationProvider_class_init_native},
@@ -501,6 +520,7 @@ static JNINativeMethod sMethods[] = {
    {"native_agps_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_failed},
    {"native_set_agps_server", "(ILjava/lang/String;I)V", (void*)android_location_GpsLocationProvider_set_agps_server},
    {"native_send_ni_response", "(II)V", (void*)android_location_GpsLocationProvider_send_ni_response},
    {"native_get_internal_state", "()Ljava/lang/String;", (void*)android_location_GpsLocationProvider_get_internal_state},
};

int register_android_location_GpsLocationProvider(JNIEnv* env)
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ interface ILocationProvider {
    void disable();
    int getStatus(out Bundle extras);
    long getStatusUpdateTime();
    String getInternalState();
    void enableLocationTracking(boolean enable);
    void setMinTime(long minTime);
    void updateNetworkState(int state, in NetworkInfo info);
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public interface LocationProviderInterface {
    int getStatus(Bundle extras);
    long getStatusUpdateTime();
    void enableLocationTracking(boolean enable);
    String getInternalState();
    void setMinTime(long minTime);
    void updateNetworkState(int state, NetworkInfo info);
    void updateLocation(Location location);
+11 −0
Original line number Diff line number Diff line
@@ -95,6 +95,10 @@ public abstract class LocationProvider {
            return LocationProvider.this.onGetStatusUpdateTime();
        }

        public String getInternalState() {
            return LocationProvider.this.onGetInternalState();
        }

        public void enableLocationTracking(boolean enable) {
            LocationProvider.this.onEnableLocationTracking(enable);
        }
@@ -266,6 +270,13 @@ public abstract class LocationProvider {
     */
    public abstract long onGetStatusUpdateTime();

    /**
     * Returns debugging information about the location provider.
     *
     * @return string describing the internal state of the location provider, or null.
     */
    public abstract String onGetInternalState();

    /**
     * Notifies the location provider that clients are listening for locations.
     * Called with enable set to true when the first client is added and
+9 −2
Original line number Diff line number Diff line
@@ -633,6 +633,10 @@ public class GpsLocationProvider implements LocationProviderInterface {
        }
    }

    public String getInternalState() {
        return native_get_internal_state();
    }

    private final class Listener implements IBinder.DeathRecipient {
        final IGpsStatusListener mListener;
        
@@ -1396,6 +1400,9 @@ public class GpsLocationProvider implements LocationProviderInterface {
    private native boolean native_supports_xtra();
    private native void native_inject_xtra_data(byte[] data, int length);

    // DEBUG Support
    private native String native_get_internal_state();

    // AGPS Support
    private native void native_agps_data_conn_open(String apn);
    private native void native_agps_data_conn_closed();
Loading