RadioIssueReportpublic class RadioIssueReport extends android.app.Activity Report radio issues to the StatisticsService. |
Fields Summary |
---|
private static final String | TAG | private static final int | HEADER_SIZE | private static final String | RADIO_BUFFER_OPTIONS | private static String[] | SYSTEM_PROPERTIESList of system properties to snapshot. | private android.widget.Button | mSubmitButton | private android.widget.EditText | mReportText | private android.telephony.ServiceState | mServiceState | private Phone.State | mPhoneState | private int | mSignalStrength | private Phone.DataState | mDataState | private String | mRadioLog | private Map | mRadioStateSnapshot of interesting variables relevant to the radio. | android.view.View.OnClickListener | mSubmitButtonHandler |
Methods Summary |
---|
private static java.lang.String | getRadioLog()
// Largely stolen from LogViewer.java
Socket sock = new Socket("127.0.0.1", 5040);
DataInputStream in = new DataInputStream(sock.getInputStream());
StringBuilder log = new StringBuilder();
// Set options
sock.getOutputStream().write(RADIO_BUFFER_OPTIONS.getBytes());
sock.getOutputStream().write('\n");
sock.getOutputStream().write('\n");
// Read in the log
try {
Calendar cal = new GregorianCalendar();
while (true) {
int length = in.readInt();
long when = (long)in.readInt();
byte[] bytes = new byte[length-4];
in.readFully(bytes);
int tagEnd = next0(bytes, HEADER_SIZE-4);
int fileEnd = next0(bytes, tagEnd + 1);
int messageEnd = next0(bytes, fileEnd + 1);
CharSequence tag
= forAsciiBytes(bytes, HEADER_SIZE-4, tagEnd);
CharSequence message
= forAsciiBytes(bytes, fileEnd + 1, messageEnd);
cal.setTimeInMillis(when*1000);
log.append(DateFormat.format("MM-dd kk:mm:ss ", cal));
log.append(tag)
.append(": ")
.append(message)
.append("\n");
}
} catch (EOFException e) {
Log.d(TAG, "reached end of stream");
}
return log.toString();
| private void | initReportText()
mReportText = (EditText) findViewById(R.id.report_text);
mReportText.requestFocus();
| private void | initSubmitButton()
mSubmitButton = (Button) findViewById(R.id.submit);
mSubmitButton.setOnClickListener(mSubmitButtonHandler);
| private static int | next0(byte[] bytes, int start)
for (int current = start; current < bytes.length; current++) {
if (bytes[current] == 0)
return current;
}
return bytes.length;
| public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
setContentView(R.layout.radio_issue);
initSubmitButton();
initReportText();
mRadioState = snapState();
| private static java.util.Map | snapState()
Map<String, String> state = Maps.newHashMap();
// Capture a bunch of system properties
for (String property: SYSTEM_PROPERTIES) {
String value = SystemProperties.get(property);
state.put(property, SystemProperties.get(property));
}
Phone phone = PhoneFactory.getDefaultPhone();
state.put("phone-data", phone.getDataConnectionState().toString());
state.put("phone-service", phone.getServiceState().toString());
state.put("phone-signal", String.valueOf(phone.getSignalStrengthASU()));
state.put("phone-state", phone.getState().toString());
try {
state.put("radio-log", getRadioLog());
} catch (IOException e) {
Log.e(TAG, "Error reading radio log", e);
}
return state;
|
|