From faa9608ad07aa248c7beffb877453d9efce24249 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 20 Jun 2023 17:11:06 +0530 Subject: [PATCH 1/3] LineageParts: Set sentry user id on boot Change-Id: Ibacba6dfe416afab01412ff939bbf96e37321e57 --- .../lineageos/lineageparts/BootReceiver.java | 4 ++ .../lineageos/lineageparts/utils/EUtils.java | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/org/lineageos/lineageparts/utils/EUtils.java diff --git a/src/org/lineageos/lineageparts/BootReceiver.java b/src/org/lineageos/lineageparts/BootReceiver.java index 309e164a..13d1cf3c 100644 --- a/src/org/lineageos/lineageparts/BootReceiver.java +++ b/src/org/lineageos/lineageparts/BootReceiver.java @@ -26,6 +26,7 @@ import androidx.preference.PreferenceManager; import org.lineageos.lineageparts.contributors.ContributorsCloudFragment; import org.lineageos.lineageparts.gestures.TouchscreenGestureSettings; import org.lineageos.lineageparts.input.ButtonSettings; +import org.lineageos.lineageparts.utils.EUtils; public class BootReceiver extends BroadcastReceiver { @@ -34,6 +35,9 @@ public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context ctx, Intent intent) { + // Set sentry id on boot + EUtils.setSentryID(ctx); + if (!hasRestoredTunable(ctx)) { /* Restore the hardware tunable values */ ButtonSettings.restoreKeyDisabler(ctx); diff --git a/src/org/lineageos/lineageparts/utils/EUtils.java b/src/org/lineageos/lineageparts/utils/EUtils.java new file mode 100644 index 00000000..911432dd --- /dev/null +++ b/src/org/lineageos/lineageparts/utils/EUtils.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 MURENA SAS + * 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 . + */ +package org.lineageos.lineageparts.utils; + +import android.content.Context; +import android.os.UserHandle; + +import lineageos.providers.LineageSettings; + +import java.util.UUID; + + +public class EUtils { + + public static void setSentryID(Context context) { + String sentryId = LineageSettings.Secure.getStringForUser( + context.getContentResolver(), LineageSettings.Secure.SENTRY_USERID, + UserHandle.USER_CURRENT); + if (sentryId == null) { + UUID uuid = UUID.randomUUID(); + LineageSettings.Secure.putStringForUser(context.getContentResolver(), + LineageSettings.Secure.SENTRY_USERID, uuid.toString(), + UserHandle.USER_CURRENT); + } + } +} -- GitLab From 75a525e4caeaa6841f915aec89a6b74119b677af Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 27 Jun 2023 11:08:34 +0530 Subject: [PATCH 2/3] LineageParts: Move settings to base Change-Id: Iccacd429383874988b02b8cff958aecdfd1cbf5b --- src/org/lineageos/lineageparts/utils/EUtils.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/org/lineageos/lineageparts/utils/EUtils.java b/src/org/lineageos/lineageparts/utils/EUtils.java index 911432dd..bba3a768 100644 --- a/src/org/lineageos/lineageparts/utils/EUtils.java +++ b/src/org/lineageos/lineageparts/utils/EUtils.java @@ -17,8 +17,7 @@ package org.lineageos.lineageparts.utils; import android.content.Context; import android.os.UserHandle; - -import lineageos.providers.LineageSettings; +import android.provider.Settings; import java.util.UUID; @@ -26,13 +25,13 @@ import java.util.UUID; public class EUtils { public static void setSentryID(Context context) { - String sentryId = LineageSettings.Secure.getStringForUser( - context.getContentResolver(), LineageSettings.Secure.SENTRY_USERID, + String sentryId = Settings.Secure.getStringForUser( + context.getContentResolver(), Settings.Secure.SENTRY_USERID, UserHandle.USER_CURRENT); if (sentryId == null) { UUID uuid = UUID.randomUUID(); - LineageSettings.Secure.putStringForUser(context.getContentResolver(), - LineageSettings.Secure.SENTRY_USERID, uuid.toString(), + Settings.Secure.putStringForUser(context.getContentResolver(), + Settings.Secure.SENTRY_USERID, uuid.toString(), UserHandle.USER_CURRENT); } } -- GitLab From 072f09694af25dc112a35d0b7420d4ee8869533b Mon Sep 17 00:00:00 2001 From: althafvly Date: Fri, 30 Jun 2023 10:57:52 +0530 Subject: [PATCH 3/3] LineageParts: Rename sentry method Change-Id: I52e7020d276bbd5fdd22a67202c833956b1f2cf8 --- src/org/lineageos/lineageparts/BootReceiver.java | 2 +- src/org/lineageos/lineageparts/utils/EUtils.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/lineageos/lineageparts/BootReceiver.java b/src/org/lineageos/lineageparts/BootReceiver.java index 13d1cf3c..534356c5 100644 --- a/src/org/lineageos/lineageparts/BootReceiver.java +++ b/src/org/lineageos/lineageparts/BootReceiver.java @@ -36,7 +36,7 @@ public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context ctx, Intent intent) { // Set sentry id on boot - EUtils.setSentryID(ctx); + EUtils.loadSentryID(ctx); if (!hasRestoredTunable(ctx)) { /* Restore the hardware tunable values */ diff --git a/src/org/lineageos/lineageparts/utils/EUtils.java b/src/org/lineageos/lineageparts/utils/EUtils.java index bba3a768..73ce5d4f 100644 --- a/src/org/lineageos/lineageparts/utils/EUtils.java +++ b/src/org/lineageos/lineageparts/utils/EUtils.java @@ -24,7 +24,7 @@ import java.util.UUID; public class EUtils { - public static void setSentryID(Context context) { + public static void loadSentryID(Context context) { String sentryId = Settings.Secure.getStringForUser( context.getContentResolver(), Settings.Secure.SENTRY_USERID, UserHandle.USER_CURRENT); -- GitLab