OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 599 |
600 this.serializeMetaData(metaFile); | 600 this.serializeMetaData(metaFile); |
601 if (filtersChanged) | 601 if (filtersChanged) |
602 { | 602 { |
603 this.serializeFilters(filtersFile); | 603 this.serializeFilters(filtersFile); |
604 this.clearFilters(); | 604 this.clearFilters(); |
605 } | 605 } |
606 | 606 |
607 return filtersChanged; | 607 return filtersChanged; |
608 } | 608 } |
| 609 |
| 610 void updateNotification(final int responseCode, final String text, final File
notificationDataFile, |
| 611 final File metaFile) throws IOException |
| 612 { |
| 613 if (responseCode != 200 || text == null) |
| 614 { |
| 615 this.meta.put(KEY_TRIED_UPDATE_TIMESTAMP, Long.toString(System.currentTime
Millis())); |
| 616 } |
| 617 else |
| 618 { |
| 619 this.meta.put(KEY_UPDATE_TIMESTAMP, Long.toString(System.currentTimeMillis
())); |
| 620 saveNotificationData(notificationDataFile, text); |
| 621 } |
| 622 serializeMetaData(metaFile); |
| 623 } |
| 624 |
| 625 private void saveNotificationData(final File filtersFile, final String text) |
| 626 { |
| 627 try (final DataOutputStream outputStream = new DataOutputStream(new Buffered
OutputStream( |
| 628 new GZIPOutputStream(new FileOutputStream(filtersFile))))) |
| 629 { |
| 630 outputStream.write(text.getBytes()); |
| 631 } |
| 632 catch (IOException e) |
| 633 { |
| 634 Log.d(TAG, "Failed to write notification data to internal storage.", e); |
| 635 } |
| 636 } |
609 } | 637 } |
OLD | NEW |