Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
interferometer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
akwizgran
interferometer
Commits
6ad3a303
Commit
6ad3a303
authored
Feb 05, 2020
by
akwizgran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hold a wifi lock to prevent sleep from affecting wifi speed.
parent
fadb253a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
app/src/main/java/org/briarproject/interferometer/MainViewModel.java
...n/java/org/briarproject/interferometer/MainViewModel.java
+14
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
6ad3a303
...
...
@@ -10,6 +10,7 @@
<uses-permission
android:name=
"android.permission.BLUETOOTH"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH_ADMIN"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission-sdk-23
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
...
...
app/src/main/java/org/briarproject/interferometer/MainViewModel.java
View file @
6ad3a303
...
...
@@ -9,6 +9,8 @@ import android.content.BroadcastReceiver;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.net.wifi.WifiManager
;
import
android.net.wifi.WifiManager.WifiLock
;
import
android.os.Bundle
;
import
android.util.Log
;
...
...
@@ -38,6 +40,8 @@ import static android.bluetooth.BluetoothAdapter.ACTION_STATE_CHANGED;
import
static
android
.
bluetooth
.
BluetoothAdapter
.
EXTRA_STATE
;
import
static
android
.
bluetooth
.
BluetoothAdapter
.
STATE_OFF
;
import
static
android
.
bluetooth
.
BluetoothAdapter
.
STATE_ON
;
import
static
android
.
content
.
Context
.
WIFI_SERVICE
;
import
static
android
.
net
.
wifi
.
WifiManager
.
WIFI_MODE_FULL_HIGH_PERF
;
import
static
java
.
util
.
concurrent
.
Executors
.
newCachedThreadPool
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
MILLISECONDS
;
import
static
org
.
briarproject
.
interferometer
.
MainViewModel
.
ConnectionState
.
DISCONNECTED
;
...
...
@@ -117,9 +121,18 @@ public class MainViewModel extends AndroidViewModel {
if
(
hostPort
==
null
)
return
INVALID_ADDRESS
;
BluetoothAdapter
adapter
=
BluetoothAdapter
.
getDefaultAdapter
();
if
(
adapter
==
null
)
return
NO_BLUETOOTH
;
Log
.
i
(
TAG
,
"Starting test"
);
task
=
executorService
.
submit
(()
->
{
WifiLock
wifiLock
=
null
;
try
{
WifiManager
wifiManager
=
(
WifiManager
)
getApplication
().
getApplicationContext
().
getSystemService
(
WIFI_SERVICE
);
if
(
wifiManager
!=
null
)
{
wifiLock
=
wifiManager
.
createWifiLock
(
WIFI_MODE_FULL_HIGH_PERF
,
TAG
);
wifiLock
.
acquire
();
}
if
(!
disableBluetooth
(
adapter
))
{
Log
.
w
(
TAG
,
"Failed to disable Bluetooth"
);
return
;
...
...
@@ -166,7 +179,6 @@ public class MainViewModel extends AndroidViewModel {
adapter
.
disable
();
}
Log
.
i
(
TAG
,
"Test finished"
);
Bundle
b
=
new
Bundle
();
b
.
putDouble
(
DOWNLOAD_DISABLED
,
mean
(
downloadDisabled
));
...
...
@@ -180,6 +192,7 @@ public class MainViewModel extends AndroidViewModel {
b
.
putBoolean
(
CONSUMED
,
false
);
results
.
postValue
(
b
);
}
finally
{
if
(
wifiLock
!=
null
)
wifiLock
.
release
();
testPhase
.
postValue
(
READY
);
}
});
...
...
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