@DSVerified
  @DSBan(DSCat.DROIDSAFE_INTERNAL)
  public static void modelService(android.app.Service service) {
    if (mApplication != null) service.setApplication(mApplication);

    service.droidsafeAttachContext(context);

    service.onCreate();
    for (IntentFilter filter : service.__ds__intentFilters) {

      Intent intent = service.__ds__registerIntentFilter(filter);

      mApplication.__ds__intentsFromFilter.add(intent);

      service.onBind(intent);
      service.onRebind(intent);
      service.onStart(intent, DSUtils.FAKE_INT);
      service.onTaskRemoved(intent);
      service.onStartCommand(intent, DSUtils.FAKE_INT, DSUtils.FAKE_INT);
      service.onUnbind(intent);
      if (service instanceof IntentService) {
        ((IntentService) service).__ds__onHandleIntent(intent);
      }
    }
    service.droidsafeOnSubServiceHook();
    service.onConfigurationChanged(new Configuration());
    service.onLowMemory();
    service.onTrimMemory(0);
    service.stopSelf(0);
    service.onDestroy();
  }
 public boolean onUnbind(android.content.Intent intent) {
   if (ScriptLoader.isCalledFromJRuby()) return super.onUnbind(intent);
   if (JRubyAdapter.isInitialized()) {
     if (scriptInfo.getCallbackProcs() != null
         && scriptInfo.getCallbackProcs()[CB_UNBIND] != null) {
       super.onUnbind(intent);
       return (Boolean)
           JRubyAdapter.runRubyMethod(
               Boolean.class, scriptInfo.getCallbackProcs()[CB_UNBIND], "call", intent);
     } else {
       String rubyClassName = scriptInfo.getRubyClassName();
       if ((Boolean)
           JRubyAdapter.runScriptlet(
               "defined?("
                   + rubyClassName
                   + ") == 'constant' && "
                   + rubyClassName
                   + ".instance_methods(false).any?{|m| m.to_sym == :on_unbind}")) {
         // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
         if (JRubyAdapter.isJRubyPreOneSeven()) {
           JRubyAdapter.put("$arg_intent", intent);
           JRubyAdapter.put("$ruby_instance", scriptInfo.getRubyInstance());
           return (Boolean) JRubyAdapter.runScriptlet("$ruby_instance.on_unbind($arg_intent)");
         } else {
           if (JRubyAdapter.isJRubyOneSeven()) {
             return (Boolean)
                 JRubyAdapter.runRubyMethod(
                     Boolean.class, scriptInfo.getRubyInstance(), "on_unbind", intent);
           } else {
             throw new RuntimeException(
                 "Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
           }
         }
       } else {
         if ((Boolean)
             JRubyAdapter.runScriptlet(
                 "defined?("
                     + rubyClassName
                     + ") == 'constant' && "
                     + rubyClassName
                     + ".instance_methods(false).any?{|m| m.to_sym == :onUnbind}")) {
           // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
           if (JRubyAdapter.isJRubyPreOneSeven()) {
             JRubyAdapter.put("$arg_intent", intent);
             JRubyAdapter.put("$ruby_instance", scriptInfo.getRubyInstance());
             return (Boolean) JRubyAdapter.runScriptlet("$ruby_instance.onUnbind($arg_intent)");
           } else {
             if (JRubyAdapter.isJRubyOneSeven()) {
               return (Boolean)
                   JRubyAdapter.runRubyMethod(
                       Boolean.class, scriptInfo.getRubyInstance(), "onUnbind", intent);
             } else {
               throw new RuntimeException(
                   "Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
             }
           }
         } else {
           return super.onUnbind(intent);
         }
       }
     }
   } else {
     Log.i("Method called before JRuby runtime was initialized: RubotoService#onUnbind");
     return super.onUnbind(intent);
   }
 }