Beispiel #1
0
        /// <summary>
        /// Get the neighboring cell info asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>Instance of NetworkNeighboringCell.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public Task <NetworkNeighboringCell> GetNeighborCellNetwork()
        {
            TaskCompletionSource <NetworkNeighboringCell> task = new TaskCompletionSource <NetworkNeighboringCell>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the neigboring cell info, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the neigboring cell info, " + (TapiError)result));
                        return;
                    }

                    NetworkNeighboringCellStruct cellStruct = Marshal.PtrToStructure <NetworkNeighboringCellStruct>(dataResponse);
                    NetworkNeighboringCell cell             = NetworkStructConversions.ConvertNeighborCellStruct(cellStruct);
                    task.SetResult(cell);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Network.GetNetworkNeighborCell(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the neigboring cell info, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Beispiel #2
0
        internal static NetworkNeighboringCell ConvertNeighborCellStruct(NetworkNeighboringCellStruct neighborStruct)
        {
            NetworkNeighboringCell   neighborCell = new NetworkNeighboringCell();
            NetworkServingCellStruct servStruct   = neighborStruct.ServCell;
            CellStruct             cellStruct     = servStruct.Cell;
            NetworkGeranCellStruct geranStruct    = cellStruct.Geran;
            NetworkCdmaCellStruct  cdmaStruct     = cellStruct.Cdma;
            NetworkUmtsCellStruct  umtsStruct     = cellStruct.Umts;
            NetworkLteCellStruct   lteStruct      = cellStruct.Lte;

            NetworkGeranCell geranCell = ConvertGeranStruct(geranStruct);

            NetworkCdmaCell cdmaCell = new NetworkCdmaCell();

            cdmaCell.BaseStnId        = cdmaStruct.BaseId;
            cdmaCell.BaseStnLatitude  = cdmaStruct.BaseStnLatitude;
            cdmaCell.BaseStnLongitude = cdmaStruct.BaseStnLongitude;
            cdmaCell.NwId             = cdmaStruct.NetworkId;
            cdmaCell.RefPn            = cdmaStruct.RefPn;
            cdmaCell.SysId            = cdmaStruct.SystemId;

            NetworkUmtsCell umtsCell = ConvertUmtsStruct(umtsStruct);

            NetworkLteCell lteCell = ConvertLteStruct(lteStruct);

            Cell cell = new Cell();

            cell.Geran = geranCell;
            cell.Cdma  = cdmaCell;
            cell.Umts  = umtsCell;
            cell.Lte   = lteCell;

            NetworkServingCell servingCell = new NetworkServingCell();

            servingCell.SysType      = servStruct.SystemType;
            servingCell.MCountryCode = servStruct.MobileCountryCode;
            servingCell.MNwCode      = servStruct.MobileNetworkCode;
            servingCell.Info         = cell;

            neighborCell.ServCell = servingCell;
            List <NetworkGeranCell> geranCellList = new List <NetworkGeranCell>();

            for (int i = 0; i < neighborStruct.GeranCount; i++)
            {
                NetworkGeranCell geran = ConvertGeranStruct(neighborStruct.GeranList[i]);
                geranCellList.Add(geran);
            }

            List <NetworkUmtsCell> umtsCellList = new List <NetworkUmtsCell>();

            for (int i = 0; i < neighborStruct.UmtsCount; i++)
            {
                NetworkUmtsCell umts = ConvertUmtsStruct(neighborStruct.UmtsList[i]);
                umtsCellList.Add(umts);
            }

            List <NetworkLteCell> lteCellList = new List <NetworkLteCell>();

            for (int i = 0; i < neighborStruct.GeranCount; i++)
            {
                NetworkLteCell lte = ConvertLteStruct(neighborStruct.LteList[i]);
                lteCellList.Add(lte);
            }

            neighborCell.GrList  = geranCellList;
            neighborCell.UmtList = umtsCellList;
            neighborCell.LtList  = lteCellList;
            return(neighborCell);
        }