federicoiosue / Omni-Notes

Open source note-taking application for Android
https://omninotes.app
GNU General Public License v3.0
2.69k stars 1.1k forks source link

Compatibility issue when calling method #863

Closed PSDroid2022 closed 2 years ago

PSDroid2022 commented 2 years ago

We confirm a compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.

In ''it.feio.android.omninotes.services.NotificationListener", you invoke the API "<android.service.notification.StatusBarNotification: java.lang.String getPackageName()>" and "<android.service.notification.StatusBarNotification: int getId()>" in "onNotificationRemoved" method as shown in following. But actually, those APIs are introduced after API level 18( https://developer.android.google.cn/reference/android/service/notification/StatusBarNotification?hl=en#getPackageName() ).

 @Override
  public void onNotificationRemoved(StatusBarNotification sbn) {
    if (getPackageName().equals(sbn.getPackageName())) {
      EventBus.getDefault().post(new NotificationRemovedEvent(sbn));
      LogDelegate.d("Notification removed for note: " + sbn.getId());
    }
  }

So when the app try to invoke this API on devices before API level 18, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT >= 18)" to fix this potential issue.

Android device

federicoiosue commented 2 years ago

Thanks for pointing out this: actually the latest code on develop branch has a minimum SDK version 21 so this issue should not apply anymore.