FORUMS
Remove All Ads from XDA

[Root] Doze Settings Editor (Android Marshmallow Only)

100 posts
Thanks Meter: 568
 
Post Reply Email Thread
Android Marshmallow Doze Settings Editor

Requires Root

This app is a simple editor of the settings or parameters which affect the operation of Doze.
If no root is available then it will offer an ADB command that will modify the doze settings.
Because there is no root on open it will always load the default settings.

Changelog - v6.0
  • You can now add your own custom profiles.
  • Added tuhinxp04's profile
  • Bugfix - No longer crashes when device settings unavailable. Will change to non root mode.
  • Bugfix - Info screen now shows default in current display type
  • Bugfix - Info screen now shows location accuracy with meters
Changelog - v5.0
  • New built in profiles
  • Bugfix - Back arrow in settings not closing activity

The next post contains descriptions of each parameter.

Source Code
https://github.com/p0isonra1n/Doze-Settings-Editor

Disclaimer
I accept no responsibility for any outcome that this app may cause. Use at your own risk.
Attached Thumbnails
Click image for larger version

Name:	WMyIEAK.png
Views:	119514
Size:	171.3 KB
ID:	3521529  
Attached Files
File Type: apk Doze Editor.apk - [Click for QR Code] (1.35 MB, 10284 views)
File Type: apk Doze Editor v2.apk - [Click for QR Code] (1.35 MB, 2398 views)
File Type: apk Doze Editor v3.apk - [Click for QR Code] (1.37 MB, 2216 views)
File Type: apk Doze Editor v4.apk - [Click for QR Code] (1.38 MB, 4742 views)
File Type: apk Doze Editor v5.apk - [Click for QR Code] (1.39 MB, 7500 views)
File Type: apk Doze Editor v6.apk - [Click for QR Code] (1.46 MB, 86786 views)
The Following 314 Users Say Thank You to p0isonra1n For This Useful Post: [ View ] Gift p0isonra1n Ad-Free
 
 
28th October 2015, 12:21 PM |#2  
p0isonra1n's Avatar
OP Senior Member
Flag Gold Coast
Thanks Meter: 568
 
Donate to Me
More
Parameter Descriptions
These are all direct from the Doze source code.

Inactive Timeout - inactive_to
This is the time, after becoming inactive, at which we start looking at the motion sensor to determine if the device is being left alone. We don't do this immediately after going inactive just because we don't want to be continually running the significant motion sensor whenever the screen is off.
Sensing Timeout - sensing_to
If we don't receive a callback from AnyMotion in this amount of time + locating_to, we will change from STATE_SENSING to STATE_INACTIVE, and any AnyMotion callbacks while not in STATE_SENSING will be ignored.
Locating Timeout - locating_to
This is how long we will wait to try to get a good location fix before going in to idle mode.
Location Accuracy - location_accuracy
The desired maximum accuracy (in meters) we consider the location to be good enough to go on to idle. We will be trying to get an accuracy fix at least this good or until locating_to expires.
Motion Inactive Timeout - motion_inactive_to
This is the time, after seeing motion, that we wait after becoming inactive from that until we start looking for motion again.
Idle After Inactive Timeout - idle_after_inactive_to
This is the time, after the inactive timeout elapses, that we will wait looking for significant motion until we truly consider the device to be idle.
Idle Pending Timeout - idle_pending_to
This is the initial time, after being idle, that we will allow ourself to be back in the IDLE_PENDING state allowing the system to run normally until we return to idle.
Max Idle Pending Timeout - max_idle_pending_to
Maximum pending idle timeout (time spent running) we will be allowed to use.
Idle Pending Factor - idle_pending_factor
Scaling factor to apply to current pending idle timeout each time we cycle through that state.
Idle Timeout - idle_to
This is the initial time that we want to sit in the idle state before waking up again to return to pending idle and allowing normal work to run.
Max Idle Timeout - max_idle_to
Maximum idle duration we will be allowed to use.
Idle Factor - idle_factor
Scaling factor to apply to current idle timeout each time we cycle through that state.
Min Time to Alarm - min_time_to_alarm
This is the minimum time we will allow until the next upcoming alarm for us to actually go in to idle mode.
Max Temp App Whitelist Duration - max_temp_app_whitelist_duration
Max amount of time to temporarily whitelist an app when it receives a high tickle.
MMS Temp App Whitelist Duration - mms_temp_app_whitelist_duration
Amount of time we would like to whitelist an app that is receiving an MMS.
SMS Temp App Whitelist Duration - sms_temp_app_whitelist_duration
Amount of time we would like to whitelist an app that is receiving an SMS.

