No Branch/Tag Specified
master
i2p-android-2.8.0-androidx
2.3.0-translations
i2p-android-2.9.0
i2p-android-2.8.2
i2p-android-2.8.0-1
i2p-android-2.8.0
i2p-android-2.7.1
2.7.1
i2p-android-2.7.0
i2p-android-2.6.0
i2p-android-2.5.1
i2p-android-2.5.2
i2p-android-2.5.0
i2p-android-2.4.2-test
i2p-android-2.4.1-test
i2p-android-2.4.0
i2p-2.3.0
android-2.2.1
i2p-android-2.2.0
i2p-android-2.1.1
android-2.1.0
android-2.0.1
android-2.0.0
android-1.9.0
i2p-android-1.8.1
android-1.8.1
android-1.8.0
android-1.7.1
android-1.7.0
android-1.6.1
android-1.6.0
android-1.5.0
android-0.9.50
android-0.9.49
android-0.9.48
0.9.48
android-0.9.47-1
android-0.9.47
android-0.9.46
android-0.9.45
android-0.9.44
android-0.9.43
android-0.9.42
android-0.9.41
android-0.9.40
android-0.9.39
android-0.9.38
android-0.9.37
android-0.9.36
android-0.9.35
android-0.9.34
android-0.9.29
android-helper-0.9.3
android-client-0.9.29
android-0.9.28
android-helper-0.9.2
android-client-0.9.28
android-0.9.27
android-helper-0.9.1
android-client-0.9.27
android-0.9.26
android-client-0.9
android-0.9.25
android-client-0.8
android-0.9.22
android-0.9.20
android-client-0.7
android-0.9.19.1
android-0.9.19
android-client-0.6
android-0.9.18
android-client-0.5.1
android-client-0.5
android-0.9.17.1
android-0.9.17
android-client-0.4
android-client-0.3
android-0.9.15.1
android-0.9.15
android-client-0.2
android-0.9.13-0_b2-API8
android-0.9.13-0_b1-API8
android-0.9.12-0_b1-API8
android-0.9.11-0_b1-API8
android-0.9.10-0_b1-API8
android-0.9.9-0_b0-API8
android-0.9.8.1-0_b1-API8
android-0.9.7.1-0_b4-API8
android-0.9.7-0_b2-API8
android-0.9.1-0_b1-API8
android-0.8.7-4_b1-API8
i2p-0.8.6
i2p-0.8.5
i2p-0.8.4
i2p-0.8.3
i2p-0.8.2
i2p-0.8.1
i2p-0.8
i2p-0.7.14
i2p-0.7.13
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2_2
i2p_0_3_2_1
i2p_0_3_2
i2p_0_3_1_5
i2p_0_3_1_4
i2p_0_3_1_3
i2p_0_3_1_2
i2p_0_3_1_1
i2p_0_3_1
i2p_0_3_0_4
i2p_post_great_renaming
i2p_0_3_0_3
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: I2P_Developers/i2p.android.base#51
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Opened 9 years ago
Last modified 7 years ago
#692assignedenhancement
Moving hosts.txt to sqlite
Reported by:MeehOwned by:zzz
Priority:
minor
Milestone:
Component:
apps/android
Version:
0.9.1
Keywords:
Cc:
Parent Tickets:
Sensitive:
no
Description
The android version is going to move host list from plaintext file to sqlite.
quick notes;
01:19:05 <@zzz> sure. Implement net.i2p.client.naming.NamingService? by extending net.i2p.client.naming.DummyNamingService?. Have at it.
01:20:30 <@zzz> once you're done, set the router config property i2p.naming.impl=my.full.class.name and it will use it.
01:21:11 <@zzz> on first instantiation, import from existing hosts.txt file into your db, see BlockfileNamingService? for clues
Subtickets
comment:8 Changed 7 years ago by Meeh
Owner:
changed from Meeh to _zzz_Status:accepted →
assigned
Sorry but for now it seems lost. But ask me and I'll do it when I got
comment:7 Changed 7 years ago by zzz
I briefly started implementing this. Do you still have your code? It would be helpful…
comment:6 Changed 9 years ago by zzz
Is a Service better? Maybe, maybe not. Like with ContentProvider?, you shouldn't use a Service just to get thread safety.
A service is like a background task, running independently of an Activity. The router, of course, is a Service. But why does the NamingService? need to be a service? Does it need to be doing something all the time? I doubt it - you look up a hostname, it either succeeds or fails… what else is there to do? And BTW, binding an Activity to a Service is a pain.
All you need for thread safety… where you need it… is of course synchronized(someLock) { … }. That's what I'm getting at. Understand what needs to be protected with a lock, if anything, and then code appropriately. Research whether your database is thread safe. If not, what's the best way?
BlockfileNamingService?, for example, just uses locking where necessary. Ditto with SingleFileNamingService?.
So again, I say: These Android constructions - ContentProvider?, Service, etc. - are there to be used for specific reasons. Not to provide magic thread safety. Maybe you need them. Maybe you don't. Maybe you're almost done implementing one. Maybe not. But I guarantee you that both of them are added complications.
comment:5 Changed 9 years ago by Meeh
Thanks for the guidelines and correction.
I've been reading a while now, and after some thinking I've changed my mind. I think it should only be instance working with the database. Now I'm looking more into a bound service, since it seems possible to make it threadsafe there. And that also make it possible to extend to a ContentProvider? later if needed for 3rdparty apps.
Also, I've read that when all "client/threads" disconnects from the service, the lifecycle will stop, so I researching if it need to be a service used with both onBind() by clients and onStartCommand(), that's starts & stops at the same time as the router.. The android documentation recommends a bound service when multiple components/threads will use it.
A service runs in the main thread of the application that hosts it, by default, so it would need a own thread too.
If I've got it right this will make it possible for both the router service and the addressbookactivity to access the resource at the same time. Also any other sub-threads, and a ContentProvider? if needed in the future. Do you think this sounds better?
refs:
http://developer.android.com/guide/components/processes-and-threads.html#ThreadSafe
http://developer.android.com/guide/components/bound-services.html#Lifecycle
http://developer.android.com/guide/components/services.html
comment:4 Changed 9 years ago by zzz
I didn't say you shouldn't use a ContentProvider?. I said you did it for the wrong reason.
Doesn't sound like you have fully analyzed the locking requirements / thread safety for your database. That's what you have to get right - whether or not it's a ContentProvider?. Saying you just changed something (i.e. switched to a ContentProvider?) and now it works doesn't inspire confidence.
Where the ContentProvider? yes/no issue _is_ important is whether the DB should be available to other apps.
Where the ContentProvider? yes/no issue _might_ be important is with AddressbookActivity? - should it work when the router isn't running? Should there be multiple instances of the DB? If it's started before the router starts, should the router somehow grab the existing DB instance? See also the rather cheap shortcut I took on that issue at the top of AddressbookActivity?.
comment:3 Changed 9 years ago by Meeh
I had some problems with database locking problems on the first try, so I gave it a try with ContentProvider? because that solved the locking problem. I see your points, but I'm a bit afraid that it could be a locking problem between the addressbook edit and router service, so I do it to be safe.
If you think it's a bad idea, I'll start over and do it your way, but I think this might be the right way to do it.
Anyway I'm finished with the importer, so when the database is called, it checks for entries, if it's emtpy it importing from hosts.txt.
comment:2 Changed 9 years ago by zzz
ref: http://developer.android.com/guide/topics/providers/content-provider-creating.html and http://developer.android.com/guide/topics/data/data-storage.html#db
Everything is threaded. Not just I2P is threaded. Android is threaded. Java is threaded. Threading is not a reason to use a ContentProvider?. You only need a ContentProvider? to allow access to the DB from other apps.
Long-term, it would be great to provide that access to other apps - this is the equivalent of I2P applications outside the router's JVM (i.e. outside of RouterContext?) accessing the NamingService? on a PC platform - something that's problematic today.
But I don't think there is anything requiring you to start out by implementing a ContentProvider?… unless it's needed to get access from both the addressbook edit activity and the router service? Is that why you are doing it?
comment:1 Changed 9 years ago by Meeh
Status:new →
accepted
I've researched a bit on how to do this now. And the solution seems to be a ContentProvider? because i2p is threaded. (database locking etc.)
Status:
Finished with the database class & initial creation
I'm soon finished with a simple ContentProvider? for getting hosts, inserting, updating, deleting.
TODO
Read more about the classes zzz talk about, and how to implementate them.
Testing,Testing,Testing,Testing,Testing
Build a NamingService? querying the contentprovider instead of hosts.txt
I will not commit to mtn before this works.