clean up user setting

pull/8/head
geeksville 2020-02-14 04:41:20 -08:00
rodzic 0befe48923
commit 9dcfb59ee0
6 zmienionych plików z 205 dodań i 229 usunięć

Wyświetl plik

@ -1,6 +1,11 @@
# High priority # High priority
MVP features required for first public alpha MVP features required for first public alpha
* use google signin to get user name (later give other options)
* always set a _unique_ owner id (if changed)
* stop scan when we start the service
* set the radio by using the service
* startforegroundservice only if we have a valid radio
* if no radio is selected, launch app on the radio select screen * if no radio is selected, launch app on the radio select screen
* when we select a new radio, restart the service * when we select a new radio, restart the service
* show bt scan progress centered and towards the bottom of the screen * show bt scan progress centered and towards the bottom of the screen
@ -47,6 +52,7 @@ Do this "Signal app compatible" release relatively soon after the alpha release
# Medium priority # Medium priority
Things for the betaish period. Things for the betaish period.
* let user pick/specify a name through ways other than google signin (for the privacy concerned, or devices without Play API)
* make my android app show mesh state * make my android app show mesh state
* show qr code for each channel https://medium.com/@aanandshekharroy/generate-barcode-in-android-app-using-zxing-64c076a5d83a * show qr code for each channel https://medium.com/@aanandshekharroy/generate-barcode-in-android-app-using-zxing-64c076a5d83a
* register app link for our URLs https://developer.android.com/studio/write/app-link-indexing.html * register app link for our URLs https://developer.android.com/studio/write/app-link-indexing.html

Wyświetl plik

@ -12,9 +12,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- for job intent service --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- for job intent service -->
<uses-permission android:name="android.permission.READ_CONTACTS " /> <!-- to get the owner's name so we can set it in the radio -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- <!--
This permission is required to allow the application to send This permission is required to allow the application to send
events and properties to Mixpanel. events and properties to Mixpanel.

Wyświetl plik

@ -17,6 +17,7 @@ interface IMeshService {
/** /**
* Set the ID info for this node * Set the ID info for this node
If myId is null, then the existing unique node ID is preserved, only the human visible longName/shortName is changed
*/ */
void setOwner(String myId, String longName, String shortName); void setOwner(String myId, String longName, String shortName);

Wyświetl plik

@ -1,15 +1,12 @@
package com.geeksville.mesh package com.geeksville.mesh
import android.Manifest import android.Manifest
import android.accounts.AccountManager
import android.bluetooth.BluetoothAdapter import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothManager import android.bluetooth.BluetoothManager
import android.content.* import android.content.*
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.provider.ContactsContract
import android.provider.ContactsContract.CommonDataKinds.Phone
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.widget.Toast import android.widget.Toast
@ -53,9 +50,7 @@ class MainActivity : AppCompatActivity(), Logging,
Manifest.permission.BLUETOOTH, Manifest.permission.BLUETOOTH,
Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.BLUETOOTH_ADMIN,
Manifest.permission.WAKE_LOCK, Manifest.permission.WAKE_LOCK,
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE
Manifest.permission.READ_CONTACTS,
Manifest.permission.GET_ACCOUNTS
) )
val missingPerms = perms.filter { val missingPerms = perms.filter {
@ -99,36 +94,10 @@ class MainActivity : AppCompatActivity(), Logging,
private fun setOwner() { private fun setOwner() {
try { try {
if (false) {
val SELF_PROJECTION =
arrayOf(Phone._ID, Phone.DISPLAY_NAME, Phone.PHOTO_THUMBNAIL_URI)
val cursor = contentResolver.query(
ContactsContract.Profile.CONTENT_URI,
SELF_PROJECTION,
null,
null,
null
)
if (cursor == null || !cursor.moveToFirst()) // Note: we are careful to not set a new unique ID
error("Can't get owner contact") meshService!!.setOwner(null, "Kevin Xter", "kx")
else {
info("me: ${cursor.getString(1)}/${cursor.getString(2)}")
}
}
val am = AccountManager.get(this) // "this" references the current Context
val accounts = am.getAccountsByType("com.google")
accounts.forEach {
info("acct ${it.name} ${it.type}")
}
} catch (e: Throwable) {
error("getting owner failed: $e")
}
meshService!!.setOwner("+16508675309", "Kevin Xter", "kx")
} }
private fun sendTestPackets() { private fun sendTestPackets() {
@ -166,7 +135,8 @@ class MainActivity : AppCompatActivity(), Logging,
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT) startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT)
} }
} else { } else {
Toast.makeText(this, "Error - this app requires bluetooth", Toast.LENGTH_LONG).show() Toast.makeText(this, "Error - this app requires bluetooth", Toast.LENGTH_LONG)
.show()
} }
requestPermission() requestPermission()
@ -253,7 +223,8 @@ class MainActivity : AppCompatActivity(), Logging,
private var isBound = false private var isBound = false
private var serviceConnection = object : ServiceConnection { private var serviceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) = exceptionReporter { override fun onServiceConnected(name: ComponentName, service: IBinder) =
exceptionReporter {
val m = IMeshService.Stub.asInterface(service) val m = IMeshService.Stub.asInterface(service)
meshService = m meshService = m
@ -330,6 +301,6 @@ class MainActivity : AppCompatActivity(), Logging,
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)
} }
} }
} }

Wyświetl plik

@ -314,8 +314,8 @@ class MeshService : Service(), Logging {
updatefn(info) updatefn(info)
// This might have been the first time we know an ID for this node, so also update the by ID map // This might have been the first time we know an ID for this node, so also update the by ID map
val userId = info.user?.id val userId = info.user?.id.orEmpty()
if (userId != null) if (userId.isNotEmpty())
nodeDBbyID[userId] = info nodeDBbyID[userId] = info
// parcelable is busted // parcelable is busted
@ -535,11 +535,12 @@ class MeshService : Service(), Logging {
clientPackages[receiverName] = packageName clientPackages[receiverName] = packageName
} }
override fun setOwner(myId: String, longName: String, shortName: String) = override fun setOwner(myId: String?, longName: String, shortName: String) =
toRemoteExceptions { toRemoteExceptions {
debug("TetOwner $myId : $longName : $shortName") debug("SetOwner $myId : $longName : $shortName")
val user = MeshProtos.User.newBuilder().also { val user = MeshProtos.User.newBuilder().also {
if (myId != null) // Only set the id if it was provided
it.id = myId it.id = myId
it.longName = longName it.longName = longName
it.shortName = shortName it.shortName = shortName

Wyświetl plik

@ -105,7 +105,7 @@ A few nodenums are reserved and will never be requested:
*/ */
message User { message User {
string id = 1; // a globally unique ID string for this user. In the case of Signal that would mean +16504442323 string id = 1; // a globally unique ID string for this user. In the case of Signal that would mean +16504442323, for the default macaddr derived id it would be !<6 hexidecimal bytes>
string long_name = 2; // A full name for this user, i.e. "Kevin Hester" string long_name = 2; // A full name for this user, i.e. "Kevin Hester"
string short_name = 3; // A VERY short name, ideally two characters. Suitable for a tiny OLED screen string short_name = 3; // A VERY short name, ideally two characters. Suitable for a tiny OLED screen
bytes macaddr = 4; // This is the addr of the radio. Not populated by the phone, but added by the esp32 when broadcasting bytes macaddr = 4; // This is the addr of the radio. Not populated by the phone, but added by the esp32 when broadcasting