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

Commit eb627be0 authored by Shen Lin's avatar Shen Lin
Browse files

Mark DataUsageState as nullable to avoid potential NPE risk

mDataUsageState is nullable in UnrestrictedDataAccessPreference.java, so we'd better
add a annotation to getDataUsageState(), and add a null-check before calling it.

Bug: 246828843

Test: manual and Robotest.
Change-Id: If7fea53ec7efd004391a09becdba5709ae686f40
parent 8b0e08ec
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.preference.PreferenceViewHolder;

import com.android.settings.R;
@@ -152,6 +153,7 @@ public class UnrestrictedDataAccessPreference extends AppSwitchPreference implem
        }
    }

    @Nullable
    public AppStateDataUsageBridge.DataUsageState getDataUsageState() {
        return mDataUsageState;
    }
+3 −1
Original line number Diff line number Diff line
@@ -194,7 +194,9 @@ public class UnrestrictedDataAccessPreferenceController extends BasePreferenceCo
            logSpecialPermissionChange(allowlisted, accessPreference.getEntry().info.packageName);
            mDataSaverBackend.setIsAllowlisted(accessPreference.getEntry().info.uid,
                    accessPreference.getEntry().info.packageName, allowlisted);
            if (accessPreference.getDataUsageState() != null) {
                accessPreference.getDataUsageState().isDataSaverAllowlisted = allowlisted;
            }
            return true;
        }
        return false;