62 implements LibFreeRDP.UIEventListener, ClipboardManagerProxy.OnClipboardChangedListener
64 public static final String PARAM_CONNECTION_REFERENCE =
"conRef";
65 public static final String PARAM_INSTANCE =
"instance";
66 private static final String TAG =
"FreeRDP.SessionActivity";
68 private Bitmap bitmap;
69 private SessionState session;
73 private static final int REFRESH_SESSIONVIEW = 1;
74 private static final int DISPLAY_TOAST = 2;
75 private static final int GRAPHICS_CHANGED = 6;
76 private static final int POINTER_SET = 7;
77 private static final int REQUEST_MEDIA_PERMISSIONS = 100;
79 private RailWindowManager railManager;
81 private final Handler uiHandler =
new Handler(Looper.getMainLooper()) {
82 @Override
public void handleMessage(Message msg)
86 case GRAPHICS_CHANGED:
88 sessionView.onSurfaceChange(session);
89 scrollView.requestLayout();
92 case REFRESH_SESSIONVIEW:
94 sessionView.invalidateRegion();
99 Toast errorToast = Toast.makeText(getApplicationContext(), msg.obj.toString(),
106 Bundle data = msg.getData();
107 if (data !=
null && data.containsKey(
"pixels"))
109 int[] pixels = data.getIntArray(
"pixels");
110 int width = data.getInt(
"width");
111 int height = data.getInt(
"height");
112 int hotX = data.getInt(
"hotX");
113 int hotY = data.getInt(
"hotY");
114 sessionView.setRemoteCursor(pixels, width, height, hotX, hotY);
115 if (touchPointerView !=
null)
116 touchPointerView.setRemoteCursor(pixels, width, height, hotX, hotY);
120 sessionView.setRemoteCursor(
null, 0, 0, 0, 0);
121 if (touchPointerView !=
null)
122 touchPointerView.setRemoteCursor(
null, 0, 0, 0, 0);
130 private int screen_width;
131 private int screen_height;
133 private BookmarkBase pendingConnectBookmark =
null;
134 private boolean connectCancelledByUser =
false;
135 private boolean sessionRunning =
false;
136 private long backPressedTime = 0;
140 private ClipboardManagerProxy mClipboardManager;
146 void hideSystemBars()
151 if (inputManager !=
null && inputManager.isSoftInputActive())
157 WindowCompat.setDecorFitsSystemWindows(getWindow(),
false);
159 if (getSupportActionBar() !=
null)
160 getSupportActionBar().hide();
162 WindowInsetsControllerCompat controller =
163 WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
164 controller.setAppearanceLightStatusBars(
false);
165 controller.setAppearanceLightNavigationBars(
false);
167 getWindow().setStatusBarColor(android.graphics.Color.TRANSPARENT);
168 getWindow().setNavigationBarColor(android.graphics.Color.TRANSPARENT);
169 getWindow().setNavigationBarContrastEnforced(
false);
171 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
176 toHide |= WindowInsetsCompat.Type.statusBars();
178 toShow |= WindowInsetsCompat.Type.statusBars();
181 toHide |= WindowInsetsCompat.Type.navigationBars();
183 toShow |= WindowInsetsCompat.Type.navigationBars();
189 controller.setSystemBarsBehavior(
190 WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
191 controller.hide(toHide);
196 controller.show(toShow);
202 int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
203 View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
205 flags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
207 flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
208 if ((flags & (View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)) !=
210 flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
212 getWindow().getDecorView().setSystemUiVisibility(flags);
215 WindowManager.LayoutParams lp = getWindow().getAttributes();
216 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
217 lp.layoutInDisplayCutoutMode =
218 WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
220 lp.layoutInDisplayCutoutMode =
221 WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
222 getWindow().setAttributes(lp);
225 @Override
public void onCreate(Bundle savedInstanceState)
227 super.onCreate(savedInstanceState);
231 this.setContentView(R.layout.session);
233 Log.v(TAG,
"Session.onCreate");
242 final View activityRootView = findViewById(R.id.session_root_view);
243 activityRootView.setFitsSystemWindows(
false);
244 ViewCompat.setOnApplyWindowInsetsListener(activityRootView,
245 (v, insets) -> onWindowInsetsChanged(v, insets));
246 activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
247 new OnGlobalLayoutListener() {
248 @Override
public void onGlobalLayout()
250 screen_width = scrollView.getWidth() - scrollView.getPaddingLeft() -
251 scrollView.getPaddingRight();
252 screen_height = scrollView.getHeight() - scrollView.getPaddingTop() -
253 scrollView.getPaddingBottom();
256 if (!sessionRunning && getIntent() !=
null)
258 processIntent(getIntent());
259 sessionRunning =
true;
264 sessionView = findViewById(R.id.sessionView);
265 sessionView.requestFocus();
267 touchPointerView = findViewById(R.id.touchPointerView);
270 @Override public void onToggleTouchPointer()
272 if (inputManager != null)
273 inputManager.toggleTouchPointer();
275 @Override
public void onToggleKeyboard()
277 if (inputManager !=
null)
278 inputManager.toggleKeyboard();
284 scrollView = findViewById(R.id.sessionScrollView);
285 scrollView.setScrollViewListener(
null);
286 railManager =
new RailWindowManager(
this, findViewById(R.id.railContainer), sessionView);
288 sessionViewModel.getState().observe(
this, this::onConnectionStateChanged);
291 @Override public void onUserCancel()
293 connectCancelledByUser = true;
300 sessionView.setSessionViewListener(inputManager);
301 touchPointerView.setTouchPointerListener(inputManager);
302 sessionView.setScaleGestureDetector(
303 new ScaleGestureDetector(
this, inputManager.getPinchZoomListener()));
305 mClipboardManager = ClipboardManagerProxy.getClipboardManager(
this);
306 mClipboardManager.addClipboardChangedListener(
this);
308 getOnBackPressedDispatcher().addCallback(
this,
new OnBackPressedCallback(
true) {
309 @Override
public void handleOnBackPressed()
318 @Override
public void onWindowFocusChanged(
boolean hasFocus)
320 super.onWindowFocusChanged(hasFocus);
324 mClipboardManager.getPrimaryClipManually();
328 @Override
protected void onStart()
331 Log.v(TAG,
"Session.onStart");
334 @Override
protected void onRestart()
337 Log.v(TAG,
"Session.onRestart");
340 @Override
protected void onResume()
343 Log.v(TAG,
"Session.onResume");
344 activeSession =
this;
347 @Override
protected void onPause()
350 Log.v(TAG,
"Session.onPause");
351 if (activeSession ==
this)
352 activeSession =
null;
354 inputManager.hideKeyboards();
357 @Override
protected void onStop()
360 Log.v(TAG,
"Session.onStop");
363 @Override
protected void onDestroy()
365 if (connectThread !=
null)
367 connectThread.interrupt();
370 Log.v(TAG,
"Session.onDestroy");
373 GlobalApp.cancelDisconnectTimer();
377 LibFreeRDP.disconnect(session.getInstance());
380 sessionViewModel.unregister();
383 mClipboardManager.removeClipboardboardChangedListener(
this);
386 GlobalApp.freeSession(session.getInstance());
391 @Override
public void onConfigurationChanged(Configuration newConfig)
393 super.onConfigurationChanged(newConfig);
398 if (session !=
null && session.getBookmark() !=
null &&
399 session.getBookmark().getActiveScreenSettings().isFitScreen())
401 scrollView.post(() -> {
402 if (screen_width > 0 && screen_height > 0)
403 LibFreeRDP.sendMonitorLayout(session.getInstance(), screen_width,
409 private WindowInsetsCompat onWindowInsetsChanged(View rootView, WindowInsetsCompat windowInsets)
411 boolean fitSafeArea = ApplicationSettingsActivity.getFitRoundedCorners(
this);
412 boolean hideStatusBar = ApplicationSettingsActivity.getHideStatusBar(
this);
413 boolean hideNavBar = ApplicationSettingsActivity.getHideNavigationBar(
this);
415 int insetsTop = windowInsets
416 .getInsets(WindowInsetsCompat.Type.statusBars() |
417 WindowInsetsCompat.Type.displayCutout())
419 rootView.setPadding(0, hideStatusBar ? 0 : insetsTop, 0, 0);
420 Insets navInsets = hideNavBar
422 : windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars());
423 if (floatingToolbar !=
null)
424 floatingToolbar.setInsets(navInsets.left, hideStatusBar ? 0 : insetsTop,
425 navInsets.right, navInsets.bottom);
427 int safeLeft = 0, safeTop = 0, safeRight = 0, safeBottom = 0;
428 if (fitSafeArea && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
430 WindowInsets platformInsets = windowInsets.toWindowInsets();
431 if (platformInsets !=
null)
433 boolean landscape = getResources().getConfiguration().orientation ==
434 Configuration.ORIENTATION_LANDSCAPE;
436 int radTL = cornerRadius(platformInsets, RoundedCorner.POSITION_TOP_LEFT);
437 int radBL = cornerRadius(platformInsets, RoundedCorner.POSITION_BOTTOM_LEFT);
438 int radTR = cornerRadius(platformInsets, RoundedCorner.POSITION_TOP_RIGHT);
439 int radBR = cornerRadius(platformInsets, RoundedCorner.POSITION_BOTTOM_RIGHT);
443 safeLeft = Math.max(0, Math.max(radTL, radBL) - rootView.getPaddingLeft());
444 safeRight = Math.max(0, Math.max(radTR, radBR) - rootView.getPaddingRight());
448 safeTop = Math.max(0, Math.max(radTL, radTR) - rootView.getPaddingTop());
449 safeBottom = Math.max(0, Math.max(radBL, radBR) - rootView.getPaddingBottom());
454 int imeBottom = windowInsets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
458 if (inputManager !=
null)
459 inputManager.onImeVisibilityChanged(imeBottom > 0);
461 View extKeyboard = findViewById(R.id.extended_keyboard);
462 if (extKeyboard instanceof ExtendedKeyboardView)
465 int kbdBottom = imeBottom > 0 ? 0 : navInsets.bottom;
466 ((ExtendedKeyboardView)extKeyboard)
467 .setInsets(Math.max(navInsets.left, safeLeft), Math.max(navInsets.right, safeRight),
473 boolean kbdVisible = extKeyboard !=
null && extKeyboard.getVisibility() == View.VISIBLE;
474 int scrollBottom = kbdVisible ? 0 : Math.max(safeBottom, navInsets.bottom);
475 scrollView.setPadding(Math.max(safeLeft, navInsets.left), safeTop,
476 Math.max(safeRight, navInsets.right), scrollBottom);
479 if (extKeyboard !=
null)
481 ViewGroup.MarginLayoutParams lp =
482 (ViewGroup.MarginLayoutParams)extKeyboard.getLayoutParams();
483 if (lp.bottomMargin != imeBottom)
485 lp.bottomMargin = imeBottom;
486 extKeyboard.setLayoutParams(lp);
490 return WindowInsetsCompat.CONSUMED;
493 @RequiresApi(Build.VERSION_CODES.S)
494 private static
int cornerRadius(WindowInsets insets,
int position)
496 RoundedCorner corner = insets.getRoundedCorner(position);
497 return (corner !=
null) ? corner.getRadius() : 0;
500 private void processIntent(Intent intent)
503 Bundle bundle = intent.getExtras();
504 Uri openUri = intent.getData();
511 else if (bundle.containsKey(PARAM_INSTANCE))
513 int inst = bundle.getInt(PARAM_INSTANCE);
514 session = GlobalApp.getSession(inst);
515 bitmap = session.getSurface().getBitmap();
518 else if (bundle.containsKey(PARAM_CONNECTION_REFERENCE))
520 String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
521 if (ConnectionReference.isHostnameReference(refStr))
523 BookmarkBase bookmark =
new BookmarkBase();
524 bookmark.setHostname(ConnectionReference.getHostname(refStr));
527 else if (ConnectionReference.isBookmarkReference(refStr))
529 sessionViewModel.loadBookmarkById(ConnectionReference.getBookmarkId(refStr),
531 if (bookmark != null)
534 closeSessionActivity(RESULT_CANCELED);
539 closeSessionActivity(RESULT_CANCELED);
545 closeSessionActivity(RESULT_CANCELED);
549 private void connect(BookmarkBase bookmark)
551 session = GlobalApp.createSession(bookmark, getApplicationContext());
553 BookmarkBase.ScreenSettings screenSettings =
554 session.getBookmark().getActiveScreenSettings();
555 Log.v(TAG,
"Screen Resolution: " + screenSettings.getResolutionString());
556 if (screenSettings.isAutomatic())
560 screenSettings.setHeight(screen_height);
561 screenSettings.setWidth(screen_width);
563 if (screenSettings.isFitScreen())
565 screenSettings.setHeight(screen_height);
566 screenSettings.setWidth(screen_width);
570 java.util.ArrayList<String> needed =
new java.util.ArrayList<>();
571 if (bookmark.getAdvancedSettings().getRedirectMicrophone() &&
572 checkSelfPermission(Manifest.permission.RECORD_AUDIO) !=
573 PackageManager.PERMISSION_GRANTED)
574 needed.add(Manifest.permission.RECORD_AUDIO);
575 if (bookmark.getAdvancedSettings().getRedirectCamera() &&
576 checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)
577 needed.add(Manifest.permission.CAMERA);
579 if (!needed.isEmpty())
581 pendingConnectBookmark = bookmark;
582 requestPermissions(needed.toArray(
new String[0]), REQUEST_MEDIA_PERMISSIONS);
586 connectWithTitle(bookmark.getLabel());
590 public void onRequestPermissionsResult(
int requestCode, @NonNull String[] permissions,
591 @NonNull
int[] grantResults)
593 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
594 if (requestCode == REQUEST_MEDIA_PERMISSIONS && pendingConnectBookmark !=
null)
596 BookmarkBase bookmark = pendingConnectBookmark;
597 pendingConnectBookmark =
null;
598 connectWithTitle(bookmark.getLabel());
602 private void connect(Uri openUri)
604 session = GlobalApp.createSession(openUri, getApplicationContext());
606 connectWithTitle(openUri.getAuthority());
609 static class ConnectThread
extends Thread
611 private final SessionState runnableSession;
612 private final Context context;
614 public ConnectThread(@NonNull Context context, @NonNull SessionState session)
616 this.context = context;
617 runnableSession = session;
622 runnableSession.connect(context.getApplicationContext());
626 private ConnectThread connectThread =
null;
628 private void connectWithTitle(String title)
630 session.setUIEventListener(
this);
632 sessionViewModel.register(session.getInstance());
634 dialogs.showProgress(title, () -> {
635 connectCancelledByUser =
true;
636 LibFreeRDP.cancelConnection(session.getInstance());
639 connectThread =
new ConnectThread(getApplicationContext(), session);
640 connectThread.start();
645 private void bindSession()
647 Log.v(TAG,
"bindSession called");
648 session.setUIEventListener(
this);
649 sessionView.onSurfaceChange(session);
650 scrollView.requestLayout();
652 Bitmap surface = session.getSurface() !=
null ? session.getSurface().getBitmap() :
null;
653 inputManager.attachSession(session.getInstance(), surface);
654 inputManager.setScreenSize(screen_width, screen_height);
656 View rootView = findViewById(R.id.session_root_view);
657 if (rootView !=
null)
658 ViewCompat.requestApplyInsets(rootView);
661 private void closeSessionActivity(
int resultCode)
664 setResult(resultCode, getIntent());
668 public void handleBackPressed()
671 if (inputManager !=
null)
673 if (inputManager.handleKeyboardBack())
675 if (inputManager.handleBackAsAltF4())
678 if (System.currentTimeMillis() - backPressedTime < 2000)
680 connectCancelledByUser =
true;
681 LibFreeRDP.disconnect(session.getInstance());
685 backPressedTime = System.currentTimeMillis();
686 Toast.makeText(
this, R.string.session_double_back_to_exit, Toast.LENGTH_SHORT).show();
690 @Override
public boolean onKeyLongPress(
int keyCode, KeyEvent event)
692 if (inputManager.onAndroidKeyLongPress(keyCode))
694 return super.onKeyLongPress(keyCode, event);
697 boolean handleKeyEvent(KeyEvent event)
699 return inputManager !=
null && inputManager.onAndroidKeyEvent(event);
708 @Override
public boolean onKeyDown(
int keycode, KeyEvent event)
710 if (keycode == KeyEvent.KEYCODE_BACK)
711 return super.onKeyDown(keycode, event);
712 return inputManager.onAndroidKeyEvent(event);
715 @Override
public boolean onKeyUp(
int keycode, KeyEvent event)
717 if (keycode == KeyEvent.KEYCODE_BACK)
718 return super.onKeyUp(keycode, event);
719 return inputManager.onAndroidKeyEvent(event);
724 @Override
public boolean onKeyMultiple(
int keyCode,
int repeatCount, KeyEvent event)
726 return inputManager.onAndroidKeyEvent(event);
734 @Override
public void OnSettingsChanged(
int width,
int height,
int bpp)
738 bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
740 bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
742 session.setSurface(
new BitmapDrawable(getResources(), bitmap));
744 if (inputManager !=
null)
745 inputManager.setBitmap(bitmap);
747 if (session.getBookmark() ==
null)
757 BookmarkBase.ScreenSettings settings = session.getBookmark().getActiveScreenSettings();
758 if ((settings.getWidth() != width && settings.getWidth() != width + 1) ||
759 settings.getHeight() != height || settings.getColors() != bpp)
760 uiHandler.sendMessage(Message.obtain(
761 null, DISPLAY_TOAST, getResources().getText(R.string.info_capabilities_changed)));
764 @Override
public void OnGraphicsUpdate(
int x,
int y,
int width,
int height)
766 LibFreeRDP.updateGraphics(session.getInstance(), bitmap, x, y, width, height);
768 sessionView.addInvalidRegion(
new Rect(x, y, x + width, y + height));
775 uiHandler.sendEmptyMessage(REFRESH_SESSIONVIEW);
778 @Override
public void OnGraphicsResize(
int width,
int height,
int bpp)
782 bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
784 bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
785 session.setSurface(
new BitmapDrawable(getResources(), bitmap));
787 if (inputManager !=
null)
788 inputManager.setBitmap(bitmap);
794 uiHandler.sendEmptyMessage(GRAPHICS_CHANGED);
798 public boolean OnAuthenticate(StringBuilder username, StringBuilder domain,
799 StringBuilder password)
805 public boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain,
806 StringBuilder password)
808 return dialogs.promptCredentials(username, domain, password);
812 public int OnVerifiyCertificateEx(String host,
long port, String commonName, String subject,
813 String issuer, String fingerprint,
long flags)
815 if (ApplicationSettingsActivity.getAcceptAllCertificates(
this))
817 return dialogs.verifyCertificate(host, port, subject, issuer, fingerprint, flags);
821 public int OnVerifyChangedCertificateEx(String host,
long port, String commonName,
822 String subject, String issuer, String fingerprint,
823 String oldSubject, String oldIssuer,
824 String oldFingerprint,
long flags)
826 if (ApplicationSettingsActivity.getAcceptAllCertificates(
this))
828 return dialogs.verifyChangedCertificate(host, port, subject, issuer, fingerprint, flags);
831 @Override
public boolean OnExperimentalFeature(
int feature)
833 final String featureKey;
834 final String displayName;
837 case LibFreeRDP.EXPERIMENTAL_REMOTEAPP:
838 featureKey =
"remoteapp";
839 displayName = getString(R.string.experimental_feature_remoteapp);
841 case LibFreeRDP.EXPERIMENTAL_CAMERA:
842 featureKey =
"camera";
843 displayName = getString(R.string.experimental_feature_camera);
848 if (ApplicationSettingsActivity.isExperimentalEnabled(
this, featureKey))
851 connectCancelledByUser =
true;
852 dialogs.showExperimentalBlocked(displayName);
856 @Override
public void OnRemoteClipboardChanged(String data)
858 Log.v(TAG,
"OnRemoteClipboardChanged: " + data);
859 mClipboardManager.setClipboardData(data);
862 @Override
public void OnRemoteClipboardImageChanged(
byte[] data)
864 Log.v(TAG,
"OnRemoteClipboardImageChanged: " + data.length +
" bytes");
865 mClipboardManager.setClipboardImage(data);
868 @Override
public void OnPointerSet(
int[] pixels,
int width,
int height,
int hotX,
int hotY)
870 Bundle data =
new Bundle();
871 data.putIntArray(
"pixels", pixels);
872 data.putInt(
"width", width);
873 data.putInt(
"height", height);
874 data.putInt(
"hotX", hotX);
875 data.putInt(
"hotY", hotY);
876 Message msg = uiHandler.obtainMessage(POINTER_SET);
878 uiHandler.sendMessage(msg);
881 @Override
public void OnPointerSetNull()
883 uiHandler.sendEmptyMessage(POINTER_SET);
886 @Override
public void OnPointerSetDefault()
888 sessionView.setDefaultCursor();
891 @Override
public void OnRailWindowUpdate(
long windowId,
int width,
int height,
int[] pixels)
893 railManager.onWindowUpdate(windowId, width, height, pixels);
896 @Override
public void OnRailWindowMove(
long windowId,
int x,
int y,
int w,
int h)
898 railManager.onWindowMove(windowId, x, y, w, h);
901 @Override
public void OnRailWindowHide(
long windowId)
903 railManager.onWindowHide(windowId);
906 @Override
public void OnRailWindowDestroy(
long windowId)
908 railManager.onWindowDestroy(windowId);
911 @Override
public void OnRailSessionEnd()
913 railManager.onSessionEnd();
916 @Override
public void OnRailMonitoredDesktop(
long[] windowIds,
long activeWindowId)
918 railManager.onMonitoredDesktop(windowIds, activeWindowId);
925 @Override
public boolean onGenericMotionEvent(MotionEvent e)
927 super.onGenericMotionEvent(e);
928 return inputManager !=
null && inputManager.onGenericMotionEvent(e);
933 @Override
public void onClipboardChanged(String data)
935 Log.v(TAG,
"onClipboardChanged: " + data);
937 LibFreeRDP.sendClipboardData(session.getInstance(), data);
940 @Override
public void onClipboardImageChanged(
byte[] data, String mimeType)
942 if (session !=
null && data !=
null)
943 LibFreeRDP.sendClipboardImageData(session.getInstance(), data, mimeType);
946 private void onConnectionStateChanged(SessionViewModel.ConnectionState state)
953 onSessionConnected();
959 onSessionDisconnected();
966 private void onSessionConnected()
968 Log.v(TAG,
"onSessionConnected");
970 if (connectCancelledByUser)
972 LibFreeRDP.disconnect(session.getInstance());
973 closeSessionActivity(RESULT_CANCELED);
980 if (ApplicationSettingsActivity.getKeepScreenOnWhenConnected(
this))
982 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
985 dialogs.dismissProgress();
987 if (session.getBookmark() ==
null)
994 Bundle bundle = getIntent().getExtras();
995 if (bundle !=
null && bundle.containsKey(PARAM_CONNECTION_REFERENCE))
997 if (ConnectionReference.isHostnameReference(
998 bundle.getString(PARAM_CONNECTION_REFERENCE)))
1000 assert session.getBookmark().getType() == BookmarkBase.TYPE_MANUAL;
1001 sessionViewModel.recordQuickConnectHistory(session.getBookmark().getHostname());
1006 private void onSessionFailed()
1008 Log.v(TAG,
"onSessionFailed");
1011 if (inputManager !=
null)
1012 inputManager.cancelPendingEvents();
1017 if (!connectCancelledByUser)
1018 uiHandler.sendMessage(Message.obtain(
1019 null, DISPLAY_TOAST, getResources().getText(R.string.error_connection_failure)));
1021 closeSessionActivity(RESULT_CANCELED);
1024 private void onSessionDisconnected()
1026 Log.v(TAG,
"onSessionDisconnected");
1029 if (inputManager !=
null)
1030 inputManager.cancelPendingEvents();
1032 if (ApplicationSettingsActivity.getKeepScreenOnWhenConnected(
this))
1034 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
1039 railManager.clear();
1041 session.setUIEventListener(
null);
1042 closeSessionActivity(RESULT_OK);