Fix a race condition in DeviceOwnerProvisioningService
The variable mDone is set in one thread, while read from another (broadcast
receiver). Mark it as volatile to make sure the write is registered.
Alternatively, I believe it should be safe to remove mDone from
IndirectHomeReceiver.
Bug: 19806407
Change-Id: I7519b09ca085f98556ec39f77d7b988d62be135a
diff --git a/src/com/android/managedprovisioning/DeviceOwnerProvisioningService.java b/src/com/android/managedprovisioning/DeviceOwnerProvisioningService.java
index 0f59f71..9b3b6f8 100644
--- a/src/com/android/managedprovisioning/DeviceOwnerProvisioningService.java
+++ b/src/com/android/managedprovisioning/DeviceOwnerProvisioningService.java
@@ -30,7 +30,6 @@
import android.os.IBinder;
import android.os.UserHandle;
import android.support.v4.content.LocalBroadcastManager;
-import android.text.TextUtils;
import com.android.internal.app.LocalePicker;
import com.android.managedprovisioning.task.AddWifiNetworkTask;
@@ -95,8 +94,8 @@
// MessageId of the last error message.
private int mLastErrorMessage = -1;
- // Indicates whether provisioning has finished succesfully (service waiting to stop).
- private boolean mDone = false;
+ // Indicates whether provisioning has finished successfully (service waiting to stop).
+ private volatile boolean mDone = false;
// Provisioning tasks.
private AddWifiNetworkTask mAddWifiNetworkTask;
@@ -124,7 +123,7 @@
sendError();
}
- // Send success if provisioning was succesful.
+ // Send success if provisioning was successful.
if (mDone) {
onProvisioningSuccess(mParams.mDeviceAdminPackageName);
}
@@ -294,6 +293,7 @@
R.array.vendor_required_apps_managed_device, true /* creating new profile */,
UserHandle.USER_OWNER, params.mLeaveAllSystemAppsEnabled,
new DeleteNonRequiredAppsTask.Callback() {
+ @Override
public void onSuccess() {
// Done with provisioning. Success.
onProvisioningSuccess(params.mDeviceAdminPackageName);
@@ -302,7 +302,7 @@
@Override
public void onError() {
error(R.string.device_owner_error_general);
- };
+ }
});
// Start first task, which starts next task in its callback, etc.