Play Sound at night - General Questions and Answers

Hello Forum,
I have an Xiaomi Redmi Note 3 with Lineage Android 7.1.2. I have installed Firefox and USI extension for inserting JavaScripts. If something happens on a special website a script should play for 20 seconds a load sound [1]. Regardless if day or night.
Problem: The Sound is only played for a short time, its a 100 ms *dut* instead of a load 20 sec *duuuuut*
Additional settings:
1. I take Firefox out from the 'Settings->Battery Power Optimization', so it runs the whole night.
2. At night I use the 'Disturb only for important messages' Mode := DOFIM-Mode.
3. For 'Setttings->Notifications' I'll allow Firefox to disturb me.
Observations at day:
a) If the DOFIM-Mode is turned off and the screen is turned off since 20 minutes I get my 20 seconds beep.
b) If the DOFIM-Mode is turned manually on at daytime and the screen is on too, I also get my 20 seconds beep.
c) If the DOFIM-Mode is turned manually on at daytime and the screen is off since 20 minutes, its again the short 100 ms *dut*.
So I thing the battery optimization together with the DOFIM-Mode turns something off that I need to play a sound. What could it be?
I'm using a german rom, so I dont know the exact names of the menu points in english language, if something is unclear, please ask.
Thanks
Peter
[1] How the JavaScript make the sound:
Code:
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var context = new AudioContext();
var o = context.createOscillator();
o.type = 'sine';
o.frequency.value = 261.63;
o.connect(context.destination);
// Play Sinus for 20 sec:
o.start(0);
setTimeout(function() { o.stop(0); }, 20000);

Related

[TUT] [Tasker] Create a widget that periodically cycles through different messages

