//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public AndroidDevice GetPrioritisedConnectedDevice() { // // Refresh ADB service and evaluate a list of connected devices or emulators. // // We want to prioritise devices over emulators here, which makes the logic a little dodgy. // LoggingUtils.PrintFunction(); AndroidDevice debuggingDevice = null; AndroidDevice [] connectedDevices = AndroidAdb.GetConnectedDevices(); if (connectedDevices.Length > 0) { for (int i = 0; i < connectedDevices.Length; ++i) { if (!connectedDevices [i].IsEmulator) { debuggingDevice = connectedDevices [i]; } } if (debuggingDevice == null) { debuggingDevice = connectedDevices [0]; } } return(debuggingDevice); }
public static void CaptureDeviceInfo(this IDiagnosticsData data, AndroidDevice device) { data.Target = device.Architecture; data.TargetOS = "API " + device.ApiVersion; data.Device = device.DeviceSerial; data.IsDevice = !device.DeviceSerial.ToLowerInvariant().StartsWith("emulator"); }
public static string GenerateUserAgent(this AndroidDevice deviceInfo, InstaApiVersion apiVersion) { if (deviceInfo == null) { return(InstaApiConstants.UserAgentDefault); } if (deviceInfo.AndroidVer == null) { deviceInfo.AndroidVer = AndroidVersion.GetRandomAndriodVersion(); } return(string.Format( InstaApiConstants.UserAgent, deviceInfo.Dpi, deviceInfo.Resolution, deviceInfo.HardwareManufacturer, deviceInfo.DeviceModelIdentifier, deviceInfo.FirmwareBrand, deviceInfo.HardwareModel, apiVersion.AppVersion, deviceInfo.AndroidVer.ApiLevel, deviceInfo.AndroidVer.VersionNumber, apiVersion.AppApiVersionCode)); }
private void btnConnect_Click(object sender, EventArgs e) { if (AndroidDevice.ConnectOverWifi(config.Get("defaultDeviceIp"))) { updTask.RunWorkerAsync(); } }
public static async void Logout() { var device = new AndroidDevice { AndroidBoardName = "msm8996", AndroidBootloader = "G935TUVU3APG1", DeviceBrand = "samsung", DeviceModel = "SM-G935T", DeviceModelBoot = "qcom", DeviceModelIdentifier = "hero2qltetmo", FirmwareBrand = "hero2qltetmo", FirmwareFingerprint = "samsung/hero2qltetmo/hero2qltetmo:6.0.1/MMB29M/G935TUVU3APG1:user/release-keys", FirmwareTags = "release-keys", FirmwareType = "user", HardwareManufacturer = "samsung", HardwareModel = "SM-G935T", DeviceGuid = Guid.NewGuid(), PhoneGuid = Guid.NewGuid(), Resolution = "1440x2560", Dpi = "640dpi" }; api.SetDevice(device); var logoutRequest = await api.LogoutAsync(); Success("Logged out."); }
private void frmWaiting_Shown(object sender, EventArgs e) { this.Refresh(); AndroidDevice.WaitForDevice(); parent.Show(); this.Close(); }
public PushClient(Instagram api, bool tryLoadData = true) { _instaApi = api ?? throw new ArgumentException("Api can't be null", nameof(api)); _user = api.Session; _device = api.Device; if (tryLoadData) { ConnectionData.LoadFromAppSettings(); } // If token is older than 24 hours then discard it if ((DateTimeOffset.Now - ConnectionData.FbnsTokenLastUpdated).TotalHours > 24) { ConnectionData.FbnsToken = ""; } // Build user agent for first time setup if (string.IsNullOrEmpty(ConnectionData.UserAgent)) { ConnectionData.UserAgent = FbnsUserAgent.BuildFbUserAgent(_device); } NetworkInformation.NetworkStatusChanged += async sender => { var internetProfile = NetworkInformation.GetInternetConnectionProfile(); if (internetProfile == null || _loopGroup == null) { return; } await Shutdown(); await StartFresh(); }; }
public HttpRequestMessage GetSignedRequest(HttpMethod method, Uri uri, AndroidDevice deviceInfo, JObject data) { var hash = CryptoHelper.CalculateHash(_apiVersion.SignatureKey, data.ToString(Formatting.None)); var payload = data.ToString(Formatting.None); var signature = $"{(IsNewerApis ? _apiVersion.SignatureKey : hash)}.{payload}"; var fields = new Dictionary <string, string> { { InstaApiConstants.HEADER_IG_SIGNATURE, signature }, }; if (!IsNewerApis) { fields.Add(InstaApiConstants.HEADER_IG_SIGNATURE_KEY_VERSION, InstaApiConstants.IG_SIGNATURE_KEY_VERSION); } var request = GetDefaultRequest(HttpMethod.Post, uri, deviceInfo); request.Content = new FormUrlEncodedContent(fields); request.Properties.Add(InstaApiConstants.HEADER_IG_SIGNATURE, signature); if (!IsNewerApis) { request.Properties.Add(InstaApiConstants.HEADER_IG_SIGNATURE_KEY_VERSION, InstaApiConstants.IG_SIGNATURE_KEY_VERSION); } return(request); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected int CreatePort(IDebugPortRequest2 portRequest, out IDebugPort2 port) { LoggingUtils.PrintFunction(); try { string requestPortName; LoggingUtils.RequireOk(portRequest.GetPortName(out requestPortName)); if (string.IsNullOrWhiteSpace(requestPortName)) { throw new InvalidOperationException("Invalid/empty port name"); } AndroidDevice device = AndroidAdb.GetConnectedDeviceById(requestPortName); if (device == null) { throw new InvalidOperationException("Failed to find a device with the name: " + requestPortName); } port = new DebuggeePort(this, device); return(Constants.S_OK); } catch (Exception e) { LoggingUtils.HandleException(e); port = null; return(Constants.E_FAIL); } }
public IInstaApi Build() { if (_httpClient == null) { _httpClient = new HttpClient(_httpHandler); _httpClient.BaseAddress = new Uri(InstaApiConstants.INSTAGRAM_URL); } AndroidDevice device = null; if (_requestMessage == null) { device = AndroidDeviceGenerator.GetRandomAndroidDevice(); _requestMessage = new ApiRequestMessage { phone_id = device.PhoneGuid.ToString(), guid = device.DeviceGuid, password = _user?.Password, username = _user?.UserName, device_id = ApiRequestMessage.GenerateDeviceId() }; } var instaApi = new InstaApi(_user, _logger, _httpClient, _httpHandler, _requestMessage, device); return(instaApi); }
public HttpRequestMessage GetDefaultRequest(HttpMethod method, Uri uri, AndroidDevice deviceInfo, Dictionary <string, string> data) { var request = GetDefaultRequest(HttpMethod.Post, uri, deviceInfo); request.Content = new FormUrlEncodedContent(data); return(request); }
/// <summary> /// Create new API instance /// </summary> /// <returns> /// API instance /// </returns> /// <exception cref="ArgumentNullException">User auth data must be specified</exception> public IInstaApi Build() { if (_user == null) { throw new ArgumentNullException("User auth data must be specified"); } if (_httpClient == null) { _httpClient = new HttpClient(_httpHandler) { BaseAddress = new Uri(InstaApiConstants.INSTAGRAM_URL) } } ; if (_requestMessage == null) { if (_device == null) { _device = AndroidDeviceGenerator.GetRandomAndroidDevice(); } _requestMessage = new ApiRequestMessage { PhoneId = _device.PhoneGuid.ToString(), Guid = _device.DeviceGuid, Password = _user?.Password, Username = _user?.UserName, DeviceId = ApiRequestMessage.GenerateDeviceId(), AdId = _device.AdId.ToString() }; } if (string.IsNullOrEmpty(_requestMessage.Password)) { _requestMessage.Password = _user?.Password; } if (string.IsNullOrEmpty(_requestMessage.Username)) { _requestMessage.Username = _user?.UserName; } if (_device == null && !string.IsNullOrEmpty(_requestMessage.DeviceId)) { _device = AndroidDeviceGenerator.GetById(_requestMessage.DeviceId); } if (_device == null) { AndroidDeviceGenerator.GetRandomAndroidDevice(); } if (_httpRequestProcessor == null) { _httpRequestProcessor = new HttpRequestProcessor(_delay, _httpClient, _httpHandler, _requestMessage, _logger); } var instaApi = new InstaApi(_user, _logger, _device, _httpRequestProcessor); return(instaApi); }
public MainForm(AndroidDevice device) { this.device = device; minicap = new MinicapStream(); //minitouch = new MiniTouchStream(device); InitializeComponent(); //判断设备方向来初始化界面SIZE if (device.Orientation == 90) { this.Width = device.VirtualHeight + 40; this.Height = device.VirtualWidth + 60; this.deviceImageBox.Width = device.VirtualHeight; this.deviceImageBox.Height = device.VirtualWidth; } else { this.Width = device.VirtualWidth + 40; this.Height = device.VirtualHeight + 60; this.deviceImageBox.Width = device.VirtualWidth; this.deviceImageBox.Height = device.VirtualHeight; } this.DoubleBuffered = true; //注册UpdatePictureBox事件,用于监听图片流队列的读取方法以更新界面图像 minicap.Update += new Minicap.MinicapEventHandler(UpdatePictureBox); Thread thread = new Thread(minicap.ReadImageStream); thread.Start(); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void RefreshThread(uint tid) { LoggingUtils.PrintFunction(); try { m_debugger.RunInterruptOperation(delegate(CLangDebugger debugger) { string command = string.Format("-thread-info {0}", (tid == 0) ? "" : tid.ToString()); MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand(command); MiResultRecord.RequireOk(resultRecord, command); if (!resultRecord.HasField("threads")) { throw new InvalidOperationException("-thread-info result missing 'threads' field"); } MiResultValueList threadsValueList = (MiResultValueList)resultRecord ["threads"] [0]; List <MiResultValue> threadsData = threadsValueList.List; bool refreshedProcesses = false; for (int i = threadsData.Count - 1; i >= 0; --i) // reported threads are in descending order. { uint id = threadsData [i] ["id"] [0].GetUnsignedInt(); CLangDebuggeeThread thread = GetThread(id) ?? AddThread(id); if (thread.RequiresRefresh) { MiResultValue threadData = threadsData [i]; if (!refreshedProcesses) { AndroidDevice hostDevice = DebugProgram.DebugProcess.NativeProcess.HostDevice; hostDevice.RefreshProcesses(DebugProgram.DebugProcess.NativeProcess.Pid); refreshedProcesses = true; } thread.Refresh(ref threadData); } } if (resultRecord.HasField("current-thread-id")) { CurrentThreadId = resultRecord ["current-thread-id"] [0].GetUnsignedInt(); } }); } catch (Exception e) { LoggingUtils.HandleException(e); } }
/// <summary> /// This is only for https://instagram.com site /// </summary> public HttpRequestMessage GetWebRequest(HttpMethod method, Uri uri, AndroidDevice deviceInfo) { var request = GetDefaultRequest(HttpMethod.Get, uri, deviceInfo); request.Headers.Remove(InstaApiConstants.HEADER_USER_AGENT); request.Headers.Add(InstaApiConstants.HEADER_USER_AGENT, InstaApiConstants.WEB_USER_AGENT); return(request); }
/// <summary> /// This is only for https://instagram.com site /// </summary> public HttpRequestMessage GetWebRequest(HttpMethod method, Uri uri, AndroidDevice deviceInfo) { var request = GetDefaultRequest(HttpMethod.Get, uri, deviceInfo); request.Headers.Remove(InstaApiConstants.HeaderUserAgent); request.Headers.Add(InstaApiConstants.HeaderUserAgent, InstaApiConstants.WebUserAgent); return(request); }
public CommentProcessor(AndroidDevice deviceInfo, UserSessionData user, IHttpRequestProcessor httpRequestProcessor, IInstaLogger logger) { _deviceInfo = deviceInfo; _user = user; _httpRequestProcessor = httpRequestProcessor; _logger = logger; }
public bool CheckIsValid(Stream stream) { if (stream is FileStream fs) { return(AndroidDevice.CheckIsValid(fs)); } return(false); }
/// <summary> /// 构造函数 /// </summary> /// <param name="scale">界面的显示比例</param> public MiniTouchStream(AndroidDevice device) { this.device = device; socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(new IPEndPoint(IPAddress.Parse(IP), PORT)); ParseBanner(socket); }
public InstaApi(UserSessionData user, IInstaLogger logger, AndroidDevice deviceInfo, IHttpRequestProcessor httpRequestProcessor) { _user = user; _logger = logger; _deviceInfo = deviceInfo; _httpRequestProcessor = httpRequestProcessor; }
private void frmMain_Load(object sender, EventArgs e) { trayIcon.Icon = this.Icon; ConsoleLog.LogWritten += Cconsole_LogWritten; LoadConfig(); AndroidDevice.DeviceStateEvent += AndroidDevice_DeviceStateEvent; AndroidDevice.StartStatusListener(); }
public Device[] GetAvailableDevices() { var adbRunner = new AndroidDebugBridgeRunner(); AndroidDeviceInfo[] deviceInfos = adbRunner.GetInfosOfAvailableDevices(); var deviceList = new Device[deviceInfos.Length]; for (int i = 0; i < deviceInfos.Length; i++) deviceList[i] = new AndroidDevice(adbRunner, deviceInfos[i]); return deviceList; }
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { if (config.Get("disconnectAtExit") == "true") { AndroidDevice.Disconnect(); } trayIcon.Visible = false; stream.Close(); }
public InstallApplication(AndroidDevice device1, ADBInstance adbi) { InitializeComponent(); device = device1; apkDetails.Enabled = false; install.Enabled = false; adbInstance = adbi; apps.DragDrop += HandleDragAndDrop; }
private static string GenerateUserAgent(AndroidDevice deviceInfo) { if (deviceInfo == null) { return(InstaApiConstants.USER_AGENT_DEFAULT); } return(string.Format(InstaApiConstants.USER_AGENT, deviceInfo.Dpi, deviceInfo.Resolution, deviceInfo.HardwareManufacturer, deviceInfo.DeviceModelIdentifier, deviceInfo.FirmwareBrand, deviceInfo.HardwareModel)); }
public MediaProcessor(AndroidDevice deviceInfo, UserSessionData user, IHttpRequestProcessor httpRequestProcessor, IInstaLogger logger, UserAuthValidate userAuthValidate) { _deviceInfo = deviceInfo; _user = user; _httpRequestProcessor = httpRequestProcessor; _logger = logger; _userAuthValidate = userAuthValidate; }
private Dictionary <string, List <string> > responseCache; // <path, FileList> public FileManager(AndroidDevice dev, ADBInstance i) { InitializeComponent(); device = dev; adbi = i; Text = "File Manager [Device Serial: " + dev.Serial + "]"; adbFM = new ADBFileManagmentService(dev, adbi); objStatusCache = new Dictionary <string, FSObjectStatus>(); responseCache = new Dictionary <string, List <string> >(); }
public UserProcessor(AndroidDevice deviceInfo, UserSessionData user, IHttpRequestProcessor httpRequestProcessor, IInstaLogger logger, UserAuthValidate userAuthValidate, InstaApi instaApi) { _deviceInfo = deviceInfo; _user = user; _httpRequestProcessor = httpRequestProcessor; _logger = logger; _userAuthValidate = userAuthValidate; _instaApi = instaApi; }
/// <summary> /// Loads the state data from stream. /// </summary> /// <param name="stream">The stream.</param> public void LoadStateDataFromStream(Stream stream) { var data = SerializationHelper.DeserializeFromStream <StateData>(stream); _deviceInfo = data.DeviceInfo; _user = data.UserSession; _httpRequestProcessor.HttpHandler.CookieContainer = data.Cookies; IsUserAuthenticated = data.IsAuthenticated; InvalidateProcessors(); }
/// <summary> /// Default ctor /// </summary> internal AndroidDeviceItem(AndroidDevice device) { this.device = device; ReloadIcon(); SetName(device.Name); SetType(device.IsEmulator ? "Emulator" : "Device"); SetSerial(Serial); SetPlatform(device.Platform); SetCpuAbi(device.ProductCpuAbi); SetState(((IDevice)device).State); }
/// <summary> /// Set custom android device. /// <para>Note: this is optional, if you didn't set this, InstagramApiSharp will choose random device.</para> /// </summary> /// <param name="androidDevice">Android device</param> /// <returns>API Builder</returns> public IInstaApiBuilder SetDevice(AndroidDevice androidDevice) { if (androidDevice == null) { _device = AndroidDeviceGenerator.GetRandomAndroidDevice(); } else { _device = androidDevice; } return(this); }
private AndroidDevice FindDevice(PostProcessorContext context) { BuildTarget platform = context.Get<BuildTarget>("BuildTarget"); AndroidTargetDevice targetDevice = PlayerSettings.Android.targetDevice; List<string> list = null; do { list = ADB.Devices(null); } while ((list.Count == 0) && EditorUtility.DisplayDialog("No Android device found!", " * Make sure USB debugging has been enabled\n * Check your device, in most cases there should be a small icon in the status bar telling you if the USB connection is up.\n * If you are sure that device is attached then it might be USB driver problem, for details please check Android SDK Setup section in Unity manual.", "Retry", "Cancel")); if (list.Count < 1) { string message = string.Format("No Android devices found.{0}\n", (Application.platform != RuntimePlatform.WindowsEditor) ? "" : " If you are sure that device is attached then it might be USB driver problem, for details please check Android SDK Setup section in Unity manual."); CancelPostProcess.AbortBuild("Couldn't find Android device", message); } AndroidDevice device2 = new AndroidDevice(list[0]); int num = Convert.ToInt32(device2.Properties["ro.build.version.sdk"]); if (num < 9) { string str2 = (("Device: " + device2.Describe() + "\n") + "The connected device is not running Android OS 2.3 or later.") + " Unity Android does not support earlier versions of the Android OS;" + " please upgrade your device to a later OS version."; Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings"); CancelPostProcess.AbortBuild("Device software is not supported", str2); } int num2 = 0; try { num2 = Convert.ToInt32(device2.Properties["ro.opengles.version"]); } catch (FormatException) { num2 = -1; } int num3 = 0xf0000; GraphicsDeviceType[] graphicsAPIs = PlayerSettings.GetGraphicsAPIs(platform); if (Enumerable.Contains<GraphicsDeviceType>(graphicsAPIs, GraphicsDeviceType.OpenGLES3)) { num3 = 0x30000; } if (Enumerable.Contains<GraphicsDeviceType>(graphicsAPIs, GraphicsDeviceType.OpenGLES2)) { num3 = 0x20000; } bool flag = device2.Features.Contains("android.hardware.opengles.aep"); if ((num3 == 0x30000) && (PlayerSettings.openGLRequireES31 || PlayerSettings.openGLRequireES31AEP)) { num3 = 0x30001; } bool flag2 = true; bool flag3 = (graphicsAPIs.Length == 1) && (graphicsAPIs[0] == GraphicsDeviceType.Vulkan); if ("Amazon" != device2.Properties["ro.product.brand"]) { string str3 = null; if (flag3 && !flag2) { str3 = "The connected device does not support Vulkan."; str3 = str3 + " Please select OpenGLES under Player Settings instead."; } if (((num2 >= 0) && (num2 < num3)) || (PlayerSettings.openGLRequireES31AEP && !flag)) { str3 = "The connected device is not compatible with the selected OpenGLES version."; str3 = str3 + " Please select a lower OpenGLES version under Player Settings instead."; } if (str3 != null) { Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings"); CancelPostProcess.AbortBuild("Device hardware is not supported", str3); } } if ((targetDevice == AndroidTargetDevice.x86) && device2.Properties["ro.product.cpu.abi"].Equals("armeabi-v7a")) { string str4 = "You are trying to install x86 APK to ARM device. "; str4 = str4 + "Please select FAT or ARM as device filter under Player Settings, or connect a x86 device."; Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings"); CancelPostProcess.AbortBuild("Device hardware is not supported", str4); } string str5 = device2.Properties["ro.product.manufacturer"]; string str6 = device2.Properties["ro.product.model"]; string action = device2.Properties["ro.product.cpu.abi"]; bool flag4 = device2.Properties["ro.secure"].Equals("1"); string str8 = string.Format("{0}{1} {2}", char.ToUpper(str5[0]), str5.Substring(1), str6); string label = string.Format("Android API-{0}", num); UsabilityAnalytics.Event("Android Device", str8, label, !flag4 ? 0 : 1); string str10 = string.Format("gles {0}.{1}{2}", num2 >> 0x10, num2 & 0xffff, !flag ? "" : " AEP"); if (num2 < 0) { str10 = "gles 2.0"; } UsabilityAnalytics.Event("Android Architecture", action, str10, 1); string str11 = device2.Properties["ro.board.platform"]; ulong i = device2.MemInfo["MemTotal"]; i = UpperboundPowerOf2(i) / ((ulong) 0x100000L); UsabilityAnalytics.Event("Android Chipset", str11, string.Format("{0}MB", i), 1); return device2; }
public void AlternateBeforeTestParam () { device = IDevice.AndroidConfig.TestDevice (); }