Downgrading DB on Android - database

I tested that it is possible for Android to pass newVersion < oldVersion to SQLiteOpenHelper.onUpgrade() method, ie. it wants the application to downgrade its database.
I don't want to handle this case, though I would like to notify the user somehow that there exists a newer version of my application (which she apparently had installed previously) and that's the one she should be using.
Any ideas what would be the best way to achieve this? Toast? AlertDialog (but in what context)?

Indeed, you can call that method with a "new" version smaller than the "old" version, but when would it ever happen?
Unless you expect your users to manually reinstall your app, overwriting it with an earlier APK, there's no need to think about this.

We have multiple active branches of our app (e.g. v1.x and v2.x), and we deliver releases internally for testing. This means a tester occasionally installs the older version over the top of the newer one.
It is a good idea to cope gracefully in this scenario (a helpful error popup, blow the database away, etc), otherwise the tester see a "Force quit" message, and then we have to look at the adb logcat logs to confirm that this was due to a version mismatch.
Initially I worried that there were other reasonable scenarios where this could happen, e.g. when Reactivating an older version in the Android Market (e.g. due to a catastrophic bug in a new version).
However, the Android docs seem to say that you can't Activate an older release:
You cannot activate a new APK that has a version code lower than that of the APK it's replacing.
So to hit this scenario you would need to rebuild the older version with a new version number before you can Activate it. IMO it is still worth coping with this scenario, as somebody could easily make this mistake at 4am while trying to backout a bad release!

Related

Silverlight 4 Out Of Browser: Check for Updates without installing?

I have created a Silverlight 4 application, that is running out of browser. As you will know, there is a function that is checking if a new version of the app is available and installing it.
But what if I want to only check for the update and not installing it?
Personally, I do not like applications that silently update themselves, downloading something from the internet. So I'd like to have the following mechanism.
- when the app starts, it checks if updates are available
- if so, I show a messagebox to the user, telling her that there is an update and that she can download and installing it via the update-button
- the user can now decide to update
Unfortunately, there seems to be no option to just checking for updates without actually downloading and installing it. Any ideas, how to achieve this?
Thanks in advance,
Frank
You can roll your own update detection, by having a small file on your server next to the XAP for your app, that contains the latest version. For example:
http://localhost/myawesomeapp.xap
http://localhost/myawesomeapp.xap.ver
When you want to check for updates without downloading them, you can always hit the .ver file, check the version listed in it and if newer then the current running app, show the Update button to the user.
Note that this approach also would allow you to create more advanced scenarios, like prompting the user to upgrade to a different version of the app (Pro for example) or that they need to upgrade their Silverlight to get the latest.
And if you have multiple apps, you can list all of them in that file and do cross-promotion between your apps.

Silverlight 4 OOB App with elevated trust and signed cert does not update? Need to re-install?

