Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Add support for Qualcomm's device. #174
Conversation
|
Thanks for the pull-request. It's a reasonably well thought out approach. That said, I have a couple of global comments, as well as some comments on the code itself. First, our ofono rilmodem code is currently based on AOSP 4.4.2, whereas as some of the new RIL requests added by this pull-request, including the critical SET_UICC_SUBSCRIPTION request have been introduced in AOSP 5. As such, I wonder if it's worth adding a device plugin ( see plugins/mtk.c ), and using a vendor quirk for set subscription behavior, as it will fail on devices running an rild < 5. Using this approach would also allow you to start to build proper support for your device's dual-modem support. Second, could you please re-format your commit messages to use prefixes ( eg. "include:", "gril:", ... ). Please take a look at some of the existing commits in our repository. |
tonyespy
reviewed
Apr 5, 2015
| @@ -372,6 +372,17 @@ | ||
| #define RIL_REQUEST_VOICE_RADIO_TECH 108 | ||
| #define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111 | ||
| +#define RIL_REQUEST_IMS_REGISTRATION_STATE 112 | ||
| +#define RIL_REQUEST_IMS_SEND_SMS 113 | ||
| +#define RIL_REQUEST_GET_DATA_CALL_PROFILE 114 |
tonyespy
Apr 5, 2015
Contributor
GET_DATA_CALL_PROFILE doesn't appear to be a standard request defined by any version of AOSP's ril.h header. If it's a custom OEM request, then it should be added in an OEM-specific header. Also, as it's not used in any of your new code, I would just leave it out of this change.
tonyespy
reviewed
Apr 5, 2015
| +#define RIL_REQUEST_IMS_REGISTRATION_STATE 112 | ||
| +#define RIL_REQUEST_IMS_SEND_SMS 113 | ||
| +#define RIL_REQUEST_GET_DATA_CALL_PROFILE 114 | ||
| +#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 115 |
tonyespy
Apr 5, 2015
Contributor
This is only defined in AOSP v5. See my global comment about this. It also might be a good idea to add a comment indicating this ( either RIL version or AOSP version ).
alfonsosanchezbeato
Apr 6, 2015
Contributor
Note also that in lollipop the number for this request is 122. See:
http://androidxref.com/5.1.0_r1/xref/hardware/ril/include/telephony/ril.h
tonyespy
reviewed
Apr 5, 2015
| +#define RIL_REQUEST_GET_DATA_CALL_PROFILE 114 | ||
| +#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 115 | ||
| +#define RIL_REQUEST_SET_DATA_SUBSCRIPTION 116 | ||
| +#define RIL_REQUEST_SIM_TRANSMIT_BASIC 117 |
tonyespy
Apr 5, 2015
Contributor
Neither SET_DATA_SUBS or SIM_TRANSMIT_BASIC appear to be standard requests defined by any version of AOSP's ril.h header. If they are custom OEM requests, then they should be added in an OEM-specific header. Also, as it's not used in any of your new code, I would just leave them out of this change.
tonyespy
reviewed
Apr 5, 2015
| +#define RIL_REQUEST_SET_DATA_SUBSCRIPTION 116 | ||
| +#define RIL_REQUEST_SIM_TRANSMIT_BASIC 117 | ||
| +#define RIL_REQUEST_SIM_OPEN_CHANNEL 118 | ||
| +#define RIL_REQUEST_SIM_CLOSE_CHANNEL 119 |
tonyespy
Apr 5, 2015
Contributor
SIM_OPEN_CHANNEL and SIM_CLOSE_CHANNEL are only defined in AOSP v5. See my global comment about this. It also might be a good idea to add comments indicating this ( either RIL version or AOSP version ).
tonyespy
reviewed
Apr 5, 2015
| +#define RIL_REQUEST_SIM_OPEN_CHANNEL 118 | ||
| +#define RIL_REQUEST_SIM_CLOSE_CHANNEL 119 | ||
| +#define RIL_REQUEST_SIM_TRANSMIT_CHANNEL 120 | ||
| +#define RIL_REQUEST_SIM_GET_ATR 121 |
tonyespy
Apr 5, 2015
Contributor
Neither SIM_TRANSMIT_CHANNEL or SIM_GET_ATR appear to be standard requests defined by any version of AOSP's ril.h header. If they are custom OEM requests, then they should be added in an OEM-specific header. Also, as it's not used in any of your new code, I would just leave them out of this change.
tonyespy
reviewed
Apr 5, 2015
| + selected_app = i; | ||
| + } | ||
| + } | ||
| + else { |
tonyespy
Apr 5, 2015
Contributor
The closing brace should be on the same line as the 'else'. Ex.
} else {
tonyespy
reviewed
Apr 5, 2015
| + * So, we need to figure out which app to use | ||
| + * and send that request out. | ||
| + */ | ||
| + search_index = sim_select_uicc_subscription(sim, status); |
tonyespy
Apr 5, 2015
Contributor
Since -1 is still a possible return value from sim_select_uicc_subscription(), it still can be used an array index, which leads to undefined behavior. We should catch this, log it as an error, and not allow it to be used.
tonyespy
reviewed
Apr 5, 2015
| + case RIL_APPTYPE_RUIM: | ||
| + break; | ||
| + default: | ||
| + selected_app = i; |
tonyespy
Apr 5, 2015
Contributor
First, shouldn't this be RIL_APPTYPE_SIM | USIM? RUIM is used by CDMA phone.
I'm also not sure why you're check app_type twice or why you'd set selected_app in the default case of the second check?
peat-psuwit
Apr 6, 2015
Contributor
This is algorithm used in CM [1]. It prefers USIM | RUIM over SIM | CSIM. (That second app_type check replaces selected_app with current one if current selected_app isn't USIM | RUIM) As there isn't CDMA support in oFono yet, it may be make sense to just log that and skip that app.
[1] https://github.com/CyanogenMod/android_frameworks_opt_telephony-msim/blob/cm-11.0/frameworks/src/com/codeaurora/telephony/msim/SubscriptionManager.java#L401-L450
|
A few additional comments on my side:
|
|
For ril.h constants, I just copy them from CM 11's version of ril.h, as that works for my device. I though it's some update from somewhere so it seemed to make sense to include them all. But, as you point out, it may be more appropriate to just include the needed constants only. |
|
Just for the record, latest HEAD in CM repo defines #define RIL_REQUEST_SET_UICC_SUBSCRIPTION 122 (as in AOSP) so as a minimum, using 115 instead of 122 must be a vendor quirk. Note also that most commits to CM's ril.h come from codeaurora guys. |
|
Ok, then it's probably Qualcomm's quirk in Android 4.4. But if I move the constant to modem-specific header, then where should I put the g_ril_set_uicc_subscription function? BTW, how should I change the code and re-submit? New pull request? |
|
It is fine to implement g_ril_set_uicc_subscription in gril as it is defined by AOSP 5. However, the constant used for the request in g_ril_send should be defined as vendor-specific in a similar way as the constants in mtk_constants.h. And when using it in rilmodem/sim.c you should check the vendor. You can rebase and resubmit this PR or use a new one, whatever which is easier for you. |
|
Resubmit this PR? You mean force-pushing new commit into this branch? |
|
@peat-psuwit yes, I normally do a "git rebase -i" to have a clean history and then a forced push when re-submitting. But, again, whatever works best for you. You can close this PR and create a new one if you prefer. |
|
Ok, new version is pushed. I hope I does it right. |
alfonsosanchezbeato
reviewed
Apr 15, 2015
| + * | ||
| + * RIL constants for Qualcomm multi-sim modem | ||
| + * | ||
| + * Copyright (C) 2014 Canonical Ltd. |
alfonsosanchezbeato
reviewed
Apr 15, 2015
| + g_ril_request_set_uicc_subscription(sd->ril, slot_id, app_index, | ||
| + sub_id, sub_status, &rilp); | ||
| + g_ril_send(sd->ril, QCOM_MSIM_RIL_REQUEST_SET_UICC_SUBSCRIPTION, &rilp, | ||
| + NULL, NULL, NULL); |
alfonsosanchezbeato
Apr 15, 2015
Contributor
I would add here a callback function to check for message->error and call g_ril_print_response_no_args() (see for instance mtkmodem/voicecall.c:mtk_set_indication_cb()), so we know when the call failed.
alfonsosanchezbeato
reviewed
Apr 15, 2015
| @@ -640,6 +641,59 @@ static void configure_active_app(struct sim_data *sd, | ||
| } | ||
| } | ||
| +static void sim_send_set_uicc_subscription(struct ofono_sim *sim, int slot_id, int app_index, int sub_id, int sub_status) |
alfonsosanchezbeato
reviewed
Apr 15, 2015
| */ | ||
| - __ofono_sim_recheck_pin(sim); | ||
| + search_index = sim_select_uicc_subscription(sim, status); |
alfonsosanchezbeato
Apr 15, 2015
Contributor
You probably need to send SET_UICC_SUBSCRIPTION only once, not after each SIM_STATUS request. I think you could check sim_data::app_index to see if it is initialized or not (it is set by configure_active_app()). You would need to initialize that variable to -1 when sim_data is created.
peat-psuwit
Apr 15, 2015
Contributor
I only send that request if search_index is -1 (actually UINT_MAX, which is more than num_apps), not every time the SIM status is replied.
alfonsosanchezbeato
Apr 15, 2015
Contributor
Ok, you are right, the modem should send a value different to -1 once the application is selected.
peat-psuwit
Apr 23, 2015
Contributor
@tonyespy this line is 2 characters longer then 80 characters. I'm not sure how to cut the word?
tonyespy
Apr 23, 2015
Contributor
It's actually only one character over 80, as the trailing line breaks aren't counted.
Take a look at the doc/coding-style.txt, as it has some examples of how this could be corrected.
The simplest would be to just wrap the 2nd parameter:
search_index = sim_select_uicc_subscription(sim,
status);
Note - all tabs are used, this puts the wrapped link just at the 80 char limit.
Or, you could wrap after the "=", like this:
search_index =
sim_select_uicc_subscription(sim, status);
But I think the first is preferable.
alfonsosanchezbeato
reviewed
Apr 15, 2015
| + int sub_status, | ||
| + struct parcel *rilp); | ||
| + | ||
| + |
alfonsosanchezbeato
reviewed
Apr 15, 2015
| - if (app->app_type != RIL_APPTYPE_UNKNOWN) { | ||
| - configure_active_app(sd, app, search_index); | ||
| - DBG("passwd_state: %d", sd->passwd_state); | ||
| + __func__, status->card_state); |
alfonsosanchezbeato
reviewed
Apr 15, 2015
| +} | ||
| + | ||
| +OFONO_PLUGIN_DEFINE(qcom_msim, "Modem driver for Qualcomm's multi-sim device", | ||
| + VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT, qcom_msim_init, qcom_msim_exit) |
|
Overall, looks pretty good to me. @tonyespy ? |
|
New version updated with @alfonsosanchezbeato suggestion and rebased to current master. |
|
So this looks pretty good to me, although I have a couple of comments:
|
|
I'll edit copyright for plugins/qcom-msim.c as you suggest. But I'm not so sure if I can add a copyright statement on my rilmodem/sim.c and grilrequest.c's addition. (Isn't there some kind of CLA?) For the last commit, I forgot to test that because I don't have PIN locking enabled. Let me test that and I'll edit the commit message in the next patchset. |
|
I'll double check with Alfonso re: the copyright. AFAIK, there is no CLA for ofono. I think the general rule of thumb is whether or not the patch is considered significant or not. Also please do test the last commit. We don't like to merge code based on assumptions... |
|
OK, after a simple checking with my phone with this patch, PIN locking seems to work fine. So I'll definitely edit the commit message. But to reduce clutter on this pull request, I'll wait until I have clarity about copyright, and will re-submit these commit again. |
|
There is no CLA, and the change you've submitted is complex enough to warrant an additional copyright statement if you want to add it, but I think the choice is yours. |
|
Ok, new version uploaded. Copyright statement is added. PIN handling's commit is edited. And the commit is rebased to the new master. |
tonyespy
reviewed
Apr 22, 2015
| + * again. An option that can be explored in the | ||
| + * future is wait before invoking core callback | ||
| + * for send_passwd until we know the real password state. | ||
| + */ |
tonyespy
Apr 22, 2015
Contributor
I hate to reject this again, but as I was doing a final review I noticed that some of these comments had been moved inside of this if block, and noticed that some of the lines are pretty long, so I checked... And at least fives lines in the first comment, and two in the next comment are all over 80 characters long. Sorry to be a stickler, but we try to stick to the coding style doc ( see /doc/coding-style.txt ).
peat-psuwit
Apr 23, 2015
Contributor
As they are indented a lot, I tough they seem to look better when they're a few characters longer. But if that's matter, I'll try to do the word cutting again.
tonyespy
Apr 23, 2015
Contributor
Well, the comments had been left in their original position, this wouldn't have been a problem.
The style guide says it's OK to exceed if it makes the code really ugly otherwise, but as we're talking about comment here, these should be fixed.
tonyespy
referenced this pull request
Apr 22, 2015
Closed
rilmodem/sim: validate returned gsm app_index #166
peat-psuwit
added some commits
Apr 13, 2015
|
LGTM. @peat-psuwit, thanks a lot for the patch and for your patience while following the review process |
peat-psuwit commentedApr 3, 2015
This add some essential code for oFono to work with LG L90 Dual (and maybe other Qualcomm's multi-sim device) correctly. This code cannot utilize 2nd sim slot yet.