Apple Magic mouse frequently disconnects and reconnects

I've had the same problem and recently I tried disabling eSCO mode in the bluetooth module:

echo 1 | sudo tee /sys/module/bluetooth/parameters/disable_esco
sudo /etc/init.d/bluetooth restart
# persist setting
echo "options bluetooth disable_esco=1" | sudo tee /etc/modprobe.d/bluetooth-tweaks.conf

The mouse's connection seems more stable now and I haven't seen a disconnect after tweaking this setting.

My laptop Lenovo W530 has a Broadcom Bluetooth adapter (internally usb is the interface).

If you have a Broadcom Bluetooth adapter, you might have to get a .hex firmware file from a windows driver and put it in /lib/firmware directory to support all Bluetooth features. More info in https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1065400/comments/11 and https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1065400 .

Use hex2hcd to convert windows driver .hex file to .hcd: https://github.com/jessesung/hex2hcd

I found Broadcom .hex files in this windows driver package. Locate the Win7/Win32/bcbtums-win7x86-brcm.inf file and search for the USB ID of your adapter.

$ lsusb |grep Bluetooth
Bus 001 Device 006: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad]

search for RAMUSB<usb product id in upper case>, for example RAMUSB21E6 for my adapter. There you will find the .hex file name:

[RAMUSB21E6.NTX86.hw.reg]
HKR,,LowerFilters, 0x00010000, "bcbtums"
HKR,,%RAMPatchFileName%,0x00000, "BCM20702A1_001.002.014.1315.1387.hex"
HKR,,%RemoteWakeEnabled%,0x00010001,1
HKR,,%DeviceRemoteWakeSupported%,0x00010001,1

In my case the file was Win7/Win32/BCM20702A1_001.002.014.1315.1387.hex

I then used hex2hcd to convert the file to /lib/firmware/fw-0a5c_21e6.hcd (again that file name contains the USB ids of your Broadcom USB Bluetooth adapter).