| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.device.nfc; | |
| 6 | |
| 7 import android.content.Context; | |
| 8 | |
| 9 import org.chromium.device.nfc.mojom.Nfc; | |
| 10 import org.chromium.device.nfc.mojom.NfcProvider; | |
| 11 import org.chromium.mojo.bindings.InterfaceRequest; | |
| 12 import org.chromium.mojo.system.MojoException; | |
| 13 import org.chromium.services.service_manager.InterfaceFactory; | |
| 14 | |
| 15 /** | |
| 16 * Android implementation of the NfcProvider Mojo interface. | |
| 17 */ | |
| 18 public class NfcProviderImpl implements NfcProvider { | |
| 19 private static final String TAG = "NfcProviderImpl"; | |
| 20 private Context mContext; | |
| 21 private NfcDelegate mDelegate; | |
| 22 | |
| 23 public NfcProviderImpl(Context context, NfcDelegate delegate) { | |
| 24 mContext = context; | |
| 25 mDelegate = delegate; | |
| 26 } | |
| 27 | |
| 28 @Override | |
| 29 public void close() {} | |
| 30 | |
| 31 @Override | |
| 32 public void onConnectionError(MojoException e) {} | |
| 33 | |
| 34 @Override | |
| 35 public void getNfcForHost(int hostId, InterfaceRequest<Nfc> request) { | |
| 36 Nfc.MANAGER.bind(new NfcImpl(mContext, hostId, mDelegate), request); | |
| 37 } | |
| 38 | |
| 39 /** | |
| 40 * A factory for implementations of the NfcProvider interface. | |
| 41 */ | |
| 42 public static class Factory implements InterfaceFactory<NfcProvider> { | |
| 43 private Context mContext; | |
| 44 private NfcDelegate mDelegate; | |
| 45 | |
| 46 public Factory(Context context, NfcDelegate delegate) { | |
| 47 mContext = context; | |
| 48 mDelegate = delegate; | |
| 49 } | |
| 50 | |
| 51 @Override | |
| 52 public NfcProvider createImpl() { | |
| 53 return new NfcProviderImpl(mContext, mDelegate); | |
| 54 } | |
| 55 } | |
| 56 } | |
| OLD | NEW |