Files
packages_apps_Settings/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
Kevin Chyn 7b0867c6d3 4/n: Remove challenge from choose/confirm, use new path
Biometric enrollment will not request a Gatekeeper HAT during
initial credential setup or credential confirmation anymore.
Instead, it is broken down into the following steps now.

Bug: 161765592

1) Request credential setup / confirmation to return a
   Gatekeeper Password
2) Biometric enrollment will generate a challenge
3) Biometric enrollment will request LockSettingsService to
   verify(GatekeeperPassword, challenge), and upon verification,
   the Gatekeeper HAT will be returned.

Since both LockSettingsService and Biometric enroll/settings
make use of biometric challenges, this allows us to make the
challenge ownership/lifecycle clear (vs. previously, where
LockSettingsService has no idea who the challenge belongs to).

Exempt-From-Owner-Approval:For files not owned by our team,
(StorageWizard), this change is just a method rename

Test: RunSettingsRoboTests

Run the following on face/fingerprint devices
Test: Remove credential
      adb shell am start -a android.app.action.SET_NEW_PASSWORD
      Set up credential + fingerprint
Test: Remove credential,
      adb shell am start -a android.settings.FINGERPRINT_SETTINGS
      This tests the ChooseLock* logic in FingerprintSettings
Test: Set up credential,
      adb shell am start -a android.settings.FINGERPRINT_SETTINGS
      This tests the ConfirmLock* logic in FingerprintSettings
Test: Remove device credential, enroll fingerprint/face. Succeeds.
      This tests the ChooseLock* returning SP path from
      BiometricEnrollIntro
Test: With credential and fingerprint/face enrolled, go to
      fingerprint/face settings and enroll. This tests the
      ConfirmLock* path in Fingerprint/FaceSettings
Test: Remove device credential, enroll credential-only, enroll
      fingerprint/face separately. Succeeds. This tests the
      ConfirmLock* returning SP path in BiometricEnrollIntro
Test: In SUW, set up credential, then biometric. This tests
      the ChooseLock* path in SUW
Test: In SUW, set up credential, go back, then set up biometric.
      This tests the ConfirmLock* path in SUW

Change-Id: Idf6fcb43f7497323d089eb9c37125294e7a7f5dc
2020-08-07 12:49:15 -07:00

173 lines
6.5 KiB
Java

/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.deviceinfo;
import static com.android.settings.deviceinfo.StorageSettings.TAG;
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.UserManager;
import android.os.storage.DiskInfo;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import java.util.Objects;
public class StorageWizardMigrateConfirm extends StorageWizardBase {
private static final int REQUEST_CREDENTIAL = 100;
private MigrateEstimateTask mEstimate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.storage_wizard_generic);
// When called with just disk, find the first private volume
if (mVolume == null) {
mVolume = findFirstVolume(VolumeInfo.TYPE_PRIVATE);
}
final VolumeInfo sourceVol = getPackageManager().getPrimaryStorageCurrentVolume();
if (sourceVol == null || mVolume == null) {
Log.d(TAG, "Missing either source or target volume");
finish();
return;
}
setIcon(R.drawable.ic_swap_horiz);
setHeaderText(R.string.storage_wizard_migrate_v2_title, getDiskShortDescription());
setBodyText(R.string.memory_calculating_size);
setAuxChecklist();
mEstimate = new MigrateEstimateTask(this) {
@Override
public void onPostExecute(String size, String time) {
setBodyText(R.string.storage_wizard_migrate_v2_body,
getDiskDescription(), size, time);
}
};
mEstimate.copyFrom(getIntent());
mEstimate.execute();
setBackButtonText(R.string.storage_wizard_migrate_v2_later);
setNextButtonText(R.string.storage_wizard_migrate_v2_now);
}
@Override
public void onNavigateBack(View view) {
FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(this,
SettingsEnums.ACTION_STORAGE_MIGRATE_LATER);
if (mDisk != null) {
final Intent intent = new Intent(this, StorageWizardReady.class);
intent.putExtra(EXTRA_MIGRATE_SKIP, true);
startActivity(intent);
} else {
finishAffinity();
}
}
@Override
public void onNavigateNext(View view) {
// Ensure that all users are unlocked so that we can move their data
if (StorageManager.isFileEncryptedNativeOrEmulated()) {
for (UserInfo user : getSystemService(UserManager.class).getUsers()) {
if (!StorageManager.isUserKeyUnlocked(user.id)) {
Log.d(TAG, "User " + user.id + " is currently locked; requesting unlock");
final CharSequence description = TextUtils.expandTemplate(
getText(R.string.storage_wizard_move_unlock), user.name);
final ChooseLockSettingsHelper.Builder builder =
new ChooseLockSettingsHelper.Builder(this);
builder.setRequestCode(REQUEST_CREDENTIAL)
.setDescription(description)
.setUserId(user.id)
.setAllowAnyUserId(true)
.setForceVerifyPath(true)
.show();
return;
}
}
}
// We only expect exceptions from StorageManagerService#setPrimaryStorageUuid
int moveId;
try {
moveId = getPackageManager().movePrimaryStorage(mVolume);
} catch (IllegalArgumentException e) {
StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);
if (Objects.equals(mVolume.getFsUuid(), sm.getPrimaryStorageVolume().getUuid())) {
final Intent intent = new Intent(this, StorageWizardReady.class);
intent.putExtra(DiskInfo.EXTRA_DISK_ID,
getIntent().getStringExtra(DiskInfo.EXTRA_DISK_ID));
startActivity(intent);
finishAffinity();
return;
} else {
throw e;
}
} catch (IllegalStateException e) {
Toast.makeText(this, getString(R.string.another_migration_already_in_progress),
Toast.LENGTH_LONG).show();
finishAffinity();
return;
}
FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(this,
SettingsEnums.ACTION_STORAGE_MIGRATE_NOW);
final Intent intent = new Intent(this, StorageWizardMigrateProgress.class);
intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
intent.putExtra(PackageManager.EXTRA_MOVE_ID, moveId);
startActivity(intent);
finishAffinity();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CREDENTIAL) {
if (resultCode == RESULT_OK) {
// Credentials confirmed, so storage should be unlocked; let's
// go look for the next locked user.
onNavigateNext(null);
} else {
// User wasn't able to confirm credentials, so we're okay
// landing back at the wizard page again, where they read
// instructions again and tap "Next" to try again.
Log.w(TAG, "Failed to confirm credentials");
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
}