content: package com.lody.virtual.client.stub;
  
  import android.app.Notification;
  import android.app.Service;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Build;
  import android.os.IBinder;
  
  import com.lody.virtual.client.core.VirtualCore;
  import com.lody.virtual.client.env.Constants;
  
  import java.io.File;
  
  
  /**
   * @author Lody
   *
   */
  public class DaemonService extends Service {
  
      private static final int NOTIFY_ID = 1001;
  
  	static boolean showNotification = true;
  
  	public static void startup(Context context) {
  		File flagFile = context.getFileStreamPath(Constants.NO_NOTIFICATION_FLAG);
  		if (Build.VERSION.SDK_INT >= 25 && flagFile.exists()) {
  			showNotification = false;
  		}
  
  		context.startService(new Intent(context, DaemonService.class));
  		if (VirtualCore.get().isServerProcess()) {
  			// PrivilegeAppOptimizer.notifyBootFinish();
  			DaemonJobService.scheduleJob(context);
  		}
  	}
  
  	@Override
  	public void onDestroy() {
  		super.onDestroy();
  		startup(this);
  	}
  
  	@Override
  	public IBinder onBind(Intent intent) {
  		return null;
  	}
  
  	@Override
  	public void onCreate() {
  		super.onCreate();
  		if (!showNotification) {
  			return;
  		}
          startService(new Intent(this, InnerService.class));
          startForeground(NOTIFY_ID, new Notification());
  	}
  
  	@Override
  	public int onStartCommand(Intent intent, int flags, int startId) {
  		return START_STICKY;
  	}
  
  	public static final class InnerService extends Service {
  
          @Override
          public int onStartCommand(Intent intent, int flags, int startId) {
              startForeground(NOTIFY_ID, new Notification());
              stopForeground(true);
              stopSelf();
              return super.onStartCommand(intent, flags, startId);
          }
  
  		@Override
  		public IBinder onBind(Intent intent) {
  			return null;
  		}
  	}
  
  
  }
  