Merge lp:~xnox/whoopsie/android-serial into lp:whoopsie

Proposed by Dimitri John Ledkov
Status: Merged
Approved by: Evan
Approved revision: 627
Merged at revision: 627
Proposed branch: lp:~xnox/whoopsie/android-serial
Merge into: lp:whoopsie
Diff against target: 113 lines (+38/-9)
2 files modified
src/identifier.c (+36/-9)
src/identifier.h (+2/-0)
To merge this branch: bzr merge lp:~xnox/whoopsie/android-serial
Reviewer Review Type Date Requested Status
Evan (community) Approve
Brian Murray Pending
Review via email: mp+229658@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Hm, My dual boot is busted again (out of disk space). So I don't have a phone to try this on, at the moment.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Hm, My dual boot is busted again (out of disk space). So I don't have a phone to try this on, at the moment.

Revision history for this message
Evan (ev) wrote :

Looks good. Landing.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/identifier.c'
2--- src/identifier.c 2014-06-12 22:47:27 +0000
3+++ src/identifier.c 2014-08-05 16:26:22 +0000
4@@ -13,6 +13,7 @@
5 static char* ofono_name = "org.ofono";
6 static gint fail_next_get_mac = 0;
7 static gint fail_next_get_uuid = 0;
8+static gint fail_next_get_serial = 0;
9
10 void whoopsie_identifier_set_ofono_name (char *name) {
11 ofono_name = name;
12@@ -113,35 +114,47 @@
13 *res = g_strdup (data);
14 }
15
16-void
17-whoopsie_identifier_get_system_uuid (char** res, GError** error)
18+static void
19+_get_serial (char** res, GError** error, const char* filename, int length, gint* fail_next_get)
20 {
21 int fp;
22
23 g_return_if_fail (res);
24
25- if (g_atomic_int_compare_and_exchange (&fail_next_get_uuid, WHOOPSIE_FAIL_GENERIC, 0)) {
26+ if (g_atomic_int_compare_and_exchange (fail_next_get, WHOOPSIE_FAIL_GENERIC, 0)) {
27 g_set_error (error, g_quark_from_static_string ("whoopsie-quark"), WHOOPSIE_FAILED_BY_REQUEST,
28 "Failed by tester request");
29 return;
30 }
31
32- fp = open ("/sys/class/dmi/id/product_uuid", O_RDONLY);
33+ fp = open (filename, O_RDONLY);
34 if (fp < 0) {
35 g_set_error (error, g_quark_from_static_string ("whoopsie-quark"), 0,
36- "Could not open the product uuid file.");
37+ "Could not open the product uuid/serial file.");
38 return;
39 }
40- *res = g_malloc (37);
41- if (read (fp, *res, 36) == 36)
42- (*res)[36] = '\0';
43+ *res = g_malloc (length+1);
44+ if (read (fp, *res, length) == length)
45+ (*res)[length] = '\0';
46 else
47 g_set_error (error, g_quark_from_static_string ("whoopsie-quark"), 0,
48- "Got an unexpected length reading the product_uuid.");
49+ "Got an unexpected length reading the product uuid/serial.");
50 close (fp);
51 }
52
53 void
54+whoopsie_identifier_get_system_uuid (char** res, GError** error)
55+{
56+ _get_serial (res, error, "/sys/class/dmi/id/product_uuid", 36, &fail_next_get_uuid);
57+}
58+
59+void
60+whoopsie_identifier_get_android_serialno (char** res, GError** error)
61+{
62+ _get_serial (res, error, "/sys/class/android_usb/android0/iSerial", 16, &fail_next_get_serial);
63+}
64+
65+void
66 whoopsie_identifier_sha512 (char* source, char* res, GError** error)
67 {
68 int md_len;
69@@ -259,6 +272,15 @@
70 *error = NULL;
71 }
72
73+ whoopsie_identifier_get_android_serialno (&identifier, error);
74+ if ((!error || !(*error)) && identifier)
75+ goto out;
76+
77+ if (error && *error) {
78+ g_error_free (*error);
79+ *error = NULL;
80+ }
81+
82 whoopsie_identifier_get_mac_address (&identifier, error);
83 if ((!error || !(*error)) && identifier) {
84 whoopsie_identifier_append_imei (&identifier, error);
85@@ -287,3 +309,8 @@
86 {
87 g_atomic_int_set (&fail_next_get_uuid, 1);
88 }
89+
90+void whoopsie_identifier_fail_next_get_serial ()
91+{
92+ g_atomic_int_set (&fail_next_get_serial, 1);
93+}
94
95=== modified file 'src/identifier.h'
96--- src/identifier.h 2014-06-12 22:47:27 +0000
97+++ src/identifier.h 2014-08-05 16:26:22 +0000
98@@ -2,6 +2,7 @@
99 void whoopsie_identifier_get_imei (char** res, GError** error);
100 void whoopsie_identifier_get_mac_address (char** res, GError** error);
101 void whoopsie_identifier_get_system_uuid (char** res, GError** error);
102+void whoopsie_identifier_get_android_serialno (char** res, GError** error);
103 void whoopsie_identifier_sha512 (char* source, char* res, GError** error);
104 void whoopsie_hex_to_char (char* buf, const char *str, int len);
105 #define HASHLEN 128
106@@ -10,6 +11,7 @@
107 void whoopsie_identifier_set_ofono_name (char* name) __attribute__ ((__warning__ ("Only for testing")));
108 void whoopsie_identifier_fail_next_get_mac (gint how) __attribute__ ((__warning__ ("Only for testing")));
109 void whoopsie_identifier_fail_next_get_uuid () __attribute__ ((__warning__ ("Only for testing")));
110+void whoopsie_identifier_fail_next_get_serial () __attribute__ ((__warning__ ("Only for testing")));
111 #define WHOOPSIE_FAIL_GENERIC 1
112 #define WHOOPSIE_FAIL_NO_IFACES 2
113 #define WHOOPSIE_FAILED_BY_REQUEST 42

Subscribers

People subscribed via source and target branches

to status/vote changes: