Skip to content

Commit

Permalink
Merge pull request #28 from mer-hybris/jb58763
Browse files Browse the repository at this point in the history
Add NR support
  • Loading branch information
mlehtima committed May 23, 2023
2 parents 5ed68de + 1a71970 commit 541faa7
Show file tree
Hide file tree
Showing 11 changed files with 394 additions and 39 deletions.
4 changes: 2 additions & 2 deletions rpm/ofono-binder-plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Source: %{name}-%{version}.tar.bz2

%define libglibutil_version 1.0.61
%define libgbinder_version 1.1.29
%define libgbinder_radio_version 1.5.3
%define libgbinder_radio_version 1.5.6
%define libmce_version 1.0.6
%define libofonobinderpluginext_version 1.1.0
%define ofono_version 1.28+git3
%define ofono_version 1.28+git8

BuildRequires: pkgconfig
BuildRequires: ofono-devel >= %{ofono_version}
Expand Down
88 changes: 86 additions & 2 deletions src/binder_cell_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ enum binder_cell_info_signal {

#define SIGNAL_CELLS_CHANGED_NAME "binder-cell-info-cells-changed"

static GUtilIdlePool* binder_cell_info_pool = NULL;
static guint binder_cell_info_signals[SIGNAL_COUNT] = { 0 };

G_DEFINE_TYPE(BinderCellInfo, binder_cell_info, G_TYPE_OBJECT)
Expand All @@ -93,7 +94,23 @@ binder_cell_info_int_format(
if (value == OFONO_CELL_INVALID_VALUE) {
return "";
} else {
static GUtilIdlePool* binder_cell_info_pool = NULL;
GUtilIdlePool* pool = gutil_idle_pool_get(&binder_cell_info_pool);
char* str = g_strdup_printf(format, value);

gutil_idle_pool_add(pool, str, g_free);
return str;
}
}

static
const char*
binder_cell_info_int64_format(
guint64 value,
const char* format)
{
if (value == OFONO_CELL_INVALID_VALUE_INT64) {
return "";
} else {
GUtilIdlePool* pool = gutil_idle_pool_get(&binder_cell_info_pool);
char* str = g_strdup_printf(format, value);

Expand Down Expand Up @@ -185,6 +202,25 @@ binder_cell_info_invalidate(
}
}

static
void
binder_cell_info_invalidate_nr(
struct ofono_cell_info_nr* nr)
{
nr->mcc = OFONO_CELL_INVALID_VALUE;
nr->mnc = OFONO_CELL_INVALID_VALUE;
nr->nci = OFONO_CELL_INVALID_VALUE_INT64;
nr->pci = OFONO_CELL_INVALID_VALUE;
nr->tac = OFONO_CELL_INVALID_VALUE;
nr->nrarfcn = OFONO_CELL_INVALID_VALUE;
nr->ssRsrp = OFONO_CELL_INVALID_VALUE;
nr->ssRsrq = OFONO_CELL_INVALID_VALUE;
nr->ssSinr = OFONO_CELL_INVALID_VALUE;
nr->csiRsrp = OFONO_CELL_INVALID_VALUE;
nr->csiRsrq = OFONO_CELL_INVALID_VALUE;
nr->csiSinr = OFONO_CELL_INVALID_VALUE;
}

static
struct ofono_cell*
binder_cell_info_new_cell_gsm(
Expand Down Expand Up @@ -295,6 +331,46 @@ binder_cell_info_new_cell_lte(
binder_cell_info_int_format(lte->timingAdvance, ",t=%d"));
return cell;
}
static
struct ofono_cell*
binder_cell_info_new_cell_nr(
gboolean registered,
const RadioCellIdentityNr* id,
const RadioSignalStrengthNr* ss)
{
struct ofono_cell* cell = binder_cell_new();
struct ofono_cell_info_nr* nr = &cell->info.nr;

cell->type = OFONO_CELL_TYPE_NR;
cell->registered = registered;

binder_cell_info_invalidate_nr(nr);
gutil_parse_int(id->mcc.data.str, 10, &nr->mcc);
gutil_parse_int(id->mnc.data.str, 10, &nr->mnc);
nr->nci = id->nci;
nr->pci = id->pci;
nr->tac = id->tac;
nr->nrarfcn = id->nrarfcn;
nr->ssRsrp = ss->ssRsrp;
nr->ssRsrq = ss->ssRsrq;
nr->ssSinr = ss->ssSinr;
nr->csiRsrp = ss->csiRsrp;
nr->csiRsrq = ss->csiRsrq;
nr->csiSinr = ss->csiSinr;
DBG("[nr] reg=%d%s%s%s%s%s%s%s%s%s%s%s", registered,
binder_cell_info_int_format(nr->mcc, ",mcc=%d"),
binder_cell_info_int_format(nr->mnc, ",mnc=%d"),
binder_cell_info_int64_format(nr->nci, ",nci=%" G_GINT64_FORMAT),
binder_cell_info_int_format(nr->pci, ",pci=%d"),
binder_cell_info_int_format(nr->tac, ",tac=%d"),
binder_cell_info_int_format(nr->ssRsrp, ",ssRsrp=%d"),
binder_cell_info_int_format(nr->ssRsrq, ",ssRsrq=%d"),
binder_cell_info_int_format(nr->ssSinr, ",ssSinr=%d"),
binder_cell_info_int_format(nr->csiRsrp, ",csiRsrp=%d"),
binder_cell_info_int_format(nr->csiRsrq, ",csiRsrq=%d"),
binder_cell_info_int_format(nr->csiSinr, ",csiSinr=%d"));
return cell;
}

static
GPtrArray*
Expand Down Expand Up @@ -427,9 +503,13 @@ binder_cell_info_array_new_1_4(
&cell->info.wcdma.cellIdentityWcdma.base,
&cell->info.wcdma.signalStrengthWcdma.base));
continue;
case RADIO_CELL_INFO_1_4_NR:
g_ptr_array_add(l, binder_cell_info_new_cell_nr(registered,
&cell->info.nr.cellIdentity,
&cell->info.nr.signalStrength));
continue;
case RADIO_CELL_INFO_1_4_TD_SCDMA:
case RADIO_CELL_INFO_1_4_CDMA:
case RADIO_CELL_INFO_1_4_NR:
break;
}
DBG("unsupported cell type %d", cell->cellInfoType);
Expand Down Expand Up @@ -467,6 +547,10 @@ binder_cell_info_array_new_1_5(
&cell->info.wcdma.signalStrengthWcdma.base));
continue;
case RADIO_CELL_INFO_1_5_NR:
g_ptr_array_add(l, binder_cell_info_new_cell_nr(registered,
&cell->info.nr.cellIdentityNr.base,
&cell->info.nr.signalStrengthNr));
continue;
case RADIO_CELL_INFO_1_5_TD_SCDMA:
case RADIO_CELL_INFO_1_5_CDMA:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/binder_devmon_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ binder_devmon_if_io_set_indication_filter(
RADIO_IND_FILTER_DATA_CALL_DORMANCY;
} else {
code = RADIO_REQ_SET_INDICATION_FILTER_1_5;
value = self->display_on ? RADIO_IND_FILTER_ALL_1_2 :
value = self->display_on ? RADIO_IND_FILTER_ALL_1_5 :
RADIO_IND_FILTER_DATA_CALL_DORMANCY;
}

Expand Down

0 comments on commit 541faa7

Please sign in to comment.