Pixel 3a charging over computer USB connection I have an Pixel 3a device that I connect to a Linux computer via USB cable (A to C). Sometimes when I plug in the device, the notification on the Pixel 3a says, "Android System - Charging this device via USB". However, the battery icon indicates the phone is not charging (does not show the lightning bolt), and indeed, the charge level does not go up. If I switch the USB connection to MIDI, PTP, USB tethering or file transfer, then the phone starts charging. 



How can I get my phone to reliably charge without granting extra data permissions? 

As for "sometimes", if the Pixel 3a previously did not charge with no data transfer, then it will continue to not charge with no data transfer in subsequent connections until some data is granted. If the Pixel 3a charged in the last connection, it may or may not charge on the next connection with no data transfer.
I assume one of the problems here is that you don't use an USB-C to USB-C cable in combination with using the "USB controlled by this device" mode.

"USB controlled by this device" should be equivalent to what was called OTG with USB2/Micro USB. At that time you could not use OTG with charging at the same time. 

In the USB-C era it should be possible if the phone supports USB-Power Delivery (USB-PD). 
The Pixel 3a as far as I know supports USB-PD.

Now comes the problem: When you connect the phone using the USB-C to USB-A converter cable and select the mode "USB controlled by this device" then the phone is in the USB master role. For a connection to the PC the PC would have to act as USB slave - which is AFAIK not possible as USB 2/3 PC connections (using the old Type A socket) can only act as USB master!

Therefore we have on each end of the cable an USB master which effectively that there is absolutely no communication possible between them, as the USB standard defines exactly one USB master in a device tree (the USB master plus x USB slaves - the connected devices and hubs).

No communication automatically means no connection for negotiating the available/required power. Therefore in the end your phone doe snot charge.

When you change the mode to "MIDI" or one of the other "use USB for" modes this implicitly changes the USB controlled by" mode to "Connected device" - Android does not only support them this way.

Conclusion: By default you should select "USB controlled by connected device" - this is the default as it was in USB2.0/3.0: The "connected device" is the computer and the computer is the USB master. 
Using this mode means computer and phone can communicate and therefore also charging works.