Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hotspot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
hotspot
Commits
5738210a
Verified
Commit
5738210a
authored
4 years ago
by
Torsten Grote
Browse files
Options
Downloads
Patches
Plain Diff
Force creation of 2GHz hotspot on API 29+
parent
ce16fac5
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Add web server for app downloading and small fixes
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/org/briarproject/hotspot/MainViewModel.java
+13
-1
13 additions, 1 deletion
...src/main/java/org/briarproject/hotspot/MainViewModel.java
app/src/main/java/org/briarproject/hotspot/StringUtils.java
+16
-0
16 additions, 0 deletions
app/src/main/java/org/briarproject/hotspot/StringUtils.java
with
29 additions
and
1 deletion
app/src/main/java/org/briarproject/hotspot/MainViewModel.java
+
13
−
1
View file @
5738210a
...
...
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import
android.app.Application
;
import
android.net.wifi.WifiManager
;
import
android.net.wifi.WifiManager.WifiLock
;
import
android.net.wifi.p2p.WifiP2pConfig
;
import
android.net.wifi.p2p.WifiP2pManager
;
import
android.net.wifi.p2p.WifiP2pManager.ActionListener
;
import
android.net.wifi.p2p.WifiP2pManager.Channel
;
...
...
@@ -21,7 +22,9 @@ import static android.content.Context.WIFI_P2P_SERVICE;
import
static
android
.
content
.
Context
.
WIFI_SERVICE
;
import
static
android
.
net
.
wifi
.
WifiManager
.
WIFI_MODE_FULL
;
import
static
android
.
net
.
wifi
.
WifiManager
.
WIFI_MODE_FULL_HIGH_PERF
;
import
static
android
.
net
.
wifi
.
p2p
.
WifiP2pConfig
.
GROUP_OWNER_BAND_2GHZ
;
import
static
android
.
os
.
Build
.
VERSION
.
SDK_INT
;
import
static
org
.
briarproject
.
hotspot
.
StringUtils
.
getRandomString
;
public
class
MainViewModel
extends
AndroidViewModel
{
...
...
@@ -91,7 +94,16 @@ public class MainViewModel extends AndroidViewModel {
}
};
try
{
wifiP2pManager
.
createGroup
(
channel
,
listener
);
if
(
SDK_INT
>=
29
)
{
WifiP2pConfig
config
=
new
WifiP2pConfig
.
Builder
()
.
setGroupOperatingBand
(
GROUP_OWNER_BAND_2GHZ
)
.
setNetworkName
(
"DIRECT-42-Briar-Download"
)
.
setPassphrase
(
getRandomString
(
8
))
.
build
();
wifiP2pManager
.
createGroup
(
channel
,
config
,
listener
);
}
else
{
wifiP2pManager
.
createGroup
(
channel
,
listener
);
}
}
catch
(
SecurityException
e
)
{
releaseWifiP2pHotspot
(
app
.
getString
(
R
.
string
.
callback_permission_denied
));
}
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/org/briarproject/hotspot/StringUtils.java
0 → 100644
+
16
−
0
View file @
5738210a
package
org.briarproject.hotspot
;
import
java.security.SecureRandom
;
import
java.util.Random
;
class
StringUtils
{
private
static
final
Random
random
=
new
SecureRandom
();
public
static
String
getRandomString
(
int
length
)
{
char
[]
c
=
new
char
[
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
c
[
i
]
=
(
char
)
(
'a'
+
random
.
nextInt
(
26
));
return
new
String
(
c
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment