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: Fred Fettinger <fred.fettinger@motorola.com>
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Fred Fettinger
2010-01-04 15:38:13 -06:00
committed by Mike Lockwood
parent 83835359e5
commit 3c8fbdf5dd
9 changed files with 76 additions and 10 deletions

View File

@@ -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,11 +476,26 @@ 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)
sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
if (sGpsNiInterface) {
sGpsNiInterface->respond(notifId, response);
}
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[] = {
@@ -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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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;
@@ -1391,12 +1395,15 @@ public class GpsLocationProvider implements LocationProviderInterface {
private native int native_read_nmea(int index, byte[] buffer, int bufferSize);
private native void native_inject_location(double latitude, double longitude, float accuracy);
// XTRA Support
// XTRA Support
private native void native_inject_time(long time, long timeReference, int uncertainty);
private native boolean native_supports_xtra();
private native void native_inject_xtra_data(byte[] data, int length);
// AGPS Support
// 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();
private native void native_agps_data_conn_failed();

View File

@@ -266,6 +266,15 @@ public class LocationProviderProxy implements LocationProviderInterface {
return 0;
}
public String getInternalState() {
try {
return mProvider.getInternalState();
} catch (RemoteException e) {
Log.e(TAG, "getInternalState failed", e);
return null;
}
}
public boolean isLocationTracking() {
return mLocationTracking;
}

View File

@@ -168,6 +168,10 @@ public class MockProvider implements LocationProviderInterface {
mStatusUpdateTime = 0;
}
public String getInternalState() {
return null;
}
public void enableLocationTracking(boolean enable) {
}

View File

@@ -106,6 +106,10 @@ public class PassiveProvider implements LocationProviderInterface {
return -1;
}
public String getInternalState() {
return null;
}
public void enableLocationTracking(boolean enable) {
mTracking = enable;
}

View File

@@ -765,7 +765,9 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
pw.println(prefix + "mMinTime=" + mMinTime + " mMinDistance=" + mMinDistance);
pw.println(prefix + "mUid=" + mUid);
pw.println(prefix + "mLastFixBroadcast:");
mLastFixBroadcast.dump(new PrintWriterPrinter(pw), prefix + " ");
if (mLastFixBroadcast != null) {
mLastFixBroadcast.dump(new PrintWriterPrinter(pw), prefix + " ");
}
pw.println(prefix + "mLastStatusBroadcast=" + mLastStatusBroadcast);
}
}
@@ -1954,6 +1956,13 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
i.getValue().dump(pw, " ");
}
}
for (LocationProviderInterface provider: mProviders) {
String state = provider.getInternalState();
if (state != null) {
pw.println(provider.getName() + " Internal State:");
pw.write(state);
}
}
}
}
}