/* * Copyright (C) 2021 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.managedprovisioning; import static com.android.managedprovisioning.ManagedProvisioningScreens.ADMIN_INTEGRATED_PREPARE; import static com.android.managedprovisioning.ManagedProvisioningScreens.ENCRYPT; import static com.android.managedprovisioning.ManagedProvisioningScreens.FINALIZATION_INSIDE_SUW; import static com.android.managedprovisioning.ManagedProvisioningScreens.FINANCED_DEVICE_LANDING; import static com.android.managedprovisioning.ManagedProvisioningScreens.LANDING; import static com.android.managedprovisioning.ManagedProvisioningScreens.POST_ENCRYPT; import static com.android.managedprovisioning.ManagedProvisioningScreens.PRE_PROVISIONING; import static com.android.managedprovisioning.ManagedProvisioningScreens.PROVISIONING; import static com.android.managedprovisioning.ManagedProvisioningScreens.RESET_AND_RETURN_DEVICE; import static com.android.managedprovisioning.ManagedProvisioningScreens.TERMS; import static com.android.managedprovisioning.ManagedProvisioningScreens.WEB; import android.app.Activity; import com.android.managedprovisioning.finalization.FinalizationInsideSuwActivity; import com.android.managedprovisioning.preprovisioning.EncryptDeviceActivity; import com.android.managedprovisioning.preprovisioning.PostEncryptionActivity; import com.android.managedprovisioning.preprovisioning.PreProvisioningActivity; import com.android.managedprovisioning.preprovisioning.WebActivity; import com.android.managedprovisioning.preprovisioning.terms.TermsActivity; import com.android.managedprovisioning.provisioning.AdminIntegratedFlowPrepareActivity; import com.android.managedprovisioning.provisioning.FinancedDeviceLandingActivity; import com.android.managedprovisioning.provisioning.LandingActivity; import com.android.managedprovisioning.provisioning.ProvisioningActivity; import com.android.managedprovisioning.provisioning.ResetAndReturnDeviceActivity; import java.util.HashMap; import java.util.Map; /** * A manager for the mapping between {@link ManagedProvisioningScreens} and {@link Activity}. * *
By default, all {@link ManagedProvisioningScreens} map to the base {@code ManagedProvisioning}
* screens. {@code ManagedProvisioning} inheritors can call {@link
* #setOverrideActivity(ManagedProvisioningScreens, Class)} if they want the screens to map to
* their own {@link Activity} implementations.
*/
final class ScreenManager {
static final Map When ManagedProvisioning wants to launch any of the screens in {@link
* ManagedProvisioningScreens}, instead of its base {@link Activity} implementation, it will
* launch the class provided here.
*/
public void setOverrideActivity(ManagedProvisioningScreens screen,
Class extends Activity> newClass) {
mScreenToActivityMap.put(screen, newClass);
}
/**
* Retrieves the {@link Activity} class associated with the provided {@code screen}.
*
* If no screens were set via {@link #setOverrideActivity(ManagedProvisioningScreens,
* Class)}, the base ManagedProvisioning {@link Activity} implementation will be returned.
*/
public Class extends Activity> getActivityClassForScreen(ManagedProvisioningScreens screen) {
return mScreenToActivityMap.get(screen);
}
private static Map