Home | History | Annotate | Download | only in client
      1 //
      2 // Copyright (C) 2016 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 #ifndef TPM_MANAGER_CLIENT_TPM_NVRAM_BINDER_PROXY_H_
     18 #define TPM_MANAGER_CLIENT_TPM_NVRAM_BINDER_PROXY_H_
     19 
     20 #include <base/macros.h>
     21 
     22 #include "android/tpm_manager/ITpmNvram.h"
     23 #include "tpm_manager/common/export.h"
     24 #include "tpm_manager/common/tpm_nvram_interface.h"
     25 
     26 namespace tpm_manager {
     27 
     28 // An implementation of TpmNvramInterface that forwards requests to tpm_managerd
     29 // using Binder.
     30 class TPM_MANAGER_EXPORT TpmNvramBinderProxy : public TpmNvramInterface {
     31  public:
     32   TpmNvramBinderProxy() = default;
     33   explicit TpmNvramBinderProxy(android::tpm_manager::ITpmNvram* binder);
     34   ~TpmNvramBinderProxy() override = default;
     35 
     36   // Initializes the client. Returns true on success.
     37   bool Initialize();
     38 
     39   // TpmNvramInterface methods. All assume a message loop and binder watcher
     40   // have already been configured elsewhere.
     41   void DefineSpace(const DefineSpaceRequest& request,
     42                    const DefineSpaceCallback& callback) override;
     43   void DestroySpace(const DestroySpaceRequest& request,
     44                     const DestroySpaceCallback& callback) override;
     45   void WriteSpace(const WriteSpaceRequest& request,
     46                   const WriteSpaceCallback& callback) override;
     47   void ReadSpace(const ReadSpaceRequest& request,
     48                  const ReadSpaceCallback& callback) override;
     49   void LockSpace(const LockSpaceRequest& request,
     50                  const LockSpaceCallback& callback) override;
     51   void ListSpaces(const ListSpacesRequest& request,
     52                   const ListSpacesCallback& callback) override;
     53   void GetSpaceInfo(const GetSpaceInfoRequest& request,
     54                     const GetSpaceInfoCallback& callback) override;
     55 
     56  private:
     57   android::sp<android::tpm_manager::ITpmNvram> default_binder_;
     58   android::tpm_manager::ITpmNvram* binder_ = nullptr;
     59 
     60   DISALLOW_COPY_AND_ASSIGN(TpmNvramBinderProxy);
     61 };
     62 
     63 }  // namespace tpm_manager
     64 
     65 #endif  // TPM_MANAGER_CLIENT_TPM_NVRAM_BINDER_PROXY_H_
     66