Hey, guys. I've been looking to use Tasker for awhile now but, it's just been laying dormant in my app drawer because I was too overwhelmed by all the options. Anyway, I finally got around to using it when I discovered a Domo-kun wallpaper that I just had to use and customise. And what I've got is in this post.
http://forum.xda-developers.com/showpost.php?p=14898952&postcount=33983
In this tutorial we will be trying to understand how to use Tasker's Minimal Text Widget Plugin and Variables. So, let's get down to it.
Objectives
Get Domo-kun to "say" stuff based on various events on the phone.
Get Domo's messages to cycle based on a preset time period.
Variables
These are basically empty labels that you must direct Tasker to fill. You can fill them with a string of characters, or with numbers and you can also perform basic math functions on them.
Minimal Text Widget Plugin
This enables Tasker to display stuff via Minimal Text Widget.
What we need
We will need a way of keeping time, so that messages will change after a specified time.
We will need a way of setting a preset message that corresponds to the battery state.
We will need a way of setting a preset message that corresponds to the wifi state.
We will need a way to tell Minimal widget when to display a message.
We will need a way to tell Minimal Widget what message it should display.
Setting a timer that will change the message after preset time.
The context for this is obviously every 'x' minutes. So we start a new profile with a Time context, and set that to repeat every 'x' minutes.
Now, we need a variable that will change after every 'x' minutes(y+1), this will eventually tell our widget when it's time to change the message. So, this will be the action for this particular context. Add a new task to the context, select Variable>>Variable Set. Let's name our variable, I will call mine %SET. The necessary action after every 'x' minutes is '%SET + 1' so this is what we will put in the "To" field. Remember to check the box "Do Math", this will treat the variable as a number, and enable us to perform the required math on it.
Let's take a look at what will happen, when this profile is active.
Every 'x' minutes, the Variable %SET will be set to %SET + 1. So, if %SET starts at 0, after 'x' minutes it will be 0 + 1; it will be 1; after another 'x' minutes it will be set to %SET + 1, 1+1; it will be 2, and so on.
You now have a variable that changes every 'x' minutes.
Setting a preset message according to the battery state.
I want to make Domo tell me how my battery is doing when it's at four different states (100%-75%, 75%-50%, 50%-25%, 25%-0%).
So, now we have four different contexts(battery ranges) in which Tasker needs to perform certain actions(Domo will say something). Let's start creating them.
For the first context(battery level 75-100) we want to display "Your battery is good". So, we will first define the context. In this case the context is a "State" in which the phone is in. Therefore our required context is in the "State" category>>Battery level, choose the range, I will choose 75 - 100. Since the message changes based on the level, we will need to set a variable here. I will call mine %BATTSTAT, and set it to "Your battery is good".
We have to repeat the steps for the other 3 battery levels. So, we create new State>>battery level profiles but, we use the SAME Variable(%BATTSTAT) for the message.
(50-74) - set %BATTSTAT to "Your battery is OK"
(25-49) - set %BATTSTAT to "Your battery is low"
(0-24) - set %BATTSTAT to "Your battery is going to die"
What is going to happen when this profile is active?
When the battery level is between 75-100 the %BATTSTAT will be "Your battery is good", when battery level hits 74, %BATTSTAT will immediately change to "Your battery is OK", and so on.
We now have a variable(%BATTSTAT) that holds a message depending on the battery level.
Setting a preset message according to wifi state.
This is pretty much the same as setting the message for battery level. The only difference is we will use a an exit task for when wifi is not connected. An Enter Task are the actions that take place when a state is entered, an Exit Task are the actions that take place when a state is exited.
So, new profile, State>>Wifi Connected, set %WIFISTAT to "Your wifi is connected", now if we don't set the %WIFISTAT Variable to change when the wifi is disconnected, it will always hold the message "Your wifi is connected". So we set an exit task for the variable %WIFISTAT to say "Your wifi is disconnected".
Okay! We now have,
%SET - A Variable that increments every 'x' minutes
%BATTSTAT - A Variable that holds a message corresponding to the battery level
%WIFISTAT - A Variable that holds a message corresponding to the wifi status
Getting tasker to communicate with Minimalistic Text Widget
This is fairly simple, all we need to do is define a variable for MTW, and set to what we want to say, in this case the message within the tasker variables (%BATTSTAT or %WIFISTAT). So, the action would be within "Plugin">>Minimalistic Text Widget. You have a field for Minimalistic Text Widget's Variable and you have a to field.
Now, we need a way to send our messages to Minimal Text Widget at the right time.
We use our Time variable to tell us what's the time. If, %SET = 0 we will send %BATTSTAT to the widget, if(after 'x' minutes) %SET = 1, we will send %WIFISTAT to the widget. Now, our next context depends on the Variable %SET, so this will be the context we coose. Event>>Variable>>Variable Set, enter the Variable(%SET) in Name field and what it will be when we perform our action (sending data to MTW) in this case, '0'. The action to perform will be, Plugin>>MTW set a Variable %DISP to %BATTSTAT.
Now we repeat this for 'x' minutes later when %SET = 1, so a new Event context has to be made, where the variable %SET = 1, and here we will send the wifi status to MTW. So, Plugin>>MTW set Variable %DISP to %WIFISTAT.
What happens here is, when %SET = 0 (at the beginning of our cycle) Tasker will send the message within %BATTSTAT to %DISP. 'x' minutes later, when %SET = 1, Tasker will send the message within %WIFISTAT to %DISP. But, wait! What happens when 'x' minutes later our time variable increments(%SET + 1 ie. 1+1 = 2)? This is a problem because we have not made a profile for %SET = 2, in relaity we don't need one because there are only two kinds of messages we want to send to MTW.
We need to reset our counter. So, we make a new Event profile for when the variable %SET is greater than 1. All we need to do is set %SET to 0.
Displaying our messages on MTW
Create your Minimalistic Text Widget, within it's "Misc" tab find Local Variable and put in the name of your MTW Variable, in this case, it is %DISP. And you're done!
___________________________________________________
This is my first attempt at writing a tutorial and also I've only been using Tasker for a couple of days, so the above procedure might not be completely optimized. Maybe our Dev/Programmer friends can enlighted us. I tried to write this tutorial not so much as a hold your hand and give you a play by play but, more as a I hope you learn something about the way Tasker works and find better uses for it. I hope it was helpful. I don't think pictures are actually necessary if people get their feet wet with Tasker but, if people think it's absolutely necessary, I will post some.

