VibratorService.startVibrationLocked

For OnePlus devices only. This hook has nothing to do with privacy. It blocks the short double vibration that occurs whenever a OnePlus phone is plugged in. This vibration cannot be disabled by any setting. Tested with OOS 4.5.15 on OP5, OOS 9.5.13 on OP7Pro. 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 "Vibrate when plugged" category. 4.b. Or, alternately, enable VibratorService.startVibrationLocked hook for "Android System" in XPL Pro. Changelog: v2 - 2020-01-03 Changed the group to "Vibrate when plugged" (no action required when upgrading the hook from version 1). Now works on all Android versions where XPrivacyLua works (v1 was broken on Oreo and later). v1 - 2018-09-06 First public release.

CollectionFif
GroupVibrate when plugged
NameVibratorService.startVibrationLocked
AuthorFif_
Version2
Updated (UTC)2020-01-04 06:55:16
Created (UTC)2018-09-06 21:30:55
Downloads824
Class namecom.android.server.VibratorService
Method namestartVibrationLocked
Parameter typescom.android.server.VibratorService$Vibration
Return typevoid
Min SDK0
Max SDK999
Min APK0
Max APK2147483647
Excluded packages^(?!android$).*
EnabledYes
OptionalNo
UsageYes
NotifyNo
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, 2020 Philippe Troin (Fif_ on XDA)

function before(hook, param)
  local clsArray = luajava.bindClass('java.lang.reflect.Array')
  local vibration = param:getArgument(0)
  local effect = vibration.effect
  local inhibit = false
  local pat0 = 0
  local pat1 = 10
  local pat2 = 150
  local pat3 = 12

  if effect == nil then
--    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) == pat0
        and clsArray:get(vibration.mPattern, 1) == pat1
        and clsArray:get(vibration.mPattern, 2) == pat2
        and clsArray:get(vibration.mPattern, 3) == pat3 ) then
      inhibit = "Up to Nougat"
    end
  else
--    local msg
--    msg = "Vibration uid=" .. tostring(vibration.uid) .. " effect=" .. tostring(effect)
--    log(msg)

    if ( vibration.uid == 1000
        and effect.mRepeat == -1
        and effect.mTimings ~= nil
        and effect.mTimings.length == 4
        and clsArray:get(effect.mTimings, 0) == pat0
        and clsArray:get(effect.mTimings, 1) == pat1
        and clsArray:get(effect.mTimings, 2) == pat2
        and clsArray:get(effect.mTimings, 3) == pat3
        and effect.mAmplitudes ~= nil
        and effect.mAmplitudes.length == 4
        and clsArray:get(effect.mAmplitudes, 0) == 0
        and clsArray:get(effect.mAmplitudes, 1) == -1
        and clsArray:get(effect.mAmplitudes, 2) == 0
        and clsArray:get(effect.mAmplitudes, 3) == -1 ) then
      inhibit = "Oreo and up"
    end
  end

  if inhibit ~= false then
    log("Detected charger plugged vibration, inhibiting (" .. inhibit .. ")")
    param:setResult(null)
    return true, "Inhibited charger plugged vibration"
  else
    return false
  end
end