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 22 /** 23 * This class provides the required configuration to create a {@link RemoteCarRootTaskView}. 24 * 25 * @hide 26 */ 27 public final class RemoteCarDefaultRootTaskViewConfig { 28 private static final String TAG = RemoteCarDefaultRootTaskViewConfig.class.getSimpleName(); 29 30 private final int mDisplayId; 31 private final boolean mEmbedHomeTask; 32 private final boolean mEmbedRecentsTask; 33 private final boolean mEmbedAssistantTask; 34 RemoteCarDefaultRootTaskViewConfig(int displayId, boolean embedHomeTask, boolean embedRecentsTask, boolean embedAssistantTask)35 private RemoteCarDefaultRootTaskViewConfig(int displayId, boolean embedHomeTask, 36 boolean embedRecentsTask, boolean embedAssistantTask) { 37 mDisplayId = displayId; 38 mEmbedHomeTask = embedHomeTask; 39 mEmbedRecentsTask = embedRecentsTask; 40 mEmbedAssistantTask = embedAssistantTask; 41 } 42 43 /** See {@link Builder#setDisplayId(int)}. */ getDisplayId()44 public int getDisplayId() { 45 return mDisplayId; 46 } 47 48 /** See {@link Builder#embedHomeTask(boolean)}. */ embedsHomeTask()49 public boolean embedsHomeTask() { 50 return mEmbedHomeTask; 51 } 52 53 /** See {@link Builder#embedRecentsTask(boolean)}. */ embedsRecentsTask()54 public boolean embedsRecentsTask() { 55 return mEmbedRecentsTask; 56 } 57 58 /** See {@link Builder#embedAssistantTask(boolean)}. */ embedsAssistantTask()59 public boolean embedsAssistantTask() { 60 return mEmbedAssistantTask; 61 } 62 63 @Override toString()64 public String toString() { 65 return TAG + " {" 66 + " displayId=" + mDisplayId 67 + " embedHomeTask=" + mEmbedHomeTask 68 + " embedRecentsTask=" + mEmbedRecentsTask 69 + " embedAssistantTask=" + mEmbedAssistantTask 70 + '}'; 71 } 72 73 /** 74 * A builder class for {@link RemoteCarDefaultRootTaskViewConfig}. 75 * 76 * @hide 77 */ 78 public static final class Builder { 79 private int mDisplayId; 80 private boolean mEmbedHomeTask; 81 private boolean mEmbedRecentsTask; 82 private boolean mEmbedAssistantTask; 83 Builder()84 public Builder() { 85 } 86 87 /** Sets the display Id of the display which the root task will be created for. */ 88 @NonNull setDisplayId(int displayId)89 public Builder setDisplayId(int displayId) { 90 mDisplayId = displayId; 91 return this; 92 } 93 94 /** Creates the {@link RemoteCarDefaultRootTaskViewConfig} object. */ 95 @NonNull build()96 public RemoteCarDefaultRootTaskViewConfig build() { 97 return new RemoteCarDefaultRootTaskViewConfig(mDisplayId, mEmbedHomeTask, 98 mEmbedRecentsTask, mEmbedAssistantTask); 99 } 100 101 /** 102 * Sets the flag indicating whether the tasks with {@code ACTIVITY_TYPE_HOME} should be 103 * embedded in the root task. 104 */ 105 @NonNull embedHomeTask(boolean embedHomeTask)106 public Builder embedHomeTask(boolean embedHomeTask) { 107 mEmbedHomeTask = embedHomeTask; 108 return this; 109 } 110 111 /** 112 * Sets the flag indicating whether the tasks with {@code ACTIVITY_TYPE_RECENTS} should be 113 * embedded in the root task. 114 */ 115 @NonNull embedRecentsTask(boolean embedRecentsTask)116 public Builder embedRecentsTask(boolean embedRecentsTask) { 117 mEmbedRecentsTask = embedRecentsTask; 118 return this; 119 } 120 121 /** 122 * Sets the flag indicating whether the tasks with {@code ACTIVITY_TYPE_ASSISTANT} 123 * should be embedded in the root task. 124 */ 125 @NonNull embedAssistantTask(boolean embedAssistantTask)126 public Builder embedAssistantTask(boolean embedAssistantTask) { 127 mEmbedAssistantTask = embedAssistantTask; 128 return this; 129 } 130 } 131 } 132