summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/incidentd/Android.mk2
-rw-r--r--cmds/incidentd/src/Reporter.cpp9
-rw-r--r--core/java/android/os/IncidentManager.java33
-rw-r--r--core/java/android/os/IncidentReportArgs.java9
-rw-r--r--services/java/com/android/server/SystemServer.java2
-rw-r--r--tools/incident_report/main.cpp15
6 files changed, 37 insertions, 33 deletions
diff --git a/cmds/incidentd/Android.mk b/cmds/incidentd/Android.mk
index 537c91093112..3b156348b0c4 100644
--- a/cmds/incidentd/Android.mk
+++ b/cmds/incidentd/Android.mk
@@ -54,9 +54,7 @@ LOCAL_SHARED_LIBRARIES := \
libservices \
libutils
-ifeq (BUILD_WITH_INCIDENTD_RC,true)
LOCAL_INIT_RC := incidentd.rc
-endif
include $(BUILD_EXECUTABLE)
diff --git a/cmds/incidentd/src/Reporter.cpp b/cmds/incidentd/src/Reporter.cpp
index ea73bcdebb95..4ffc11984224 100644
--- a/cmds/incidentd/src/Reporter.cpp
+++ b/cmds/incidentd/src/Reporter.cpp
@@ -225,9 +225,8 @@ Reporter::runReport()
// and report to those that care that we're doing it.
for (const Section** section=SECTION_LIST; *section; section++) {
const int id = (*section)->id;
- ALOGD("Taking incident report section %d '%s'", id, (*section)->name.string());
-
if (this->batch.containsSection(id)) {
+ ALOGD("Taking incident report section %d '%s'", id, (*section)->name.string());
// Notify listener of starting
for (ReportRequestSet::iterator it=batch.begin(); it!=batch.end(); it++) {
if ((*it)->listener != NULL && (*it)->args.containsSection(id)) {
@@ -251,6 +250,7 @@ Reporter::runReport()
IIncidentReportStatusListener::STATUS_FINISHED);
}
}
+ ALOGD("Finish incident report section %d '%s'", id, (*section)->name.string());
}
}
@@ -324,6 +324,7 @@ Reporter::upload_backlog()
struct stat st;
status_t err;
+ ALOGD("Start uploading backlogs in %s", INCIDENT_DIRECTORY);
if ((err = create_directory(INCIDENT_DIRECTORY)) != NO_ERROR) {
ALOGE("directory doesn't exist: %s", strerror(-err));
return REPORT_FINISHED;
@@ -337,6 +338,7 @@ Reporter::upload_backlog()
sp<DropBoxManager> dropbox = new DropBoxManager();
// Enumerate, count and add up size
+ int count = 0;
while ((entry = readdir(dir)) != NULL) {
if (entry->d_name[0] == '.') {
continue;
@@ -360,8 +362,9 @@ Reporter::upload_backlog()
// boot or the next checkin. If the directory gets too big older files will
// be rotated out.
unlink(filename.string());
+ count++;
}
-
+ ALOGD("Successfully uploaded %d files to Dropbox.", count);
closedir(dir);
return REPORT_FINISHED;
diff --git a/core/java/android/os/IncidentManager.java b/core/java/android/os/IncidentManager.java
index bc8e2e470c55..1336c66b7133 100644
--- a/core/java/android/os/IncidentManager.java
+++ b/core/java/android/os/IncidentManager.java
@@ -21,8 +21,6 @@ import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
-import android.os.IIncidentManager;
-import android.os.ServiceManager;
import android.provider.Settings;
import android.util.Slog;
@@ -37,7 +35,7 @@ import android.util.Slog;
public class IncidentManager {
private static final String TAG = "incident";
- private Context mContext;
+ private final Context mContext;
/**
* @hide
@@ -54,18 +52,7 @@ public class IncidentManager {
android.Manifest.permission.PACKAGE_USAGE_STATS
})
public void reportIncident(IncidentReportArgs args) {
- final IIncidentManager service = IIncidentManager.Stub.asInterface(
- ServiceManager.getService("incident"));
- if (service == null) {
- Slog.e(TAG, "reportIncident can't find incident binder service");
- return;
- }
-
- try {
- service.reportIncident(args);
- } catch (RemoteException ex) {
- Slog.e(TAG, "reportIncident failed", ex);
- }
+ reportIncidentInternal(args);
}
/**
@@ -89,7 +76,7 @@ public class IncidentManager {
})
public void reportIncident(String settingName, byte[] headerProto) {
// Sections
- String setting = Settings.System.getString(mContext.getContentResolver(), settingName);
+ String setting = Settings.Global.getString(mContext.getContentResolver(), settingName);
IncidentReportArgs args;
try {
args = IncidentReportArgs.parseSetting(setting);
@@ -98,23 +85,25 @@ public class IncidentManager {
return;
}
if (args == null) {
- Slog.i(TAG, "Incident report requested but disabled: " + settingName);
+ Slog.i(TAG, String.format("Incident report requested but disabled with "
+ + "settings [name: %s, value: %s]", settingName, setting));
return;
}
- // Header
args.addHeader(headerProto);
- // Look up the service
+ Slog.i(TAG, "Taking incident report: " + settingName);
+ reportIncidentInternal(args);
+ }
+
+ private void reportIncidentInternal(IncidentReportArgs args) {
final IIncidentManager service = IIncidentManager.Stub.asInterface(
- ServiceManager.getService("incident"));
+ ServiceManager.getService(Context.INCIDENT_SERVICE));
if (service == null) {
Slog.e(TAG, "reportIncident can't find incident binder service");
return;
}
- // Call the service
- Slog.i(TAG, "Taking incident report: " + settingName);
try {
service.reportIncident(args);
} catch (RemoteException ex) {
diff --git a/core/java/android/os/IncidentReportArgs.java b/core/java/android/os/IncidentReportArgs.java
index ce2ae1071d01..abb316171309 100644
--- a/core/java/android/os/IncidentReportArgs.java
+++ b/core/java/android/os/IncidentReportArgs.java
@@ -18,7 +18,6 @@ package android.os;
import android.annotation.SystemApi;
import android.annotation.TestApi;
-import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.IntArray;
@@ -50,10 +49,12 @@ public final class IncidentReportArgs implements Parcelable {
readFromParcel(in);
}
+ @Override
public int describeContents() {
return 0;
}
+ @Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mAll ? 1 : 0);
@@ -100,6 +101,7 @@ public final class IncidentReportArgs implements Parcelable {
/**
* Print this report as a string.
*/
+ @Override
public String toString() {
final StringBuilder sb = new StringBuilder("Incident(");
if (mAll) {
@@ -131,10 +133,11 @@ public final class IncidentReportArgs implements Parcelable {
}
/**
- * Add this section to the incident report.
+ * Add this section to the incident report. Skip if the input is smaller than 2 since section
+ * id are only valid for positive integer as Protobuf field id. Here 1 is reserved for Header.
*/
public void addSection(int section) {
- if (!mAll) {
+ if (!mAll && section > 1) {
mSections.add(section);
}
}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index a1b9099f8bab..c08fc335a3aa 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -1842,7 +1842,7 @@ public final class SystemServer {
// TODO: Switch from checkService to getService once it's always
// in the build and should reliably be there.
final IIncidentManager incident = IIncidentManager.Stub.asInterface(
- ServiceManager.checkService("incident"));
+ ServiceManager.getService(Context.INCIDENT_SERVICE));
if (incident != null) incident.systemRunning();
} catch (Throwable e) {
reportWtf("Notifying incident daemon running", e);
diff --git a/tools/incident_report/main.cpp b/tools/incident_report/main.cpp
index 78e5c054a904..250d1186c672 100644
--- a/tools/incident_report/main.cpp
+++ b/tools/incident_report/main.cpp
@@ -97,6 +97,8 @@ read_message(CodedInputStream* in, Descriptor const* descriptor, GenericMessage*
message->addInt64(fieldId, value64);
break;
} else {
+ fprintf(stderr, "bad VARINT: 0x%x (%d) at index %d\n", tag, tag,
+ in->CurrentPosition());
return false;
}
case WireFormatLite::WIRETYPE_FIXED64:
@@ -104,10 +106,14 @@ read_message(CodedInputStream* in, Descriptor const* descriptor, GenericMessage*
message->addInt64(fieldId, value64);
break;
} else {
+ fprintf(stderr, "bad VARINT: 0x%x (%d) at index %d\n", tag, tag,
+ in->CurrentPosition());
return false;
}
case WireFormatLite::WIRETYPE_LENGTH_DELIMITED:
if (!read_length_delimited(in, fieldId, descriptor, message)) {
+ fprintf(stderr, "bad LENGTH_DELIMITED: 0x%x (%d) at index %d\n",
+ tag, tag, in->CurrentPosition());
return false;
}
break;
@@ -116,6 +122,8 @@ read_message(CodedInputStream* in, Descriptor const* descriptor, GenericMessage*
message->addInt32(fieldId, value32);
break;
} else {
+ fprintf(stderr, "bad FIXED32: 0x%x (%d) at index %d\n", tag, tag,
+ in->CurrentPosition());
return false;
}
default:
@@ -146,7 +154,7 @@ print_value(Out* out, FieldDescriptor const* field, GenericMessage::Node const&
out->printf("%f", *(float*)&node.value32);
break;
default:
- out->printf("(unexpected value %d (0x%x)", node.value32, node.value32);
+ out->printf("(unexpected value32 %d (0x%x)", node.value32, node.value32);
break;
}
break;
@@ -177,8 +185,11 @@ print_value(Out* out, FieldDescriptor const* field, GenericMessage::Node const&
}
break;
case FieldDescriptor::TYPE_ENUM:
+ out->printf("%s", field->enum_type()->FindValueByNumber((int)node.value64)
+ ->name().c_str());
+ break;
default:
- out->printf("(unexpected value %ld (0x%x))", node.value64, node.value64);
+ out->printf("(unexpected value64 %ld (0x%x))", node.value64, node.value64);
break;
}
break;