mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Add suport for accessibility service permission
This commit is contained in:
+23
-3
@@ -74,9 +74,15 @@ export interface DeviceAttributesVersion7 {
|
||||
highestOverlayPermission: RuntimePermissionStatus
|
||||
}
|
||||
|
||||
export interface DeviceAttributesVersion8 {
|
||||
// as = accessibility service
|
||||
asEnabled: boolean
|
||||
wasAsEnabled: boolean
|
||||
}
|
||||
|
||||
export type DeviceAttributes = DeviceAttributesVersion1 & DeviceAttributesVersion2 &
|
||||
DeviceAttributesVersion3 & DeviceAttributesVersion4 & DeviceAttributesVersion5 &
|
||||
DeviceAttributesVersion6 & DeviceAttributesVersion7
|
||||
DeviceAttributesVersion6 & DeviceAttributesVersion7 & DeviceAttributesVersion8
|
||||
|
||||
export type DeviceInstance = Sequelize.Instance<DeviceAttributes> & DeviceAttributes
|
||||
export type DeviceModel = Sequelize.Model<DeviceInstance, DeviceAttributes>
|
||||
@@ -191,6 +197,17 @@ export const attributesVersion7: SequelizeAttributes<DeviceAttributesVersion7> =
|
||||
}
|
||||
}
|
||||
|
||||
export const attributesVersion8: SequelizeAttributes<DeviceAttributesVersion8> = {
|
||||
asEnabled: {
|
||||
...booleanColumn,
|
||||
defaultValue: false
|
||||
},
|
||||
wasAsEnabled: {
|
||||
...booleanColumn,
|
||||
defaultValue: false
|
||||
}
|
||||
}
|
||||
|
||||
export const attributes: SequelizeAttributes<DeviceAttributes> = {
|
||||
...attributesVersion1,
|
||||
...attributesVersion2,
|
||||
@@ -198,7 +215,8 @@ export const attributes: SequelizeAttributes<DeviceAttributes> = {
|
||||
...attributesVersion4,
|
||||
...attributesVersion5,
|
||||
...attributesVersion6,
|
||||
...attributesVersion7
|
||||
...attributesVersion7,
|
||||
...attributesVersion8
|
||||
}
|
||||
|
||||
export const createDeviceModel = (sequelize: Sequelize.Sequelize): DeviceModel => sequelize.define<DeviceInstance, DeviceAttributes>('Device', attributes)
|
||||
@@ -208,6 +226,7 @@ export const hasDeviceManipulation = (device: DeviceAttributes) => {
|
||||
const manipulationOfNotificationAccess = device.currentNotificationAccessPermission !== device.highestNotificationAccessPermission
|
||||
const manipulationOfAppVersion = device.currentAppVersion !== device.highestAppVersion
|
||||
const manipulationOfOverlayPermission = device.currentOverlayPermission !== device.highestOverlayPermission
|
||||
const manipulationOfAsPermission = device.asEnabled !== device.wasAsEnabled
|
||||
|
||||
const hasActiveManipulationWarning = manipulationOfProtectionLevel ||
|
||||
manipulationOfUsageStats ||
|
||||
@@ -215,7 +234,8 @@ export const hasDeviceManipulation = (device: DeviceAttributes) => {
|
||||
manipulationOfAppVersion ||
|
||||
device.triedDisablingDeviceAdmin ||
|
||||
device.didReboot ||
|
||||
manipulationOfOverlayPermission
|
||||
manipulationOfOverlayPermission ||
|
||||
manipulationOfAsPermission
|
||||
|
||||
const hasAnyManipulation = hasActiveManipulationWarning || device.hadManipulation
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* server component for the TimeLimit App
|
||||
* Copyright (C) 2019 Jonas Lochmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, version 3 of the License.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { QueryInterface, Sequelize } from 'sequelize'
|
||||
import { attributesVersion8 } from '../../device'
|
||||
|
||||
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
|
||||
await sequelize.transaction({
|
||||
type: 'EXCLUSIVE'
|
||||
}, async (transaction) => {
|
||||
await queryInterface.addColumn('Devices', 'asEnabled', {
|
||||
...attributesVersion8.asEnabled
|
||||
}, {
|
||||
transaction
|
||||
})
|
||||
|
||||
await queryInterface.addColumn('Devices', 'wasAsEnabled', {
|
||||
...attributesVersion8.wasAsEnabled
|
||||
}, {
|
||||
transaction
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
|
||||
await sequelize.transaction({
|
||||
type: 'EXCLUSIVE'
|
||||
}, async (transaction) => {
|
||||
await queryInterface.removeColumn('Devices', 'asEnabled', { transaction })
|
||||
await queryInterface.removeColumn('Devices', 'wasAsEnabled', { transaction })
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user