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

Commit 5f366a3a authored by Robin Lee's avatar Robin Lee
Browse files

Add null check for getActionBar()

This is done for all other fragments but missed in the root
SettingsActivity. Devices overlaying a theme that does not include an
action bar will crash when attempting to access it.

Test: atest CtsRoleTestCases
Bug: 155350832
Change-Id: I3a52baa8fcd60d880efceddf26b5d9e7ca3cd482
parent 8cc6fabf
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.permissioncontroller.role.ui.handheld;

import android.app.ActionBar;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -82,7 +83,10 @@ abstract class SettingsFragment extends PreferenceFragmentCompat {
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        requireActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
        ActionBar actionBar = requireActivity().getActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }

        mEmptyText.setText(getEmptyTextResource());