Did I screw up my System_server service?

限于喜欢 提交于 2020-01-23 12:30:07

问题


My phone is producing a non-stop Log.d output. The following repeats over and over again about 1200 times per second.

04-25 15:58:04.883 1542-5012/? D/NetworkStatsCollection: getHistory:mUID 10266 isVideoCallUID: false

PID 1542 is System_server which I've come to understand manages an array of Android services. In the app I'm developing, I use the Alarm Manager and Notification service as seen below. Is there anything I could have done to cause this service to react the way it is?

public void scheduleNotification(Context context, long alarmTime, int notificationId, String setOrCancel) {
    EditText questionView = (EditText)findViewById(R.id.question);
    String questionText = questionView.getText().toString();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(context.getString(R.string.app_name))
            .setContentText(questionText)
            .setAutoCancel(true)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(((BitmapDrawable) context.getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap())
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

    Intent intent = new Intent(context, DashboardActivity.class);
    PendingIntent activity = PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setContentIntent(activity);

    Notification notification = builder.build();

    Intent notificationIntent = new Intent(context, TrackerNotificationService.class);
    notificationIntent.putExtra(TrackerNotificationService.NOTIFICATION_ID, notificationId);
    notificationIntent.putExtra(TrackerNotificationService.NOTIFICATION, notification);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId,
            notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    if (setOrCancel.equals("set")) {
        alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntent);
        Log.d("Check it", "scheduleNotification: " + alarmTime);
    }else{
        alarmManager.cancel(pendingIntent);
    }

}

TrackerNotificationService.java

import android.app.Notification;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class TrackerNotificationService extends BroadcastReceiver {


    public static String NOTIFICATION_ID = "notification_id";
    public static String NOTIFICATION = "notification";

    @Override
    public void onReceive(final Context context, Intent intent) {

        NotificationManager notificationManager = (NotificationManager) 
                context.getSystemService(Context.NOTIFICATION_SERVICE);

        Notification notification = intent.getParcelableExtra(NOTIFICATION);
        int notificationId = intent.getIntExtra(NOTIFICATION_ID, 0);
        notificationManager.notify(notificationId, notification);
    }
}

回答1:


I have a Samsung Galaxy S7 Edge and I've noticed that the NetworkStatsCollection spam in my LogCat started happening on my device as well.

As indicated by this post, this appears to be a Core OS process. The device manufacturer (Samsung in my case) must have done some modifications in their latest OS update and left some debugging on. Very annoying I must add.

Use this as a temporary workaround, but also report it to your nearest Samsung service Center. Hopefully with enough reports they can quickly deploy an OS update that fixes it



来源:https://stackoverflow.com/questions/43623272/did-i-screw-up-my-system-server-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!