1/*
2 * Copyright (C) 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
17package android.hardware.confirmationui@1.0;
18
19/**
20 * UI modification options.
21 */
22enum UIOption : uint32_t {
23    /** Accessibility: Requests color inverted style. */
24    AccessibilityInverted = 0,
25    /** Accessibility: Requests magnified style. */
26    AccessibilityMagnified = 1,
27};
28
29/**
30 * Codes returned by ConfirmationUI API calls.
31 */
32enum ResponseCode : uint32_t {
33    /** API call succeeded or the user gave approval (result callback). */
34    OK = 0,
35    /** The user canceled the TUI (result callback). */
36    Canceled = 1,
37    /** IConfirmationUI::abort() was called. (result callback). */
38    Aborted = 2,
39    /** Cannot start another prompt. */
40    OperationPending = 3,
41    /** IConfirmationUI::deliverSecureInputEvent call was ingored. */
42    Ignored = 4,
43    /** An unexpected system error occured. */
44    SystemError = 5,
45    /** Returned by an unimplemented API call. */
46    Unimplemented = 6,
47     /**
48       * This is returned when an error is diagnosed that should have been
49       * caught by earlier input sanitization. Should never be seen in production.
50       */
51    Unexpected = 7,
52    /** General UI error. */
53    UIError = 0x10000,
54    UIErrorMissingGlyph,
55    /**
56     * The implementation must return this error code on promptUserConfirmation if the
57     * resulting formatted message does not fit into MessageSize::MAX bytes. It is
58     * advised that the implementation formats the message upon receiving this API call to
59     * be able to diagnose this syndrome.
60     */
61    UIErrorMessageTooLong,
62    UIErrorMalformedUTF8Encoding,
63};
64
65/**
66 * This defines the maximum message size. This indirectly limits the size of the prompt text
67 * and the extra data that can be passed to the confirmation UI. The prompt text and extra data
68 * must fit in to this size including CBOR header information.
69 */
70enum MessageSize : uint32_t { MAX = 0x1800 };
71
72/**
73 * The test key is 32byte word with all bytes set to TestKeyBits::BYTE.
74 */
75enum TestKeyBits: uint8_t { BYTE = 0xA5 };
76
77/**
78 * Test mode commands.
79 *
80 * IConfirmationUI::deliverSecureInputEvent can be used to test certain code paths.
81 * To that end, the caller passes an auth token that has an HMAC keyed with the test key
82 * (see TestKeyBits in types.hal). Implementations first check the HMAC against test key.
83 * If the test key produces a matching HMAC, the implementation evaluates the challenge field
84 * of the auth token against the values defined in TestModeCommand.
85 * If the command indicates that a confirmation token is to be generated the test key MUST be used
86 * to generate this confirmation token.
87 *
88 * See command code for individual test command descriptions.
89 */
90enum TestModeCommands: uint64_t {
91    /**
92     * Simulates the user pressing the OK button on the UI. If no operation is pending
93     * ResponseCode::Ignored must be returned. A pending operation is finalized successfully
94     * see IConfirmationResultCallback::result, however, the test key (see TestKeyBits) MUST be
95     * used to generate the confirmation token.
96     */
97    OK_EVENT = 0,
98    /**
99     * Simulates the user pressing the CANCEL button on the UI. If no operation is pending
100     * Result::Ignored must be returned. A pending operation is finalized as specified in
101     * IConfirmationResultCallback.hal.
102     */
103    CANCEL_EVENT = 1,
104};
105