Closed
Bug 1192695
Opened 9 years ago
Closed 9 years ago
Use pref instead of hard-coded string as origin of bluetooth app
Categories
(Firefox OS Graveyard :: Bluetooth, defect)
Tracking
(feature-b2g:2.5+, firefox43 fixed)
Tracking | Status | |
---|---|---|
firefox43 | --- | fixed |
People
(Reporter: dwi2, Assigned: jaliu)
References
Details
Attachments
(1 file, 3 obsolete files)
Currently in gecko we use hard-coded string as origin of bluetooth app. See https://dxr.mozilla.org/mozilla-central/source/dom/bluetooth/BluetoothCommon.h#216 However, in build other than phone build, we might need to use other app to do bluetooth pairing task. Or further more, bluetooth app might change its app origin string in the future. Hence we need a flexible way to specify origin of bluetooth app. We could explore all possible ways in this bug. One possible way is that we could use prefs and let gaia decide which app origin of bluetooth app we'd like to use in build time.
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → jaliu
Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8645549 -
Flags: review?(btian)
Comment 2•9 years ago
|
||
Comment on attachment 8645549 [details] [diff] [review] Use pref instead of pre-defined C string as origin of bluetooth app. (v1) Review of attachment 8645549 [details] [diff] [review]: ----------------------------------------------------------------- Please see my comment below. ::: dom/bluetooth/bluetooth2/BluetoothAdapter.cpp @@ +984,3 @@ > NS_ENSURE_TRUE(doc, false); > > uint16_t appStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED; Suggest to revise with guardian clauses as following: uint16_t appStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED; doc->NodePrincipal()->GetAppStatus(&appStatus); if (appStatus != nsIPrincipal::APP_STATUS_CERTIFIED) { return false; } // Get the app origin of Bluetooth app from PrefService. nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (!prefs) { BT_WARNING("Failed to get preference service"); return false; } nsCString prefOrigin; nsresult rv = prefs->GetCharPref("dom.bluetooth.app-origin", getter_Copies(prefOrigin)); if (NS_FAILED(rv)) { BT_WARNING("Failed to get the pref value 'dom.bluetooth.app-origin'"); return false; } nsAutoCString appOrigin; doc->NodePrincipal()->GetOriginNoSuffix(appOrigin); return appOrigin.Equals(prefOrigin); @@ +989,5 @@ > doc->NodePrincipal()->GetAppStatus(&appStatus); > doc->NodePrincipal()->GetOriginNoSuffix(appOrigin); > > + // Get the app origin of Bluetooth app from PrefService. > + nsCString prefOrigin; Should we use |nsAutoCString| here? @@ +993,5 @@ > + nsCString prefOrigin; > + nsresult rv = NS_ERROR_FAILURE; > + nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); > + if (prefs) { > + rv = prefs->GetCharPref("dom.bluetooth.app-origin", Define dom.bluetooth.app-origin in BluetoothCommon.h
Attachment #8645549 -
Flags: review?(btian)
Updated•9 years ago
|
feature-b2g: --- → 2.5+
Assignee | ||
Comment 3•9 years ago
|
||
Thank Ben for reviewing the patch.
Attachment #8645549 -
Attachment is obsolete: true
Assignee | ||
Comment 4•9 years ago
|
||
(In reply to Ben Tian [:btian] from comment #2) > Comment on attachment 8645549 [details] [diff] [review] > Use pref instead of pre-defined C string as origin of bluetooth app. (v1) > > Review of attachment 8645549 [details] [diff] [review]: > @@ +989,5 @@ > > doc->NodePrincipal()->GetAppStatus(&appStatus); > > doc->NodePrincipal()->GetOriginNoSuffix(appOrigin); > > > > + // Get the app origin of Bluetooth app from PrefService. > > + nsCString prefOrigin; > > Should we use |nsAutoCString| here? Good idea. :)
Assignee | ||
Updated•9 years ago
|
Attachment #8645616 -
Flags: review?(btian)
Comment 5•9 years ago
|
||
Comment on attachment 8645616 [details] [diff] [review] Use pref instead of pre-defined C string as origin of bluetooth app. (v2) Review of attachment 8645616 [details] [diff] [review]: ----------------------------------------------------------------- r=me with comment addressed. ::: dom/bluetooth/BluetoothCommon.h @@ +209,5 @@ > */ > #define SYS_MSG_BT_PAIRING_REQ "bluetooth-pairing-request" > > /** > + * The preference name of app origin of bluetooth app. The default value is Simplify to The preference name of bluetooth app origin. ... ::: dom/bluetooth/bluetooth2/BluetoothAdapter.cpp @@ +996,5 @@ > + return false; > + } > + > + nsAutoCString prefOrigin; > + nsresult rv = prefs->GetCharPref("dom.bluetooth.app-origin", Replace with |PREF_BLUETOOTH_APP_ORIGIN|. @@ +999,5 @@ > + nsAutoCString prefOrigin; > + nsresult rv = prefs->GetCharPref("dom.bluetooth.app-origin", > + getter_Copies(prefOrigin)); > + if (NS_FAILED(rv)) { > + BT_WARNING("Failed to get the pref value 'dom.bluetooth.app-origin'"); Replace with |PREF_BLUETOOTH_APP_ORIGIN| as [1]. [1] https://dxr.mozilla.org/mozilla-central/source/dom/bluetooth/bluetooth2/BluetoothService.cpp?offset=100#145
Attachment #8645616 -
Flags: review?(btian) → review+
Assignee | ||
Comment 6•9 years ago
|
||
- revise previous patch based on #comment 5. Thank Ben for reviewing the patch.
Attachment #8645616 -
Attachment is obsolete: true
Assignee | ||
Comment 7•9 years ago
|
||
Pushed to try server. https://treeherder.mozilla.org/#/jobs?repo=try&revision=151e591cb22f
Assignee | ||
Comment 8•9 years ago
|
||
Add two spaces in front of and behind |PREF_BLUETOOTH_APP_ORIGIN| since C++11 requires a space between literal and identifier.
Attachment #8646302 -
Attachment is obsolete: true
Assignee | ||
Comment 9•9 years ago
|
||
The result of try server looks fine. https://treeherder.mozilla.org/#/jobs?repo=try&revision=23a2b409627a P.S. I believe the build break of |B2G Desktop OS X debug| is caused by Bug 1191877 and Bug 1165763.
Updated•9 years ago
|
Status: NEW → ASSIGNED
Comment 11•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/44084e8ee8dc
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox43:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → FxOS-S5 (21Aug)
Assignee | ||
Updated•9 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•