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;
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;
134 private boolean connectCancelledByUser =
false;
135 private boolean sessionRunning =
false;
136 private long backPressedTime = 0;
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 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
170 getWindow().setNavigationBarContrastEnforced(
false);
172 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
177 toHide |= WindowInsetsCompat.Type.statusBars();
179 toShow |= WindowInsetsCompat.Type.statusBars();
182 toHide |= WindowInsetsCompat.Type.navigationBars();
184 toShow |= WindowInsetsCompat.Type.navigationBars();
190 controller.setSystemBarsBehavior(
191 WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
192 controller.hide(toHide);
197 controller.show(toShow);
203 int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
204 View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
206 flags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
208 flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
209 if ((flags & (View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)) !=
211 flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
213 getWindow().getDecorView().setSystemUiVisibility(flags);
216 WindowManager.LayoutParams lp = getWindow().getAttributes();
217 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
218 lp.layoutInDisplayCutoutMode =
219 WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
220 else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
221 lp.layoutInDisplayCutoutMode =
222 WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
223 getWindow().setAttributes(lp);
226 @Override
public void onCreate(Bundle savedInstanceState)
228 super.onCreate(savedInstanceState);
232 this.setContentView(R.layout.session);
234 Log.v(TAG,
"Session.onCreate");
243 final View activityRootView = findViewById(R.id.session_root_view);
244 activityRootView.setFitsSystemWindows(
false);
245 ViewCompat.setOnApplyWindowInsetsListener(activityRootView,
246 (v, insets) -> onWindowInsetsChanged(v, insets));
247 activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
248 new OnGlobalLayoutListener() {
249 @Override
public void onGlobalLayout()
251 screen_width = scrollView.getWidth() - scrollView.getPaddingLeft() -
252 scrollView.getPaddingRight();
253 screen_height = scrollView.getHeight() - scrollView.getPaddingTop() -
254 scrollView.getPaddingBottom();
257 if (!sessionRunning && getIntent() !=
null)
259 processIntent(getIntent());
260 sessionRunning =
true;
265 sessionView = findViewById(R.id.sessionView);
266 sessionView.requestFocus();
268 touchPointerView = findViewById(R.id.touchPointerView);
271 @Override public void onToggleTouchPointer()
273 if (inputManager != null)
274 inputManager.toggleTouchPointer();
276 @Override
public void onToggleKeyboard()
278 if (inputManager !=
null)
279 inputManager.toggleKeyboard();
285 scrollView = findViewById(R.id.sessionScrollView);
286 scrollView.setScrollViewListener(
null);
287 railManager =
new RailWindowManager(
this, findViewById(R.id.railContainer), sessionView);
289 sessionViewModel.getState().observe(
this, this::onConnectionStateChanged);
292 @Override public void onUserCancel()
294 connectCancelledByUser = true;
301 sessionView.setSessionViewListener(inputManager);
302 touchPointerView.setTouchPointerListener(inputManager);
303 sessionView.setScaleGestureDetector(
304 new ScaleGestureDetector(
this, inputManager.getPinchZoomListener()));
307 mClipboardManager.addClipboardChangedListener(
this);
309 getOnBackPressedDispatcher().addCallback(
this,
new OnBackPressedCallback(
true) {
310 @Override
public void handleOnBackPressed()
319 @Override
public void onWindowFocusChanged(
boolean hasFocus)
321 super.onWindowFocusChanged(hasFocus);
325 mClipboardManager.getPrimaryClipManually();
329 @Override
protected void onStart()
332 Log.v(TAG,
"Session.onStart");
334 LibFreeRDP.setForeground(session.getInstance(),
true);
337 @Override
protected void onRestart()
340 Log.v(TAG,
"Session.onRestart");
343 @Override
protected void onResume()
346 Log.v(TAG,
"Session.onResume");
347 activeSession =
this;
350 @Override
protected void onPause()
353 Log.v(TAG,
"Session.onPause");
354 if (activeSession ==
this)
355 activeSession =
null;
357 inputManager.hideKeyboards();
360 @Override
protected void onStop()
363 Log.v(TAG,
"Session.onStop");
365 LibFreeRDP.setForeground(session.getInstance(),
false);
368 @Override
protected void onDestroy()
370 if (connectThread !=
null)
372 connectThread.interrupt();
375 Log.v(TAG,
"Session.onDestroy");
378 GlobalApp.cancelDisconnectTimer();
382 LibFreeRDP.disconnect(session.getInstance());
385 sessionViewModel.unregister();
388 mClipboardManager.removeClipboardboardChangedListener(
this);
391 GlobalApp.freeSession(session.getInstance());
396 @Override
public void onConfigurationChanged(Configuration newConfig)
398 super.onConfigurationChanged(newConfig);
403 if (session !=
null && session.getBookmark() !=
null &&
404 session.getBookmark().getActiveScreenSettings().isFitScreen())
406 scrollView.post(() -> {
407 if (screen_width > 0 && screen_height > 0)
408 LibFreeRDP.sendMonitorLayout(session.getInstance(), screen_width,
414 private WindowInsetsCompat onWindowInsetsChanged(View rootView, WindowInsetsCompat windowInsets)
416 boolean fitSafeArea = ApplicationSettingsActivity.getFitRoundedCorners(
this);
417 boolean hideStatusBar = ApplicationSettingsActivity.getHideStatusBar(
this);
418 boolean hideNavBar = ApplicationSettingsActivity.getHideNavigationBar(
this);
420 int insetsTop = windowInsets
421 .getInsets(WindowInsetsCompat.Type.statusBars() |
422 WindowInsetsCompat.Type.displayCutout())
424 rootView.setPadding(0, hideStatusBar ? 0 : insetsTop, 0, 0);
425 Insets navInsets = hideNavBar
427 : windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars());
428 if (floatingToolbar !=
null)
429 floatingToolbar.setInsets(navInsets.left, hideStatusBar ? 0 : insetsTop,
430 navInsets.right, navInsets.bottom);
432 int safeLeft = 0, safeTop = 0, safeRight = 0, safeBottom = 0;
433 if (fitSafeArea && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
435 WindowInsets platformInsets = windowInsets.toWindowInsets();
436 if (platformInsets !=
null)
438 boolean landscape = getResources().getConfiguration().orientation ==
439 Configuration.ORIENTATION_LANDSCAPE;
441 int radTL = cornerRadius(platformInsets, RoundedCorner.POSITION_TOP_LEFT);
442 int radBL = cornerRadius(platformInsets, RoundedCorner.POSITION_BOTTOM_LEFT);
443 int radTR = cornerRadius(platformInsets, RoundedCorner.POSITION_TOP_RIGHT);
444 int radBR = cornerRadius(platformInsets, RoundedCorner.POSITION_BOTTOM_RIGHT);
448 safeLeft = Math.max(0, Math.max(radTL, radBL) - rootView.getPaddingLeft());
449 safeRight = Math.max(0, Math.max(radTR, radBR) - rootView.getPaddingRight());
453 safeTop = Math.max(0, Math.max(radTL, radTR) - rootView.getPaddingTop());
454 safeBottom = Math.max(0, Math.max(radBL, radBR) - rootView.getPaddingBottom());
459 int imeBottom = windowInsets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
463 if (inputManager !=
null)
464 inputManager.onImeVisibilityChanged(imeBottom > 0);
466 View extKeyboard = findViewById(R.id.extended_keyboard);
467 if (extKeyboard instanceof ExtendedKeyboardView)
470 int kbdBottom = imeBottom > 0 ? 0 : navInsets.bottom;
471 ((ExtendedKeyboardView)extKeyboard)
472 .setInsets(Math.max(navInsets.left, safeLeft), Math.max(navInsets.right, safeRight),
478 boolean kbdVisible = extKeyboard !=
null && extKeyboard.getVisibility() == View.VISIBLE;
479 int scrollBottom = kbdVisible ? 0 : Math.max(safeBottom, navInsets.bottom);
480 scrollView.setPadding(Math.max(safeLeft, navInsets.left), safeTop,
481 Math.max(safeRight, navInsets.right), scrollBottom);
484 if (extKeyboard !=
null)
486 ViewGroup.MarginLayoutParams lp =
487 (ViewGroup.MarginLayoutParams)extKeyboard.getLayoutParams();
488 if (lp.bottomMargin != imeBottom)
490 lp.bottomMargin = imeBottom;
491 extKeyboard.setLayoutParams(lp);
495 return WindowInsetsCompat.CONSUMED;
498 @RequiresApi(Build.VERSION_CODES.S)
499 private static
int cornerRadius(WindowInsets insets,
int position)
501 RoundedCorner corner = insets.getRoundedCorner(position);
502 return (corner !=
null) ? corner.getRadius() : 0;
505 private void processIntent(Intent intent)
508 Bundle bundle = intent.getExtras();
509 Uri openUri = intent.getData();
516 else if (bundle.containsKey(PARAM_INSTANCE))
518 int inst = bundle.getInt(PARAM_INSTANCE);
519 session = GlobalApp.getSession(inst);
520 bitmap = session.getSurface().getBitmap();
523 else if (bundle.containsKey(PARAM_CONNECTION_REFERENCE))
525 String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
526 if (ConnectionReference.isHostnameReference(refStr))
528 BookmarkBase bookmark =
new BookmarkBase();
529 bookmark.setHostname(ConnectionReference.getHostname(refStr));
532 else if (ConnectionReference.isBookmarkReference(refStr))
534 sessionViewModel.loadBookmarkById(ConnectionReference.getBookmarkId(refStr),
536 if (bookmark != null)
539 closeSessionActivity(RESULT_CANCELED);
544 closeSessionActivity(RESULT_CANCELED);
550 closeSessionActivity(RESULT_CANCELED);
554 private void connect(BookmarkBase bookmark)
556 session = GlobalApp.createSession(bookmark, getApplicationContext());
558 BookmarkBase.ScreenSettings screenSettings =
559 session.getBookmark().getActiveScreenSettings();
560 Log.v(TAG,
"Screen Resolution: " + screenSettings.getResolutionString());
561 if (screenSettings.isAutomatic())
565 screenSettings.setHeight(screen_height);
566 screenSettings.setWidth(screen_width);
568 if (screenSettings.isFitScreen())
570 screenSettings.setHeight(screen_height);
571 screenSettings.setWidth(screen_width);
576 java.util.ArrayList<String> needed =
new java.util.ArrayList<>();
577 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CINNAMON_BUN)
579 final String permission = Manifest.permission.ACCESS_LOCAL_NETWORK;
581 if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED)
582 needed.add(permission);
585 if (bookmark.getAdvancedSettings().getRedirectMicrophone() &&
586 checkSelfPermission(Manifest.permission.RECORD_AUDIO) !=
587 PackageManager.PERMISSION_GRANTED)
588 needed.add(Manifest.permission.RECORD_AUDIO);
589 if (bookmark.getAdvancedSettings().getRedirectCamera() &&
590 checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)
591 needed.add(Manifest.permission.CAMERA);
593 if (!needed.isEmpty())
595 pendingConnectBookmark = bookmark;
596 requestPermissions(needed.toArray(
new String[0]), REQUEST_MEDIA_PERMISSIONS);
600 connectWithTitle(bookmark.getLabel());
604 public void onRequestPermissionsResult(
int requestCode, @NonNull String[] permissions,
605 @NonNull
int[] grantResults)
607 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
608 if (requestCode == REQUEST_MEDIA_PERMISSIONS && pendingConnectBookmark !=
null)
610 BookmarkBase bookmark = pendingConnectBookmark;
611 pendingConnectBookmark =
null;
612 connectWithTitle(bookmark.getLabel());
616 private void connect(Uri openUri)
618 session = GlobalApp.createSession(openUri, getApplicationContext());
620 connectWithTitle(openUri.getAuthority());
623 static class ConnectThread
extends Thread
625 private final SessionState runnableSession;
626 private final Context context;
628 public ConnectThread(@NonNull Context context, @NonNull SessionState session)
630 this.context = context;
631 runnableSession = session;
636 runnableSession.connect(context.getApplicationContext());
640 private ConnectThread connectThread =
null;
642 private void connectWithTitle(String title)
644 session.setUIEventListener(
this);
646 sessionViewModel.register(session.getInstance());
648 dialogs.showProgress(title, () -> {
649 connectCancelledByUser =
true;
650 LibFreeRDP.cancelConnection(session.getInstance());
653 connectThread =
new ConnectThread(getApplicationContext(), session);
654 connectThread.start();
659 private void bindSession()
661 Log.v(TAG,
"bindSession called");
662 session.setUIEventListener(
this);
663 sessionView.onSurfaceChange(session);
664 scrollView.requestLayout();
666 Bitmap surface = session.getSurface() !=
null ? session.getSurface().getBitmap() :
null;
667 inputManager.attachSession(session.getInstance(), surface);
668 inputManager.setScreenSize(screen_width, screen_height);
670 View rootView = findViewById(R.id.session_root_view);
671 if (rootView !=
null)
672 ViewCompat.requestApplyInsets(rootView);
675 private void closeSessionActivity(
int resultCode)
678 setResult(resultCode, getIntent());
682 public void handleBackPressed()
685 if (inputManager !=
null)
687 if (inputManager.handleKeyboardBack())
689 if (inputManager.handleBackAsAltF4())
692 if (System.currentTimeMillis() - backPressedTime < 2000)
694 connectCancelledByUser =
true;
695 LibFreeRDP.disconnect(session.getInstance());
699 backPressedTime = System.currentTimeMillis();
700 Toast.makeText(
this, R.string.session_double_back_to_exit, Toast.LENGTH_SHORT).show();
704 @Override
public boolean onKeyLongPress(
int keyCode, KeyEvent event)
706 if (inputManager.onAndroidKeyLongPress(keyCode))
708 return super.onKeyLongPress(keyCode, event);
711 boolean handleKeyEvent(KeyEvent event)
713 return inputManager !=
null && inputManager.onAndroidKeyEvent(event);
722 @Override
public boolean onKeyDown(
int keycode, KeyEvent event)
724 if (keycode == KeyEvent.KEYCODE_BACK)
725 return super.onKeyDown(keycode, event);
726 return inputManager.onAndroidKeyEvent(event);
729 @Override
public boolean onKeyUp(
int keycode, KeyEvent event)
731 if (keycode == KeyEvent.KEYCODE_BACK)
732 return super.onKeyUp(keycode, event);
733 return inputManager.onAndroidKeyEvent(event);
738 @Override
public boolean onKeyMultiple(
int keyCode,
int repeatCount, KeyEvent event)
740 return inputManager.onAndroidKeyEvent(event);
748 @Override
public void OnSettingsChanged(
int width,
int height,
int bpp)
752 bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
754 bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
756 session.setSurface(
new BitmapDrawable(getResources(), bitmap));
758 if (inputManager !=
null)
759 inputManager.setBitmap(bitmap);
761 if (session.getBookmark() ==
null)
771 BookmarkBase.ScreenSettings settings = session.getBookmark().getActiveScreenSettings();
772 if ((settings.getWidth() != width && settings.getWidth() != width + 1) ||
773 settings.getHeight() != height || settings.getColors() != bpp)
774 uiHandler.sendMessage(Message.obtain(
775 null, DISPLAY_TOAST, getResources().getText(R.string.info_capabilities_changed)));
778 @Override
public void OnGraphicsUpdate(
int x,
int y,
int width,
int height)
780 LibFreeRDP.updateGraphics(session.getInstance(), bitmap, x, y, width, height);
782 sessionView.addInvalidRegion(
new Rect(x, y, x + width, y + height));
789 uiHandler.sendEmptyMessage(REFRESH_SESSIONVIEW);
792 @Override
public void OnReconnecting()
794 railManager.onSessionEnd();
795 uiHandler.sendMessage(Message.obtain(
null, DISPLAY_TOAST,
796 getResources().getText(R.string.info_reconnecting)));
799 @Override
public void OnGraphicsResize(
int width,
int height,
int bpp)
803 bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
805 bitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
806 session.setSurface(
new BitmapDrawable(getResources(), bitmap));
808 if (inputManager !=
null)
809 inputManager.setBitmap(bitmap);
815 uiHandler.sendEmptyMessage(GRAPHICS_CHANGED);
819 public boolean OnAuthenticate(StringBuilder username, StringBuilder domain,
820 StringBuilder password)
822 return dialogs.promptCredentials(username, domain, password);
826 public boolean OnGatewayAuthenticate(StringBuilder username, StringBuilder domain,
827 StringBuilder password)
829 return dialogs.promptCredentials(username, domain, password);
833 public int OnVerifiyCertificateEx(String host,
long port, String commonName, String subject,
834 String issuer, String fingerprint,
long flags)
836 if (ApplicationSettingsActivity.getAcceptAllCertificates(
this))
838 return dialogs.verifyCertificate(host, port, subject, issuer, fingerprint, flags);
842 public int OnVerifyChangedCertificateEx(String host,
long port, String commonName,
843 String subject, String issuer, String fingerprint,
844 String oldSubject, String oldIssuer,
845 String oldFingerprint,
long flags)
847 if (ApplicationSettingsActivity.getAcceptAllCertificates(
this))
849 return dialogs.verifyChangedCertificate(host, port, subject, issuer, fingerprint, flags);
852 @Override
public boolean OnExperimentalFeature(
int feature)
854 final String featureKey;
855 final String displayName;
858 case LibFreeRDP.EXPERIMENTAL_REMOTEAPP:
859 featureKey =
"remoteapp";
860 displayName = getString(R.string.experimental_feature_remoteapp);
862 case LibFreeRDP.EXPERIMENTAL_CAMERA:
863 featureKey =
"camera";
864 displayName = getString(R.string.experimental_feature_camera);
869 if (ApplicationSettingsActivity.isExperimentalEnabled(
this, featureKey))
872 connectCancelledByUser =
true;
873 dialogs.showExperimentalBlocked(displayName);
877 @Override
public void OnRemoteClipboardChanged(String data)
879 Log.v(TAG,
"OnRemoteClipboardChanged: " + data);
880 mClipboardManager.setClipboardData(data);
883 @Override
public void OnRemoteClipboardImageChanged(
byte[] data)
885 Log.v(TAG,
"OnRemoteClipboardImageChanged: " + data.length +
" bytes");
886 mClipboardManager.setClipboardImage(data);
889 @Override
public void OnPointerSet(
int[] pixels,
int width,
int height,
int hotX,
int hotY)
891 Bundle data =
new Bundle();
892 data.putIntArray(
"pixels", pixels);
893 data.putInt(
"width", width);
894 data.putInt(
"height", height);
895 data.putInt(
"hotX", hotX);
896 data.putInt(
"hotY", hotY);
897 Message msg = uiHandler.obtainMessage(POINTER_SET);
899 uiHandler.sendMessage(msg);
902 @Override
public void OnPointerSetNull()
904 uiHandler.sendEmptyMessage(POINTER_SET);
907 @Override
public void OnPointerSetDefault()
909 sessionView.setDefaultCursor();
912 @Override
public void OnRailWindowUpdate(
long windowId,
int width,
int height,
int[] pixels)
914 railManager.onWindowUpdate(windowId, width, height, pixels);
917 @Override
public void OnRailWindowMove(
long windowId,
int x,
int y,
int w,
int h)
919 railManager.onWindowMove(windowId, x, y, w, h);
922 @Override
public void OnRailWindowHide(
long windowId)
924 railManager.onWindowHide(windowId);
927 @Override
public void OnRailWindowDestroy(
long windowId)
929 railManager.onWindowDestroy(windowId);
932 @Override
public void OnRailSessionEnd()
934 railManager.onSessionEnd();
937 @Override
public void OnRailMonitoredDesktop(
long[] windowIds,
long activeWindowId)
939 railManager.onMonitoredDesktop(windowIds, activeWindowId);
946 @Override
public boolean onGenericMotionEvent(MotionEvent e)
948 super.onGenericMotionEvent(e);
949 return inputManager !=
null && inputManager.onGenericMotionEvent(e);
954 @Override
public void onClipboardChanged(String data)
956 Log.v(TAG,
"onClipboardChanged: " + data);
958 LibFreeRDP.sendClipboardData(session.getInstance(), data);
961 @Override
public void onClipboardImageChanged(
byte[] data, String mimeType)
963 if (session !=
null && data !=
null)
964 LibFreeRDP.sendClipboardImageData(session.getInstance(), data, mimeType);
967 private void onConnectionStateChanged(SessionViewModel.ConnectionState state)
974 onSessionConnected();
980 onSessionDisconnected();
987 private void onSessionConnected()
989 Log.v(TAG,
"onSessionConnected");
991 if (connectCancelledByUser)
993 LibFreeRDP.disconnect(session.getInstance());
994 closeSessionActivity(RESULT_CANCELED);
1001 if (ApplicationSettingsActivity.getKeepScreenOnWhenConnected(
this))
1003 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
1006 dialogs.dismissProgress();
1008 if (session.getBookmark() ==
null)
1015 Bundle bundle = getIntent().getExtras();
1016 if (bundle !=
null && bundle.containsKey(PARAM_CONNECTION_REFERENCE))
1018 if (ConnectionReference.isHostnameReference(
1019 bundle.getString(PARAM_CONNECTION_REFERENCE)))
1021 assert session.getBookmark().getType() == BookmarkBase.TYPE_MANUAL;
1022 sessionViewModel.recordQuickConnectHistory(session.getBookmark().getHostname());
1027 private void onSessionFailed()
1029 Log.v(TAG,
"onSessionFailed");
1032 if (inputManager !=
null)
1033 inputManager.cancelPendingEvents();
1035 dialogs.dismissProgress();
1038 if (!connectCancelledByUser)
1039 uiHandler.sendMessage(Message.obtain(
1040 null, DISPLAY_TOAST, getResources().getText(R.string.error_connection_failure)));
1042 closeSessionActivity(RESULT_CANCELED);
1045 private void onSessionDisconnected()
1047 Log.v(TAG,
"onSessionDisconnected");
1050 if (inputManager !=
null)
1051 inputManager.cancelPendingEvents();
1053 if (ApplicationSettingsActivity.getKeepScreenOnWhenConnected(
this))
1055 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
1058 dialogs.dismissProgress();
1060 railManager.clear();
1062 session.setUIEventListener(
null);
1063 closeSessionActivity(RESULT_OK);