VibratorService.startVibrationLocked

For OnePlus 5 only.
This hook has nothing to do with privacy. It blocks the short double vibration that occurs whenever a OnePlus 5 phone is plugged in.
Tested with OOS 4.5.15.
Instructions:
1. Download this hook.
2. Make sure that the Fif collection is enabled in XPL Pro.
3. In XPL, navigate to the "Android System" app (you may have to change the filter to "Show all apps" first), and expand the restriction categories.
4.a. Check the "Utility" category.
4.b. Or, alternately, enable VibratorService.startVibrationLocked hook for "Android System" in XPL Pro.
Changelog:
v1 - 2018-09-06
First public release.

Collection

Fif

Group

Utilities

Name

VibratorService.startVibrationLocked

Author

Fif_

Version

1

Updated (UTC)

2018-09-06 21:30:55

Created (UTC)

2018-09-06 21:30:55

Downloads

623

Class name

com.android.server.VibratorService

Method name

startVibrationLocked

Parameter types

com.android.server.VibratorService$Vibration

Return type

void

Min SDK

0

Max SDK

999

Min APK

0

Max APK

2147483647

Excluded packages

^(?!android$).*

Enabled

Yes

Optional

No

Usage

Yes

Notify

No

Settings

-

-- Fif.VibratorService.startVibrationLocked is a Lua hook definition
-- designed to work with XPrivacyLua.
-- Fif.VibratorService.startVibrationLocked is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- Fif.VibratorService.startVibrationLocked is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with XPrivacyLua. If not, see <http://www.gnu.org/licenses/>.
-- Copyright (C) 2018 Philippe Troin (Fif_ on XDA)
function before(hook, param)
local clsArray = luajava.bindClass('java.lang.reflect.Array')
local vibration = param:getArgument(0)
-- local msg
-- msg = "Vibration mUid=" .. tostring(vibration.mUid)
-- .. " mTimeout=" .. tostring(vibration.mTimeout)
-- .. " mRepeat=" .. tostring(vibration.mRepeat)
-- .. " mPattern="
-- local pattern = vibration.mPattern
-- if pattern == nil then
-- msg = msg .. "<null>"
-- else
-- local i
-- for i = 0, pattern.length-1 do
-- msg = msg .. " " .. tostring(clsArray:get(pattern, i))
-- end
-- end
-- log(msg)
if ( vibration.mUid == 1000
and vibration.mTimeout == 0
and vibration.mRepeat == -1
and vibration.mPattern ~= nil
and vibration.mPattern.length == 4
and clsArray:get(vibration.mPattern, 0) == 0
and clsArray:get(vibration.mPattern, 1) == 10
and clsArray:get(vibration.mPattern, 2) == 150
and clsArray:get(vibration.mPattern, 3) == 12 ) then
log("Detected charger plugged vibration, inhibiting")
param:setResult(null)
return true, "Inhibited charger plugged vibration"
end
return false
end