Home | History | Annotate | Download | only in default
      1 /*
      2 **
      3 ** Copyright 2017, The Android Open Source Project
      4 **
      5 ** Licensed under the Apache License, Version 2.0 (the "License");
      6 ** you may not use this file except in compliance with the License.
      7 ** You may obtain a copy of the License at
      8 **
      9 **     http://www.apache.org/licenses/LICENSE-2.0
     10 **
     11 ** Unless required by applicable law or agreed to in writing, software
     12 ** distributed under the License is distributed on an "AS IS" BASIS,
     13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 ** See the License for the specific language governing permissions and
     15 ** limitations under the License.
     16 */
     17 
     18 #include "ConfirmationUI.h"
     19 
     20 #include "PlatformSpecifics.h"
     21 
     22 #include <android/hardware/confirmationui/support/cbor.h>
     23 #include <android/hardware/confirmationui/support/confirmationui_utils.h>
     24 
     25 #include <android/hardware/confirmationui/1.0/generic/GenericOperation.h>
     26 
     27 #include <time.h>
     28 
     29 namespace android {
     30 namespace hardware {
     31 namespace confirmationui {
     32 namespace V1_0 {
     33 namespace implementation {
     34 
     35 using ::android::hardware::confirmationui::V1_0::generic::Operation;
     36 using ::android::hardware::keymaster::V4_0::HardwareAuthToken;
     37 
     38 uint8_t hmacKey[32];
     39 
     40 // Methods from ::android::hardware::confirmationui::V1_0::IConfirmationUI follow.
     41 Return<ResponseCode> ConfirmationUI::promptUserConfirmation(
     42     const sp<IConfirmationResultCallback>& resultCB, const hidl_string& promptText,
     43     const hidl_vec<uint8_t>& extraData, const hidl_string& locale,
     44     const hidl_vec<UIOption>& uiOptions) {
     45     auto& operation = MyOperation::get();
     46     auto result = operation.init(resultCB, promptText, extraData, locale, uiOptions);
     47     if (result == ResponseCode::OK) {
     48         // This is where implementation start the UI and then call setPending on success.
     49         operation.setPending();
     50     }
     51     return result;
     52 }
     53 
     54 Return<ResponseCode> ConfirmationUI::deliverSecureInputEvent(
     55     const HardwareAuthToken& secureInputToken) {
     56     auto& operation = MyOperation::get();
     57     return operation.deliverSecureInputEvent(secureInputToken);
     58 }
     59 
     60 Return<void> ConfirmationUI::abort() {
     61     auto& operation = MyOperation::get();
     62     operation.abort();
     63     operation.finalize(hmacKey);
     64     return Void();
     65 }
     66 
     67 }  // namespace implementation
     68 }  // namespace V1_0
     69 }  // namespace confirmationui
     70 }  // namespace hardware
     71 }  // namespace android
     72