[Sony Xperia M2] f2065:
I'm in the RR - sensors operate constantly when the screen is off - I see a dark red glow of the proximity sensor.

If these options are turned off - then the proximity sensor does not light up during normal use. And when the screen is off, too, does not shine. Lights only when talking on the phone and when starting the test.

And if the options are on - then when the screen is on and unlocked the proximity sensor does not glow, but when the screen is turned off - the proximity sensor glows continuously. Phone all night is with the screen off and all the night continually working proximity sensor.

Moreover, the "pocket detection" and "accidental touch" modes despite the glowing proximity sensor - does not work!

I press the proximity sensor with my finger and this does not prevent the phone from turning on the power button and unlocking the PIN.

Pressing the power button with an open proximity sensor:

D2403:/ # dmesg -c
[ 5130.215383] stk_ps_enable_store: Enable PS : 0
[ 5130.246584] [01:45:39.050126] [0000002012907481] [wpa_s] wlan: [E :HDD] wlan_hdd_get_frame_logs: Frame Logging not init!
[ 5130.260866] stk3x1x_enable_ps: stk3x1x_enable_ps() read H/L THD from register before auto cal => H_THD = 6, 9E, L_THD = 6, 67
[ 5130.270642] stk3x1x_enable_ps: use Auto calibration value: hang_up_hthd = 1694, hang_up_lthd = 1639
[ 5130.278238] stk3x1x_enable_ps: write H/L thd when ps disable: ps_thd_h = 1694, ps_thd_l = 1639
[ 5130.289133] stk_als_delay_store: set als poll delay=1000000
[ 5130.289139] stk_als_delay_store: delay is too small
[ 5130.292486] stk_als_delay_store: set als poll delay=400000000
[ 5130.293113] stk_als_delay_store: set als poll delay=250000000
[ 5130.295357] stk_ps_enable_store: Enable PS : 1
[ 5130.312047] stk3x1x_enable_ps: stk3x1x_enable_ps() read H/L THD from register before auto cal => H_THD = 6, 9E, L_THD = 6, 67
[ 5130.312053] stk3x1x_enable_ps: [CCI]stk3x1x_enable_ps() show first boot H/L THD => FIRST_BOOT_H_THD = 1694, FIRST_BOOT_L_THD = 1639
[ 5130.312058] stk3x1x_enable_ps: [CCI]stk3x1x_enable_ps() show factory H/L THD => cci_ps_high_thd = 0, cci_ps_low_thd = 0, cci_result_ct = 0
[ 5130.312061] stk3x1x_enable_ps: [CCI]set psi_set = 0, psa = 0, psi = 0xFFFF
[ 5130.315142] mdss_dsi_on+: ctrl=00000000 ndx=0
[ 5130.325014] stk3x1x_enable_ps: ps input event=1, ps code = 1544
[ 5130.347137] lp11_delay
[ 5130.347138] mdss_dsi_panel_reset: enable = 1
[ 5130.353113] mdss_dsi_panel_on+: ctrl=00000000 ndx=0
[ 5130.384925] stk_als_delay_store: set als poll delay=250000000
[ 5130.433020] [stk]word_data=1539
[ 5130.433027] [stk]update psa: psa=1539,psi=65535
[ 5130.433031] [stk]update psi: psa=1539,psi=1539
[ 5130.445339] kionix into kionix_accel_enable finish ++
[ 5130.445530] kionix into kionix_accel_enable finish --
[ 5130.445959] alp : interval (3241255024)
[ 5130.445962] alp : kxtj2_set_poll buf (66)
[ 5130.445976] kxtj2 1-000f: kionix_accel_grp4_update_odr() ++ poll=66
[ 5130.445981] alp : kionix_accel_grp4_update_odr i(6), cutoff(80), mask(1)
[ 5130.445984] alp : data_ctrl(1), ctrl_reg(40)
[ 5130.446646] kxtj2 1-000f: ODR = 25 Hz
[ 5130.446650] kxtj2 1-000f: kionix_accel_grp4_update_odr() --
[ 5130.446654] kxtj2 1-000f: kionix_accel_set_delay() --poll_interval= 66
[ 5130.488443] qup_i2c f9925000.i2c: QUP: I2C status flags :0xc1300c8, irq:129
[ 5130.488468] qup_i2c f9925000.i2c: I2C slave addr:0x28 not connected
[ 5130.510806] [TP][cyttsp4_core_lately_resume] start
[ 5130.512895] cyttsp4_core main_ttsp_core.cyttsp4_i2c_adapter: cyttsp4_wakeup: WAKEUP CYTTSP gpio=17 r=0
[ 5130.584246] [stk]word_data=1542
[ 5130.584252] [stk]update psa: psa=1542,psi=1539
[ 5130.614023] [stk]word_data=1540

