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

Commit f7631498 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Disable Reset app preference during the call." into main

parents 7ee0e07a 41bb05c7
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -18,9 +18,11 @@ package com.android.settings.applications.manageapplications;

import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -70,4 +72,19 @@ public class ResetAppPrefPreferenceController extends AbstractPreferenceControll
    public void onSaveInstanceState(Bundle outState) {
        mResetAppsHelper.onSaveInstanceState(outState);
    }

    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        Preference preference = screen.findPreference(getPreferenceKey());
        if (preference != null) {
            preference.setEnabled(!isInCallState());
        }
    }

    boolean isInCallState() {
        TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
        return telephonyManager.getCallState(telephonyManager.getSubscriptionId())
                != TelephonyManager.CALL_STATE_IDLE;
    }
}