diff options
| -rw-r--r-- | core/api/current.txt | 17 | ||||
| -rw-r--r-- | core/api/system-current.txt | 7 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageManager.java | 10 | ||||
| -rw-r--r-- | core/java/android/nfc/INfcAdapter.aidl | 9 | ||||
| -rw-r--r-- | core/java/android/nfc/INfcWlcStateListener.aidl | 30 | ||||
| -rw-r--r-- | core/java/android/nfc/NfcAdapter.java | 164 | ||||
| -rw-r--r-- | core/java/android/nfc/NfcWlcStateListener.java | 120 | ||||
| -rw-r--r-- | core/java/android/nfc/WlcLDeviceInfo.aidl | 19 | ||||
| -rw-r--r-- | core/java/android/nfc/WlcLDeviceInfo.java | 107 | ||||
| -rw-r--r-- | core/java/android/nfc/flags.aconfig | 7 |
10 files changed, 487 insertions, 3 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index ec8f0706379c..df073dda254a 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -12932,6 +12932,7 @@ package android.content.pm { field public static final String FEATURE_MIDI = "android.software.midi"; field public static final String FEATURE_NFC = "android.hardware.nfc"; field public static final String FEATURE_NFC_BEAM = "android.sofware.nfc.beam"; + field @FlaggedApi("android.nfc.enable_nfc_charging") public static final String FEATURE_NFC_CHARGING = "android.hardware.nfc.charging"; field public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; field public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef"; field public static final String FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE = "android.hardware.nfc.ese"; @@ -28813,6 +28814,7 @@ package android.nfc { method public void enableReaderMode(android.app.Activity, android.nfc.NfcAdapter.ReaderCallback, int, android.os.Bundle); method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context); method @Nullable public android.nfc.NfcAntennaInfo getNfcAntennaInfo(); + method @FlaggedApi("android.nfc.enable_nfc_charging") @Nullable public android.nfc.WlcLDeviceInfo getWlcLDeviceInfo(); method public boolean ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler); method public boolean isEnabled(); method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean isObserveModeSupported(); @@ -28820,6 +28822,7 @@ package android.nfc { method @FlaggedApi("android.nfc.enable_nfc_reader_option") public boolean isReaderOptionSupported(); method public boolean isSecureNfcEnabled(); method public boolean isSecureNfcSupported(); + method @FlaggedApi("android.nfc.enable_nfc_charging") public boolean isWlcEnabled(); field public static final String ACTION_ADAPTER_STATE_CHANGED = "android.nfc.action.ADAPTER_STATE_CHANGED"; field public static final String ACTION_NDEF_DISCOVERED = "android.nfc.action.NDEF_DISCOVERED"; field @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public static final String ACTION_PREFERRED_PAYMENT_CHANGED = "android.nfc.action.PREFERRED_PAYMENT_CHANGED"; @@ -28905,6 +28908,20 @@ package android.nfc { ctor public TagLostException(String); } + @FlaggedApi("android.nfc.enable_nfc_charging") public final class WlcLDeviceInfo implements android.os.Parcelable { + ctor public WlcLDeviceInfo(double, double, double, int); + method public int describeContents(); + method public double getBatteryLevel(); + method public double getProductId(); + method public int getState(); + method public double getTemperature(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field public static final int CONNECTED_CHARGING = 2; // 0x2 + field public static final int CONNECTED_DISCHARGING = 3; // 0x3 + field @NonNull public static final android.os.Parcelable.Creator<android.nfc.WlcLDeviceInfo> CREATOR; + field public static final int DISCONNECTED = 1; // 0x1 + } + } package android.nfc.cardemulation { diff --git a/core/api/system-current.txt b/core/api/system-current.txt index b15bc0e589b1..0d4169fb9121 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -9884,17 +9884,20 @@ package android.nfc { method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean enable(); method @FlaggedApi("android.nfc.enable_nfc_reader_option") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean enableReaderOption(boolean); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean enableSecureNfc(boolean); + method @FlaggedApi("android.nfc.enable_nfc_charging") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean enableWlc(boolean); method @FlaggedApi("android.nfc.enable_nfc_mainline") public int getAdapterState(); method @NonNull @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public java.util.Map<java.lang.String,java.lang.Boolean> getTagIntentAppPreferenceForUser(int); method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean isControllerAlwaysOn(); method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean isControllerAlwaysOnSupported(); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isTagIntentAppPreferenceSupported(); method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public void registerControllerAlwaysOnListener(@NonNull java.util.concurrent.Executor, @NonNull android.nfc.NfcAdapter.ControllerAlwaysOnListener); + method @FlaggedApi("android.nfc.enable_nfc_charging") public void registerWlcStateListener(@NonNull java.util.concurrent.Executor, @NonNull android.nfc.NfcAdapter.WlcStateListener); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean removeNfcUnlockHandler(android.nfc.NfcAdapter.NfcUnlockHandler); method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean setControllerAlwaysOn(boolean); method @FlaggedApi("android.nfc.enable_nfc_mainline") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void setReaderMode(boolean); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int setTagIntentAppPreferenceForUser(int, @NonNull String, boolean); method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public void unregisterControllerAlwaysOnListener(@NonNull android.nfc.NfcAdapter.ControllerAlwaysOnListener); + method @FlaggedApi("android.nfc.enable_nfc_charging") public void unregisterWlcStateListener(@NonNull android.nfc.NfcAdapter.WlcStateListener); field @FlaggedApi("android.nfc.enable_nfc_mainline") public static final String ACTION_REQUIRE_UNLOCK_FOR_NFC = "android.nfc.action.REQUIRE_UNLOCK_FOR_NFC"; field public static final int TAG_INTENT_APP_PREF_RESULT_PACKAGE_NOT_FOUND = -1; // 0xffffffff field public static final int TAG_INTENT_APP_PREF_RESULT_SUCCESS = 0; // 0x0 @@ -9909,6 +9912,10 @@ package android.nfc { method public boolean onUnlockAttempted(android.nfc.Tag); } + @FlaggedApi("android.nfc.enable_nfc_charging") public static interface NfcAdapter.WlcStateListener { + method public void onWlcStateChanged(@NonNull android.nfc.WlcLDeviceInfo); + } + } package android.nfc.cardemulation { diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index a8638708824b..d02a80ca4531 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -3295,6 +3295,14 @@ public abstract class PackageManager { /** * Feature for {@link #getSystemAvailableFeatures} and + * {@link #hasSystemFeature}: The device supports NFC charging. + */ + @SdkConstant(SdkConstantType.FEATURE) + @FlaggedApi(android.nfc.Flags.FLAG_ENABLE_NFC_CHARGING) + public static final String FEATURE_NFC_CHARGING = "android.hardware.nfc.charging"; + + /** + * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The Beam API is enabled on the device. */ @SdkConstant(SdkConstantType.FEATURE) @@ -3304,7 +3312,7 @@ public abstract class PackageManager { * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device supports any * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION}, - * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features. + * {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF}, or {@link #FEATURE_NFC_CHARGING} features. * * @hide */ diff --git a/core/java/android/nfc/INfcAdapter.aidl b/core/java/android/nfc/INfcAdapter.aidl index f6beec179d57..967a0cc92ef5 100644 --- a/core/java/android/nfc/INfcAdapter.aidl +++ b/core/java/android/nfc/INfcAdapter.aidl @@ -30,8 +30,10 @@ import android.nfc.INfcFCardEmulation; import android.nfc.INfcUnlockHandler; import android.nfc.ITagRemovedCallback; import android.nfc.INfcDta; +import android.nfc.INfcWlcStateListener; import android.nfc.NfcAntennaInfo; import android.os.Bundle; +import android.nfc.WlcLDeviceInfo; /** * @hide @@ -86,4 +88,11 @@ interface INfcAdapter boolean enableReaderOption(boolean enable); boolean isObserveModeSupported(); boolean setObserveMode(boolean enabled); + + @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)") + boolean enableWlc(boolean enable); + boolean isWlcEnabled(); + void registerWlcStateListener(in INfcWlcStateListener listener); + void unregisterWlcStateListener(in INfcWlcStateListener listener); + WlcLDeviceInfo getWlcLDeviceInfo(); } diff --git a/core/java/android/nfc/INfcWlcStateListener.aidl b/core/java/android/nfc/INfcWlcStateListener.aidl new file mode 100644 index 000000000000..c2b7075bc6e4 --- /dev/null +++ b/core/java/android/nfc/INfcWlcStateListener.aidl @@ -0,0 +1,30 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.nfc; + +import android.nfc.WlcLDeviceInfo; +/** + * @hide + */ +oneway interface INfcWlcStateListener { + /** + * Called whenever NFC WLC state changes + * + * @param wlcLDeviceInfo NFC wlc listener information + */ + void onWlcStateChanged(in WlcLDeviceInfo wlcLDeviceInfo); +} diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java index f407fb73534f..21e23ae53979 100644 --- a/core/java/android/nfc/NfcAdapter.java +++ b/core/java/android/nfc/NfcAdapter.java @@ -75,6 +75,7 @@ public final class NfcAdapter { static final String TAG = "NFC"; private final NfcControllerAlwaysOnListener mControllerAlwaysOnListener; + private final NfcWlcStateListener mNfcWlcStateListener; /** * Intent to start an activity when a tag with NDEF payload is discovered. @@ -440,6 +441,7 @@ public final class NfcAdapter { static boolean sIsInitialized = false; static boolean sHasNfcFeature; static boolean sHasCeFeature; + static boolean sHasNfcWlcFeature; // Final after first constructor, except for // attemptDeadServiceRecovery() when NFC crashes - we accept a best effort @@ -650,8 +652,9 @@ public final class NfcAdapter { || pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF) || pm.hasSystemFeature(PackageManager.FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC) || pm.hasSystemFeature(PackageManager.FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE); + sHasNfcWlcFeature = pm.hasSystemFeature(PackageManager.FEATURE_NFC_CHARGING); /* is this device meant to have NFC */ - if (!sHasNfcFeature && !sHasCeFeature) { + if (!sHasNfcFeature && !sHasCeFeature && !sHasNfcWlcFeature) { Log.v(TAG, "this device does not have NFC support"); throw new UnsupportedOperationException(); } @@ -776,6 +779,7 @@ public final class NfcAdapter { mTagRemovedListener = null; mLock = new Object(); mControllerAlwaysOnListener = new NfcControllerAlwaysOnListener(getService()); + mNfcWlcStateListener = new NfcWlcStateListener(getService()); } /** @@ -944,7 +948,8 @@ public final class NfcAdapter { Log.e(TAG, "Failed to recover NFC Service."); } } - return serviceState && (isTagReadingEnabled() || isCardEmulationEnabled()); + return serviceState + && (isTagReadingEnabled() || isCardEmulationEnabled() || sHasNfcWlcFeature); } /** @@ -2587,4 +2592,159 @@ public final class NfcAdapter { return false; } } + + /** + * Sets NFC charging feature. + * <p>This API is for the Settings application. + * @return True if successful + * @hide + */ + @SystemApi + @FlaggedApi(Flags.FLAG_ENABLE_NFC_CHARGING) + @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) + public boolean enableWlc(boolean enable) { + if (!sHasNfcWlcFeature) { + throw new UnsupportedOperationException(); + } + try { + return sService.enableWlc(enable); + } catch (RemoteException e) { + attemptDeadServiceRecovery(e); + // Try one more time + if (sService == null) { + Log.e(TAG, "Failed to recover NFC Service."); + return false; + } + try { + return sService.enableWlc(enable); + } catch (RemoteException ee) { + Log.e(TAG, "Failed to recover NFC Service."); + } + return false; + } + } + + /** + * Checks NFC charging feature is enabled. + * + * @return True if NFC charging is enabled, false otherwise + * @throws UnsupportedOperationException if FEATURE_NFC_CHARGING + * is unavailable + */ + @FlaggedApi(Flags.FLAG_ENABLE_NFC_CHARGING) + public boolean isWlcEnabled() { + if (!sHasNfcWlcFeature) { + throw new UnsupportedOperationException(); + } + try { + return sService.isWlcEnabled(); + } catch (RemoteException e) { + attemptDeadServiceRecovery(e); + // Try one more time + if (sService == null) { + Log.e(TAG, "Failed to recover NFC Service."); + return false; + } + try { + return sService.isWlcEnabled(); + } catch (RemoteException ee) { + Log.e(TAG, "Failed to recover NFC Service."); + } + return false; + } + } + + /** + * A listener to be invoked when NFC controller always on state changes. + * <p>Register your {@code ControllerAlwaysOnListener} implementation with {@link + * NfcAdapter#registerWlcStateListener} and disable it with {@link + * NfcAdapter#unregisterWlcStateListenerListener}. + * @see #registerWlcStateListener + * @hide + */ + @SystemApi + @FlaggedApi(Flags.FLAG_ENABLE_NFC_CHARGING) + public interface WlcStateListener { + /** + * Called on NFC WLC state changes + */ + void onWlcStateChanged(@NonNull WlcLDeviceInfo wlcLDeviceInfo); + } + + /** + * Register a {@link WlcStateListener} to listen for NFC WLC state changes + * <p>The provided listener will be invoked by the given {@link Executor}. + * + * @param executor an {@link Executor} to execute given listener + * @param listener user implementation of the {@link WlcStateListener} + * @throws UnsupportedOperationException if FEATURE_NFC_CHARGING + * is unavailable + * + * @hide + */ + @SystemApi + @FlaggedApi(Flags.FLAG_ENABLE_NFC_CHARGING) + public void registerWlcStateListener( + @NonNull @CallbackExecutor Executor executor, + @NonNull WlcStateListener listener) { + if (!sHasNfcWlcFeature) { + throw new UnsupportedOperationException(); + } + mNfcWlcStateListener.register(executor, listener); + } + + /** + * Unregister the specified {@link WlcStateListener} + * <p>The same {@link WlcStateListener} object used when calling + * {@link #registerWlcStateListener(Executor, WlcStateListener)} + * must be used. + * + * <p>Listeners are automatically unregistered when application process goes away + * + * @param listener user implementation of the {@link WlcStateListener}a + * @throws UnsupportedOperationException if FEATURE_NFC_CHARGING + * is unavailable + * + * @hide + */ + @SystemApi + @FlaggedApi(Flags.FLAG_ENABLE_NFC_CHARGING) + public void unregisterWlcStateListener( + @NonNull WlcStateListener listener) { + if (!sHasNfcWlcFeature) { + throw new UnsupportedOperationException(); + } + mNfcWlcStateListener.unregister(listener); + } + + /** + * Returns information on the NFC charging listener device + * + * @return Information on the NFC charging listener device + * @throws UnsupportedOperationException if FEATURE_NFC_CHARGING + * is unavailable + */ + @FlaggedApi(Flags.FLAG_ENABLE_NFC_CHARGING) + @Nullable + public WlcLDeviceInfo getWlcLDeviceInfo() { + if (!sHasNfcWlcFeature) { + throw new UnsupportedOperationException(); + } + try { + return sService.getWlcLDeviceInfo(); + } catch (RemoteException e) { + attemptDeadServiceRecovery(e); + // Try one more time + if (sService == null) { + Log.e(TAG, "Failed to recover NFC Service."); + return null; + } + try { + return sService.getWlcLDeviceInfo(); + } catch (RemoteException ee) { + Log.e(TAG, "Failed to recover NFC Service."); + } + return null; + } + } } diff --git a/core/java/android/nfc/NfcWlcStateListener.java b/core/java/android/nfc/NfcWlcStateListener.java new file mode 100644 index 000000000000..8d793101f41f --- /dev/null +++ b/core/java/android/nfc/NfcWlcStateListener.java @@ -0,0 +1,120 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.nfc; + +import android.annotation.NonNull; +import android.nfc.NfcAdapter.WlcStateListener; +import android.os.Binder; +import android.os.RemoteException; +import android.util.Log; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Executor; + +/** + * @hide + */ +public class NfcWlcStateListener extends INfcWlcStateListener.Stub { + private static final String TAG = NfcWlcStateListener.class.getSimpleName(); + + private final INfcAdapter mAdapter; + + private final Map<WlcStateListener, Executor> mListenerMap = new HashMap<>(); + + private WlcLDeviceInfo mCurrentState = null; + private boolean mIsRegistered = false; + + public NfcWlcStateListener(@NonNull INfcAdapter adapter) { + mAdapter = adapter; + } + + /** + * Register a {@link WlcStateListener} with this + * {@link WlcStateListener} + * + * @param executor an {@link Executor} to execute given listener + * @param listener user implementation of the {@link WlcStateListener} + */ + public void register(@NonNull Executor executor, @NonNull WlcStateListener listener) { + synchronized (this) { + if (mListenerMap.containsKey(listener)) { + return; + } + + mListenerMap.put(listener, executor); + + if (!mIsRegistered) { + try { + mAdapter.registerWlcStateListener(this); + mIsRegistered = true; + } catch (RemoteException e) { + Log.w(TAG, "Failed to register"); + } + } + } + } + + /** + * Unregister the specified {@link WlcStateListener} + * + * @param listener user implementation of the {@link WlcStateListener} + */ + public void unregister(@NonNull WlcStateListener listener) { + synchronized (this) { + if (!mListenerMap.containsKey(listener)) { + return; + } + + mListenerMap.remove(listener); + + if (mListenerMap.isEmpty() && mIsRegistered) { + try { + mAdapter.unregisterWlcStateListener(this); + } catch (RemoteException e) { + Log.w(TAG, "Failed to unregister"); + } + mIsRegistered = false; + } + } + } + + private void sendCurrentState(@NonNull WlcStateListener listener) { + synchronized (this) { + Executor executor = mListenerMap.get(listener); + final long identity = Binder.clearCallingIdentity(); + try { + executor.execute(() -> listener.onWlcStateChanged( + mCurrentState)); + } finally { + Binder.restoreCallingIdentity(identity); + } + } + } + + @Override + public void onWlcStateChanged(@NonNull WlcLDeviceInfo wlcLDeviceInfo) { + synchronized (this) { + mCurrentState = wlcLDeviceInfo; + + for (WlcStateListener cb : mListenerMap.keySet()) { + sendCurrentState(cb); + } + } + } +} + diff --git a/core/java/android/nfc/WlcLDeviceInfo.aidl b/core/java/android/nfc/WlcLDeviceInfo.aidl new file mode 100644 index 000000000000..33143fe81162 --- /dev/null +++ b/core/java/android/nfc/WlcLDeviceInfo.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.nfc; + +parcelable WlcLDeviceInfo; diff --git a/core/java/android/nfc/WlcLDeviceInfo.java b/core/java/android/nfc/WlcLDeviceInfo.java new file mode 100644 index 000000000000..016431e90d8e --- /dev/null +++ b/core/java/android/nfc/WlcLDeviceInfo.java @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.nfc; + +import android.annotation.FlaggedApi; +import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Contains information of the nfc wireless charging listener device information. + */ +@FlaggedApi(Flags.FLAG_ENABLE_NFC_CHARGING) +public final class WlcLDeviceInfo implements Parcelable { + public static final int DISCONNECTED = 1; + + public static final int CONNECTED_CHARGING = 2; + + public static final int CONNECTED_DISCHARGING = 3; + + private double mProductId; + private double mTemperature; + private double mBatteryLevel; + private int mState; + + public WlcLDeviceInfo(double productId, double temperature, double batteryLevel, int state) { + this.mProductId = productId; + this.mTemperature = temperature; + this.mBatteryLevel = batteryLevel; + this.mState = state; + } + + /** + * ProductId of the WLC listener device. + */ + public double getProductId() { + return mProductId; + } + + /** + * Temperature of the WLC listener device. + */ + public double getTemperature() { + return mTemperature; + } + + /** + * BatteryLevel of the WLC listener device. + */ + public double getBatteryLevel() { + return mBatteryLevel; + } + + /** + * State of the WLC listener device. + */ + public int getState() { + return mState; + } + + private WlcLDeviceInfo(Parcel in) { + this.mProductId = in.readDouble(); + this.mTemperature = in.readDouble(); + this.mBatteryLevel = in.readDouble(); + this.mState = in.readInt(); + } + + public static final @NonNull Parcelable.Creator<WlcLDeviceInfo> CREATOR = + new Parcelable.Creator<WlcLDeviceInfo>() { + @Override + public WlcLDeviceInfo createFromParcel(Parcel in) { + return new WlcLDeviceInfo(in); + } + + @Override + public WlcLDeviceInfo[] newArray(int size) { + return new WlcLDeviceInfo[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeDouble(mProductId); + dest.writeDouble(mTemperature); + dest.writeDouble(mBatteryLevel); + dest.writeDouble(mState); + } +} diff --git a/core/java/android/nfc/flags.aconfig b/core/java/android/nfc/flags.aconfig index 0d073cc6c819..ce4f77725ef1 100644 --- a/core/java/android/nfc/flags.aconfig +++ b/core/java/android/nfc/flags.aconfig @@ -55,3 +55,10 @@ flag { description: "Enable sending broadcasts to Wallet role holder when a tag enters/leaves the field." bug: "306203494" } + +flag { + name: "enable_nfc_charging" + namespace: "nfc" + description: "Flag for NFC charging changes" + bug: "292143899" +} |