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

Commit c6544f99 authored by Fan Wu's avatar Fan Wu
Browse files

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

Disable Reset app preference during the call. Similar with ag/27511802, this is for non-SPA environment

Bug: 342627537
Test: manual
Flag: EXEMPT Bug fix
Change-Id: If64b6c878b2f793c6852d000d9d90dda18ef2420
parent dc1a52a2
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;
    }
}