It adds an extra 600ms on my Nexus 4 with ~2000 apks from the
F-Droid index. But I think it is the only way, as we really need
to iterate over every single installed apk, to see if it is still
wanted. The up side is that we can query for a large amount of
them, rather than quering individually for each apk.
NOTE: I haven't added a new status message yet, because we are
about to do a stable release. After the stable release, I'll
add a new status message to cover for this > half a second
(on my relatively fast device). This will probably be part of
an overhaul of the update process in general, including a
proper progress dialog.
This can later be removed again if the user still has a way to easily update
repos manually without having to enter "Manage Repos" and exit again. A good
option would be a pull-to-refresh action.
The problem was that they defaulted to 0 if not specified, however
the code checking for current version was looking for -1 for a "no upstream version".
The idea was good: reduce the amount of copied/pasted code
where ContentValues were initialized, populated, then inserted.
I've kept the idea, by putting it in its own method which is
called twice. But the resources are not loaded dynamically any
more. This is so that the compiler will be able to pick up if
we reference a missing resource. Also, I took the opportunity
to replace the field name string literals with references to
RepoProvider.DataColumns.* constants.
Finally, changed the tests around because now we need to
have the "getInteger()" call mocked in resources correctly
(for priority/inUse).
From before content providers, where we rolled our own update notification
system for when data changed in the database. I also removed the property
"ctx", because it is availble in getApplicationContext(). As a general rule,
it is usually safer to not use a member field if not neccesary. That way,
there doesn't need to be any assumptions about when it is set and what value
it has. In this case, it was only set half way through onCreate, and therefore
usage before then would break.
Safer and less error-prone because:
* Always checks for null
* Checks for sizes
* Inits App/Apk lists at known capacity
* Properly closes all cursors
There are still one or two cursors that are not closed correctly and show
things like these:
W/CursorWrapperInner(19973): Cursor finalized without prior close()
The Activity.getActionBar() method can only be called after
setContentView() has been invoked, as described here:
http://blog.perpetumdesign.com/2011/08/strange-case-of-dr-action-and-mr-bar.html
I couldn't think of any way to enforce this safely
(i.e. make the compiler kick up a stink if we didn't do it). As such,
I just put a comment above each usage of the ActionBarCompat class.
Another outstanding issue is a duplicate of 474, where it crashes when you
press the "Up" button from ManageRepos, but I'll create a different issue
for that.
The cryptographically secure random number generator exposed to Android
through the Java Cryptography Architecture is not properly initialized
on some older unpatched versions of Android. Google provides
a PRNGFixes.java class to force secure seeding of the CSRNG on all
platform versions. This comment adds the PRNGFixes class & and a call to
invoke the fixes from the FDroidApp class.
More detail is available from the Google Android Developers blogpost on
the subject:
http://android-developers.blogspot.ca/2013/08/some-securerandom-thoughts.html
When adding "default_repo_priority", it was copy/pasted from
"default_repo_pubkey" without changing the name, and so
tried to cast the string value into an int and failed.