| 1 | /* |
| 2 | * Copyright (C) 2019 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.service.controls.actions; |
| 18 | |
| 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.Nullable; |
| 21 | import android.os.Bundle; |
| 22 | import android.service.controls.Control; |
| 23 | import android.service.controls.templates.StatelessTemplate; |
| 24 | |
| 25 | /** |
| 26 | * A simple {@link ControlAction} indicating that the user has interacted with a {@link Control} |
| 27 | * created using a {@link StatelessTemplate}. |
| 28 | */ |
| 29 | public final class CommandAction extends ControlAction { |
| 30 | |
| 31 | private static final @ActionType int TYPE = TYPE_COMMAND; |
| 32 | |
| 33 | /** |
| 34 | * @param templateId the identifier of the {@link StatelessTemplate} that originated this |
| 35 | * action. |
| 36 | * @param challengeValue a value sent by the user along with the action to authenticate. {@code} |
| 37 | * null is sent when no authentication is needed or has not been |
| 38 | * requested. |
| 39 | */ |
| 40 | public CommandAction(@NonNull String templateId, @Nullable String challengeValue) { |
| 41 | super(templateId, challengeValue); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @param templateId the identifier of the {@link StatelessTemplate} that originated this |
| 46 | * action. |
| 47 | */ |
| 48 | public CommandAction(@NonNull String templateId) { |
| 49 | this(templateId, null); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @param b |
| 54 | * @hide |
| 55 | */ |
| 56 | CommandAction(Bundle b) { |
| 57 | super(b); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @return {@link ControlAction#TYPE_COMMAND} |
| 62 | */ |
| 63 | @Override |
| 64 | public int getActionType() { |
| 65 | return TYPE; |
| 66 | } |
| 67 | } |