Tuesday, 27 November 2018

Android Battery Drain issue - How to dig and find the root cause?

Mobile phones is getting more and more powerful silicons and processors, which causes more and more issues on battery management. It is unavoidable to consume more electric power for higher processing power. In this article, I'll investigate and present the basic concept of Android mobile phones and how to dig the battery drain issue. Simple answer that we can find in the internet would be : disable GPS/Location/Bluetooth/WiFi/4G/NFC/etc services, which somehow does not make much sense. You possess the powerful smartphone, and of course you want to maximise the usage of the expensive toy.

1. Screen on
Obviously, screen is the most energy-consuming components of any mobile devices. Longer the screen is on, higher power consumption rate you will see. The only possible way to reduce power consumption for screen-on is to reduce the brightness. Full brightness can consume 7 times more energy than the lowest brightness. Therefore, it is advisable to disable the automatic brightness and adjust it manually not exceeding certain brightness.

2. Screen off / sleep / deep sleep
It is obvious that battery is draining a lot during screen-on. More common issue that caused me chaotic was when my battery drained super fast even when the screen was off. I checked battery stats and all other settings in the system, but the Android built-in battery status doesn't provide much detail. I suspect Google Play Services consumes a lot of battery, but I cannot find what apps use what kind of Services.

For convenience, it is called "sleep mode" when the screen is off. Once the screen is off, the Android system is into sleep mode. Furthermore, if the sleep mode lasts long and no background app is running for certain time, Android is falling into deep-sleep mode. During deep-sleep mode, it uses minimum battery close to 0%.

For most cases, the battery drain issue happens when the phone is only in sleep mode, but cannot fall into the deep sleep mode. Your screen is on for 1~2 hours but the battery lasts only for 8~9 hours, means that some apps repeatedly wake up the phone in sleep mode on the background.

The easiest way to find out how long your phone was sleeping deeply is to use 3rd party battery status app, one of: AccuBattery, GSam Battery Monitor, or BetterBatteryStats (BBS).
Especially, GSam and BBS are very useful to detect which app keeps waking up your Android in sleep mode.

Install one of the 3 battery status apps (just one) and check the deep-sleep time and percentage. If your deep sleep time is 90%+, your battery will last for loooooong time. Above 50% would be normal if you install any social media apps, because they will wake your phone up periodically to check new updates.

3. Wakelock
Wakelock is a proper term in Android used by apps to wake up the mobile. If an app request Wakelock, then Android system will be awake from sleep mode and check whatever the app requested. Therefore, our target to prevent battery draining is how to reduce the number of wakelocks.

If you installed GSam or BBS properly with all permissions given with 'adb' command, it can show the detailed information of Wakelocks. In BBS, check "Partial lock" part to see which apps send Wakelocks. In GSam, go to app usage page and check each app. In the detail page, it shows Wakelock details which tells you what app makes the device awake from sleeping.

Once you found the apps with this method, there are plenty of options you can choose. For advanced users, you can probably set to ignore Wakelock from certain apps, which might cause some issues but increase the battery lasting time. Or, just uninstall the app. Or, disable permission to specific service from the app.

4. My Usecase
First of all, I installed AccuBattery to check overall battery consumption speed. It showed my battery consumption is about 15~30%/hour when screen is on, and 2~3%/hour when screen is off. However, from some time, the battery consumption for battery off increased to 7~8%/hour. I have to find the reason.

I then installed GSam to check the detailed usage of battery by each app, as well as to see which app keeps waking up the system. I found that if GSam and AccuBattery are installed at the same time, they interfere each other which somewhat result in faulty measurement. Basically those battery status apps themselves drain quite large amount of the battery, so it's not a good idea to keep both running.

In GSam, I checked the detailed of Google Play Services, and location service is called excessive number of times. Yes, those general advice is correct, that we have to turn off the location service to save the battery! However, I don't want to loose all the benefits that Google brings to me with the location service. Instead of turning Location Service off, I changed the GPS settings to 'Battery Saving' mode which uses only mobile network and WiFi information without using GPS. With this option, location service will drain much less energy.

