mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-06-05 21:49:48 +02:00
make quit button work by letting BtSocketIoThread actually leave its main loop, do not display "Unknown" for unknown numbers but the number itself.
This commit is contained in:
@@ -150,6 +150,7 @@ public class BluetoothCommunicationService extends Service {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (mBtSocketIoThread != null) {
|
if (mBtSocketIoThread != null) {
|
||||||
try {
|
try {
|
||||||
|
mBtSocketIoThread.quit();
|
||||||
mBtSocketIoThread.join();
|
mBtSocketIoThread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -172,7 +173,7 @@ public class BluetoothCommunicationService extends Service {
|
|||||||
|
|
||||||
private String getContactDisplayNameByNumber(String number) {
|
private String getContactDisplayNameByNumber(String number) {
|
||||||
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
|
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
|
||||||
String name = "Unknown";
|
String name = number;
|
||||||
|
|
||||||
if (number == null || number.equals("")) {
|
if (number == null || number.equals("")) {
|
||||||
return name;
|
return name;
|
||||||
@@ -233,6 +234,7 @@ public class BluetoothCommunicationService extends Service {
|
|||||||
private class BtSocketIoThread extends Thread {
|
private class BtSocketIoThread extends Thread {
|
||||||
private final InputStream mmInStream;
|
private final InputStream mmInStream;
|
||||||
private final OutputStream mmOutStream;
|
private final OutputStream mmOutStream;
|
||||||
|
private boolean mQuit = false;
|
||||||
|
|
||||||
public BtSocketIoThread(InputStream instream, OutputStream outstream) {
|
public BtSocketIoThread(InputStream instream, OutputStream outstream) {
|
||||||
mmInStream = instream;
|
mmInStream = instream;
|
||||||
@@ -243,7 +245,7 @@ public class BluetoothCommunicationService extends Service {
|
|||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
while (true) {
|
while (!mQuit) {
|
||||||
try {
|
try {
|
||||||
bytes = mmInStream.read(buffer, 0, 4);
|
bytes = mmInStream.read(buffer, 0, 4);
|
||||||
if (bytes < 4)
|
if (bytes < 4)
|
||||||
@@ -296,5 +298,9 @@ public class BluetoothCommunicationService extends Service {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void quit() {
|
||||||
|
mQuit = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user