Further a lot [stk]word_data, after a few minutes of my inaction this all ends like this:

[ 5298.312784] [stk]update psa: psa=1561,psi=1531
[ 5298.381084] stk_work_func: CCI_FTM_INTERRUPT = 86
[ 5298.384096] stk_work_func: stk_work_func() read H/L THD from register when interrupt trigger => H_THD = 6, 9E, L_THD = 6, 67
[ 5298.393879] stk_work_func: ps input event=0, ps code = 1710
[ 5298.492829] [stk]word_data=1686
[ 5298.492835] [stk]update psa: psa=1686,psi=1531
[ 5298.612849] [stk]word_data=1680
[ 5298.732858] [stk]word_data=1708
[ 5298.732865] [stk]update psa: psa=1708,psi=1531
[ 5298.792830] [stk]word_data=1752
[ 5298.792836] [stk]update psa: psa=1752,psi=1531
[ 5298.912848] [stk]word_data=1816
[ 5298.912853] [stk]update psa: psa=1816,psi=1531
[ 5299.033973] [stk]word_data=2005
[ 5299.033980] [stk]update psa: psa=2005,psi=1531
[ 5299.092783] [stk]word_data=2539
[ 5299.092788] [stk]update psa: psa=2539,psi=1531
[ 5299.092794] stk_ps_tune_zero_func_fae: NO cci_ps_cover and cci_result_ct data!!
[ 5299.098062] [stk] use STK default value
[ 5299.098369] [stk]FAE tune0 psa-psi(1008) > STK_DIFF found
[ 5303.320408] stk_work_func: CCI_FTM_INTERRUPT = 87
[ 5303.323421] stk_work_func: stk_work_func() read H/L THD from register when interrupt trigger => H_THD = 6, 7D, L_THD = 6, 46
[ 5303.333073] stk_work_func: ps input event=1, ps code = 1604

And then in dmesg is empty.

Now pressing the power-button, putting a finger on the proximity sensor:

