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

Commit 28fad30d authored by Azhara Assanova's avatar Azhara Assanova
Browse files

Suppress OnNameExpected lint for ComponentCaller APIs in Activity

OnNameExpected asks to rename an API to on<Something> or make it final.

Renaming to on<Something> doesn't make sense for these APIs. Making them
final may introduce inconsistency to other existing methods like
getCallingPackage().

This change also fixes the error message for the getCurrentCaller API.

Bug: 341038044
Test: m checkapi
Flag: EXEMPT bugfix
Change-Id: I628402f4f7b485160c1fcb6b4125ddbb54918900
parent 412a1d55
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1183,6 +1183,7 @@ public class Activity extends ContextThemeWrapper
     * @see #setIntent(Intent, ComponentCaller)
     */
    @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS)
    @SuppressLint("OnNameExpected")
    public @Nullable ComponentCaller getCaller() {
        return mCaller;
    }
@@ -1203,6 +1204,7 @@ public class Activity extends ContextThemeWrapper
     * @see #getCaller
     */
    @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS)
    @SuppressLint("OnNameExpected")
    public void setIntent(@Nullable Intent newIntent, @Nullable ComponentCaller newCaller) {
        internalSetIntent(newIntent, newCaller);
    }
@@ -7159,6 +7161,7 @@ public class Activity extends ContextThemeWrapper
     * @see ComponentCaller
     */
    @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS)
    @SuppressLint("OnNameExpected")
    public @NonNull ComponentCaller getInitialCaller() {
        return mInitialCaller;
    }
@@ -7186,10 +7189,11 @@ public class Activity extends ContextThemeWrapper
     * @see #getCaller
     */
    @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS)
    @SuppressLint("OnNameExpected")
    public @NonNull ComponentCaller getCurrentCaller() {
        if (mCurrentCaller == null) {
            throw new IllegalStateException("The caller is null because #getCurrentCaller should be"
                    + " called within #onNewIntent method");
                    + " called within #onNewIntent or #onActivityResult methods");
        }
        return mCurrentCaller;
    }