Extra Infomation
Difference: Doze and App Standby (developer.android.com)
Some tests and issues: code.google.com
The Following 89 Users Say Thank You to p0isonra1n For This Useful Post: [ View ] Gift p0isonra1n Ad-Free
28th October 2015, 07:03 PM |#3  
Account currently disabled
Thanks Meter: 879
 
More
Requires root.... so.... source code?
The Following 13 Users Say Thank You to doitright For This Useful Post: [ View ] Gift doitright Ad-Free
28th October 2015, 07:13 PM |#4  
Mkkt Bkkt's Avatar
Senior Member
Thanks Meter: 165
 
More
Going to play with this on my Oneplus one for some time.
Thanks for your work m8.
28th October 2015, 07:56 PM |#5  
Member
Vienna
Thanks Meter: 101
 
More
9THX!

Does it show the default numbers or does it read out the current settings?
E.g. can we see what is changed with aggressive doze from greenify?

Edit: aggressive doze seems not edit directly these strings ...

----------------------------------------------------------------------------------------------

note:
whitelist is only for app Standby!
Difference: Doze and App Standby (developer.android.com)
Some tests and issues: code.google.com

Some add links:
Power Management (source.android.com)
Doze and App Standby (developer.android.com)
Doze steps (xda)
Understanding what Doze mode means for your app - Pro-tip by +Joanna Smith (G+)
time explanation in more simple english (xda)

what we found out:
*timeout means not max. time - so the system check only from time to time if there are timeouts over, then it will stop - this is not exactly triggered (only linux sw timer)
** if e.g. sensing_timeout = 0 it will stop sensing after the next control cycle (SystemClock Interrupt AlarmTime) - although it is 0, it will check the motion sensor for few seconds

*idle mode (doze) stops if
**idle_to is reached or
**phone detect any significant motion (!)
**some tests from @italia0101

idle def (source code):
Code:
/** Device is in the idle state, trying to stay asleep as much as possible. */
Device idle controller (deviceidle) dump options:

(adb shell dumpsys battery unplug)
Code:
adb shell dumpsys deviceidle -h
Device idle controller (deviceidle) dump options:
  [-h] [CMD]
  -h: print this help text.
Commands:
  step
    Immediately step to next state, without waiting for alarm.
  force-idle
    Force directly into idle mode, regardless of other device state.
    Use "step" to get out.
  disable
    Completely disable device idle mode.
  enable
    Re-enable device idle mode after it had previously been disabled.
  enabled
    Print 1 if device idle mode is currently enabled, else 0.
  whitelist
    Print currently whitelisted apps.
  whitelist [package ...]
    Add (prefix with +) or remove (prefix with -) packages.
  tempwhitelist [package ..]
    Temporarily place packages in whitelist for 10 seconds.
[GUIDE][ADB]Easiest How to use adb, logcat, etc for noobs and newbies

adb shell dumpsys deviceidle - output:
Code:
adb shell dumpsys deviceidle
  Settings:
    inactive_to=+30m0s0ms
    sensing_to=+4m0s0ms
    locating_to=+30s0ms
    location_accuracy=20.0m
    motion_inactive_to=+10m0s0ms
    idle_after_inactive_to=+30m0s0ms
    idle_pending_to=+5m0s0ms
    max_idle_pending_to=+10m0s0ms
    idle_pending_factor=2.0
    idle_to=+60m0s0ms
    max_idle_to=+6h0m0s0ms
    idle_factor=2.0
    min_time_to_alarm=+60m0s0ms
    max_temp_app_whitelist_duration=+5m0s0ms
    mms_temp_app_whitelist_duration=+60s0ms
    sms_temp_app_whitelist_duration=+20s0ms
  Whitelist (except idle) system apps:
    com.android.providers.downloads
    com.android.vending
    com.google.android.gms
  Whitelist system apps:
    com.google.android.gms
  Whitelist (except idle) all app ids:
    10008
    10011
    10020
  Whitelist all app ids:
    10011
  mEnabled=true
  mForceIdle=false
  mSigMotionSensor={Sensor name="Significant Motion Detector", vendor="QTI", version=1, type=17, maxRange=1.0, resolution=1.0, power=0.3999939, minDelay=-1}
  mCurDisplay=Display id 0: DisplayInfo{"Integrierter Bildschirm", uniqueId "local:0", app 1080 x 1823, real 1080 x 1920, largest app 1835 x 1769, smallest app 1080 x 1026, mode 1, defaultMode 1, modes [{id=1, width=1080, height=1920, fps=60.0}], rotation 0, density 360 (442.451 x 443.345) dpi, layerStack 0, appVsyncOff 7500000, presDeadline 12666667, type BUILT_IN, state OFF, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS}, DisplayMetrics{density=2.25, width=1080, height=1823, scaledDensity=2.25, xdpi=442.451, ydpi=443.345}, isValid=true
  mScreenOn=false
  mCharging=false
  mSigMotionActive=false
  mSensing=false mNotMoving=false
  mLocating=false mHaveGps=false mLocated=false
  mState=INACTIVE
  mInactiveTimeout=+5m0s0ms
  mNextAlarmTime=+4m57s175ms
