require "import"
import "com.androlua.Ticker"
local Settings = luajava.bindClass("android.provider.Settings$System")
local context = activity or service
local contentResolver = context.getContentResolver()
local currentBrightness = Settings.getInt(contentResolver, "screen_brightness", 128)

if ti then
ti.stop()
service.speak("停止")
ti=nil
return true
end
ti=Ticker()
ti.Period=1000
ti.onTick=function()
if not service.isScreenOn() or service.getAppName()~="相机"
ti.stop()
ti=nil
service.setTouchExplorationMode(true)
service.setUseVolumeKeyEnabled(true)
Settings.putInt(contentResolver, "screen_brightness",currentBrightness)
end
end
ti.start()
service.startApp("相机")
service.setTouchExplorationMode(false)
service.setUseVolumeKeyEnabled(false)
Settings.putInt(contentResolver, "screen_brightness",255)
return true