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

Commit 02a8e101 authored by BadDaemon's avatar BadDaemon Committed by Gerrit Code Review
Browse files

Improve SmartDialer

Only enable sensors when Dialpad is opened

Change-Id: I158cf73df97a6f1e8b6274e5c91f7f22fd175688
parent 2d42fc2e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -536,6 +536,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
            // will not cause an extra view to be sent out on rotation
            if (mIsDialpadShown) {
                AnalyticsUtil.sendScreenView(mDialpadFragment, this);
                mDialpadFragment.enableSmartCall(true);
            }
            mIsRestarting = false;
        }
@@ -756,6 +757,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
        if (!isInSearchUi()) {
            enterSearchUi(true /* isSmartDial */, mSearchQuery);
        }

        mDialpadFragment.enableSmartCall(true);
    }

    private void onFloatingActionButtonHidden() {
@@ -815,6 +818,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
                exitSearchUi();
            }
        }

        mDialpadFragment.enableSmartCall(false);
    }

    /**
+12 −4
Original line number Diff line number Diff line
@@ -294,6 +294,18 @@ public class DialpadFragment extends Fragment
        return prefs.getBoolean(GeneralSettingsFragment.BUTTON_SMART_DIALER_KEY, false);
    }

    public void enableSmartCall(boolean enable){
        if (mPickupDetector == null || !isSmartCallEnabled() || isPhoneInUse()) {
            return;
        }

        if (enable) {
            mPickupDetector.enable();
        } else {
            mPickupDetector.disable();
        }
    }

    private TelecomManager getTelecomManager() {
        return (TelecomManager) getActivity().getSystemService(Context.TELECOM_SERVICE);
    }
@@ -697,10 +709,6 @@ public class DialpadFragment extends Fragment

        stopWatch.stopAndLog(TAG, 50);

        if (!isPhoneInUse() && isSmartCallEnabled()) {
            mPickupDetector.enable();
        }

        mSmsPackageComponentName = DialerUtils.getSmsComponent(activity);

        // Populate the overflow menu in onResume instead of onCreate, so that if the SMS activity