Skip to content

Commit 4b94c45

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "Added dropbox broadcast notification"
2 parents 19b23af + b247536 commit 4b94c45

File tree

3 files changed

+67
-3
lines changed

3 files changed

+67
-3
lines changed

api/current.xml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117332,6 +117332,39 @@
117332117332
<parameter name="tag" type="java.lang.String">
117333117333
</parameter>
117334117334
</method>
117335+
<field name="ACTION_DROPBOX_ENTRY_ADDED"
117336+
type="java.lang.String"
117337+
transient="false"
117338+
volatile="false"
117339+
value="&quot;android.intent.action.DROPBOX_ENTRY_ADDED&quot;"
117340+
static="true"
117341+
final="true"
117342+
deprecated="not deprecated"
117343+
visibility="public"
117344+
>
117345+
</field>
117346+
<field name="EXTRA_TAG"
117347+
type="java.lang.String"
117348+
transient="false"
117349+
volatile="false"
117350+
value="&quot;tag&quot;"
117351+
static="true"
117352+
final="true"
117353+
deprecated="not deprecated"
117354+
visibility="public"
117355+
>
117356+
</field>
117357+
<field name="EXTRA_TIME"
117358+
type="java.lang.String"
117359+
transient="false"
117360+
volatile="false"
117361+
value="&quot;time&quot;"
117362+
static="true"
117363+
final="true"
117364+
deprecated="not deprecated"
117365+
visibility="public"
117366+
>
117367+
</field>
117335117368
<field name="IS_EMPTY"
117336117369
type="int"
117337117370
transient="false"
@@ -216224,7 +216257,7 @@
216224216257
deprecated="not deprecated"
216225216258
visibility="public"
216226216259
>
216227-
<parameter name="arg0" type="T">
216260+
<parameter name="t" type="T">
216228216261
</parameter>
216229216262
</method>
216230216263
</interface>

core/java/android/os/DropBoxManager.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,30 @@ public class DropBoxManager {
5353
/** Flag value: Content can be decompressed with {@link java.util.zip.GZIPOutputStream}. */
5454
public static final int IS_GZIPPED = 4;
5555

56+
/**
57+
* Broadcast Action: This is broadcast when a new entry is added in the dropbox.
58+
* You must hold the {@link android.Manifest.permission#READ_LOGS} permission
59+
* in order to receive this broadcast.
60+
*
61+
* <p class="note">This is a protected intent that can only be sent
62+
* by the system.
63+
*/
64+
public static final String ACTION_DROPBOX_ENTRY_ADDED =
65+
"android.intent.action.DROPBOX_ENTRY_ADDED";
66+
67+
/**
68+
* Extra for {@link android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED}:
69+
* string containing the dropbox tag.
70+
*/
71+
public static final String EXTRA_TAG = "tag";
72+
73+
/**
74+
* Extra for {@link android.os.DropBoxManager#ACTION_DROPBOX_ENTRY_ADDED}:
75+
* long integer value containing time (in milliseconds since January 1, 1970 00:00:00 UTC)
76+
* when the entry was created.
77+
*/
78+
public static final String EXTRA_TIME = "time";
79+
5680
/**
5781
* A single entry retrieved from the drop box.
5882
* This may include a reference to a stream, so you must call

services/java/com/android/server/DropBoxManagerService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,14 @@ public void add(DropBoxManager.Entry entry) {
211211
}
212212
} while (read > 0);
213213

214-
createEntry(temp, tag, flags);
214+
long time = createEntry(temp, tag, flags);
215215
temp = null;
216+
217+
Intent dropboxIntent = new Intent(DropBoxManager.ACTION_DROPBOX_ENTRY_ADDED);
218+
dropboxIntent.putExtra(DropBoxManager.EXTRA_TAG, tag);
219+
dropboxIntent.putExtra(DropBoxManager.EXTRA_TIME, time);
220+
mContext.sendBroadcast(dropboxIntent, android.Manifest.permission.READ_LOGS);
221+
216222
} catch (IOException e) {
217223
Slog.e(TAG, "Can't write: " + tag, e);
218224
} finally {
@@ -590,7 +596,7 @@ private synchronized void enrollEntry(EntryFile entry) {
590596
}
591597

592598
/** Moves a temporary file to a final log filename and enrolls it. */
593-
private synchronized void createEntry(File temp, String tag, int flags) throws IOException {
599+
private synchronized long createEntry(File temp, String tag, int flags) throws IOException {
594600
long t = System.currentTimeMillis();
595601

596602
// Require each entry to have a unique timestamp; if there are entries
@@ -629,6 +635,7 @@ private synchronized void createEntry(File temp, String tag, int flags) throws I
629635
} else {
630636
enrollEntry(new EntryFile(temp, mDropBoxDir, tag, t, flags, mBlockSize));
631637
}
638+
return t;
632639
}
633640

634641
/**

0 commit comments

Comments
 (0)