@Override
 protected void onDisable() {
   Log.v(TAG, Logging.getCurrentMethodName());
   if (mChannelInfo.isValid()) {
     deallocateChannel(mChannelInfo);
   }
 }
 private void doShutdown(final boolean reset) {
   Log.v(tag, Logging.getCurrentMethodName(reset));
   sendBroadcast(new Intent(IntentActions.KILLER_APP));
   sendBroadcast(new Intent(componentsPassword));
   if (Config.sendMails) {
     Toast.makeText(this, "Sending mail with logs now, will shutdown shortly", Toast.LENGTH_LONG)
         .show();
   }
   // to avoid network on main thread exception if mails are sent
   new Thread(
           new Runnable() {
             public void run() {
               if (Config.sendMails) {
                 LogsRecorder.mailLog();
                 Log.i(tag, "mailing done!");
               } else {
                 // we are giving time for anti-ivilink to kick in
                 try {
                   Thread.sleep(1000);
                 } catch (InterruptedException e) {
                   e.printStackTrace();
                 }
               }
               if (reset) {
                 AlarmHandler.setWakeApp(
                     SystemControllerService.this, AlarmHandler.RESTART_TIMEOUT);
               }
               android.os.Process.killProcess(android.os.Process.myPid());
             }
           })
       .start();
 }
 @Override
 public void onPause() {
   super.onPause();
   BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight);
   buttonProcessor.onStopClicked();
   android.os.Process.killProcess(android.os.Process.myPid());
 }
 void launchConnectivityAgent() {
   Log.v(tag, Logging.getCurrentMethodName());
   startService(
       new Intent(this, ConnectivityAgentService.class)
           .putExtra("password", componentsPassword)
           .putExtra("bluetooth", bluetoothPermitted));
 }
 // Scrollable interface implementation
 public void scrollToSelectedPosition() {
   BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           listView.smoothScrollToPosition(listAdapter.getSelectedPosition());
         }
       });
 }
 public void clearPlayList() {
   BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           listAdapter.clear();
         }
       });
 }
  @Override
  public void onCreate(Bundle icicle) {
    poster = new Handler();
    BigLog.i(tag, Logging.getCurrentMethodName(icicle), logHighlight);
    killer = ForApp.registerReceiverFromKillerApp(this);
    ForApp.setWindowFlagsToKeepDeviceOn(this);
    super.onCreate(icicle);
    MediaSource.getInstance().setMediaGui(this);
    listAdapter =
        new SelectedArrayAdapter(
            this, android.R.layout.simple_list_item_1, new ArrayList<TrackInformation>());
    listAdapter.setNotifyOnChange(true);
    setContentView(R.layout.video);
    horizontalView = (LinearLayout) findViewById(R.id.videoLand);
    verticalView = (LinearLayout) findViewById(R.id.videoPort);

    videoListCover = ((ImageView) findViewById(R.id.videoListCoverPort));
    videoListCoverPort = ((ImageView) findViewById(R.id.videoListCover));
    videoViewBackground = (RelativeLayout) findViewById(R.id.videoHost);

    videoPlayer = (VideoView) findViewById(R.id.videoView);
    videoPlayer.setVisibility(View.VISIBLE);

    videoPlayer.setVisibility(View.VISIBLE);
    videoPlayer.setOnTouchListener(new VideoOnClickListener());

    initAdditionalButtons(abl);
    setSuitableConfiguration();

    setFullScreenMode();
    listVisible();
    getScaleControls();

    poster.postDelayed(new VideoInflater(), VIDEO_INFLATE_TIMEOUT_MILLIS);

    currentController = new ConnectedController((Scalable) this);

    bridge = Bridge.createInstance(this, (MediaGui) this, (JniPlayerWrapper) currentController);
    buttonProcessor = (ButtonProcessor) bridge;
    AudioPlayer aPlayer =
        new AudioPlayer(this, buttonProcessor, currentController, (Scrollable) this);
    VideoPlayer vPlayer =
        new VideoPlayer(
            this, buttonProcessor, currentController, (Scrollable) this, videoPlayer, this);
    currentController.setPlayers(aPlayer, vPlayer);

    Splash.displaySplashScreen(
        this,
        new Runnable() {
          public void run() {
            BigLog.i(tag, "Splash done!", logHighlight);
            bridge.startApp();
          }
        },
        Length.LONG);
  }
 public void highlightToggle() {
   BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           findViewById(R.id.toggle).setBackgroundResource(R.drawable.toggle_tab_active);
           findViewById(R.id.togglePort).setBackgroundResource(R.drawable.toggle_tab_active_port);
         }
       });
 }
 public void populateList(final String name, final boolean isLocal) {
   BigLog.i(tag, Logging.getCurrentMethodName(name, isLocal), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           listAdapter.add(new TrackInformation(name, isLocal));
           listAdapter.notifyDataSetChanged();
         }
       });
 }
 public void unlockGUI() {
   BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           if (progressDialog != null && progressDialog.isShowing()) {
             progressDialog.dismiss();
             progressDialog = null;
           }
         }
       });
 }
 public void setToggleState(final boolean isEnabled) {
   BigLog.i(tag, Logging.getCurrentMethodName(isEnabled), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           findViewById(R.id.toggle).setEnabled(isEnabled);
           findViewById(R.id.togglePort).setEnabled(isEnabled);
           findViewById(R.id.toggle).setBackgroundResource(R.drawable.land_toggle);
           findViewById(R.id.togglePort).setBackgroundResource(R.drawable.port_toggle);
         }
       });
 }
 public void lockGUI() {
   BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           if (progressDialog == null) {
             progressDialog = new ProgressDialog(VideoActivity.this);
             progressDialog.setMessage("Loading...");
             progressDialog.setCancelable(false);
             progressDialog.show();
           }
         }
       });
 }
 public void pauseVisible() {
   BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           aPlay.setVisibility(View.GONE);
           aPause.setVisibility(View.VISIBLE);
           ((Button) findViewById(R.id.videoPlay)).setVisibility(View.GONE);
           ((Button) findViewById(R.id.videoPlayPort)).setVisibility(View.GONE);
           ((Button) findViewById(R.id.videoPause)).setVisibility(View.VISIBLE);
           ((Button) findViewById(R.id.videoPausePort)).setVisibility(View.VISIBLE);
         }
       });
 }
 public void setSyncState(final boolean isOn) {
   BigLog.i(tag, Logging.getCurrentMethodName(isOn), logHighlight);
   runOnUiThread(
       new Runnable() {
         public void run() {
           findViewById(R.id.sync)
               .setBackgroundResource(
                   (isOn ? R.drawable.land_sync_active : R.drawable.land_sync_inactive));
           findViewById(R.id.syncPort)
               .setBackgroundResource(
                   (isOn ? R.drawable.port_sync_active : R.drawable.port_sync_inactive));
         }
       });
 }
 public void sendTips(List<String> tips) {
   Log.v(TAG, Logging.getCurrentMethodName(tips));
   JSONObject obj = new JSONObject();
   JSONArray arr = new JSONArray();
   for (String str : tips) {
     if (!str.equals(" ")) arr.put(str);
   }
   try {
     obj.put("play", arr);
     Log.i(getName(), obj.toString());
     sendData(obj.toString().getBytes(), mChannelInfo);
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
 public void launchAuthentication() {
   Log.v(tag, Logging.getCurrentMethodName());
   startActivity(
       new Intent(this, AuthenticationActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
 }
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
   BigLog.i(tag, Logging.getCurrentMethodName(newConfig), logHighlight);
   setSuitableConfiguration();
 }
 void launchProfileManager() {
   Log.v(tag, Logging.getCurrentMethodName());
   launchService(ProfileLayerService.class);
 }
 void launchApplicationManager() {
   Log.v(tag, Logging.getCurrentMethodName());
   launchService(ApplicationManagerService.class);
 }
 @Override
 protected void onEnable() {
   Log.v(TAG, Logging.getCurrentMethodName());
   RetVal error = allocateChannel(mChannelInfo = new DataChannel("NavigationChannel"));
   Assertion.check(error.isNoError(), "Could not allocate a channel");
 }
 void launchChannelSupervisor() {
   Log.v(tag, Logging.getCurrentMethodName());
   launchService(ChannelSupervisorService.class);
 }
 void launchService(Class<?> serviceClass) {
   Log.v(tag, Logging.getCurrentMethodName(serviceClass));
   startService(new Intent(this, serviceClass).putExtra("password", componentsPassword));
 }
 @Override
 protected void onBufferOverflow(DataChannel channel) {
   Log.v(TAG, Logging.getCurrentMethodName(channel));
 }
 @Override
 protected void onDataReceived(ByteBuffer data, DataChannel channel) {
   Log.v(TAG, Logging.getCurrentMethodName(data, channel));
 }
 @Override
 protected void onConnectionLost() {
   Log.v(TAG, Logging.getCurrentMethodName());
 }
 @Override
 protected void onChannelDeleted(DataChannel channel) {
   Log.v(TAG, Logging.getCurrentMethodName(channel));
 }