Beispiel #1
0
 public override void PairingConnectionFailed(PairingResult result)
 {
     if (this.FailureEvent != null)
     {
         this.FailureEvent(result);
     }
 }
 public override void PairingConnectionFailed(PairingResult result)
 {
     if (this.FailureEvent != null)
     {
         this.FailureEvent(result);
     }
 }
        void OnPairingConnectionFailed(PairingResult result)
        {
            Debug.LogWarning("Direct pairing failed: " + result.ToString());

            if (this.AutoReconnect)
            {
                StartPairing();
            }
        }
        void OnPairingConnectionFailed(PairingResult result)
        {
            Debug.LogWarning("Direct pairing failed: " + result.ToString());

            if (this.AutoReconnect)
            {
                StartPairing();
            }
        }
Beispiel #5
0
        private void OnPairingConnectionFailed(PairingResult result)
        {
            Debug.LogWarning("Direct pairing failed: " + result);

            if (AutoReconnect)
            {
                Debug.LogWarning("Attempting to reconnect...");
                StartPairing();
            }
        }
Beispiel #6
0
 public virtual void PairingConnectionFailed(PairingResult reason)
 {
     if (SwigDerivedClassHasMethod("PairingConnectionFailed", swigMethodTypes1))
     {
         SharingClientPINVOKE.PairingListener_PairingConnectionFailedSwigExplicitPairingListener(swigCPtr, (int)reason);
     }
     else
     {
         SharingClientPINVOKE.PairingListener_PairingConnectionFailed(swigCPtr, (int)reason);
     }
 }
        void StartPairing()
        {
            if (this.sharingMgr != null)
            {
                PairingManager pairingMgr = this.sharingMgr.GetPairingManager();

                PairingResult result = pairingMgr.BeginPairing(this.pairMaker, this.pairingAdapter);
                if (result != PairingResult.Ok)
                {
                    Debug.LogError("Failed to start pairing");
                }
            }
        }
 public override void PairingConnectionFailed(PairingResult reason)
 {
     app.LogWriteLine("Pairing connection failed");
     app.BeginPairing();
 }
 public virtual void PairingConnectionFailed(PairingResult reason) {
   if (SwigDerivedClassHasMethod("PairingConnectionFailed", swigMethodTypes1)) SharingClientPINVOKE.PairingListener_PairingConnectionFailedSwigExplicitPairingListener(swigCPtr, (int)reason); else SharingClientPINVOKE.PairingListener_PairingConnectionFailed(swigCPtr, (int)reason);
 }
Beispiel #10
0
        public virtual PairingResult BeginPairing(PairMaker pairMaker, PairingListener listener)
        {
            PairingResult ret = (PairingResult)SharingClientPINVOKE.PairingManager_BeginPairing(swigCPtr, PairMaker.getCPtr(pairMaker), PairingListener.getCPtr(listener));

            return(ret);
        }
Beispiel #11
0
 public override void PairingConnectionFailed(PairingResult reason)
 {
     LogWriteLine("Pairing connection failed");
     app.BeginPairing();
 }
