Notification.Ranker.onNotificationRemoved

Refer to the Notification.Ranker.onNotificationPosted hook for documentation.

CollectionFif
GroupGroup notifications
NameNotification.Ranker.onNotificationRemoved
AuthorFif_
Version4
Updated (UTC)2019-12-20 22:43:54
Created (UTC)2018-03-12 21:38:36
Downloads1607
Class nameandroid.ext.services.notification.Ranker
Method nameonNotificationRemoved
Parameter typesandroid.service.notification.StatusBarNotification
Return type-
Min SDK24
Max SDK25
Min APK0
Max APK2147483647
Excluded packages^(?!com\.google\.android\.ext\.services$).*
EnabledYes
OptionalNo
UsageYes
NotifyNo
SettingsUngrouped notification package names
-- Fif.Notification is a Lua hook set designed to work with XPrivacyLua.
-- Copyright (C) 2018, 2019 Philippe Troin (Fif_ on XDA)

-- Fif.Notification 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.Notification 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/>.

function before(hook, param)
    local notif = param:getArgument(0)
    if notif == nil then
        return false
    end

    local context = param:getApplicationContext()
    local UngroupedApps = param:getValue('Fif.Notification.UngroupedApps', context)

    if UngroupedApps == nil then
        local packages = param:getSetting("Ungrouped notification package names")
        UngroupedApps = {}
        local ungroupedAppsLog = {}
        if packages ~= nil then
            packages:gsub('[%S]+', function(x) UngroupedApps[x] = true table.insert(ungroupedAppsLog, x) end)
        end
        param:putValue('Fif.Notification.UngroupedApps', UngroupedApps, context)
        log('Apps with ungrouped notifications: ' .. table.concat(ungroupedAppsLog, ', '))
    end

    local package = notif:getPackageName()
    
    if UngroupedApps[package] then
        log('Deny ' .. package)
        param:setResult(nil)
        return true, package
    else
        log('Allow ' .. package)
        return false
    end
end