Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a871ea1 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

SetupWizard: Toggle oem unlocking toggle for Pixel 5 only

parent 8df729e4
Loading
Loading
Loading
Loading

res/values/arrays.xml

0 → 100644
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright Murena SAS 2023
  ~ This program 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.
  ~
  ~ 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 General Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Public License
  ~  along with this program.  If not, see <https://www.gnu.org/licenses/>.
  -->
<resources>
    <!-- Array resource for allowed brands and devices to toggle 
        off oem unlocking toggle in Developer options. Only for devices
        that supports bootloader locking in custom rom -->
    <string-array name="allowed_brands_and_devices">
        <!-- Each item represents a combination of allowed brand name and device codename-->
        <item>google:redfin</item>
    </string-array>
</resources>
+15 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package org.lineageos.setupwizard;


import android.app.Application;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.service.oemlock.OemLockManager;
@@ -103,7 +104,20 @@ public class SetupWizardApp extends Application {
        if (SetupWizardUtils.isOwner()
                && !SetupWizardUtils.isBootloaderUnlocked(this)
                && SetupWizardUtils.isOemunlockAllowed(this)) {
            String manufacturer = Build.MANUFACTURER.toLowerCase();
            String device = Build.DEVICE.toLowerCase();
            String[] allowedBrandsAndDevices = getResources().getStringArray(R.array.allowed_brands_and_devices);

            for (String brandAndDevice : allowedBrandsAndDevices) {
                String[] parts = brandAndDevice.split(":");
                String allowedBrand = parts[0];
                String allowedDevice = parts[1];

                if (manufacturer.equals(allowedBrand) && device.equals(allowedDevice)) {
                    getSystemService(OemLockManager.class).setOemUnlockAllowedByUser(false);
                    break;
                }
            }
        }
    }