mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
Improve device transfer reliability.
This commit is contained in:
committed by
Alex Hart
parent
0c4c280a50
commit
3e9146a6f5
@@ -5,6 +5,7 @@ import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -47,6 +48,7 @@ public class DeviceToDeviceTransferService extends Service implements ShutdownCa
|
||||
private DeviceTransferServer server;
|
||||
private DeviceTransferClient client;
|
||||
private PowerManager.WakeLock wakeLock;
|
||||
private WifiManager.WifiLock wifiLock;
|
||||
|
||||
public static void startServer(@NonNull Context context,
|
||||
@NonNull ServerTask serverTask,
|
||||
@@ -121,6 +123,10 @@ public class DeviceToDeviceTransferService extends Service implements ShutdownCa
|
||||
wakeLock.release();
|
||||
}
|
||||
|
||||
if (wifiLock != null && wifiLock.isHeld()) {
|
||||
wifiLock.release();
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -207,6 +213,17 @@ public class DeviceToDeviceTransferService extends Service implements ShutdownCa
|
||||
if (!wakeLock.isHeld()) {
|
||||
wakeLock.acquire(TimeUnit.HOURS.toMillis(2));
|
||||
}
|
||||
|
||||
if (wifiLock == null) {
|
||||
WifiManager wifiManager = ContextCompat.getSystemService(this, WifiManager.class);
|
||||
if (wifiManager != null) {
|
||||
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "signal:d2dwifi");
|
||||
}
|
||||
}
|
||||
|
||||
if (wifiLock != null && !wifiLock.isHeld()) {
|
||||
wifiLock.acquire();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNotification(@NonNull TransferStatus transferStatus) {
|
||||
|
||||
Reference in New Issue
Block a user