The Persistent Problem of Hikvision Push Notifications on GrapheneOS

For over a year, users of Hikvision's camera security apps on GrapheneOS faced a frustrating limitation: push notifications simply did not work. This issue forced some, like the developer who tackled the problem, to reluctantly use LineageOS, a different Android variant, just to maintain essential functionality. The breaking point for this developer came recently when Google services on their phone experienced significant disruptions, prompting a renewed effort to solve the Hikvision notification bug.

The root cause of the problem lies in how Hikvision's applications are coded. They perform a strict check for the presence of com.google.android.gsf, the Google Services Framework. If this specific package is not detected, the app abandons its push notification registration process entirely. This occurs even if alternative services like GmsCore are installed and functional, and the Firebase Cloud Messaging (FCM) service, which handles push notifications, is operational. GrapheneOS, a privacy-focused mobile operating system, deliberately omits Google Services Framework by default, meaning this check would always fail for its users.

Initial attempts to find a solution through official channels proved fruitless. The developer reached out to the GrapheneOS team, who, while acknowledging the issue, moved the discussion to a third-party app forum and locked the thread, indicating it was outside their direct scope. A similar attempt to contact Hikvision and its associated brand Annke yielded no response. Faced with a lack of support and a year-long unresolved issue, the developer resorted to reverse engineering the Hikvision application's APK file to find a fix.

Reverse Engineering and Code Modification

The process began with decompiling the Hikvision application's APK. By analyzing the decompiled code, the developer traced the logic responsible for push notification registration. The critical piece of code identified was a conditional check that explicitly looked for the existence of the com.google.android.gsf package. If this package was absent, the application would proceed to disable push notification functionality.

To circumvent this hardcoded dependency, the developer modified the application's code. The goal was to remove or bypass this specific check, allowing the app to register for push notifications even without the Google Services Framework being present. This involved identifying the relevant code segment, altering the conditional logic, and recompiling the APK. The modification effectively tricks the Hikvision app into believing that the necessary Google services are available, thereby enabling the push notification registration pathway.

After successfully modifying the APK, the developer tested the changes on their GrapheneOS device. The tests confirmed that push notifications from the Hikvision app were now functioning as expected. This was a significant breakthrough, solving a persistent problem that had plagued GrapheneOS users for an extended period.

Decompiled APK code snippet showing the GSF check logic

Submitting a Patch for Community Benefit

Recognizing the value of this fix for the wider GrapheneOS and privacy-conscious Android community, the developer did not stop at a personal solution. They packaged their modifications into a patch and submitted a pull request (PR) to the Hikvision application's development repository. This proactive step aims to integrate the fix into the official application, benefiting all users who encounter the same issue.

The submission of the PR represents a significant contribution to the open-source ecosystem and the broader goal of making privacy-focused operating systems more compatible with essential third-party applications. By addressing a hardcoded dependency on Google Services Framework, this fix not only restores a crucial feature but also highlights the potential for community-driven solutions when official support is lacking. The success of this reverse engineering effort underscores the importance of developer initiative in ensuring a more functional and inclusive digital experience for users who prioritize privacy and choose alternative operating systems.

The implications of this fix extend beyond just Hikvision users. It demonstrates a viable method for developers to approach similar issues with other applications that exhibit an over-reliance on Google Mobile Services (GMS) components, particularly within the context of de-Googled or privacy-enhanced Android distributions. The developer's work provides a blueprint and a tangible solution that could inspire similar efforts for other apps, ultimately fostering greater compatibility and user choice in the mobile ecosystem.