我有一个在 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 DeveloperssetZenMode
中没有记录该方法,并且在获取 NotificationManager 类的实例后无法调用该方法。
在这一点上,我开始没有想法接下来要尝试什么或去哪里看。让滑块像以前一样工作的任何帮助都会很棒!