kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
feat: Adds Request user info (#1279)
* Request user info * safe calls * Fix: Ensure NodeInfo is sent when requesting user info The `requestUserInfo` function now correctly sends `NodeInfo` when requesting user info by using the ` toNodeInfo()` method on `ourNodeInfo`. This ensures the recipient receives the necessary information. * fix: remove unused parameters, use service's node db for our node entity --------- Co-authored-by: musznik <bymucha@gmail.com>pull/1286/head
rodzic
83c3b484ad
commit
f944a236ac
|
@ -168,4 +168,7 @@ interface IMeshService {
|
||||||
|
|
||||||
/// Stop providing location (from phone GPS) to mesh
|
/// Stop providing location (from phone GPS) to mesh
|
||||||
void stopProvideLocation();
|
void stopProvideLocation();
|
||||||
|
|
||||||
|
/// Send request for node UserInfo
|
||||||
|
void requestUserInfo(in int destNum);
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,6 +411,15 @@ class UIViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun requestUserInfo(destNum: Int) {
|
||||||
|
info("Requesting UserInfo for '$destNum'")
|
||||||
|
try {
|
||||||
|
meshService?.requestUserInfo( destNum )
|
||||||
|
} catch (ex: RemoteException) {
|
||||||
|
errormsg("Request NodeInfo error: ${ex.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun requestPosition(destNum: Int, position: Position = Position(0.0, 0.0, 0)) {
|
fun requestPosition(destNum: Int, position: Position = Position(0.0, 0.0, 0)) {
|
||||||
info("Requesting position for '$destNum'")
|
info("Requesting position for '$destNum'")
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1928,7 +1928,18 @@ class MeshService : Service(), Logging {
|
||||||
removeByNodenum = nodeNum
|
removeByNodenum = nodeNum
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
override fun requestUserInfo( destNum: Int ) = toRemoteExceptions {
|
||||||
|
if (destNum != myNodeNum) {
|
||||||
|
sendToRadio(newMeshPacketTo(destNum
|
||||||
|
).buildMeshPacket(
|
||||||
|
channel = nodeDBbyNodeNum[destNum]?.channel ?: 0
|
||||||
|
) {
|
||||||
|
portnumValue = Portnums.PortNum.NODEINFO_APP_VALUE
|
||||||
|
wantResponse = true
|
||||||
|
payload = nodeDBbyNodeNum[myNodeNum]!!.user.toByteString()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
override fun requestPosition(destNum: Int, position: Position) = toRemoteExceptions {
|
override fun requestPosition(destNum: Int, position: Position) = toRemoteExceptions {
|
||||||
sendToRadio(newMeshPacketTo(destNum).buildMeshPacket(
|
sendToRadio(newMeshPacketTo(destNum).buildMeshPacket(
|
||||||
channel = nodeDBbyNodeNum[destNum]?.channel ?: 0,
|
channel = nodeDBbyNodeNum[destNum]?.channel ?: 0,
|
||||||
|
|
|
@ -85,6 +85,10 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
||||||
R.id.metrics -> {
|
R.id.metrics -> {
|
||||||
navigateToMetrics(node.num)
|
navigateToMetrics(node.num)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
R.id.request_userinfo -> {
|
||||||
|
model.requestUserInfo(node.num)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
android:id="@+id/direct_message"
|
android:id="@+id/direct_message"
|
||||||
android:title="@string/direct_message"
|
android:title="@string/direct_message"
|
||||||
app:showAsAction="withText" />
|
app:showAsAction="withText" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/request_userinfo"
|
||||||
|
android:title="@string/request_userinfo"
|
||||||
|
app:showAsAction="withText" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/request_position"
|
android:id="@+id/request_position"
|
||||||
android:title="@string/request_position"
|
android:title="@string/request_position"
|
||||||
|
|
|
@ -268,4 +268,5 @@
|
||||||
<string name="encryption_pkc_text">Direct messages are using the new public key infrastructure for encryption. Requires firmware version 2.5 or greater.</string>
|
<string name="encryption_pkc_text">Direct messages are using the new public key infrastructure for encryption. Requires firmware version 2.5 or greater.</string>
|
||||||
<string name="encryption_error">Public key mismatch</string>
|
<string name="encryption_error">Public key mismatch</string>
|
||||||
<string name="encryption_error_text">The public key does not match the recorded key. You may remove the node and let it exchange keys again, but this may indicate a more serious security problem. Contact the user through another trusted channel, to determine if the key change was due to a factory reset or other intentional action.</string>
|
<string name="encryption_error_text">The public key does not match the recorded key. You may remove the node and let it exchange keys again, but this may indicate a more serious security problem. Contact the user through another trusted channel, to determine if the key change was due to a factory reset or other intentional action.</string>
|
||||||
|
<string name="request_userinfo">Request user info</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Ładowanie…
Reference in New Issue