Next, I disabled "Ok Google" voice recognition as I seldom use the voice command. Note that if you enable "Ok Google" feature, it always keeps turn on the microphone to detect the voice, which prevents the mobile falling into deep sleep. Maybe better option is to detect your voice only when the screen is on. Anyway, in my case, I disabled even for screen on. (Settings -> Google -> Search, Assistance & Voice -> Voice -> Voice Match)

In fact, there are a lot of settings in Google which can have a big impact on the battery drain. The biggest one would be location services, but other settings should be also carefully reviewed. If you don't think you're using those services, just disable it to save more battery. It's critical part.

Lastly, I found my WeChat also drains quite big amount of energy. Weirdly, it keeps accessing to the step-counter sensor, which should be used only by Google Fit or Samsung Health app. I dig into WeChat settings and found that a feature called "WeChat Run" is enabled. This app-in-app is counting the walking steps and comparing with my friends.I disable this feature, along with other features in the app.

Overall, those internet advice is correct. Disable GPS/Location/etc/etc will save the battery, and my final solution was in fact similar. However, the huge difference in this article is that you KNOW what app makes the battery draining before you disable or uninstall it. As different users have different pattern of mobile usage, it is critical to know what exactly causes the battery issue IN YOUR MOBILE.

For further information, please read these guides and manuals:
https://forum.xda-developers.com/galaxy-s8/help/guide-hunting-wakelocks-battery-drain-t3697324
http://blogger.gsamlabs.com/2011/11/badass-battery-monitor-users-guide.html
https://pdfs.semanticscholar.org/f098/ce049f0d537fac404fd45a58c9f8f4c0bca8.pdf

Friday, 12 October 2018

Windows 10 1709 (Oct 2018 ver.) migration from MBR HDD to GPT SSD (or another HDD)

You purchase a new lightening-fast SSD or super-sized HDD, and it's time to copy your Windows system to the new storage!

If your original HDD and new SSD are both partitioned with GPT, simply use a free version partition management software from EaseUS or Minitool. Free versions still support cloning a partition from GPT to GPT, or MBR to MBR.

However, if your old disk uses MBR and want to get benefits of the fancy GPT partition on your new disk, it can bring some headache. The easiest way is to purchase a "Pro" version of the previously mentioned commercialized software. Only paid versions support migrating (or cloning) a system partition from MBR to GPT.

If your budget is limited and you do not want to pay $$ for one-time system migration, then this is the article for you! There're simple steps.


1. Attach the new drive, detach the old drive, and create EFI partition on the new drive.

Boot with the Windows 10 installation media, and clean-install Windows on your new drive with GPT partition. This will create an EFI partition automatically on your new drive which allow to boot on UEFI/GPT mode.

Instead of installing the new Windows, you can simply try to manually partition the new drive for Recovery (500MB, NTFS, OEM Partition), EFI (100MB, FAT32, EFI), and Windows (NTFS). EFI partition will be used to install Windows booting information after cloning the old windows to the new windows partition.


2. Attach the old drive and clone the old Windows NTFS partition.

The easiest way is to boot with the old windows, install EaseUS Todo Backup free version, and clone the old drive (C:) to the newly created Windows partition of the new drive (overwrite). You don't need to use "System clone" which is supported only by paid software. Just use "data clone" function in the free version.
In fact, this will ruin the clean-installed windows on the new drive because you overwrite the windows partition with the old system. You cannot boot with the copied partition YET.

You can do this with Clonezilla, ntfsclone, Minitool, or any other disk cloning software.

3.Detach the old drive again, and recover the booting of the new drive.

Once the cloning is completed, it's time to recover the booting from the newly copied volume on the new drive. When you tried to boot with the new drive, it'll simply throw an error message.

Boot with the Windows Installation Media USB, select Repair, go to Advanced, and open Command Prompt. The prompt shows up with X:\ as a default drive.

Type these commands to assign a drive letter for EFI partition:
X:\> diskpart
list disk
sel disk 0  // if 0 is the new drive
list vol
sel vol 3 // if 3 is the EFI partition with 100MB FAT32
assign letter=G:
exit

Then, format G with the following command:
X:\> format G: /fs:FAT32

Now, you have to install EFI partition with a new boot for the cloned Windows partition.
Type the following command:
X:\> bcdboot C:\windows /s G: /f UEFI

Now your EFI partition is recovered with the cloned Windows.
Unplug the USB and reboot! Windows should be able to boot without any problem.

Once Windows is working well with the new drive, you can attach the old drive if you want to use it for other purposes.

Wednesday, 3 October 2018

Dell Optiplex 9020 SFF Upgrade Guide: Graphic Card (e.g. GTX 1050Ti) and SSD (Hard Drive)

Dell Optiplex mainboard layout from the service manual:

(Image source: https://topics-cdn.dell.com/pdf/optiplex-9020-desktop_owners-manual_en-us.pdf)

As you can see from the above layout, the mainboard has 2 PCI Express slots for powerful graphic cards, as well as 3 SATA connectors for additional SSD/HDD device.

1. Graphic Card

You can install up-to-date Low Profile graphic card to 9020 SFF machine, e.g. GTX 1050Ti 4GB LP.
However, note that only 4x PCI Express slot can be used for 1050Ti models because of the fan on the graphic card (16x PCI-E slot will be wasted). All 1050Ti LP products have a large fan and heat-sink taking an additional slot, which is the the 16x slot on 9020 SFF. Thus, if you want to use GTX 1050Ti, it is unavoidable to give up using additional device connecting to PCI-E slot. Of course if the new graphic card takes only one slot, both PCI-E slots can be exploited.

Regarding the performance for 4x PCI-E, compared to 16x PCI-E, most people on the internet say there will be little or no performance difference for 1050Ti class graphic card. Of course there will be quite a lot of difference for a higher graphic cards, such as GTX 1080, but 1050Ti is not powerful enough to get benefit from 16x PCI-E, meaning 4x PCI-E is fast enough to transfer all data between GPU and CPU.

I personally purchased and tried Gigabyte GTX 1050Ti OC LP (4GB) model on my 9020 SFF for 3 months so far, which is working perfectly without any issue. I haven't experienced any frozen or blue screen for this time even when I was running pretty heavy 3D games. Of course, don't expect to run the most recent 3D games in the highest configuration, which probably needs 1080Ti + 8th Gen i7 processor.

2. SSD/HDD

In most cases, the default 9020 SFF configuration comes with 1xDVD-RW drive and 1xHDD(or SSD), which are connected to two SATA data connectors (No 12 in the above photo), and one power connector (No 11). If so, there is one extra SATA data connector left blank (No 12 has 3 ports) which can be used for an additional SSD. Note that, if you want to 'replace' (no 'add') your SSD or HDD, simply remove the current one and insert a new one. The only tricky part will be mounting the drive to the chassis, which might need to use a sticky tape or 3rd party cradle.

If you want to install an new SSD in addition to the old drive, 2 more cables are necessary:

1) SATA power splitter (15pin) Y cable: one 15-pin male (that connects to the current cable's female part) and two 15-pin females (connect to the old drive and the new SSD).
(Image: Amazon)

2) SATA data cable
(Image: Amazon)

I found a YouTube video that made a custom power cable by soldering cables to the original cable, but it's totally unnecessary if you can get the power splitter cable. Do NOT buy any cable with the old 4-pin connectors. There are a lot of places you can get 15-pin SATA one male to 2 female power cables (from $1 on eBay..).

Once you have a new SSD drive and the two extra cables, connect the power splitter cable to the new and old drives and the data cable to the drive and the empty port on the main board (No 12).

In order to attach the new SSD to the chassis, you will need to use a sticky tape or purchase a 3rd party cradle. If you don't need the DVD-RW drive, it's even possible to remove the DVD-RW and use the space to put the SSD. In this case, up to 3 SSD/HDDs can be installed in total.

Conclusion

Dell OptiPlex 9020 SFF is such a small desktop provides full of performance and expandability. It comes with 4th Generation i5 or i7 CPU, Intel Q87 main chipset, 4x DDR3 1600 memory slots,  2x PCI-E slots, and 3xSATA ports.

If you're lucky enough to get this incredible machine at a cheap price (2nd-hand at around US$ 150-200), it's easy to upgrade the basic machine to a powerful Windows game platform by simply adding a good graphic card, extra SSD, and memory (if the basic machine has less RAM installed).
Enjoy any 3D game with this cheap and small machine!

Android Battery Drain issue - How to dig and find the root cause?

Mobile phones is getting more and more powerful silicons and processors, which causes more and more issues on battery management. It is unav...