mirror of
https://github.com/google/bumble.git
synced 2026-04-16 00:25:31 +00:00
add intent parameters
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
android:theme="@style/Theme.RemoteHCI">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
@@ -39,31 +39,30 @@ public class HciServer {
|
||||
|
||||
private void loop() throws IOException {
|
||||
mListener.onHostConnectionState(false);
|
||||
mListener.onMessage("Waiting for connection on port " + mPort);
|
||||
try (
|
||||
ServerSocket serverSocket = new ServerSocket(mPort);
|
||||
Socket clientSocket = serverSocket.accept()
|
||||
) {
|
||||
mListener.onHostConnectionState(true);
|
||||
mListener.onMessage("Connected");
|
||||
HciParser parser = new HciParser(mListener);
|
||||
InputStream inputStream = clientSocket.getInputStream();
|
||||
synchronized (this) {
|
||||
mOutputStream = clientSocket.getOutputStream();
|
||||
}
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
|
||||
try {
|
||||
for (;;) {
|
||||
int bytesRead = inputStream.read(buffer);
|
||||
if (bytesRead < 0) {
|
||||
Log.d(TAG, "end of stream");
|
||||
break;
|
||||
}
|
||||
parser.feedData(buffer, bytesRead);
|
||||
try (ServerSocket serverSocket = new ServerSocket(mPort)) {
|
||||
mListener.onMessage("Waiting for connection on port " + serverSocket.getLocalPort());
|
||||
try (Socket clientSocket = serverSocket.accept()) {
|
||||
mListener.onHostConnectionState(true);
|
||||
mListener.onMessage("Connected");
|
||||
HciParser parser = new HciParser(mListener);
|
||||
InputStream inputStream = clientSocket.getInputStream();
|
||||
synchronized (this) {
|
||||
mOutputStream = clientSocket.getOutputStream();
|
||||
}
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
|
||||
try {
|
||||
for (; ; ) {
|
||||
int bytesRead = inputStream.read(buffer);
|
||||
if (bytesRead < 0) {
|
||||
Log.d(TAG, "end of stream");
|
||||
break;
|
||||
}
|
||||
parser.feedData(buffer, bytesRead);
|
||||
}
|
||||
} catch (IOException error) {
|
||||
Log.d(TAG, "exception in read loop: " + error);
|
||||
}
|
||||
} catch (IOException error) {
|
||||
Log.d(TAG, "exception in read loop: " + error);
|
||||
}
|
||||
} finally {
|
||||
synchronized (this) {
|
||||
|
||||
@@ -111,14 +111,18 @@ class MainActivity : ComponentActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
appViewModel.loadPreferences(getPreferences(Context.MODE_PRIVATE))
|
||||
|
||||
val tcpPort = intent.getIntExtra("port", -1)
|
||||
if (tcpPort >= 0) {
|
||||
appViewModel.tcpPort = tcpPport
|
||||
}
|
||||
|
||||
setContent {
|
||||
MainView(appViewModel, ::startProxy)
|
||||
}
|
||||
|
||||
run()
|
||||
}
|
||||
|
||||
private fun run() {
|
||||
if (intent.getBooleanExtra("autostart", false)) {
|
||||
startProxy()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startProxy() {
|
||||
|
||||
Reference in New Issue
Block a user