[Root] Doze Settings Editor (Android Marshmallow Only)

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.
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
Requires root.... so.... source code?
Going to play with this on my Oneplus one for some time.
Thanks for your work m8.
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.
[B] Use "step" to get out.[/B]
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.[B]MOTION_INACTIVE_TIMEOUT[/B], "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;
[B]mInactiveTimeout = timeout; [/B]
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([B]mInactiveTimeout[/B], 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.[B]SENSING_TIMEOUT[/B]);
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.[B]accumulate[/B](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.getRunning[B]Average[/B]();
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 < [B]THRESHOLD_ANGLE[/B]) && (mRunningStats.getEnergy() < [B]THRESHOLD_ENERGY[/B])) {
return [B]RESULT_STATIONARY[/B];
} 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 [B]RESULT_MOVED[/B];
}
long diffTime = mCurrentGravityVector.timeMillisSinceBoot -
mPreviousGravityVector.timeMillisSinceBoot;
if ([B]diffTime [/B]> [B]STALE_MEASUREMENT_TIMEOUT_MILLIS[/B]) {
return [B]RESULT_UNKNOWN[/B];
}
return [B]RESULT_MOVED[/B];
}
/** 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;
[B][/B]
/android/server/DeviceIdleController.java
motionLocked() https://android.googlesource.com/pl...android/server/DeviceIdleController.java#1402
scheduleAlarmLocked https://android.googlesource.com/pl...android/server/DeviceIdleController.java#1402
sensing scheduleAlarmLocked https://android.googlesource.com/pl...android/server/DeviceIdleController.java#1490
/android/hardware/Sensor.java
description of a significant motion trigger sensor (TYPE_SIGNIFICANT_MOTION = 17) https://android.googlesource.com/pl...er/core/java/android/hardware/Sensor.java#305
mPower: https://android.googlesource.com/pl...er/core/java/android/hardware/Sensor.java#721
SensorPrintString https://android.googlesource.com/pl...er/core/java/android/hardware/Sensor.java#848
/android/hardware/SensorManager.java
cancelTriggerSensor https://android.googlesource.com/pl...java/android/hardware/SensorManager.java#1534
/android/server/AnyMotionDetector.java
constant: https://android.googlesource.com/pl.../com/android/server/AnyMotionDetector.java#64
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:
test:
final:
I will try it (a better "aggressiv doze")
Are the numbers in this app in seconds?
Sent from my Nexus 6 using XDA Free mobile app
freebee269 said:
Are the numbers in this app in seconds?
Sent from my Nexus 6 using XDA Free mobile app
Click to expand...
Click to collapse
Milliseconds e.g. 600000 means 10min
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
freebee269 said:
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
Click to expand...
Click to collapse
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/nexus-6/general/doze-depth-t3234529
So I think we could combine both.
The command "dumpsys deviceidle disable" should disable Doze.
The app will read the current settings but will fall back to loading the defaults if it can't read the settings.
this is what i have so far. greenify uninstalled.
- inactive_to set to 600000 (10min) - the time i want my device to sit before it thinks about going into doze.
- locating_to set to 0 - going into idle (doze) right away
- sensing_to set to 0 - disabling motion and going into inactive right away
- location_accuracy not changed - doesnt matter because we are going into idle right away with locating_to set to 0
- motion_inactive_to set to 0 - disabling motion
- idle_after_inactive_to set to 0 - we are already waiting 10min with inactive_to, no need to wait any longer
- idle_pending_to set to 120000 (2min) - my phone can check for updates for 2min before going back into idle
- max_idle_pending set to 120000 (2min) - my phone can check for updates for 2min before going back into idle
- idle_to set to 1800000 (30min) - the time in idle before my phone can change to idle pending to check for updates
i wonder if these settings will revert to defaults if i reboot? if so, is there a way to automate these settings with initd?
They should stick through a reboot as they are saved in the global settings.
Mkkt Bkkt said:
Going to play with this on my Oneplus one for some time.
Thanks for your work m8.
Click to expand...
Click to collapse
which marshmallow rom are you using on 1+1 ? doze is marshmallow only JFYI
---------- Post added at 10:20 AM ---------- Previous post was at 10:14 AM ----------
freebee269 said:
this is what i have so far. greenify uninstalled.
- inactive_to set to 600000 (10min) - the time i want my device to sit before it thinks about going into doze.
- locating_to set to 0 - going into idle (doze) right away
- sensing_to set to 0 - disabling motion and going into inactive right away
- location_accuracy not changed - doesnt matter because we are going into idle right away with locating_to set to 0
- motion_inactive_to set to 0 - disabling motion
- idle_after_inactive_to set to 0 - we are already waiting 10min with inactive_to, no need to wait any longer
- idle_pending_to set to 120000 (2min) - my phone can check for updates for 2min before going back into idle
- max_idle_pending set to 120000 (2min) - my phone can check for updates for 2min before going back into idle
- idle_to set to 1800000 (30min) - the time in idle before my phone can change to idle pending to check for updates
i wonder if these settings will revert to defaults if i reboot? if so, is there a way to automate these settings with initd?
Click to expand...
Click to collapse
there will be tasker integration i'm sure and depending on ones skill it should be possible to set this up in tasker already, something like day and night profiles. this app will be a runner once people get aware of it. will replace amplify since doze in action beats amplify by far on my N6 and N5. Surprised how fast someone came up with such a thing even though it was clear from day one that it will happen LOL "CHAPEAU" to @p0isonra1n
would be interesting if it is possible to log the doze steps: (Doze - In depth)
*IDLE_PENDING
*SENSING
*IDLE
*IDLE_MAINTENANCE
to find out how doze exactly works with different settings
magnamentis said:
which marshmallow rom are you using on 1+1 ? doze is marshmallow only JFYI
---------- Post added at 10:20 AM ---------- Previous post was at 10:14 AM ----------
there will be tasker integration i'm sure and depending on ones skill it should be possible to set this up in tasker already, something like day and night profiles. this app will be a runner once people get aware of it. will replace amplify since doze in action beats amplify by far on my N6 and N5. Surprised how fast someone came up with such a thing even though it was clear from day one that it will happen LOL "CHAPEAU" to @p0isonra1n
Click to expand...
Click to collapse
I'm using experimental home build.
5% drain over 9hours of deep sleep.
6hours to 8hours SOT max. (Depends on usage..etc)
Mkkt Bkkt said:
I'm using experimental home build.
5% drain over 9hours of deep sleep.
6hours to 8hours SOT max. (Depends on usage..etc)
Click to expand...
Click to collapse
ok, thanks for the feedback
i get 1% drain in 9-10h idle with my nexus 5, 2-3% drain with nexus 6 due to LED always on and i think 5% is slightly on the high side depending.
the 1% on nexus 5 correlate with 0.09% awake which is an absolute record result. the N6 has not only LED always on but as well has wake gestures ( dt2w ) active at all times while the N5 switches that of off charger. unfortunately that tasker intent, albeit it works, cannot be used on N6 because for yet unknown reason it will cause a random reboot a minute or 2 after the intent was executed. still trying to get feedback from the kernel dev as to what could be the reason. congrates for having MM on OPO, my OPO is now used by my dad hence i wait a bit for things to settle until i shall flash MM on that device.
GeraldRudi said:
would be interesting if it is possible to log the doze steps: (Doze - In depth)
*IDLE_PENDING
*SENSING
*IDLE
*IDLE_MAINTENANCE
to find out how doze exactly works with different settings
Click to expand...
Click to collapse
The sequence starts with sensing and locating. Once those 2 timeouts have passed and have not been tripped then it goes to inactive. After inactive timeout passes then it goes into idle which is the actual doze. It periodically wakes itself from doze with idle pending setting for normal phone function then goes back into doze.
Sent from my Nexus 6 using XDA Free mobile app
I am using Cataclysm without root(office mail requirement) on my N6.
Is there a way that we can achieve this in TWRP?
Sent from my Nexus 6 using Tapatalk

The combination of Greenify and Doze Settings seems to be TOO good

* sorry for my English.
Okay guys, I know many of us Android fanboys are obsessed of Dozing and Greenifying and Napping or whatever that keeps their phone deepsleep. I used to be one of them, but now I'm too old and following those guides from Amplify, Tasker, Greenify etc. or whatever it is, has turned out to be too complicated and ridiculous for me. A few days ago I took some time to investigate about doze and decided to mess up with the phone once more.
At first, I made my own doze settings as below:
randomseasons said:
Hi all, after hours and hours of reading (English is not my native language) and testing, I think I have set up a pretty good settings for Doze.
I'm not saying that other profiles are bad, but the matter is that some profiles were set up very early while all of us hadn't understood Doze thoroughly yet
Before we start, let's talk about what I'm aiming for. Basically, doze profiles are aiming for "decrease the time it takes for the phone to sleep, and increase the duration between awake checkups". But is that what we should look forward to? For me, it's reasonable to have my phone sleep soon, however I won't want my phone dead all the time, so I'm heading to "After I leave my phone, wait a short enough time then sleep, but don't let the phone sleep for too long, instead wake it soon enough while decrease the duration of the wakeups. Then after I leave it for a long enough time which really means I'm not using my phone, multiply the time between wakeups."
This way compared to other profiles, for daily use my phone stays more ready (shorter sleeping periods), but it also works less (shorter awake duration), and when I don't use my phone, it will actually catch up with the long sleeping states soon (higher multiply factor).
Here are my settings with that motto in mind:
*** all the parameters are in seconds ***
A) ------------------------------------------
Inactive Timeout - inactive_to: 180
Sensing Timeout - sensing_to: 0
Locating Timeout - locating_to: 0
Location Accuracy - location_accuracy: 50
- This one is easy. I want my phone to sleep right away after 3 minutes of being inactive (screen off), ignoring any motion. You can change the inactive timeout to whatever number that suits you. As we set the location timeout to 0, the Location Accuracy doesn't matter anymore, however I increase it to 50 although just because... I can do it , it's a safe number.
------------------------------------------------
B)-----------------------------------------------
Motion Inactive Timeout - motion_inactive_to: 60
- This number means if the phone checks and finds any motion, it will wait 60 seconds to check for any SIGNIFICANT (strong motion, different from light motion as in the sensing period) motion again. As we don't check for any motion in the beginning, this parameter is useless, however I still set it at 60 seconds, imagine for some particular reason the doze does check for motion (again, this won't happen if the app works as it's supposed to), then I don't want my phone to stay as long as 600 seconds (the default) value, and I don't want my phone to checks too often either, hence I want it to check again after one minute.
Idle After Inactive Timeout - idle_after_inactive_to: 0
- I want my phone to sleep right away after the inactive timeout elapses, I don't want it to wait to check for significant motion, so zero for this.
----------------------------------------------
C) -----------------------------------------------
Idle Pending Timeout - idle_pending_to: 15 seconds.
Max Idle Pending Timeout - max_idle_pending_to: 120 seconds.
Idle Pending Factor - idle_pending_factor: 2.
- This means: when the phone first wakes up (the criteria of when it will happen is in part D below), it will be kept awake for 15 seconds. The second times it will wake up, it will multiply by 2, which is 30 seconds, and so on. The maximum duration of wakeup is 120 seconds.
For me, I want to wake my phone soon enough (see in part D) and decrease the time of the phone being awake. I think 15 seconds for the first time is long enough. You can change it as you want, though :silly:
-----------------------------------------------
D) -----------------------------------------------
Idle Timeout - idle_to: 1200s (default is 3600)
Max Idle Timeout - max_idle_to: 21600s
Idle Factor - idle_factor: 2.
- After 1200s (20 mins), my phone will wake and check for 15 seconds (see part C), then the next time it wakes, it will need 40 minutes before waking up. The maximum time is basically as long as we want so 21600s is okay.
- I'm thinking to change this part to 900s or 720s and idle factor 3, which means that the phone will wake up sooner, at <=15 minutes mark, but after that, the sleeping duration will increase 3 times faster.
------------------------------------------
E) -----------------------------------------------
Min Time to Alarm - min_time_to_alarm: 3600.
This is the minimum time we will allow until the next upcoming alarm for us to actually go in to idle mode.
I don't get what this sentence says, my English sometimes sucks, but I guess it means if the next alarm is within the set number then the phone won't try to go into idle mode. I leave it default.
Max Temp App Whitelist Duration - max_temp_app_whitelist_duration: 20s
Max amount of time to temporarily whitelist an app when it receives a high tickle.
- Set this number whatever you feel like, for me I think 20s is enough.
MMS Temp App Whitelist Duration - mms_temp_app_whitelist_duration: 0
Amount of time we would like to whitelist an app that is receiving an MMS.
- Set this number whatever you feel like, I live in Vietnam, I don't ever use MMS at all so 0 for it.
SMS Temp App Whitelist Duration - sms_temp_app_whitelist_duration: 15s
Amount of time we would like to whitelist an app that is receiving an SMS.
- Set this number whatever you feel like, for me I think 15s is enough.
----------------------------------------------------------------------
BRIEF TEST:
1. Turned the screen off, sent an email to myself within 3 minutes (inactive timeout duration), the phone notified right away, no delay, 7 tries, worked every time.
2. Turned the screen off, waited at least 3 minutes, sent an email to myself, the phone didn't notify right away. If I turned the screen on, of course the email came right away. Out of 8 tries, 6 times the phone notified me between 15min - 20min mark, which followed closely to my rule. 2 times it notified me between 5 - 10 minutes. I think it was because some app woke my phone unexpectedly.
After 2 days, the observation showed me that my Doze Setting has been working decently, I'm quite satisfied. I will keep testing though :silly::victory:
Sorry for my bad English.
Edited: English and grammar.
Click to expand...
Click to collapse
As some guy pointed out, some settings don't act in the way I thought they do, anyway I was having a fantastic result with these settings. My phone was deepsleeping often enough, it woke up after every short time, but each time was short, exactly my purpose.
Then a few days ago, I installed Greenify with xposed, and as it turned out, it's working TOO GOOD. , no matter how many apps I run, Facebook, Messenger, Maps, 8tracks, internet-based apps, clouds etc... (I only Greenify very few of of them), the phone changes its state to idle too strictly and too perfectly and I want it to be. For example, my current doze records were like:
8:00 - turned off my phone
8:04 - 8:19: doze // 14 mins
8:19 - 8:20: awake // 20s
8:20 - 9:00: doze // 40 mins
9:00 - 9:01: doze // 1 mins.
9:01 - 13:00: doze / 4 hours.
etc...
If you have read my doze configs, you can see that my phone now nearly perfect as my settings, I set it to doze after 3 minutes, then after 15 mins wake up 15 secs, then doze for 45 minutes.... etc... without any big difference. The weird thing is that music apps still works perfectly for me. :angel:
Now with Zenfone 2, my phone only drains 3% through the night, with all wifi gps 3G on, and I can still receive notifications ! Zenfone 2 users please come and praise me lol
It's been a long time since I last visited xda so I don't know if anybody has tried this, it would be a shame if I'm sharing what everyone already knew, but if not I guess this post would be very useful for many people.
Cheers, for a better and more simpler Android world ! :silly:
randomseasons said:
* sorry for my English.
Okay guys, I know many of us Android fanboys are obsessed of Dozing and Greenifying and Napping or whatever that keeps their phone deepsleep. I used to be one of them, but now I'm too old and following those guides from Amplify, Tasker, Greenify etc. or whatever it is, has turned out to be too complicated and ridiculous for me. A few days ago I took some time to investigate about doze and decided to mess up with the phone once more.
At first, I made my own doze settings as below:
As some guy pointed out, some settings don't act in the way I thought they do, anyway I was having a fantastic result with these settings. My phone was deepsleeping often enough, it woke up after every short time, but each time was short, exactly my purpose.
Then a few days ago, I installed Greenify with xposed, and as it turned out, it's working TOO GOOD. , no matter how many apps I run, Facebook, Messenger, Maps, 8tracks, internet-based apps, clouds etc... (I only Greenify very few of of them), the phone changes its state to idle too strictly and too perfectly and I want it to be. For example, my current doze records were like:
8:00 - turned off my phone
8:04 - 8:19: doze // 14 mins
8:19 - 8:20: awake // 20s
8:20 - 9:00: doze // 40 mins
9:00 - 9:01: doze // 1 mins.
9:01 - 13:00: doze / 4 hours.
etc...
If you have read my doze configs, you can see that my phone now nearly perfect as my settings, I set it to doze after 3 minutes, then after 15 mins wake up 15 secs, then doze for 45 minutes.... etc... without any big difference. The weird thing is that music apps still works perfectly for me. :angel:
Now with Zenfone 2, my phone only drains 3% through the night, with all wifi gps 3G on, and I can still receive notifications ! Zenfone 2 users please come and praise me lol
It's been a long time since I last visited xda so I don't know if anybody has tried this, it would be a shame if I'm sharing what everyone already knew, but if not I guess this post would be very useful for many people.
Cheers, for a better and more simpler Android world ! :silly:
Click to expand...
Click to collapse
Do you you Aggressive Doze and Disable Motion Sensing at all? Naptime has these settings and I'm not sure whether to put them on or not!

can’t set screentime in setup! Why?

Hi, i tried to reduce my screen on time from 30 sec. down to 15. sec. but if i tap on this feature in my setup, nothing changes!!!
I can only change the value with an external app. FW is b197. Any suggestions?
edit: solved
save energy mode seems to change access.
after switching to off, the time could be set.
Same goes with certain apps that change screen on time (Floatify is an example, free version sets screen on time to 15 seconds and it can't be changed)

Heart rate zones alert

Hi,
I have my Huawei watch 2 for two months now and I like a lot of features, but on the other hand I am quite disappointed that some features which I know from other devices are missing... Now I am looking for setting or some app which will beep/vibrate every time I get in a get out of desired hr zone. I had this on my sporttester: 1 beep -enter zone 1, 2 beeps - enter zone 2, 3 beeps - enter zone 3, how simple. But I cannot find anything similar for Wear OS...The only settings I can find is HR limit warning ( https://consumer.huawei.com/en/support/faqs/detail/?id=137396 ), but I am more interested in reporting entering the hr zone...any ideas?
Thanks!

Categories

Resources