# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


def IncrementalOTA_InstallEnd(info):
  ReplaceDeviceConfig(info)

def FullOTA_InstallEnd(info):
  ReplaceDeviceConfig(info)

def ReplaceDeviceConfig(info):
  info.script.Mount("/system")
  info.script.AppendExtra('ui_print("Installing fingerprint firmware for: " + getprop("ro.bootloader"));')
  info.script.AppendExtra('run_program("/sbin/sh", "/system/etc/patch_fingerprint.sh");')
  info.script.AppendExtra('ifelse(getprop("ro.bootloader") == "0xC212", set_metadata("/system/vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-fpcservice", "uid", 0, "gid", 2000, "dmode", 0755, "fmode", 0755, "selabel", "u:object_r:hal_fingerprint_default_exec:s0"));')
  info.script.AppendExtra('ifelse(getprop("ro.bootloader") == "0xC212", set_metadata("/system/vendor/etc/init/android.hardware.biometrics.fingerprint@2.1-service.rc", "uid", 0, "gid", 0, "dmode", 0644, "fmode", 0644, "selabel", "u:object_r:vendor_configs_file:s0"));')
  info.script.AppendExtra('ifelse(getprop("ro.bootloader") == "0xC212", set_metadata("/system/vendor/lib/com.fingerprints.extension@1.0_vendor.so", "uid", 0, "gid", 0, "dmode", 0644, "fmode", 0644, "selabel", "u:object_r:vendor_file:s0"));')
  info.script.AppendExtra('ui_print("Checking NFC, compass and DTV support");')
  info.script.AppendExtra('run_program("/sbin/sh", "/system/vendor/bin/check_features.sh");')
  info.script.Unmount("/system")
  

# Copyright (C) 2016 The CyanogenMod Project
# Copyright (C) 2017 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


def IncrementalOTA_InstallEnd(info):
  ReplaceDeviceConfig(info)

def FullOTA_InstallEnd(info):
  ReplaceDeviceConfig(info)

def ReplaceDeviceConfig(info):
  info.script.Mount("/system")
  info.script.AppendExtra('ui_print("Installing fingerprint firmware for: " + getprop("ro.bootloader"));')
  info.script.AppendExtra('run_program("/sbin/sh", "/system/etc/patch_fingerprint.sh");')
  info.script.AppendExtra('ifelse(getprop("ro.bootloader") == "0xC212", set_metadata("/system/vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-fpcservice", "uid", 0, "gid", 2000, "dmode", 0755, "fmode", 0755, "selabel", "u:object_r:hal_fingerprint_default_exec:s0"));')
  info.script.AppendExtra('ifelse(getprop("ro.bootloader") == "0xC212", set_metadata("/system/vendor/etc/init/android.hardware.biometrics.fingerprint@2.1-service.rc", "uid", 0, "gid", 0, "dmode", 0644, "fmode", 0644, "selabel", "u:object_r:vendor_configs_file:s0"));')
  info.script.AppendExtra('ifelse(getprop("ro.bootloader") == "0xC212", set_metadata("/system/vendor/lib/com.fingerprints.extension@1.0_vendor.so", "uid", 0, "gid", 0, "dmode", 0644, "fmode", 0644, "selabel", "u:object_r:vendor_file:s0"));')
  info.script.AppendExtra('ui_print("Checking NFC, compass and DTV support");')
  info.script.AppendExtra('run_program("/sbin/sh", "/system/vendor/bin/check_features.sh");')
  info.script.Unmount("/system")
  

# Copyright (C) 2016 The CyanogenMod Project # Copyright (C) 2017 The LineageOS Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #      http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.