25140. (a) Except as otherwise provided in subdivision (b), a person shall, when leaving a handgun in an unattended vehicle, lock the handgun in the vehicle’s trunk, lock the handgun in a locked container and place the container out of plain view, or lock the handgun in a locked container that is permanently affixed to the vehicle’s interior and not in plain view.

(b) A peace officer, when leaving a handgun in an unattended vehicle not equipped with a trunk, may, if unable to otherwise comply with subdivision (a), lock the handgun out of plain view within the center utility console of that motor vehicle with a padlock, keylock, combination lock, or other similar locking device.

(c) A violation of subdivision (a) is an infraction punishable by a fine not exceeding one thousand dollars ($1,000).

(d) (1) As used in this section, the following definitions shall apply:

(A) “Locked container” means a secure container that is fully enclosed and locked by a padlock, keylock, combination lock, or similar locking device. The term “locked container” does not include the utility or glove compartment of a motor vehicle.

(B) “Peace officer” means a sworn officer described in Chapter 4.5 (commencing with Section 830) of Title 3 of Part 2, or a sworn federal law enforcement officer, who is authorized to carry a firearm in the course and scope of that officer’s duties, while that officer is on duty or off duty.

(C) “Trunk” means the fully enclosed and locked main storage or luggage compartment of a vehicle that is not accessible from the passenger compartment. A trunk does not include the rear of a hatchback, station wagon, or sport utility vehicle, any compartment which has a window, or a toolbox or utility box attached to the bed of a pickup truck.

(D) “Vehicle” has the same meaning as specified in Section 670 of the Vehicle Code.

(2) For purposes of this section, a vehicle is unattended when a person who is lawfully carrying or transporting a handgun in a vehicle is not within close enough proximity to the vehicle to reasonably prevent unauthorized access to the vehicle or its contents.

(3) For purposes of this section, plain view includes any area of the vehicle that is visible by peering through the windows of the vehicle, including windows that are tinted, with or without illumination.

(e) This section does not apply to a peace officer during circumstances requiring immediate aid or action that are within the course of his or her official duties.

(f) This section does not supersede any local ordinance that regulates the storage of handguns in unattended vehicles if the ordinance was in effect before September 26, 2016.