summaryrefslogtreecommitdiff
path: root/java/com/android
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-08-14 12:07:44 -0700
committerEric Erfanian <erfanian@google.com>2017-08-14 14:39:33 -0700
commitfea083f71d9ca31f9180ae04be59ec80a2feb915 (patch)
tree36419233e7560db8f6f6ed9a090d3b62ebd6d970 /java/com/android
parent43c7bb6575ebaa06efdf709aeb7bc27e6526de67 (diff)
Handle setup wizard relaunching
Visual voicemail activation is delayed until the setup wizard is completed, so all settings like user language can be gathered. This is don by monitoring the DEVICE_PROVISIONED system setting. Previously it is asserted that when DEVICE_PROVISIONED changed it can only be changed to "1". This is not true and the "0" case must be handled by rescheduling the monitoring job. Bug: 62666193 Test: DeviceProvisionedJobServiceTest PiperOrigin-RevId: 165210810 Change-Id: I15990eba65cfc41faeec057cd4bc56b6fdc72082
Diffstat (limited to 'java/com/android')
-rw-r--r--java/com/android/voicemail/impl/DeviceProvisionedJobService.java33
1 files changed, 20 insertions, 13 deletions
diff --git a/java/com/android/voicemail/impl/DeviceProvisionedJobService.java b/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
index a0b999d23..20993d051 100644
--- a/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
+++ b/java/com/android/voicemail/impl/DeviceProvisionedJobService.java
@@ -29,6 +29,7 @@ import android.content.Intent;
import android.os.Build.VERSION_CODES;
import android.provider.Settings;
import android.provider.Settings.Global;
+import android.support.annotation.VisibleForTesting;
import android.telecom.PhoneAccountHandle;
import com.android.dialer.constants.ScheduledJobIds;
@@ -39,29 +40,25 @@ import com.android.dialer.constants.ScheduledJobIds;
@TargetApi(VERSION_CODES.O)
public class DeviceProvisionedJobService extends JobService {
- private static final String EXTRA_PHONE_ACCOUNT_HANDLE = "EXTRA_PHONE_ACCOUNT_HANDLE";
+ @VisibleForTesting static final String EXTRA_PHONE_ACCOUNT_HANDLE = "EXTRA_PHONE_ACCOUNT_HANDLE";
/** Queue the phone account to be reactivated after the setup wizard has completed. */
public static void activateAfterProvisioned(
Context context, PhoneAccountHandle phoneAccountHandle) {
- JobInfo jobInfo =
- new JobInfo.Builder(
- ScheduledJobIds.VVM_DEVICE_PROVISIONED_JOB,
- new ComponentName(context, DeviceProvisionedJobService.class))
- .addTriggerContentUri(
- new TriggerContentUri(Global.getUriFor(Global.DEVICE_PROVISIONED), 0))
- // VVM activation must be run as soon as possible to avoid voicemail loss
- .setTriggerContentMaxDelay(0)
- .build();
-
Intent intent = new Intent();
intent.putExtra(EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
- context.getSystemService(JobScheduler.class).enqueue(jobInfo, new JobWorkItem(intent));
+ context
+ .getSystemService(JobScheduler.class)
+ .enqueue(createJobInfo(context), new JobWorkItem(intent));
}
@Override
public boolean onStartJob(JobParameters params) {
- Assert.isTrue(isDeviceProvisioned());
+ if (!isDeviceProvisioned()) {
+ VvmLog.i("DeviceProvisionedJobService.onStartJob", "device not provisioned, rescheduling");
+ getSystemService(JobScheduler.class).schedule(createJobInfo(this));
+ return false; // job not running in background
+ }
VvmLog.i("DeviceProvisionedJobService.onStartJob", "device provisioned");
for (JobWorkItem item = params.dequeueWork(); item != null; item = params.dequeueWork()) {
PhoneAccountHandle phoneAccountHandle =
@@ -82,4 +79,14 @@ public class DeviceProvisionedJobService extends JobService {
private boolean isDeviceProvisioned() {
return Settings.Global.getInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) == 1;
}
+
+ private static JobInfo createJobInfo(Context context) {
+ return new JobInfo.Builder(
+ ScheduledJobIds.VVM_DEVICE_PROVISIONED_JOB,
+ new ComponentName(context, DeviceProvisionedJobService.class))
+ .addTriggerContentUri(new TriggerContentUri(Global.getUriFor(Global.DEVICE_PROVISIONED), 0))
+ // VVM activation must be run as soon as possible to avoid voicemail loss
+ .setTriggerContentMaxDelay(0)
+ .build();
+ }
}