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

Commit 5dbc8190 authored by Hakan Seyalioglu's avatar Hakan Seyalioglu
Browse files

Fix crash in onRestoreInstanceState

bug: 34973084
Test: Manually verified crash stops

Change-Id: Ic28f98bc422d12f0db5c5921e89008eb2da1862d
parent be339625
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -531,16 +531,7 @@ public class ResolverActivity extends Activity {
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        if (mSupportsAlwaysUseOption) {
            final int checkedPos = mAdapterView.getCheckedItemPosition();
            final boolean hasValidSelection = checkedPos != ListView.INVALID_POSITION;
            mLastSelected = checkedPos;
            setAlwaysButtonEnabled(hasValidSelection, checkedPos, true);
            mOnceButton.setEnabled(hasValidSelection);
            if (hasValidSelection) {
                mAdapterView.setSelection(checkedPos);
            }
        }
        resetAlwaysOrOnceButtonBar();
    }

    private boolean hasManagedProfile() {
@@ -577,7 +568,13 @@ public class ResolverActivity extends Activity {
        boolean enabled = false;
        if (hasValidSelection) {
            ResolveInfo ri = mAdapter.resolveInfoForPosition(checkedPos, filtered);
            if (ri.targetUserId == UserHandle.USER_CURRENT) {
            if (ri == null) {
                Log.e(TAG, "Invalid position supplied to setAlwaysButtonEnabled");
                return;
            } else if (ri.targetUserId != UserHandle.USER_CURRENT) {
                Log.e(TAG, "Attempted to set selection to resolve info for another user");
                return;
            } else {
                enabled = true;
            }
        }