D2403:/ # dmesg -c
[ 5421.994714] stk_work_func: CCI_FTM_INTERRUPT = 88
[ 5421.997844] stk_work_func: stk_work_func() read H/L THD from register when interrupt trigger => H_THD = 6, 7D, L_THD = 6, 46
[ 5422.007784] stk_work_func: ps input event=0, ps code = 1707
[ 5426.670386] stk_als_delay_store: set als poll delay=1000000
[ 5426.670392] stk_als_delay_store: delay is too small
[ 5426.705546] stk_als_delay_store: set als poll delay=1000000
[ 5426.705553] stk_als_delay_store: delay is too small
[ 5426.780484] stk_als_enable_store: Enable ALS : 0
[ 5426.781751] stk_als_enable_store: Enable ALS : 1
[ 5426.782316] stk_als_delay_store: set als poll delay=250000000
[ 5426.795749] mdss_dsi_on+: ctrl=00000000 ndx=0
[ 5426.797620] kionix into kionix_accel_enable finish ++
[ 5426.797796] kionix into kionix_accel_enable finish --
[ 5426.797967] alp : interval (3241255024)
[ 5426.797970] alp : kxtj2_set_poll buf (66)
[ 5426.797983] kxtj2 1-000f: kionix_accel_grp4_update_odr() ++ poll=66
[ 5426.797987] alp : kionix_accel_grp4_update_odr i(6), cutoff(80), mask(1)
[ 5426.797990] alp : data_ctrl(1), ctrl_reg(40)
[ 5426.798548] kxtj2 1-000f: ODR = 25 Hz
[ 5426.798552] kxtj2 1-000f: kionix_accel_grp4_update_odr() --
[ 5426.798556] kxtj2 1-000f: kionix_accel_set_delay() --poll_interval= 66
[ 5426.803706] [01:50:35.607249] [0000002165F26CC6] [wpa_s] wlan: [E :HDD] wlan_hdd_get_frame_logs: Frame Logging not init!
[ 5426.827234] lp11_delay
[ 5426.827235] mdss_dsi_panel_reset: enable = 1
[ 5426.832871] mdss_dsi_panel_on+: ctrl=00000000 ndx=0
[ 5426.992582] [TP][cyttsp4_core_lately_resume] start
[ 5426.994737] cyttsp4_core main_ttsp_core.cyttsp4_i2c_adapter: cyttsp4_wakeup: WAKEUP CYTTSP gpio=17 r=0
[ 5427.121083] qup_i2c f9925000.i2c: QUP: I2C status flags :0xc1300c8, irq:129
[ 5427.125720] qup_i2c f9925000.i2c: I2C slave addr:0x28 not connected
[ 5427.614698] [01:50:36.418234] [0000002166E004B2] [wpa_s] wlan: [E :HDD] wlan_hdd_enter_bmps: SME timeout while requesting fullpower
D2403:/ #

once again turn on the power button by covering the proximity sensor with finger:

D2403:/ # dmesg -c
[ 5517.392893] stk_work_func: CCI_FTM_INTERRUPT = 90
[ 5517.395953] stk_work_func: stk_work_func() read H/L THD from register when interrupt trigger => H_THD = 6, 7D, L_THD = 6, 46
[ 5517.405365] stk_work_func: ps input event=0, ps code = 1707
[ 5520.993895] stk_als_delay_store: set als poll delay=1000000
[ 5520.993902] stk_als_delay_store: delay is too small
[ 5520.998094] stk_als_delay_store: set als poll delay=400000000
[ 5520.998808] stk_als_delay_store: set als poll delay=250000000
[ 5521.056190] mdss_dsi_on+: ctrl=00000000 ndx=0
[ 5521.057424] stk_als_delay_store: set als poll delay=250000000
[ 5521.087175] lp11_delay
[ 5521.087175] mdss_dsi_panel_reset: enable = 1
[ 5521.087584] mdss_dsi_panel_on+: ctrl=00000000 ndx=0
[ 5521.144997] kionix into kionix_accel_enable finish ++
[ 5521.145182] kionix into kionix_accel_enable finish --
[ 5521.145496] alp : interval (3241255024)
[ 5521.145499] alp : kxtj2_set_poll buf (66)
[ 5521.145514] kxtj2 1-000f: kionix_accel_grp4_update_odr() ++ poll=66
[ 5521.145518] kxtj2 1-000f: kionix_accel_set_delay() --poll_interval= 66
[ 5521.192931] [01:52:09.996474] [00000021D1F78498] [wpa_s] wlan: [E :HDD] wlan_hdd_get_frame_logs: Frame Logging not init!
[ 5521.249143] [TP][cyttsp4_core_lately_resume] start
[ 5521.251216] cyttsp4_core main_ttsp_core.cyttsp4_i2c_adapter: cyttsp4_wakeup: WAKEUP CYTTSP gpio=17 r=0
[ 5521.330473] qup_i2c f9925000.i2c: QUP: I2C status flags :0xc1300c8, irq:129
[ 5521.335117] qup_i2c f9925000.i2c: I2C slave addr:0x28 not connected
D2403:/ #

