Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
packages_apps_Nfc
Commits
663c0153
Commit
663c0153
authored
14 years ago
by
Sylvain Fonteneau
Committed by
Jeff Hamilton
14 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Ensure disconnection from remote peer before sleeping, in P2P mode.
Change-Id: I0d8fce569f2e6431fe62a299278a0106c86cda9a
parent
434bb344
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
8 deletions
+31
-8
src/com/android/nfc/NfcService.java
src/com/android/nfc/NfcService.java
+31
-8
No files found.
src/com/android/nfc/NfcService.java
View file @
663c0153
...
...
@@ -2054,11 +2054,24 @@ public class NfcService extends Application {
Iterator
<?>
iterator
=
mObjectMap
.
values
().
iterator
();
while
(
iterator
.
hasNext
())
{
Object
object
=
iterator
.
next
();
if
(
object
!=
null
&&
object
instanceof
NativeNfcTag
)
{
if
(
object
instanceof
NativeNfcTag
)
{
// Disconnect from tags
NativeNfcTag
tag
=
(
NativeNfcTag
)
object
;
tag
.
disconnect
();
iterator
.
remove
();
}
else
if
(
object
instanceof
NativeP2pDevice
)
{
// Disconnect from P2P devices
NativeP2pDevice
device
=
(
NativeP2pDevice
)
object
;
if
(
device
.
getMode
()
==
NativeP2pDevice
.
MODE_P2P_TARGET
)
{
// Remote peer is target, request disconnection
device
.
doDisconnect
();
}
else
{
// Remote peer is initiator, we cannot disconnect
// Just wait for field removal
}
}
iterator
.
remove
();
}
}
}
...
...
@@ -2385,6 +2398,8 @@ public class NfcService extends Application {
/* Activate Llcp Link */
if
(
mManager
.
doActivateLlcp
())
{
if
(
DBG
)
Log
.
d
(
TAG
,
"Initiator Activate LLCP OK"
);
// Register P2P device
mObjectMap
.
put
(
device
.
getHandle
(),
device
);
activateLlcpLink
();
}
else
{
/* should not happen */
...
...
@@ -2408,6 +2423,8 @@ public class NfcService extends Application {
/* Activate Llcp Link */
if
(
mManager
.
doActivateLlcp
())
{
if
(
DBG
)
Log
.
d
(
TAG
,
"Target Activate LLCP OK"
);
// Register P2P device
mObjectMap
.
put
(
device
.
getHandle
(),
device
);
activateLlcpLink
();
}
}
else
{
...
...
@@ -2420,12 +2437,18 @@ public class NfcService extends Application {
device
=
(
NativeP2pDevice
)
msg
.
obj
;
Log
.
d
(
TAG
,
"LLCP Link Deactivated message. Restart polling loop."
);
if
(
device
.
getMode
()
==
NativeP2pDevice
.
MODE_P2P_TARGET
)
{
if
(
DBG
)
Log
.
d
(
TAG
,
"disconnecting from target"
);
/* Restart polling loop */
device
.
doDisconnect
();
}
else
{
if
(
DBG
)
Log
.
d
(
TAG
,
"not disconnecting from initiator"
);
synchronized
(
NfcService
.
this
)
{
/* Check if the device has been already unregistered */
if
(
mObjectMap
.
remove
(
device
.
getHandle
())
!=
null
)
{
/* Disconnect if we are initiator */
if
(
device
.
getMode
()
==
NativeP2pDevice
.
MODE_P2P_TARGET
)
{
if
(
DBG
)
Log
.
d
(
TAG
,
"disconnecting from target"
);
/* Restart polling loop */
device
.
doDisconnect
();
}
else
{
if
(
DBG
)
Log
.
d
(
TAG
,
"not disconnecting from initiator"
);
}
}
}
/* Broadcast Intent Link LLCP activated */
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment