1 /* 2 * Copyright (C) 2023 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 17 package android.car.app; 18 19 20 import android.annotation.NonNull; 21 import android.content.ComponentName; 22 23 import java.util.List; 24 25 /** 26 * This class provides the required configuration to create a {@link RemoteCarRootTaskView}. 27 * 28 * @hide 29 */ 30 public final class RemoteCarRootTaskViewConfig { 31 private static final String TAG = RemoteCarRootTaskViewConfig.class.getSimpleName(); 32 33 private final int mDisplayId; 34 private final List<ComponentName> mAllowListedActivities; 35 RemoteCarRootTaskViewConfig(int displayId, @NonNull List<ComponentName> allowListedActivities)36 private RemoteCarRootTaskViewConfig(int displayId, 37 @NonNull List<ComponentName> allowListedActivities) { 38 mDisplayId = displayId; 39 mAllowListedActivities = allowListedActivities; 40 } 41 42 /** See {@link Builder#setDisplayId(int)}. */ getDisplayId()43 public int getDisplayId() { 44 return mDisplayId; 45 } 46 47 /** See {@link Builder#setAllowListedActivities(List)}. */ getAllowListedActivities()48 public List<ComponentName> getAllowListedActivities() { 49 return mAllowListedActivities; 50 } 51 52 @Override toString()53 public String toString() { 54 return TAG + " {" 55 + " displayId=" + mDisplayId 56 + " allowListedActivities= " + mAllowListedActivities 57 + '}'; 58 } 59 60 /** 61 * A builder class for {@link RemoteCarRootTaskViewConfig}. 62 * 63 * @hide 64 */ 65 public static final class Builder { 66 private int mDisplayId; 67 68 private List<ComponentName> mAllowListedActivities; 69 Builder()70 public Builder() { 71 } 72 73 /** Sets the display Id of the display which the root task will be created for. */ 74 @NonNull setDisplayId(int displayId)75 public Builder setDisplayId(int displayId) { 76 mDisplayId = displayId; 77 return this; 78 } 79 80 /** 81 * Sets the initial list of all the allow listed activities which will be persisted on the 82 * root task that is embedded inside the task view. 83 */ 84 @NonNull setAllowListedActivities( @onNull List<ComponentName> allowListedActivities)85 public Builder setAllowListedActivities( 86 @NonNull List<ComponentName> allowListedActivities) { 87 mAllowListedActivities = allowListedActivities; 88 return this; 89 } 90 91 /** Creates the {@link RemoteCarRootTaskViewConfig} object. */ 92 @NonNull build()93 public RemoteCarRootTaskViewConfig build() { 94 return new RemoteCarRootTaskViewConfig(mDisplayId, mAllowListedActivities); 95 } 96 } 97 } 98