Now I turn on the power-button without touching the proximity sensor:

D2403:/ # dmesg -c
[ 5578.729003] stk_als_delay_store: set als poll delay=1000000
[ 5578.729010] stk_als_delay_store: delay is too small
[ 5578.788985] stk_als_delay_store: set als poll delay=1000000
[ 5578.788991] stk_als_delay_store: delay is too small
[ 5578.811425] stk_als_enable_store: Enable ALS : 0
[ 5578.813041] stk_als_enable_store: Enable ALS : 1
[ 5578.815428] stk_als_delay_store: set als poll delay=250000000
[ 5578.820842] mdss_dsi_on+: ctrl=00000000 ndx=0
[ 5578.847647] lp11_delay
[ 5578.847648] mdss_dsi_panel_reset: enable = 1
[ 5578.851086] [01:53:07.654630] [0000002213F38E48] [wpa_s] wlan: [E :HDD] wlan_hdd_get_frame_logs: Frame Logging not init!
[ 5578.930802] mdss_dsi_panel_on+: ctrl=00000000 ndx=0
[ 5578.975810] kionix into kionix_accel_enable finish ++
[ 5578.975975] kionix into kionix_accel_enable finish --
[ 5578.976190] alp : interval (3241255024)
[ 5578.976193] alp : kxtj2_set_poll buf (66)
[ 5578.976204] kxtj2 1-000f: kionix_accel_grp4_update_odr() ++ poll=66
[ 5578.976208] alp : kionix_accel_grp4_update_odr i(6), cutoff(80), mask(1)
[ 5578.976211] alp : data_ctrl(1), ctrl_reg(40)
[ 5578.977039] kxtj2 1-000f: ODR = 25 Hz
[ 5578.977042] kxtj2 1-000f: kionix_accel_grp4_update_odr() --
[ 5578.977047] kxtj2 1-000f: kionix_accel_set_delay() --poll_interval= 66
[ 5579.062517] qup_i2c f9925000.i2c: QUP: I2C status flags :0xc1300c8, irq:129
[ 5579.062540] qup_i2c f9925000.i2c: I2C slave addr:0x28 not connected
[ 5579.107172] [TP][cyttsp4_core_lately_resume] start
[ 5579.109252] cyttsp4_core main_ttsp_core.cyttsp4_i2c_adapter: cyttsp4_wakeup: WAKEUP CYTTSP gpio=17 r=0
[ 5579.744698] [01:53:08.548232] [0000002214F95A99] [wpa_s] wlan: [E :HDD] wlan_hdd_enter_bmps: SME timeout while requesting fullpower

Maybe somewhere in the firmware they forgot to implement a proximity sensor poll when the screen is turned on?

Because when telephone conversation, the proximity sensor works as expected.

Bug only here with the function of preventing unlocking in pocket.

when the screen is off, if put finger on the proximity sensor, then in dmesg immediately such an entry:

D2403:/ # dmesg -c
[ 5824.465833] stk_work_func: CCI_FTM_INTERRUPT = 96
[ 5824.470172] stk_work_func: stk_work_func() read H/L THD from register when interrupt trigger => H_THD = 6, 7D, L_THD = 6, 46
[ 5824.480089] stk_work_func: ps input event=0, ps code = 1663

when finger is removed from the proximity sensor:

D2403:/ # dmesg -c
[ 5834.147726] stk_work_func: CCI_FTM_INTERRUPT = 97
[ 5834.151196] stk_work_func: stk_work_func() read H/L THD from register when interrupt trigger => H_THD = 6, 7D, L_THD = 6, 46
[ 5834.160637] stk_work_func: ps input event=1, ps code = 1516

The dmesg-log is always correctly spelled stk_work_func: ps input event=1 if the proximity sensor is open, and stk_work_func: ps input event=0 if the proximity sensor is covered with a finger.