I have a OOB app that did not require elevated trust and was not signed. Many people have downloaded it and use it OOB.
I then needed to use elevated trust features, so I bought a legitimate certificate from Comodo and I now sign it. Everything works great on localhost - it is trusted and recognises the certificate.
However, once I uploaded the new version my existing OOB install (which was the old unsigned, non-elevated trust app) did not do the usual "new version check and update".
This is critical as many people have installed it - is there some limitation on changing to signed, elevated trust with regards to downloads? The .xap name is the same and in the same location. A fiddler lookup sees the new change so it' snot a caching issue. I cleared all my caches with CCleaner to be sure.
I uninstalled the old OOB app on another computer and the signed cert is working fine on install (ie. I get the nice "trusted publisher" install message) so it's not a signing issue. You can see it live here (I will leave the new version up as there is no harm - the old users just wont know about it!)
I believe it is something to do with the Elevated Trust change?
Update: I did some more testing: I removed the Elevated Trust and uploaded it again. The OLD one that did not update then DID update, and the new one (elevated trust + signed) on the other computer did NOT update. So it seems as they the update process cannot handle a change in the Trust elevation, regardless of whether it is signed or not. This is a BIG problem with all the users who will be stuck on an old version and never know it.
The other problem is that the NEW signed app thinks that the app is install on my computer (the old unsigned one that does not update) and hence will not show the Install option. And very few users will know how to uninstall it and reinstall it IF they even went to the website one day to check. This is a really serious bug if it is the case.
Unfortunately, your users will need to uninstall and reinstall the application. It's not a bug as such (I don't believe), but more by design. If you take a look at this article on MSDN: http://msdn.microsoft.com/en-us/library/dd550721(VS.95).aspx, you'll see that it states:
Silverlight 4 provides support for running out-of-browser applications with elevated trust. Trusted applications cannot use the update mechanism described in this section unless the application and the update have both been signed with the same valid, code-signing certificate. To update a trusted application that does not have a valid signature, users must uninstall the old version and install the new version manually.
It more or less seems to indicate in the last sentence (in a round about way) that users with the unsigned application will need to uninstall the application, and then install the one with elevated trust to update it. I've read something that stated this in a more exact way, but can't remember where it was sorry :(.
Hope this helps...
Chris
After receiving no reply/leads I am unfortunately coming to the conclusion that this is a bug in SL4.
I assume that because the app now requires a UI confirmation to confirm the elevated trust there is no way for the existing non-trusted app to handle this UI on update, so it just doesn't download it.
For some reason, removing elevated trust has the same issue (trusted OOB apps wont update the non-elevated trust update either, which is even weirder).
So it seems to me the bottom line is that if you change Elevated Trust, you have just isolated all the people who have already installed your app.
So then there seems to be 2 options:
Just update the app and rely on blogs etc. to tell them that they have to uninstall it and reinstall it. This sucks because they wont KNOW that there is a knew version and could use the old version for another 10 years without knowing. Plus, if they go to the online version, it thinks it is already is installed so wont offer the Install menu again until you uninstall the old one - very messy! I think this is the route that Tim Heuer took here with the signed Facebook app - http://timheuer.com/blog/archive/2010/04/15/silverlight-client-for-facebook-updated-for-silverlight-4-release.aspx
Rename the .XAP file and start a new project for it. Make the old .xap file have a message saying "There's a new version" with uninstall and reinstall instructions/links. Then if they view the new one without having uninstalled the old one it will still install as it is a different XAP name, AND you can at least communicate with them telling them the old one is dead.
Any other suggestions?!
A nice way to fix those users who need to update would be to provide them with a little application to run that would automatically update them. Using this article: Install Silverlight-out-of-browser So the end users would just download the little exe which would uninstall the "untrusted" one and then reinstall with the new one.

How to check if a visitor is using the latest version of his/her browser?

Is there a simple and automatic way of checking if a visitor to my website (written in asp.net) is using the latest version of his browser? This would allow me to display a message to inform them that they're running an old version and that they might want to upgrade.
My website is tested on most broswers but I don't test old versions (such as Internet Explorer 6 etc). When one of my visitors is using such an old version, basically, I would like to encourage (not force) them to upgrade.
Of course I could do this myself by getting the version of the browser and look it up in my database but I don't want to have to maintain a 'browser version' database myself.
Any ideas?
Speaking as a user of websites, if I come across a site that advised me to upgrade my browser then that would be an immediate black mark against that site.
I might not be able to upgrade (if I'm accessing from a corporate network for example); I might have a specific reason for using a particular version (if I'm a web developer wanting to ensure compatibility with my user community for example).
So personally, I would say that a blanket disclaimer that you don't test this site on earlier versions would be the way to go. That's quite apart from the technical challenge of what you want to do.
Edit: as Yeti points out, however valid my concerns, I don't answer the question directly. This is done in Pace's answer, and the w3schools resource he points to gives you what you need to do this on the client side.

How do you track versions in Bugzilla?

We are in the process of migrating our bug tracking to Bugzilla from a really old version of track and I am running out of Advil.
We have a legacy application that has been around for a long time. Mix in the fact that our versioning management has been through a few iterations it generated a lot of different versions in the wild. To make matters worse, because of contractual limitations it is not always possible to upgrade the clients to the latest and greatest, so we must branch, fix, test and release, on the version they currently have, yielding yet another version number.
The end result is that the version combo box is ludicrously long. Lastly, for various reasons, we want to track three different version information :
the version in which the bug was found (version), the version in which we plan to fix (milestone) the bug and the version in which it has ultimately been fixed (open to suggestions). here is my problem in fact... this can actually be multiple numbers where we did a retroactive fix for some of these customers (this happens VERY often).
This is where I need your collective wisdom :
How do you keep track of these versions (found, planned and multiple fixed) in Bugzilla?
What are the best practices around linking versions and bug tracking ?
Answers
It seems that cloning the bug for each version is a good way to track, thus the target version is always tracked in the milestone as well as the fixed version, and the buggy version is always the native version.
Also to have each clone block the original bug make it a good way to trace the history back to the original submission.
Although I have accepted the answer I still welcome your input.
Often, if we need to fix something in multiple released versions (generally branches in the source code repository), the bug will be cloned for each branch so that all the commits and release status can be tracked separately. I think the only time we don't do this is when the change is not directly related to the codebase itself and cannot be fixed simply by updating our libraries.
As for version tracking in general, this has struck me as a reasonable way to do things, given that we generally only need to support 2-3 major versions (plus the trunk) at any time. If you have multiple disjoint versions that need supporting, e.g. customer-specific deployments, then things are going to be harder to track. (Arguably this is going to cause headaches in general and it would be better to unify things to a more central version theme).
I use Bugzilla to keep track not only of bugs, but also of new features, enhancements, and vague ideas. For each planned and released version, I have a Tracking Bug (something that I saw on the original Mozilla bugzilla, and found to be useful).
So if you have a bug report, you enter the bug with the version number that it was reported. Create additional bugs (one for each version you plan to fix it in) which all depend on (block) the original bug and block the version-specific Tracking Bugs.
If all bugs blocking the original bug are closed/verified (whatever your QA implements), you can also close the original bug.
I was looking for a similar feature in TFS, and while doing some investigation, I found that there is an enhancement request to manage "sightings" in Bugzilla:
"Bug 55970 - (bz-branch) Bugzilla needs to deal better with branches (implement sightings)":
https://bugzilla.mozilla.org/show_bug.cgi?id=55970
There is also a proposed design:
https://bug55970.bugzilla.mozilla.org/attachment.cgi?id=546912
For information, we are going to implement something similar in TFS 2010, with a "Bug Parent" or "Bug Master" to hold the information about the bug itself (repro steps, severity, technical info, impacted components...), that can have child of type "Bug Child" or "Sighting" that will hold the information specific to a given branch (target milestone, priority, specific information for that branch...).
We are using jira and still have this problem. I think it is a question of requirements and how are versions used rather than any one tool.
Who uses versions and how do they use them?
How are versions related to milestones in a project plan?
We use a 4 dectet version (major.minor.patch.buildNO). buildNo is the SVN head revision # at time of build. Each version is stored in JIRA and issues have an affects version and fixed-in version field that's a multi select.
After a short while we have many versions. Jira does allow us to control the list in two ways
1. Archive versions (greyed out from pick list)
2. Merge versions (rolls several versions together into a new version - no undo)
We have used Archive, but have avoided Merge due to the lack of the undo. So we still have a list of many many versions.
I'm sure you could probably accomplish a merge action in Bugzilla with some scripting and time, the question is: when is it OK to merge several older versions together?
If I have released, do I need to know that I have 17 builds between start and release? Do I need to keep the knowledge of a bug being found in build 1, fixed in 2, found again in 7, fixed again 9? Or is Found in release 1.0.0 fixed in release 1.0.1 good enough?
i'm going to ask a large question on this topic later on today, but I know the basic answer already:
- Depends on how your team wants to track things.
Implementation is fun, but it all comes down to requirements, goals and working back from user experience to solution. Which is rough when people don't necessarily know how that want to use something that doesn't quite exist in the form they'd like to use.
I have created a custom field (string) to list to version(s) (as V.M.P.B) where a bug has been fixed.
I have created also another custom field (string) to list to version(s) affected by a bug.
Doing that you are able to perform quick-search on specific version.

Auto update for WinForms application

When creating an auto updating feature for a .NET WinForms application, how does it update the DLLs and not affect the currently running application?
Since the application is running during the update process, won't there be a lock on the DLLs (because those DLLs will have to be overwritten during the update).
Usually you would download the new files into a separate area. Then shutdown and restart and at startup you look for and use the new files if found. Always keeping a last known working version on the side so that the user can revert to something that definitely works if the download causes problems.
ClickOnce is a good technology from Microsoft that does this for you and you can use it directly from Visual Studio 2008.
You'll have to shutdown your application and restart it, as other people have already commented.
I wrote an open-source code to do just that in a transparent mode - including an external update application to do the actual cold update. See http://www.code972.com/blog/2010/08/nappupdate-application-auto-update-framework-for-dotnet/
The code is at http://github.com/synhershko/NAppUpdate (Licensed under the Apache 2.0 license)
I have a seperate 'launcher' application that checks for updates via a web service. If there are updates, it downloads them and then executes my application, which is in a seperate assembly.
The other alternatives are using things like ClickOnce, or downloading the files to a seperate area and restarting the app, as someone else mentioned.
Be warned about ClickOnce, though - it's not as flexible as it sounds. And if you deploy to a system that requires elevating your program to a higer security level to run, you might run into problems if you don't have a certificate for your app installed. I found it very difficult to get straight answers on the Internet to things like certificate management when it comes to ClickOnce. If you have a complex app, you may want to just roll your own updater, which is what I ended up having to do.
If you publish via ClickOnce, all of that tends to be handled for you. It has it's own pro's and con's but usually easier than trying to code it all yourself.
Both Wikipedia and 15seconds have decent info on using ClickOnce, how it works, etc.
As others have stated, ClickOnce isn't as flexible as rolling your own solution but it is a LOT less complicated. It has a small learning curve at first, but with pretty much everything bundled into Visual Studio and the use of Wizards, it usually doesn't take long to stumble onto a working solution.
As deployments get more complex (i.e. beyond than just having prerequisites or application code that needs updating) and you need to do a lot of post-install or pre-install tasks, there are things like WiX which give you somewhat of a hybrid solution between Windows Installer and ClickOnce, with the cost of flexibility being a much steeper learning curve.
The only reason I try to avoid custom installers is that you end up spending way too much time trying to get it just right to handle a bunch of different "What If" scenarios...
These days Windows can do such updates automatically for you with AppInstaller if your app is packaged in the MSIX package.
It downloads the new version of the app in another folder inside ProgramFiles\WindowsApps, then when a user runs the app via the start menu, the system knows what folder it should use. The previous version gets deleted when not in use.
If you want to know how to package your app this way I collected my findings in this answer.

Resources