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

Commit f88000f4 authored by Hui Yu's avatar Hui Yu
Browse files

Generate new field short_name_hash for atom ForegroundServiceStateChanged.

A new field short_name_hash is added to atom ForegroundServiceStateChanged.
This field is SHA-1 hashed ServiceRecord#shortInstanceName combined with ANDROID_ID.

Bug: 187857932
Test: atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java
Change-Id: I959d50205f72ea3ed7b2a0b0ed2df77bd393ed1c
parent ab28cf73
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6191,7 +6191,8 @@ public final class ActiveServices {
                r.mFgsNotificationDeferred,
                r.mFgsNotificationShown,
                durationMs,
                r.mStartForegroundCount);
                r.mStartForegroundCount,
                ActivityManagerUtils.hashComponentNameForAtom(r.shortInstanceName));
    }

    boolean canAllowWhileInUsePermissionInFgsLocked(int callingPid, int callingUid,
+8 −0
Original line number Diff line number Diff line
@@ -121,4 +121,12 @@ public class ActivityManagerUtils {

        return (((double) hash) / Integer.MAX_VALUE) <= rate;
    }

    /**
     * @param shortInstanceName {@link ServiceRecord#shortInstanceName}.
     * @return hash of the ServiceRecord's shortInstanceName, combined with ANDROID_ID.
     */
    public static int hashComponentNameForAtom(String shortInstanceName) {
        return getUnsignedHashUnCached(shortInstanceName) ^ getAndroidIdHash();
    }
}