@ -125,6 +125,10 @@ Power::Power()
// Now start to take powerhint
// Now start to take powerhint
mReady . store ( true ) ;
mReady . store ( true ) ;
ALOGI ( " PowerHAL ready to process hints " ) ;
ALOGI ( " PowerHAL ready to process hints " ) ;
// setFeature() is called before loading powerhint.json
// is finished so update dt2w state here
switchDT2W ( mDoubleTapEnabled ) ;
} ) ;
} ) ;
mNumPerfProfiles = android : : base : : GetIntProperty ( kPowerHalProfileNumProp , 0 ) ;
mNumPerfProfiles = android : : base : : GetIntProperty ( kPowerHalProfileNumProp , 0 ) ;
mInitThread . detach ( ) ;
mInitThread . detach ( ) ;
@ -186,25 +190,17 @@ Return<void> Power::setProfile(PowerProfile profile) {
return Void ( ) ;
return Void ( ) ;
}
}
Return < void > Power : : switchDT2W ( bool dt2w ) {
updateHint ( " DOUBLE_TAP_TO_WAKE " , dt2w ) ;
std : : this_thread : : sleep_for ( 20 ms ) ;
return Void ( ) ;
}
// Methods from ::android::hardware::power::V1_0::IPower follow.
// Methods from ::android::hardware::power::V1_0::IPower follow.
Return < void > Power : : setInteractive ( bool interactive ) {
Return < void > Power : : setInteractive ( bool interactive ) {
// Enable dt2w before turning TSP off
if ( mDoubleTapEnabled & & ! interactive ) {
updateHint ( " DOUBLE_TAP_TO_WAKE " , true ) ;
// It takes some time till the cmd is executed in the Kernel, there
// is an interface to check that. To avoid that just wait for 25ms
// till we turn off the touchscreen and lcd.
std : : this_thread : : sleep_for ( 20 ms ) ;
}
updateHint ( " NOT_INTERACTIVE " , ! interactive ) ;
updateHint ( " NOT_INTERACTIVE " , ! interactive ) ;
// Disable dt2w after turning TSP back on
if ( mDoubleTapEnabled & & interactive ) {
updateHint ( " DOUBLE_TAP_TO_WAKE " , false ) ;
std : : this_thread : : sleep_for ( 10 ms ) ;
}
return Void ( ) ;
return Void ( ) ;
}
}
@ -283,6 +279,11 @@ Return<void> Power::setFeature(Feature feature, bool activate) {
switch ( feature ) {
switch ( feature ) {
case Feature : : POWER_FEATURE_DOUBLE_TAP_TO_WAKE :
case Feature : : POWER_FEATURE_DOUBLE_TAP_TO_WAKE :
mDoubleTapEnabled = activate ;
mDoubleTapEnabled = activate ;
// this is only called when the device is booting up or
// the user changed the dt2w setting so the touchscreen
// should always be on when this is called
switchDT2W ( activate ) ;
break ;
break ;
default :
default :
break ;
break ;