diff --git a/src/org/lineageos/lineageparts/BootReceiver.java b/src/org/lineageos/lineageparts/BootReceiver.java index 309e164affd1bc349878821a8c9213ab62b4b28d..534356c590cc8914b38d7954d9b771da4ec9ce21 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.loadSentryID(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 0000000000000000000000000000000000000000..73ce5d4f601b3179c3d598502f183f188b9707e6 --- /dev/null +++ b/src/org/lineageos/lineageparts/utils/EUtils.java @@ -0,0 +1,38 @@ +/* + * 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 android.provider.Settings; + +import java.util.UUID; + + +public class EUtils { + + public static void loadSentryID(Context context) { + String sentryId = Settings.Secure.getStringForUser( + context.getContentResolver(), Settings.Secure.SENTRY_USERID, + UserHandle.USER_CURRENT); + if (sentryId == null) { + UUID uuid = UUID.randomUUID(); + Settings.Secure.putStringForUser(context.getContentResolver(), + Settings.Secure.SENTRY_USERID, uuid.toString(), + UserHandle.USER_CURRENT); + } + } +}