我在OOS Open Beta 15,Android 7.1.1上运行OnePlus 3t。我想让它的警报滑块分别将我的手机放入所有声音/振动/静音模式。在尝试了第三方应用程序和Tasker配置文件的每种可能组合后,我开始研究创建自己的Magisk模块以更改滑块的行为。
我发现所有警报滑块逻辑都在包com.oneplus.threekey
内。使用
adb shell 'pm list packages' > C:\packages.txt
我列出了所有已安装的软件包,包含“oneplus”一词的唯一软件包如下:
package:com.oneplus
package:com.oneplus.aod
package:com.oneplus.applocker
package:com.oneplus.calculator
package:com.oneplus.camera
package:com.oneplus.camera.service
package:com.oneplus.config
package:com.oneplus.deskclock
package:com.oneplus.dirac.simplemanager
package:com.oneplus.gallery
package:com.oneplus.iconpack.dives
package:com.oneplus.iconpack.o2default
package:com.oneplus.iconpack.rifon
package:com.oneplus.ifaaservice
package:com.oneplus.opbackup
package:com.oneplus.opbugreport
package:com.oneplus.opbugreportlite
package:com.oneplus.oplocationservice
package:com.oneplus.screenshot
package:com.oneplus.sdcardservice
package:com.oneplus.security
package:com.oneplus.setupwizard
package:com.oneplus.simcontacts
package:com.oneplus.skin
package:com.oneplus.sms.smscplugger
package:com.oneplus.soundrecorder
package:com.oneplus.wallpaper
package:com.oneplus.wifiapsettings
在没有这样的任何地方,我决定进一步研究我的logcat输出。使用“threekey”过滤它,这是我每次更改警报滑块位置时的输出:
10-03 00:00:53.223 1407-1872/? D/ThreeKeyHw: OEM UEVENT: {SUBSYSTEM=switch, SEQNUM=11574, ACTION=change, SWITCH_STATE=3, SWITCH_NAME=tri-state-key, DEVPATH=/devices/virtual/switch/tri-state-key}
10-03 00:00:53.227 1407-1407/? D/ThreeKeyAudioPolicy: set mode ring, mVibrateFlag=false, mMuteMediaFlag=true
10-03 00:00:53.231 1407-1407/? D/ZenModeHelper: setConfigLocked reason=ThreeKeyAudioPolicy
java.lang.Throwable
at com.android.server.notification.ZenModeHelper.setConfigLocked(ZenModeHelper.java:706)
at com.android.server.notification.ZenModeHelper.setManualZenMode(ZenModeHelper.java:543)
at com.android.server.notification.ZenModeHelper.setManualZenMode(ZenModeHelper.java:503)
at com.android.server.notification.NotificationManagerService$5.setZenMode(NotificationManagerService.java:2193)
at android.app.NotificationManager.setZenMode(NotificationManager.java:422)
at com.oneplus.threekey.ThreeKeyAudioPolicy.setRing(ThreeKeyAudioPolicy.java:177)
at com.oneplus.threekey.ThreeKeyAudioPolicy.setDown(ThreeKeyAudioPolicy.java:87)
at com.oneplus.threekey.ThreeKey.setDown(ThreeKey.java:46)
at com.oneplus.threekey.ThreeKeyBase.setSwitchState(ThreeKeyBase.java:54)
at com.oneplus.threekey.ThreeKeyBase$ThreeKeyBroadcastReceiver.onReceive(ThreeKeyBase.java:80)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1163)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at com.android.server.SystemServer.run(SystemServer.java:367)
at com.android.server.SystemServer.main(SystemServer.java:237)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
10-03 00:00:53.298 2002-2087/? I/vol.VolumeDialogControl: s updateZenModeW zen:0 threeKeySatus:3 mVibrateWhenMute:0
10-03 00:00:53.300 1407-1407/? D/ThreeKeyAudioPolicy: settings change selfChange=false uri=content://settings/global/zen_mode
10-03 00:00:53.301 1407-1407/? D/ThreeKeyAudioPolicy: zen mode was changed, zen mode=ZEN_MODE_OFF, three key status=3
10-03 00:00:53.302 2002-2087/? I/vol.VolumeDialogControl: s updateZenModeW zen:0 threeKeySatus:3 mVibrateWhenMute:0
10-03 00:00:53.306 2002-2002/? D/VolumeUI: mZenModeObserver:zenMode=3, threeKeyStatus=3, mLastThreeKeyStatus=2
10-03 00:00:53.314 2002-2002/? D/VolumeUI: mZenModeObserver:zenMode=3, threeKeyStatus=3, mLastThreeKeyStatus=3
在这里我注意到Throwable部分中的三键类/服务(我真的不知道那是什么)调用setZenMode
,它似乎负责通知声音。但事实证明Android Developers没有记录setZenMode
方法,并且在获取NotificationManager类的实例后无法调用。
在这一点上,我开始没有想法接下来要尝试什么,或者在哪里看。任何帮助让滑块像以前一样工作会很棒!