If the cops are asking, it means they need your permission and you have the right to say no. They might be dicks about it but if they’re asking, you can say no. Conversely if they don’t need your permission, they won’t bother asking. And you can always verbally tell them you don’t consent to searches; you only really get in trouble for physically interfering.
Also, companies in particular have lawyers whose entire full time job is to know when to tell the government to “stuff it” (though usually in much classier terms). Apple famously did this with the FBI: https://en.wikipedia.org/wiki/Apple–FBI_encryption_dispute