From 3bad02dec85f3946f4ded0751f2ad7966318e474 Mon Sep 17 00:00:00 2001 From: Sander Alewijnse Date: Thu, 2 Oct 2014 14:57:05 +0100 Subject: Allow orientation change (restart) for the learn more dialog. This does NOT fix the orientation change issues in the managed provisioning activity. Bug:17384624 Change-Id: Iac89f8b5eca228bb6f3408fef54f42e7db513470 --- .../DeviceOwnerProvisioningActivity.java | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'src/com/android/managedprovisioning/DeviceOwnerProvisioningActivity.java') diff --git a/src/com/android/managedprovisioning/DeviceOwnerProvisioningActivity.java b/src/com/android/managedprovisioning/DeviceOwnerProvisioningActivity.java index f7f33e97..c2b521eb 100644 --- a/src/com/android/managedprovisioning/DeviceOwnerProvisioningActivity.java +++ b/src/com/android/managedprovisioning/DeviceOwnerProvisioningActivity.java @@ -19,6 +19,7 @@ package com.android.managedprovisioning; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; +import android.app.DialogFragment; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; @@ -63,7 +64,9 @@ import java.util.Locale; * repeated. We made sure that all tasks can be done twice without causing any problems. *

*/ -public class DeviceOwnerProvisioningActivity extends Activity { +public class DeviceOwnerProvisioningActivity extends Activity + implements UserConsentDialog.ConsentCallback { + private static final String KEY_USER_CONSENTED = "user_consented"; private static final int ENCRYPT_DEVICE_REQUEST_CODE = 1; @@ -80,6 +83,9 @@ public class DeviceOwnerProvisioningActivity extends Activity { // Indicates whether user consented by clicking on positive button of interstitial. private boolean mUserConsented = false; + // Params that will be used after user consent. + private ProvisioningParams mParamsToConsent; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -160,22 +166,23 @@ public class DeviceOwnerProvisioningActivity extends Activity { } else { // Notify the user that the admin will have full control over the device, // then start provisioning. - new UserConsentDialog(this, UserConsentDialog.DEVICE_OWNER, new Runnable() { - @Override - public void run() { - mUserConsented = true; - startDeviceOwnerProvisioningService(params); - } - } /* onUserConsented */ , new Runnable() { - @Override - public void run() { - finish(); - } - } /* onCancel */).show(getFragmentManager(), - "UserConsentDialogFragment"); + mParamsToConsent = params; + UserConsentDialog.newInstance(UserConsentDialog.DEVICE_OWNER) + .show(getFragmentManager(), "UserConsentDialogFragment"); } } + @Override + public void onDialogConsent() { + mUserConsented = true; + startDeviceOwnerProvisioningService(mParamsToConsent); + } + + @Override + public void onDialogCancel() { + finish(); + } + private void startDeviceOwnerProvisioningService(ProvisioningParams params) { Intent intent = new Intent(this, DeviceOwnerProvisioningService.class); intent.putExtra(DeviceOwnerProvisioningService.EXTRA_PROVISIONING_PARAMS, params); -- cgit v1.2.3