Skip to content

Commit 1fff819

Browse files
committed
Merge pull request #93 from Fuzion24/feature/notify_user_about_updated_test
Add a flag that controls whether an existing test was updated to notify the user
2 parents a1ab9cf + c7e5630 commit 1fff819

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

app/src/main/java/fuzion24/device/vulnerability/broadcastreceiver/ApplicationUpdateBroadcastReceiver.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class ApplicationUpdateBroadcastReceiver extends BroadcastReceiver {
2929

3030
private static final int NOTIFICATION_ID = 1;
3131

32+
private static final boolean mTestWasChanged = false;
33+
3234
@Override
3335
public void onReceive(final Context context, final Intent intent) {
3436
List<String> currentTestsAvailable = new ArrayList<>();
@@ -41,7 +43,7 @@ public void onReceive(final Context context, final Intent intent) {
4143

4244
// First run, save the current list of scans.
4345
if (testsAvailableOnPreviousBuild == null) {
44-
Log.d(TAG, "This is the first time this detection is running.");
46+
Log.d(TAG, "This is the first time this detection is running.");
4547
SharedPreferencesUtils.setTheListOfScansAvailable(context, currentTestsAvailable);
4648

4749
return;
@@ -50,11 +52,16 @@ public void onReceive(final Context context, final Intent intent) {
5052
// Update application with the tests available.
5153
SharedPreferencesUtils.setTheListOfScansAvailable(context, currentTestsAvailable);
5254

55+
if(mTestWasChanged){
56+
buildNotification(context, false);
57+
Log.d(TAG, "An existing test was updated");
58+
}
59+
5360
for (String testName : currentTestsAvailable) {
5461
if (!testsAvailableOnPreviousBuild.contains(testName)) {
5562

5663
// This test is new, show a notification to the user.
57-
buildNotification(context);
64+
buildNotification(context, true);
5865
Log.d(TAG, String.format("New test available:, %s", testName));
5966

6067
return;
@@ -64,11 +71,12 @@ public void onReceive(final Context context, final Intent intent) {
6471
Log.d(TAG, "Without new tests detected.");
6572
}
6673

67-
private void buildNotification(Context context) {
74+
private void buildNotification(Context context, boolean forNewTest) {
6875
NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_notification)
6976
.setAutoCancel(true)
7077
.setContentTitle(context.getString(R.string.app_name))
71-
.setContentText(context.getString(R.string.notification_new_tests));
78+
.setContentText(forNewTest ? context.getString(R.string.notification_new_tests) :
79+
context.getString(R.string.existing_test_updated));
7280

7381
Intent notificationIntent = new Intent(context, MainActivity.class);
7482

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<string name="cvssv2">CVSSV2: </string>
3636
<string name="cve_date">CVE Date: </string>
3737
<string name="notification_new_tests">New tests are available</string>
38+
<string name="existing_test_updated">An existing vulnerability test has been updated</string>
3839
<string name="scan_details">Scan details</string>
3940
<string name="my_device_is_vulnerable_info">Now What?</string>
4041
<string name="scan_details_number_failed_tests">Number of failed tests:</string>

0 commit comments

Comments
 (0)