Open
Conversation
Author: Thecrazyskull <anaskarbila@gmail.com>
Date: Tue Jan 17 10:56:39 2017 -0600
SystemUI: Enable NFC tile
Change-Id: Ib21f927d336fcb5e460552786828b79551b235fa
Author: Luca Stefani <luca.stefani.ge1@gmail.com>
Date: Tue Sep 4 10:07:17 2018 +0200
SystemUI: Update NFCTile to match P style
Change-Id: I8309eda6b2dbb28156dd463e667ff60545b37b7d
Author: inthewaves <inthewaves@pm.me>
Date: Sun Sep 20 14:59:10 2020 -0700
have NfcTile get an NfcAdapter directly
This changes the NfcTile to not be dependent on an NfcManager giving the
NfcTile an NfcAdapter.
The problem with NfcTile is that the NfcService doesn't start until the
device is unlocked after a reboot, but NfcTile can be created and have
its state updated before the device is unlocked.
The state of NfcTile depends on an NfcAdapter. The tile gets an
NfcAdapter from a call to NfcAdapter#getDefaultAdapter, which gets an
adapter from an NfcManager via Context#getSystemService, and NfcManager
tries to get an adapter in its constructor via NfcAdapter#getNfcAdapter.
If this is done before unlock, NfcService isn't started, so the
constructor of NfcManager fails to get an adapter, opting to just store
null. This means that the NfcManager that's _cached_ by the NfcTile's
application context holds a null NfcAdapter, so subsequent calls in
NfcTile to get the NfcAdapter will keep returning null.
We can just have NfcTile get the NfcAdapter directly via
NfcAdapter#getNfcAdapter instead of relying on an NfcManager to call the
same method for us to get its default adapter. We just have to make sure
we use the application context for NfcAdapter#getNfcAdapter, as per the
doc comments for getNfcAdapter. This means that there's no longer an
NfcManager associated with the NfcTile's application context.
It doesn't look like NfcManager does anything special with the
NfcAdapter anyway. It seems to just be some middle man for NfcAdapters:
* The NfcAdapter field in NfcManager is final, and it doesn't do
anything else with it besides have a getter method for returning it. The
NfcManager seems to be a way to force third-party apps that want to get
an NfcAdapter to use the application context.
* NfcAdapter#getNfcAdapter manages the caching of NfcAdapters by
application context in a static HashMap. NfcManager doesn't manage
caching; it just calls NfcAdapter#getNfcAdapter.
Change-Id: Ifafc666568a001a60baf7c8c16782dca1ee4d011
Change-Id: Ia06b923ee15e91a9c84a806d4c69755478df2063
Signed-off-by: SahilSonar <sss.sonar2003@gmail.com>
Signed-off-by: HeroBuxx <me@herobuxx.xyz>
Signed-off-by: HeroBuxx <herobuxx@conqueros.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author: Thecrazyskull anaskarbila@gmail.com
Date: Tue Jan 17 10:56:39 2017 -0600
Author: Luca Stefani luca.stefani.ge1@gmail.com
Date: Tue Sep 4 10:07:17 2018 +0200
Author: inthewaves inthewaves@pm.me
Date: Sun Sep 20 14:59:10 2020 -0700
Change-Id: Ia06b923ee15e91a9c84a806d4c69755478df2063
Signed-off-by: SahilSonar sss.sonar2003@gmail.com
Signed-off-by: HeroBuxx me@herobuxx.xyz
Signed-off-by: HeroBuxx herobuxx@conqueros.co
Signed-off-by: Dreadwyrm enprytna@gmail.com