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

Commit 224988e2 authored by Fan Wu's avatar Fan Wu Committed by Android (Google) Code Review
Browse files

Merge "Disable Reset app preference during the call. Similar with ag/27511802,...

Merge "Disable Reset app preference during the call. Similar with ag/27511802, this is for non-SPA environment" into main
parents 2e3fc477 c6544f99
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;
    }
}