MOTION_INACTIVE_TIMEOUT
Code:
@Override
        public void onTrigger(TriggerEvent event) {
            synchronized (DeviceIdleController.this) {
                active = false;
                motionLocked();
            }
        }
        @Override
        public void onSensorChanged(SensorEvent event) {
            synchronized (DeviceIdleController.this) {
                mSensorManager.unregisterListener(this, mMotionSensor);
                active = false;
                motionLocked();
            }
        }

void motionLocked() {
      // The motion sensor will have been disabled at this point
      handleMotionDetectedLocked(mConstants.MOTION_INACTIVE_TIMEOUT, "motion");
    }

void handleMotionDetectedLocked(long timeout, String type) {
        // The device is not yet active, so we want to go back to the pending idle
        // state to wait again for no motion.  Note that we only monitor for motion
        // after moving out of the inactive state, so no need to worry about that.
        if (mState != STATE_ACTIVE) {
            scheduleReportActiveLocked(type, Process.myUid());
            mState = STATE_ACTIVE;
            mInactiveTimeout = timeout; 
            EventLogTags.writeDeviceIdle(mState, type);
            becomeInactiveIfAppropriateLocked();
        }
    }

void becomeInactiveIfAppropriateLocked() {
        if (((!mScreenOn && !mCharging) || mForceIdle) && mEnabled && mState == STATE_ACTIVE) {
            // Screen has turned off; we are now going to become inactive and start
            // waiting to see if we will ultimately go idle.
            mState = STATE_INACTIVE;
            resetIdleManagementLocked();
            scheduleAlarmLocked(mInactiveTimeout, false);
            EventLogTags.writeDeviceIdle(mState, "no activity");
        }
    }

void scheduleAlarmLocked(long delay, boolean idleUntil) {
        mNextAlarmTime = SystemClock.elapsedRealtime() + delay;
        if (idleUntil) {
            mAlarmManager.setIdleUntil(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                    mNextAlarmTime, mAlarmIntent);
        } else {
            mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                    mNextAlarmTime, mAlarmIntent);
        }
    }
SENISING_TIMEOUT
Code:
switch (mState) {
            case STATE_INACTIVE:
                // We have now been inactive long enough, it is time to start looking
                // for motion and sleep some more while doing so.
                ...
                break;
            case STATE_IDLE_PENDING:
                mState = STATE_SENSING;
                EventLogTags.writeDeviceIdle(mState, "step");
                scheduleSensingAlarmLocked(mConstants.SENSING_TIMEOUT);
                cancelSensingAlarmLocked();
                cancelLocatingLocked();
                mAnyMotionDetector.checkForAnyMotion();
                mNotMoving = false;
                mLocated = false;
                mLastGenericLocation = null;
                mLastGpsLocation = null;
                break;
            case STATE_SENSING:
                ...
}

void scheduleAlarmLocked(long delay, boolean idleUntil) {
        mNextAlarmTime = SystemClock.elapsedRealtime() + delay;
        if (idleUntil) {
            mAlarmManager.setIdleUntil(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                    mNextAlarmTime, mAlarmIntent);
        } else {
            mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                    mNextAlarmTime, mAlarmIntent);
        }
    }
 
// mAlarmManager.setIdleUntil    * Schedule an idle-until alarm, which will keep the alarm manager idle until the given time.
// mAlarmManager.set * Schedule an alarm.; If the stated trigger time is in the past, the alarm will be triggered immediately.

