Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
9382fa6c
Kaydet (Commit)
9382fa6c
authored
Eyl 06, 2012
tarafından
Andrzej J.R. Hunt
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Automatically enable/disable bluetooth as necessary for searching/connection.
Change-Id: Ie7a11c05cf1ba6181e955a65ebef03117c956f1a
üst
6a1c29d7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
23 deletions
+61
-23
BluetoothClient.java
...reoffice/impressremote/communication/BluetoothClient.java
+18
-3
BluetoothFinder.java
...reoffice/impressremote/communication/BluetoothFinder.java
+17
-15
Client.java
...c/org/libreoffice/impressremote/communication/Client.java
+10
-4
CommunicationService.java
...ice/impressremote/communication/CommunicationService.java
+16
-1
No files found.
android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
Dosyayı görüntüle @
9382fa6c
...
...
@@ -25,14 +25,22 @@ import android.support.v4.content.LocalBroadcastManager;
*/
public
class
BluetoothClient
extends
Client
{
private
boolean
mBluetoothWasEnabled
;
private
BluetoothAdapter
mAdapter
;
public
BluetoothClient
(
Server
aServer
,
CommunicationService
aCommunicationService
)
{
super
(
aServer
,
aCommunicationService
);
try
{
BluetoothAdapter
aAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
BluetoothDevice
aDevice
=
aAdapter
.
getRemoteDevice
(
aServer
mAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
mBluetoothWasEnabled
=
mAdapter
.
isEnabled
();
if
(!
mBluetoothWasEnabled
)
{
mAdapter
.
enable
();
}
BluetoothDevice
aDevice
=
mAdapter
.
getRemoteDevice
(
aServer
.
getAddress
());
a
Adapter
.
cancelDiscovery
();
m
Adapter
.
cancelDiscovery
();
BluetoothSocket
aSocket
=
aDevice
.
createRfcommSocketToServiceRecord
(
UUID
.
fromString
(
"00001101-0000-1000-8000-00805F9B34FB"
));
...
...
@@ -115,5 +123,11 @@ public class BluetoothClient extends Client {
// }
}
protected
void
onDisconnect
()
{
if
(!
mBluetoothWasEnabled
)
{
mAdapter
.
disable
();
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
Dosyayı görüntüle @
9382fa6c
...
...
@@ -31,12 +31,10 @@ public class BluetoothFinder {
if
(
mAdapter
==
null
)
{
return
;
// No bluetooth adapter found (emulator, special devices)
}
System
.
out
.
println
(
"BT:Discovery starting"
);
IntentFilter
aFilter
=
new
IntentFilter
(
BluetoothDevice
.
ACTION_FOUND
);
aFilter
.
addAction
(
BluetoothAdapter
.
ACTION_DISCOVERY_FINISHED
);
aFilter
.
addAction
(
BluetoothAdapter
.
ACTION_STATE_CHANGED
);
mContext
.
registerReceiver
(
mReceiver
,
aFilter
);
mAdapter
.
enable
();
mAdapter
.
startDiscovery
();
}
...
...
@@ -62,31 +60,35 @@ public class BluetoothFinder {
@Override
public
void
onReceive
(
Context
context
,
Intent
aIntent
)
{
// TODO Auto-generated method stub
if
(
aIntent
.
getAction
().
equals
(
BluetoothDevice
.
ACTION_FOUND
))
{
System
.
out
.
println
(
"Found"
);
BluetoothDevice
aDevice
=
(
BluetoothDevice
)
aIntent
.
getExtras
()
.
get
(
BluetoothDevice
.
EXTRA_DEVICE
);
Server
aServer
=
new
Server
(
Protocol
.
BLUETOOTH
,
aDevice
.
getAddress
(),
aDevice
.
getName
(),
System
.
currentTimeMillis
());
mServerList
.
put
(
aServer
.
getAddress
(),
aServer
);
System
.
out
.
println
(
"Added "
+
aServer
.
getName
());
System
.
out
.
println
(
"Now we have: "
+
mServerList
.
size
());
Intent
aNIntent
=
new
Intent
(
CommunicationService
.
MSG_SERVERLIST_CHANGED
);
LocalBroadcastManager
.
getInstance
(
mContext
).
sendBroadcast
(
aNIntent
);
}
else
if
(
aIntent
.
getAction
().
equals
(
BluetoothAdapter
.
ACTION_DISCOVERY_FINISHED
))
{
BluetoothAdapter
.
ACTION_DISCOVERY_FINISHED
)
||
aIntent
.
getAction
()
.
equals
(
BluetoothAdapter
.
ACTION_STATE_CHANGED
))
{
// Start discovery again after a small delay.
Handler
aHandler
=
new
Handler
();
aHandler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
mAdapter
.
startDiscovery
();
}
},
1000
*
15
);
;
// but check whether device is on incase the user manually
// disabled bluetooth
if
(
mAdapter
.
isEnabled
())
{
Handler
aHandler
=
new
Handler
();
aHandler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
System
.
out
.
println
(
"Looping"
);
}
},
1000
*
15
);
}
}
}
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
Dosyayı görüntüle @
9382fa6c
...
...
@@ -95,6 +95,7 @@ public abstract class Client {
e1
.
printStackTrace
();
}
finally
{
latestInstance
=
null
;
onDisconnect
();
}
}
...
...
@@ -108,10 +109,7 @@ public abstract class Client {
}
/**
* Send a valid JSON string to the server.
*
* @param command
* Must be a valid JSON string.
* Send a valid command to the Server.
*/
public
void
sendCommand
(
String
command
)
{
try
{
...
...
@@ -125,5 +123,12 @@ public abstract class Client {
}
}
/**
* Called after the Client disconnects. Can be extended to allow for
* cleaning up bluetooth properties etc.
*/
protected
void
onDisconnect
()
{
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
Dosyayı görüntüle @
9382fa6c
...
...
@@ -102,14 +102,29 @@ public class CommunicationService extends Service implements Runnable {
}
private
boolean
mBluetoothPreviouslyEnabled
;
public
void
startSearching
()
{
mNetworkFinder
.
startFinding
();
mBluetoothFinder
.
startFinding
();
BluetoothAdapter
aAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
if
(
aAdapter
!=
null
)
{
mBluetoothPreviouslyEnabled
=
aAdapter
.
isEnabled
();
if
(!
mBluetoothPreviouslyEnabled
)
aAdapter
.
enable
();
mBluetoothFinder
.
startFinding
();
}
}
public
void
stopSearching
()
{
mNetworkFinder
.
stopFinding
();
mBluetoothFinder
.
stopFinding
();
BluetoothAdapter
aAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
if
(
aAdapter
!=
null
)
{
if
(!
mBluetoothPreviouslyEnabled
)
{
aAdapter
.
disable
();
}
}
}
public
void
connectTo
(
Server
aServer
)
{
...
...
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