1 /*
2  * Copyright (C) 2020 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.car.provision;
17 
18 import android.content.ComponentName;
19 
20 import java.util.Objects;
21 
22 /**
23  * Info about a Device Policy Controller app.
24  */
25 final class DpcInfo {
26 
27     public final String name;
28     public final String packageName;
29     private final String mLegacyActivityName;
30     private final String mReceiverName;
31     public final String checkSum;
32     public final String downloadUrl;
33 
DpcInfo(String name, String packageName, String legacyActivityName, String receiverName, String checkSum, String downloadUrl)34     DpcInfo(String name, String packageName, String legacyActivityName,
35             String receiverName, String checkSum, String downloadUrl) {
36         this.name = Objects.requireNonNull(name, "name cannot be null");
37         this.packageName = Objects.requireNonNull(packageName, "packageName cannot be null");
38         this.mReceiverName = Objects.requireNonNull(receiverName, "receiverName cannot be null");
39         this.mLegacyActivityName = legacyActivityName;
40         this.checkSum = checkSum;
41         this.downloadUrl = downloadUrl;
42     }
43 
44     /***
45      * Gets the name of the activity that launches the legacy workflow.
46      */
getLegacyActivityComponentName()47     public ComponentName getLegacyActivityComponentName() {
48         return new ComponentName(packageName, mLegacyActivityName);
49     }
50 
51     /***
52      * Gets the name of the admin receiver.
53      */
getAdminReceiverComponentName()54     public ComponentName getAdminReceiverComponentName() {
55         return new ComponentName(packageName, mReceiverName);
56     }
57 
58     @Override
toString()59     public String toString() {
60         return "DpcInfo[name=" + name + ", package=" + packageName
61                 + ", legacyWorkflowComponentName=" + getLegacyActivityComponentName()
62                 + ", adminComponentName=" + getAdminReceiverComponentName()
63                 + ", checkSum=" + checkSum
64                 + ", downloadUrl=" + downloadUrl
65                 + "]";
66     }
67 }
68