//android/server/AnyMotionDetector.java
public AnyMotionDetector(AlarmManager am, PowerManager pm, Handler handler, SensorManager sm,
            DeviceIdleCallback callback) {
        mAlarmManager = am;
        mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
        mHandler = handler;
        mSensorManager = sm;
        mAccelSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        mMeasurementInProgress = false;
        mState = STATE_INACTIVE;
        mCallback = callback;
        mRunningStats = new RunningSignalStats();
        mNumSufficientSamples = (int) Math.ceil(
                ((double)ORIENTATION_MEASUREMENT_DURATION_MILLIS / SAMPLING_INTERVAL_MILLIS));
    }

private final class MotionListener extends TriggerEventListener
            implements SensorEventListener {
            ...
}


    private final SensorEventListener mListener = new SensorEventListener() {
        @Override
        public void onSensorChanged(SensorEvent event) {
            int status = RESULT_UNKNOWN;
            synchronized (mLock) {
                Vector3 accelDatum = new Vector3(SystemClock.elapsedRealtime(), event.values[0],
                        event.values[1], event.values[2]);
                mRunningStats.accumulate(accelDatum);

                // If we have enough samples, stop accelerometer data acquisition.
                if (mRunningStats.getSampleCount() >= mNumSufficientSamples) {
                    status = stopOrientationMeasurementLocked();
                }
            }
            if (status != RESULT_UNKNOWN) {
                mCallback.onAnyMotionResult(status);
            }
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
        }
    };

private int stopOrientationMeasurementLocked() {
        int status = RESULT_UNKNOWN;
        if (mMeasurementInProgress) {
            mSensorManager.unregisterListener(mListener);
            mHandler.removeCallbacks(mMeasurementTimeout);
            if (mWakeLock.isHeld()) {
                mWakeLock.release();
            }
            long detectionEndTime = SystemClock.elapsedRealtime();
            mMeasurementInProgress = false;
            mPreviousGravityVector = mCurrentGravityVector;
            mCurrentGravityVector = mRunningStats.getRunningAverage();
            mRunningStats.reset();
            status = getStationaryStatus();
            if (status != RESULT_UNKNOWN) {
                mState = STATE_INACTIVE;
            } else {
                /*
                 * Unknown due to insufficient measurements. Schedule another orientation
                 * measurement.
                 */
               Message msg = Message.obtain(mHandler, mSensorRestart);
                msg.setAsynchronous(true);
                mHandler.sendMessageDelayed(msg, ORIENTATION_MEASUREMENT_INTERVAL_MILLIS);
            }
        }
        return status;
    }

    /*
     * Updates mStatus to the current AnyMotion status.
     */
    public int getStationaryStatus() {
        if ((mPreviousGravityVector == null) || (mCurrentGravityVector == null)) {
            return RESULT_UNKNOWN;
        }
        Vector3 previousGravityVectorNormalized = mPreviousGravityVector.normalized();
        Vector3 currentGravityVectorNormalized = mCurrentGravityVector.normalized();
        float angle = previousGravityVectorNormalized.angleBetween(currentGravityVectorNormalized);
        if ((angle < THRESHOLD_ANGLE) && (mRunningStats.getEnergy() < THRESHOLD_ENERGY)) {
            return RESULT_STATIONARY;
        } else if (Float.isNaN(angle)) {
          /**
           * Floating point rounding errors have caused the angle calcuation's dot product to 
           * exceed 1.0. In such case, we report RESULT_MOVED to prevent devices from rapidly
           * retrying this measurement.
           */
            return RESULT_MOVED;
        }
        long diffTime = mCurrentGravityVector.timeMillisSinceBoot -
                mPreviousGravityVector.timeMillisSinceBoot;
        if (diffTime > STALE_MEASUREMENT_TIMEOUT_MILLIS) {
            return RESULT_UNKNOWN;
        }
        return RESULT_MOVED;
    }

    /** Current measurement state. */
    private int mState;

    /** Threshold angle in degrees beyond which the device is considered moving. */
    private final float THRESHOLD_ANGLE = 2f;

    /** Threshold energy above which the device is considered moving. */
    private final float THRESHOLD_ENERGY = 5f;

    /** The duration of the accelerometer orientation measurement. */
    private static final long ORIENTATION_MEASUREMENT_DURATION_MILLIS = 2500;

    /** The maximum duration we will collect accelerometer data. */
    private static final long ACCELEROMETER_DATA_TIMEOUT_MILLIS = 3000;

    /** The interval between accelerometer orientation measurements. */
    private static final long ORIENTATION_MEASUREMENT_INTERVAL_MILLIS = 5000;

    /**
     * The duration in milliseconds after which an orientation measurement is considered
     * too stale to be used.
     */
    private static final int STALE_MEASUREMENT_TIMEOUT_MILLIS = 2 * 60 * 1000;

    /** The accelerometer sampling interval. */
    private static final int SAMPLING_INTERVAL_MILLIS = 40;
