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

Commit 5acfd037 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Settings: add preference for sentry user id

parent e9579f55
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -218,6 +218,9 @@
    <string name="fast_charging_title">Fast charging</string>
    <string name="fast_charging_summary">Disable to reduce the heat produced by the device while charging or to extend the lifespan of the battery</string>

    <!-- /e/ Sentry -->
    <string name="sentry_userid_title">Sentry User ID</string>

    <!-- /e/ Telemetry -->
    <string name="enable_telemetry">Enable /e/OS Telemetry</string>
    <string name="telemetry_details">Enable automatic bug reporting</string>
+8 −0
Original line number Diff line number Diff line
@@ -623,6 +623,14 @@
            android:key="enable_telemetry"
            android:title="@string/enable_telemetry"
            android:summary="@string/telemetry_details" />

        <Preference
            android:key="sentry_userid"
            android:title="@string/sentry_userid_title"
            android:summary="@string/summary_placeholder"
            android:selectable="false"
            settings:enableCopying="true"
            settings:controller="com.android.settings.deviceinfo.firmwareversion.SentryDetailPreferenceController"/>
    </PreferenceCategory>

    <com.android.settings.development.autofill.AutofillPreferenceCategory
+73 −0
Original line number Diff line number Diff line
/*
 * 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 <https://www.gnu.org/licenses/>.
 */

package com.android.settings.deviceinfo.firmwareversion;

import android.content.Context;
import android.os.UserHandle;
import android.text.TextUtils;
import android.provider.Settings;

import androidx.preference.Preference;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.slices.Sliceable;


public class SentryDetailPreferenceController extends BasePreferenceController {

    private static final String TAG = "SentryDetailPreferenceController";

    private static final String TELEMETRY_KEY = "e_telemetry";

    public SentryDetailPreferenceController(Context context, String key) {
        super(context, key);
    }

    @Override
    public int getAvailabilityStatus() {
        boolean enable = Settings.System.getInt(mContext.getContentResolver(), TELEMETRY_KEY, 0) == 1;
        return enable ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    @Override
    public boolean useDynamicSliceSummary() {
        return true;
    }

    @Override
    public boolean isSliceable() {
        return true;
    }

    @Override
    public CharSequence getSummary() {
        String sentryId = Settings.Secure.getStringForUser(
                mContext.getContentResolver(), Settings.Secure.SENTRY_USERID,
                UserHandle.USER_CURRENT);
        if (sentryId == null) {
            return mContext.getString(R.string.unknown);
        }
        return sentryId;
    }

    @Override
    public void copy() {
        Sliceable.setCopyContent(mContext, getSummary(),
                mContext.getText(R.string.sentry_userid_title));
    }
}