Skip to content

Commit 9a0a5f1

Browse files
committed
review changes
1 parent ad4136b commit 9a0a5f1

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

app/src/main/java/app/attestation/auditor/AttestationActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ public boolean onOptionsItemSelected(final MenuItem item) {
553553
else if (itemId == R.id.action_remote_verify_now) {
554554
if (checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
555555
requestPermissions(new String[]{Manifest.permission.POST_NOTIFICATIONS},
556-
PERMISSIONS_REQUEST_POST_NOTIFICATIONS_SUBMIT_SAMPLE);
556+
PERMISSIONS_REQUEST_POST_NOTIFICATIONS_REMOTE_VERIFY);
557557
} else {
558558
RemoteVerifyJob.schedule(this, -1);
559559
snackbar.setText(R.string.remote_verify_now).show();

app/src/main/java/app/attestation/auditor/RemoteVerifyJob.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class RemoteVerifyJob extends JobService {
3939
private static final String TAG = "RemoteVerifyJob";
4040
private static final int PERIODIC_JOB_ID = 0;
4141
private static final int FIRST_RUN_JOB_ID = 1;
42+
43+
private static final int FIRE_ONCE_JOB_ID = 2;
4244
static final String DOMAIN = "attestation.app";
4345
private static final String CHALLENGE_URL = "https://" + DOMAIN + "/challenge";
4446
private static final String VERIFY_URL = "https://" + DOMAIN + "/verify";
@@ -117,13 +119,14 @@ static void schedule(final Context context, int interval) {
117119
throw new RuntimeException("job schedule failed");
118120
}
119121
}
120-
final JobInfo.Builder builder = new JobInfo.Builder(PERIODIC_JOB_ID, serviceName)
122+
final JobInfo.Builder builder = scheduleNow ?
123+
new JobInfo.Builder(FIRE_ONCE_JOB_ID, serviceName)
124+
.setPersisted(true)
125+
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
126+
: new JobInfo.Builder(PERIODIC_JOB_ID, serviceName)
121127
.setPersisted(true)
122-
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
123-
124-
if(!scheduleNow) {
125-
builder.setPeriodic(intervalMillis, flexMillis);
126-
}
128+
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
129+
.setPeriodic(intervalMillis, flexMillis);
127130

128131
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
129132
builder.setEstimatedNetworkBytes(ESTIMATED_DOWNLOAD_BYTES, ESTIMATED_UPLOAD_BYTES);

0 commit comments

Comments
 (0)