/android/server/DeviceIdleController.java
motionLocked() https://android.googlesource.com/pla...ller.java#1402
scheduleAlarmLocked https://android.googlesource.com/pla...ller.java#1402
sensing scheduleAlarmLocked https://android.googlesource.com/pla...ller.java#1490

/android/hardware/Sensor.java
description of a significant motion trigger sensor (TYPE_SIGNIFICANT_MOTION = 17) https://android.googlesource.com/pla...ensor.java#305
mPower: https://android.googlesource.com/pla...ensor.java#721
SensorPrintString https://android.googlesource.com/pla...ensor.java#848

/android/hardware/SensorManager.java
cancelTriggerSensor https://android.googlesource.com/pla...ager.java#1534

/android/server/AnyMotionDetector.java
constant: https://android.googlesource.com/pla...tector.java#64
The Following 12 Users Say Thank You to GeraldRudi For This Useful Post: [ View ] Gift GeraldRudi Ad-Free
28th October 2015, 08:49 PM |#6  
Member
Vienna
Thanks Meter: 101
 
More
I think with the string sensing_to = 0 we could deaktivate any motion for doze.
Could that be right?

Im not sure if all settings (pic) make sense... :/
original:
Click image for larger version

Name:	Screenshot_20151028-185854.png
Views:	12276
Size:	142.4 KB
ID:	3524291
test:
Click image for larger version

Name:	Screenshot_20151028-204004.png
Views:	11132
Size:	135.6 KB
ID:	3522151

final:

I will try it (a better "aggressiv doze")
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20151030-102727.png
Views:	358094
Size:	129.0 KB
ID:	3524293  
The Following 13 Users Say Thank You to GeraldRudi For This Useful Post: [ View ] Gift GeraldRudi Ad-Free
28th October 2015, 11:14 PM |#7  
freebee269's Avatar
Senior Member
Flag Kalamazoo
Thanks Meter: 674
 
Donate to Me
More
Are the numbers in this app in seconds?

Sent from my Nexus 6 using XDA Free mobile app
The Following User Says Thank You to freebee269 For This Useful Post: [ View ] Gift freebee269 Ad-Free
28th October 2015, 11:39 PM |#8  
Member
Vienna
Thanks Meter: 101
 
More
Quote:
Originally Posted by freebee269

Are the numbers in this app in seconds?

Sent from my Nexus 6 using XDA Free mobile app

Milliseconds e.g. 600000 means 10min
The Following 7 Users Say Thank You to GeraldRudi For This Useful Post: [ View ] Gift GeraldRudi Ad-Free
29th October 2015, 12:03 AM |#9  
freebee269's Avatar
Senior Member
Flag Kalamazoo
Thanks Meter: 674
 
Donate to Me
More
If you have greenify beta installed you might want to disable doze setting as it may affect this app changes.

Sent from my Nexus 6 using XDA Free mobile app
The Following 2 Users Say Thank You to freebee269 For This Useful Post: [ View ] Gift freebee269 Ad-Free
29th October 2015, 12:19 AM |#10  
Member
Vienna
Thanks Meter: 101
 
More
Quote:
Originally Posted by freebee269

If you have greenify beta installed you might want to disable doze setting as it may affect this app changes.

Sent from my Nexus 6 using XDA Free mobile app

I think greenify use such a code:
" adb shell dumpsys deviceidle force-idle" to (only!) force doze mode if screen goes off.
http://forum.xda-developers.com/nexu...depth-t3234529

So I think we could combine both.
The Following User Says Thank You to GeraldRudi For This Useful Post: [ View ] Gift GeraldRudi Ad-Free
29th October 2015, 12:55 AM |#11  
p0isonra1n's Avatar
OP Senior Member
Flag Gold Coast
Thanks Meter: 568
 
Donate to Me
More
The command "dumpsys deviceidle disable" should disable Doze.
The Following User Says Thank You to p0isonra1n For This Useful Post: [ View ] Gift p0isonra1n Ad-Free
Post Reply Subscribe to Thread

Tags
deep sleep, deviceidle, doze, editor, marshmallow

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes