[Tutorial] Battery drain & lag after OS update


After this command:
adb shell "cmd package bg-dexopt-job"
Your adb prompt will looks like in idle, but in a second plan, your device will start to rebuild the cache. After a 15 min with you device connected, the adb will show "success".

It looks nothing are happening, but the process is happening in second plan with no confirmation message.
then I hope I didn't do any damage by stopping it because it didn't seem to work. Thank you
 
After this command:
adb shell "cmd package bg-dexopt-job"
Your adb prompt will looks like in idle, but in a second plan, your device will start to rebuild the cache. After a 15 min with you device connected, the adb will show "success".

It looks nothing are happening, but the process is happening in second plan with no confirmation message.
Did you turn on the 2 adb debug options? (Adb debug + adb debug security settings)

(Edit: oops wrong reply.)
 
Last edited:
When do we need to run this command? After specific conditions are met (for example you drain your battery till the 30sec timer, then you charge the full battery and then you run the command after discharging) or anytime ?
 
When do we need to run this command? After specific conditions are met (for example you drain your battery till the 30sec timer, then you charge the full battery and then you run the command after discharging) or anytime ?
The command ~is supposed to force the optimization to happen before all the criterias it needs are met. ~Just have enough battery or plug in a charger and done
 
  • Like
Reactions: xNAPx
Isn't this function already included in the xiaomi.eu rom when activating app preloading option?
 

Attachments

  • Screenshot_2021-07-02-14-03-23-672_com.android.settings.jpg
    Screenshot_2021-07-02-14-03-23-672_com.android.settings.jpg
    92.9 KB · Views: 851
Hello, many people complain about battery drain & lags after OS update. This method maybe can help u.

Lest first explane why and what this method do. Tutorial is taken from chinese xiaomi fans.

Probably each of you was faced with high battery consumption in the first 3-4 days after updating or flashing the device, the android system is the first in the list of consumption and has 30-40% of use! This guide will help to remove this problem.
It should be after flashing or installing updates on older versions of Android starting from 6 and below.

You have encountered such a system dialog as "Optimizing app xx from xx"

In Android 7.0, did they hide this from the user's eyes or delete it? Does this mean that the optimization has been removed? No, this is not such. This option was not lost, but simply postponed, and the postponement of this task causes the battery to run out. Do you think that optimization is happening in the background? The answer is not correct. It only starts under special conditions. Lack of this optimization will drain the battery. Optimization is not performed because we do not know how to fulfill the conditions necessary for its launch. The consequence of this is the accelerated discharge of the phone.

You can often watch how the Android system consumes energy more than other applications. This is the result of not allowing the system to optimize.
If in Android 6 and earlier optimization was forced, then starting with Android 7 and higher. A new option was added to skip this step and optimize applications on the fly (JIT, Just-In-Time) while using applications.
At the same time, the initial optimization has not been deleted and only starts if the following conditions are met:
  • the phone is connected to the charger,
  • fully charged,
  • turned on (the phone itself, not the screen),
  • is not used,
  • inactive (like after at least 30 minutes).

If these conditions are met, optimization begins.


Why do we need this optimization?

Because application developers cannot do this for each set of hardware and each device is already. It compiles applications into the most efficient code for its processor. So just use your device and let it take care of the cache itself or help your device make full optimization with simpl command.
Quick note

Be that as it may, you have the option to force the optimization to run.

For users with root:
open a terminal emulator and execute (along with quotation marks, as this is part of the command):

su -c "cmd package bg-dexopt-job"

or

su

next

"cmd package bg-dexopt-job"

If you don’t have root, use ADB. Connect the phone to the device, make sure it is available (enable USB debugging and USB debugging secure settings). Open CMD ADB platform-tools and write command one by one:

adb devices

Run the following command

adb shell cmd package bg-dexopt-job

or

adb shell "cmd package bg-dexopt-job"

If you have 10 android you will see Success, if from 7 to 9 a new line for entering the command will simply appear!
View attachment 32438

The process can take from 20 minutes to 3 hours (on my MI 9t this operation take 40 minutes).
Disconnecting the device during optimization will interrupt the process, but will not harm the device. It is absolutely safe.
Users without root may find the error message


It’s not worth worrying, you can ignore it and run the command again.
Hello, thank you for this tutorial, I'm with rooted Mi9T with xiaami. eu, and I want to use this command
Hello, many people complain about battery drain & lags after OS update. This method maybe can help u.

Lest first explane why and what this method do. Tutorial is taken from chinese xiaomi fans.

Probably each of you was faced with high battery consumption in the first 3-4 days after updating or flashing the device, the android system is the first in the list of consumption and has 30-40% of use! This guide will help to remove this problem.
It should be after flashing or installing updates on older versions of Android starting from 6 and below.

You have encountered such a system dialog as "Optimizing app xx from xx"

In Android 7.0, did they hide this from the user's eyes or delete it? Does this mean that the optimization has been removed? No, this is not such. This option was not lost, but simply postponed, and the postponement of this task causes the battery to run out. Do you think that optimization is happening in the background? The answer is not correct. It only starts under special conditions. Lack of this optimization will drain the battery. Optimization is not performed because we do not know how to fulfill the conditions necessary for its launch. The consequence of this is the accelerated discharge of the phone.

You can often watch how the Android system consumes energy more than other applications. This is the result of not allowing the system to optimize.
If in Android 6 and earlier optimization was forced, then starting with Android 7 and higher. A new option was added to skip this step and optimize applications on the fly (JIT, Just-In-Time) while using applications.
At the same time, the initial optimization has not been deleted and only starts if the following conditions are met:
  • the phone is connected to the charger,
  • fully charged,
  • turned on (the phone itself, not the screen),
  • is not used,
  • inactive (like after at least 30 minutes).

If these conditions are met, optimization begins.


Why do we need this optimization?

Because application developers cannot do this for each set of hardware and each device is already. It compiles applications into the most efficient code for its processor. So just use your device and let it take care of the cache itself or help your device make full optimization with simpl command.
Quick note

Be that as it may, you have the option to force the optimization to run.

For users with root:
open a terminal emulator and execute (along with quotation marks, as this is part of the command):

su -c "cmd package bg-dexopt-job"

or

su

next

"cmd package bg-dexopt-job"

If you don’t have root, use ADB. Connect the phone to the device, make sure it is available (enable USB debugging and USB debugging secure settings). Open CMD ADB platform-tools and write command one by one:

adb devices

Run the following command

adb shell cmd package bg-dexopt-job

or

adb shell "cmd package bg-dexopt-job"

If you have 10 android you will see Success, if from 7 to 9 a new line for entering the command will simply appear!
View attachment 32438

The process can take from 20 minutes to 3 hours (on my MI 9t this operation take 40 minutes).
Disconnecting the device during optimization will interrupt the process, but will not harm the device. It is absolutely safe.
Users without root may find the error message


It’s not worth worrying, you can ignore it and run the command again.
Hello and thank you for this tutorial, I'm with rooted Mi9T with xiaomi. eu ROM and I want to use this command to try optimizing:
su -c "cmd package bg-dexopt-job" I tried with termux but when I use the command it said

Are you rooted?

when I typed: Y

it starts following

y
y
y
y
y
all over the terminal

Can you tell me what steps I have to do before writing the command?

Thank you in advance!
 
Hello, thank you for this tutorial, I'm with rooted Mi9T with xiaami. eu, and I want to use this command

Hello and thank you for this tutorial, I'm with rooted Mi9T with xiaomi. eu ROM and I want to use this command to try optimizing:
su -c "cmd package bg-dexopt-job" I tried with termux but when I use the command it said

Are you rooted?

when I typed: Y

it starts following

y
y
y
y
y
all over the terminal

Can you tell me what steps I have to do before writing the command?

Thank you in advance!
Did you grant termux superuser rights ?
 
  • Like
Reactions: kingornet
Hello, many people complain about battery drain & lags after OS update. This method maybe can help u.

Lest first explane why and what this method do. Tutorial is taken from chinese xiaomi fans.

Probably each of you was faced with high battery consumption in the first 3-4 days after updating or flashing the device, the android system is the first in the list of consumption and has 30-40% of use! This guide will help to remove this problem.
It should be after flashing or installing updates on older versions of Android starting from 6 and below.

You have encountered such a system dialog as "Optimizing app xx from xx"

In Android 7.0, did they hide this from the user's eyes or delete it? Does this mean that the optimization has been removed? No, this is not such. This option was not lost, but simply postponed, and the postponement of this task causes the battery to run out. Do you think that optimization is happening in the background? The answer is not correct. It only starts under special conditions. Lack of this optimization will drain the battery. Optimization is not performed because we do not know how to fulfill the conditions necessary for its launch. The consequence of this is the accelerated discharge of the phone.

You can often watch how the Android system consumes energy more than other applications. This is the result of not allowing the system to optimize.
If in Android 6 and earlier optimization was forced, then starting with Android 7 and higher. A new option was added to skip this step and optimize applications on the fly (JIT, Just-In-Time) while using applications.
At the same time, the initial optimization has not been deleted and only starts if the following conditions are met:
  • the phone is connected to the charger,
  • fully charged,
  • turned on (the phone itself, not the screen),
  • is not used,
  • inactive (like after at least 30 minutes).

If these conditions are met, optimization begins.


Why do we need this optimization?

Because application developers cannot do this for each set of hardware and each device is already. It compiles applications into the most efficient code for its processor. So just use your device and let it take care of the cache itself or help your device make full optimization with simpl command.
Quick note

Be that as it may, you have the option to force the optimization to run.

For users with root:
open a terminal emulator and execute (along with quotation marks, as this is part of the command):

su -c "cmd package bg-dexopt-job"

or

su

next

"cmd package bg-dexopt-job"

If you don’t have root, use ADB. Connect the phone to the device, make sure it is available (enable USB debugging and USB debugging secure settings). Open CMD ADB platform-tools and write command one by one:

adb devices

Run the following command

adb shell cmd package bg-dexopt-job

or

adb shell "cmd package bg-dexopt-job"

If you have 10 android you will see Success, if from 7 to 9 a new line for entering the command will simply appear!
View attachment 32438

The process can take from 20 minutes to 3 hours (on my MI 9t this operation take 40 minutes).
Disconnecting the device during optimization will interrupt the process, but will not harm the device. It is absolutely safe.
Users without root may find the error message


It’s not worth worrying, you can ignore it and run the command again.
Hello.

Is this procedule necessary to run everytime after flash a new ROM(Ex weekly ROM)?
 
Sorry to ask because I don't understand, what does it do in the system, makes it lighter, faster?

End up disabling something in the background?
 
Last edited:
What about Android 12? :-D

Edit: Did it over ADB... did work and was taking about 2 min. (Mi 11 Ultra MIUI 13)

we will see if its working...

Edit #2: Sadly Its not working for me... :-/ its the same as before.
 
Last edited:
  • Like
Reactions: xeGox
What about Android 12? :-D

Edit: Did it over ADB... did work and was taking about 2 min. (Mi 11 Ultra MIUI 13)

we will see if its working...

Edit #2: Sadly Its not working for me... :-/ its the same as before.
Yes i am having the same problem as well. (Mi 11 lite , MIUI 13.0.7). It doesn't seem to work in android 12 i guess