Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13229 closed Bug Report - General (fixed)

Android frontend needs a HostName

Reported by: Peter Bennett Owned by: Peter Bennett
Priority: minor Milestone: 30.0
Component: Ports - Android Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Frontend settings are stored in the database with a key of hostid. The NVidia Shield Android device finds a hostid of "localhost", which is not very helpful and will cause havoc if you have more than 1 android device with different settings.

It is not clear what the best solution is. Options:

  • Generate a random id (ANDROIDXXXXX) when the application is installed
  • Ask the user to enter a unique id
  • Use the Android-id (if I can figure out how to find it)

Attachments (2)

20180228_1306_android_hostid.patch (2.6 KB) - added by Peter Bennett 6 years ago.
Use android id for host id
20180304_1431_android_hostid.patch (2.2 KB) - added by Peter Bennett 6 years ago.
Updated patch for hostid

Download all attachments as: .zip

Change History (10)

comment:1 Changed 6 years ago by gigem

I don't know that there is a real fix for this, at least not until Nvidie/Google? provide a real hostname. There is a work around, though, as Mark Spieth pointed out to me when I first encountered the problem. That is to go into the database configuration in setup and enable and set the custom identifier for database purposes feature. I have two Shields and am able to keep there configurations separate that way.

comment:2 Changed 6 years ago by Mark Spieth

Use the android ID as the default custom id.

A bit of jni to suck it out should be easy.

comment:3 Changed 6 years ago by Peter Bennett

Status: newaccepted

Attached patch will use the android id (with prefix android-) as host id if the host id returned by default is "localhost" or empty.

Is that sufficient or should it check for other values or maybe always use android id with android systems?

Note the value in config.xml will override the android-xxxx if there is one in config.xml

Changed 6 years ago by Peter Bennett

Use android id for host id

comment:4 Changed 6 years ago by Mark Spieth

Replace both includes with

#include <QtAndroidExtras>

Replace the first call with

QAndroidJniObject activity = QtAndroid::androidActivity();

See mythdisplay.cpp for example (search DispInfo?: and then LOC)

I usually don't bother with exception checking.

Also Im not sure you need an object since the final is a static object method call. Not sure whats required in this case.

The string param in the last call could probably be just a literal.

comment:5 Changed 6 years ago by Peter Bennett

Replace both includes with #include <QtAndroidExtras?> Replace the first call with QAndroidJniObject activity = QtAndroid::androidActivity();

I changed the includes and the call to get the activity as you suggested.

I usually don't bother with exception checking.

I changed it to use a macro to make the exception checking a little less intrusive. What happens if there is an exception and you don't clear it? It seems like bad things may happen later?

Also Im not sure you need an object since the final is a static object method call. Not sure whats required in this case.

The call to android/provider/Settings$Secure is a static call but it requires you to pass in a ContentResolver object. It is a bit weird. Proper object-oriented code would let you just call a method on the ContentResolver object. (I would think - but I am no Android expert).

The string param in the last call could probably be just a literal.

Replacing myID.object<jstring>() with "android-id" causes a crash with signal 33 at the point where it does that call. Nothing useful shows in the backtrace. Is that what you had proposed, or did I misunderstand?

Updated patch is attached.

Changed 6 years ago by Peter Bennett

Updated patch for hostid

comment:6 Changed 6 years ago by Mark Spieth

If its needed then its needed.

Havent ever considered exception handling in jni. sounds like the right thing to do.

SHIPIT

comment:7 Changed 6 years ago by Peter Bennett <pbennett@…>

Resolution: fixed
Status: acceptedclosed

In 9d08c23d55ab56604e8dbf04566245b2d0b0dcf5/mythtv:

Android: Fix detection of host name

Android was seeing the host name as localhost. Change to getting
it from the adnroid id if it is not specified in config.xml.

Fixes #13229

comment:8 Changed 6 years ago by Peter Bennett

Owner: changed from Peter Bennett to Peter Bennett
Note: See TracTickets for help on using tickets.