Re: But who owns the device?
Of course the county has the right to access the contents of their own phone.
Forget about this case for a moment, take real life: You bought an iPhone. Obviously you have the right to access the contents of your own phone. You set up a passcode. And being a bit negligent, you forget the passcode. So you take your phone to the Apple Store. Of course you still have the right to access the contents of your own phone.
So what do they tell you at the store? The "Genius" at the Apple Store obviously can't crack the code. They are quite clever, I bet they have a list of codes to try, like birthdays, postcodes, phone numbers, 1234, and so on, but beyond that they cannot help you.
If you have a four digit passcode, no extra security, and no backup, they will tell you that you have the choice of resetting your phone and losing everything, or trying 10,000 possible passcodes. Only takes two days. If you have extra security and no backup, they will tell you that you are stuffed.
If they followed this case, and you have a backup but not a recent one, they will tell you to take your iPhone back home to the WiFi network it knows, plug it into power, and it will start backing up to iCloud. That works even when it is locked. So when that is done, you can then erase your phone and restore from the iCloud backup. Saved.
That's what happens if it happens to you out of forgetfulness. And the exact same thing happens to San Bernardino County when they borrowed their iPhone to a terrorist who got himself killed and can't unlock the phone anymore.