1 /*
2  * Copyright 2017, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.managedprovisioning.model;
17 
18 import android.annotation.Nullable;
19 import android.content.Context;
20 import android.webkit.URLUtil;
21 
22 import com.android.managedprovisioning.common.Utils;
23 
24 /**
25  * Captures parameters related to brand customization (e.g. tint color).
26  */
27 public class CustomizationParams {
28     /** Support url of the organization where the device is being provisioned. */
29     public final @Nullable String supportUrl;
30 
31     /**
32      * Computes an instance from {@link ProvisioningParams} and required helper classes.
33      * @param params {@link ProvisioningParams} instance to compute the values from
34      * @param context {@link Context} instance to resolve color ids
35      */
createInstance( ProvisioningParams params, Context context, Utils utils)36     public static CustomizationParams createInstance(
37             ProvisioningParams params, Context context, Utils utils) {
38         return createInstance(params.supportUrl, context);
39     }
40 
createInstance( @ullable String supportUrl, Context context)41     private static CustomizationParams createInstance(
42             @Nullable String supportUrl,
43             Context context) {
44         supportUrl = URLUtil.isNetworkUrl(supportUrl) ? supportUrl : null;
45         return new CustomizationParams(supportUrl);
46     }
47 
CustomizationParams(String supportUrl)48     private CustomizationParams(String supportUrl) {
49         this.supportUrl = supportUrl;
50     }
51 }
52