Beispiel #12
0
        /// <summary>
        /// Asynchronously pairs a device with the host.
        /// </summary>
        /// <param name="cancellationToken">
        /// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
        /// </param>
        /// <returns>
        /// A <see cref="Task"/> representing the asynchronous operation. The task completes when the device has
        /// paired successfully, or when the user has refused pairing.
        /// </returns>
        public virtual async Task <PairingRecord> PairAsync(CancellationToken cancellationToken)
        {
            PairingResult result = null;

            await using (var notificationProxyClient = await this.notificationProxyClientFactory.CreateAsync(NotificationProxyClient.InsecureServiceName, cancellationToken))
            {
                // Very early implementations listen for a "request host buid" notification, too. When this notification is received, the
                // host should set the "UntrustedHostBUID" lockdown property with the system buid. However, it looks like this is not needed
                // for recent versions of lockdown, and is currently not implemented.
                await notificationProxyClient.ObserveNotificationAsync(Notifications.RequestPair, cancellationToken).ConfigureAwait(false);

                // First, attempt to validate the current pairing record stored in usbmuxd (if any such pairing record is present).
                var pairingRecord = await this.muxer.ReadPairingRecordAsync(this.context.Device.Udid, cancellationToken).ConfigureAwait(false);

                if (pairingRecord != null)
                {
                    await using (var lockdownClient = await this.lockdownClientFactory.CreateAsync(cancellationToken))
                    {
                        // Check the validity of the current pairing record. If the pairing record is valid (i.e. we can start a Lockdown session),
                        // use that pairing record. If the pairing record is not valid, we need to check whether we're still pending user validation
                        // of this pairing record or whether the user has rejected pairing.
                        if (await lockdownClient.ValidatePairAsync(pairingRecord, cancellationToken).ConfigureAwait(false))
                        {
                            return(pairingRecord);
                        }

                        result = await lockdownClient.PairAsync(pairingRecord, cancellationToken).ConfigureAwait(false);

                        // If the pairing record is invalid, delete the pairing record from the muxer.
                        if (result?.Status == PairingStatus.UserDeniedPairing)
                        {
                            result = await lockdownClient.UnpairAsync(pairingRecord, cancellationToken).ConfigureAwait(false);

                            await this.muxer.DeletePairingRecordAsync(this.context.Device.Udid, cancellationToken).ConfigureAwait(false);

                            pairingRecord = null;
                            result        = null;
                        }
                        else if (result?.Status != PairingStatus.PairingDialogResponsePending &&
                                 result.Status != PairingStatus.Success)
                        {
                            await this.muxer.DeletePairingRecordAsync(this.context.Device.Udid, cancellationToken).ConfigureAwait(false);

                            pairingRecord = null;
                            result        = null;
                        }
                    }
                }

                // If a valid pairing record was not found, create a new one, and store it in the muxer.
                if (pairingRecord == null)
                {
                    await using (var lockdownClient = await this.lockdownClientFactory.CreateAsync(cancellationToken))
                    {
                        var devicePublicKey = await lockdownClient.GetPublicKeyAsync(cancellationToken).ConfigureAwait(false);

                        var wifi = await lockdownClient.GetWifiAddressAsync(cancellationToken).ConfigureAwait(false);

                        var systemBuid = await this.muxer.ReadBuidAsync(cancellationToken).ConfigureAwait(false);

                        pairingRecord = this.pairingRecordGenerator.Generate(devicePublicKey, systemBuid);
                        pairingRecord.WiFiMacAddress = wifi;

                        result = await lockdownClient.PairAsync(pairingRecord, cancellationToken).ConfigureAwait(false);

                        Debug.Assert(
                            result?.Status == PairingStatus.PairingDialogResponsePending || result?.Status == PairingStatus.Success,
                            "Invalid response");

                        await this.muxer.SavePairingRecordAsync(this.context.Device.Udid, pairingRecord, cancellationToken).ConfigureAwait(false);
                    }
                }

                Debug.Assert(pairingRecord != null, "A pairing record should exist");

                // At this point, we have a pairing record. If the we're pending a response from the user, wait for that response.
                if (result?.Status == PairingStatus.PairingDialogResponsePending)
                {
                    string notification = await notificationProxyClient.ReadRelayNotificationAsync(cancellationToken).ConfigureAwait(false);

                    Debug.Assert(notification == Notifications.RequestPair, "Got an unexpected notification");

                    await using (var lockdownClient = await this.lockdownClientFactory.CreateAsync(cancellationToken))
                    {
                        result = await lockdownClient.PairAsync(pairingRecord, cancellationToken).ConfigureAwait(false);
                    }

                    // Save the escrow bag if one is available.
                    if (result.Status == PairingStatus.Success)
                    {
                        if (pairingRecord.EscrowBag == null && result.EscrowBag != null)
                        {
                            pairingRecord.EscrowBag = result.EscrowBag;
                            await this.muxer.SavePairingRecordAsync(udid : this.context.Device.Udid, pairingRecord, cancellationToken).ConfigureAwait(false);
                        }
                    }
                    else
                    {
                        await this.muxer.DeletePairingRecordAsync(udid : this.context.Device.Udid, cancellationToken).ConfigureAwait(false);
                    }
                }

                // Return the pairing record if we paired successfully; otherwise, return null.
                if (result?.Status == PairingStatus.Success)
                {
                    return(pairingRecord);
                }

                return(null);
            }
        }