androidnotificationmanagermeizu

Why do my Android app notifications stop getting displayed (Meizu Flyme OS)?


I made a simple Android Studio project to test the notifications API. The app has a single button, which when pressed displays the notification. I'm installing the app on an Android Meizu phone running the Flyme OS. See code below:

public class MainActivity extends AppCompatActivity {

private AppBarConfiguration appBarConfiguration;
private ActivityMainBinding binding;

NotificationManager notification;
Button btn;
String ChannelID = "ChannelID";
String ChannelName = "ChannelName";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    binding = ActivityMainBinding.inflate(getLayoutInflater());
    setContentView(binding.getRoot());

    setSupportActionBar(binding.toolbar);

    NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
    appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
    NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);

    binding.fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    btn = findViewById(R.id.button_first);
    notification = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

    btn.setOnClickListener(view -> {
        NotificationChannel notificationChannel = new NotificationChannel(ChannelID,
                ChannelName,
                NotificationManager.IMPORTANCE_HIGH);
        notification.createNotificationChannel(notificationChannel);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this, ChannelID);

        builder.setSmallIcon(R.mipmap.ic_launcher_round)
                .setContentTitle("Test Title").setContentText("Test content text");
        Notification n = builder.build();
        notification.notify((int) (new Date()).getTime(), builder.build());
    });
}
}

This works fine initially and the notifications appear as expected. However after the program has been installed for a while, the notifications stop appearing when the button is pressed. I've tried deleting and reinstalling the program, restarting the phone, and restarting Android Studio, but none of those cause the notifications to begin displaying again.

The only thing I've found that works is to change the project's Application ID (right-click on root folder in Android Studio -> Default Config tag -> Application ID). When I change this and reinstall, the notifications start displaying again.

There's nothing unusual in the logs for my app, but when I looked at the system logs around when I press the button, there are some logs from something called NotificationService and NotificationFirewall that seem suspect.

When the notifications are displayed, the logs look like this:

NotificationFirewall    pid-1562    D  getFilterResult Main begin
NotificationFirewall    pid-1562    D  interceptNotification A begin
NotificationFirewall    pid-1562    D  handleMessage: interceptNotification begin
NotificationFirewall    pid-1562    D  handleMessage: interceptNotification end,mResult=category=news;categoryPriority=0,notificationPriority=0;userFilter=0;tag=news;isValid=true;intercept=false,score=100.0,score_scale=10.0,shouldAffectRanking =true,shouldAffectIntercept=true,shouldAuthorityManagement=false,filterByUserBefore=false
NotificationFirewall    pid-1562    D  interceptNotification A end
NotificationFirewall    pid-1562    D  getFilterResult: mResultNull=false,mNotificationKey=0|com.example.notiftest5|-1785528131|null|10600,sbn.getKey()=0|com.example.notiftest5|-1785528131|null|10600
NotificationFirewall    pid-1562    D  getNotificationFilter: pkg=com.example.notiftest5,result=category=news;categoryPriority=0,notificationPriority=0;userFilter=0;tag=news;isValid=true;intercept=false,score=100.0,score_scale=10.0,shouldAffectRanking =true,shouldAffectIntercept=true,shouldAuthorityManagement=false,filterByUserBefore=false
NotificationFirewall    pid-1562    D  getNotificationFilter: pkg=com.example.notiftest5,isMediaNoti=false,isAutoFilterMode=true
NotificationService     pid-1562    D  enqueueNotificationInternal: pkg=com.example.notiftest5,id=-1785528131,ufk=com.example.notiftest5$ChannelID,n.filter=category=news;categoryPriority=0,notificationPriority=0;userFilter=0;tag=news;score=10.000000,score_scale=10.000000;intercept=false;shouldAffectRanking=true;shouldAffectIntercept=true;shouldAuthorityManagement=true;filterByUserBefore=false
NotificationService     pid-1562    D  showWakeUpScreen: aboveThreshold=true,DND=0,isUpdate=false,alertOnce=0,noClear=0,onGoing=0,category=nulluserFilter=0

When they aren't, the logs change to this:

NotificationFirewall    pid-1562    D  getFilterResult Main begin
NotificationFirewall    pid-1562    D  interceptNotification A begin
NotificationFirewall    pid-1562    D  handleMessage: interceptNotification begin
NotificationFirewall    pid-1562    D  handleMessage: interceptNotification end,mResult=category=news;categoryPriority=0,notificationPriority=0;userFilter=0;tag=news;isValid=true;intercept=false,score=100.0,score_scale=10.0,shouldAffectRanking =true,shouldAffectIntercept=true,shouldAuthorityManagement=false,filterByUserBefore=false
NotificationFirewall    pid-1562    D  interceptNotification A end
NotificationFirewall    pid-1562    D  getFilterResult: mResultNull=false,mNotificationKey=0|com.example.notiftest|-1785734812|null|10599,sbn.getKey()=0|com.example.notiftest|-1785734812|null|10599
NotificationFirewall    pid-1562    D  getNotificationFilter: pkg=com.example.notiftest,result=category=news;categoryPriority=0,notificationPriority=0;userFilter=0;tag=news;isValid=true;intercept=false,score=100.0,score_scale=10.0,shouldAffectRanking =true,shouldAffectIntercept=true,shouldAuthorityManagement=false,filterByUserBefore=false
NotificationFirewall    pid-1562    D  getNotificationFilter: pkg=com.example.notiftest,isMediaNoti=false,isAutoFilterMode=true
NotificationService     pid-1562    D  enqueueNotificationInternal: pkg=com.example.notiftest,id=-1785734812,ufk=com.example.notiftest$ChannelID,n.filter=category=news;categoryPriority=0,notificationPriority=0;userFilter=0;tag=news;score=-100.000000,score_scale=10.000000;intercept=true;shouldAffectRanking=true;shouldAffectIntercept=true;shouldAuthorityManagement=true;filterByUserBefore=true
NotificationService     pid-1562    D  showWakeUpScreen: aboveThreshold=false,DND=0,isUpdate=false,alertOnce=0,noClear=0,onGoing=0,category=nulluserFilter=0

Specifically, when the notifications stop displaying, the values "score=10.000000", "intercept=false", "filterByUserBefore=false" change to "score=-100.000000", "intercept=true", "filterByUserBefore=true".

So it seems like something is getting set in the OS that filters out notifications for my app ID. However I can't find any information about NotificationFirewall or NotificationService, so I still don't know why my app notifications are getting filtered or how to change the filter settings.


Solution

  • It turned out my notifications were getting intercepted by the "Not Important notification" feature of the Flyme OS.

    On the upper-right corner of the notification pane there is a small icon that looks like a picture. Tap it to open the "Not Important notifications" page. Intercepted notifications will be shown there. Long press a notification to see a number of options. Tap "Alert" to continue receiving notifications from that channel and prevent them from getting intercepted.