[TIMOB-23156] Windows: Automatically add required Capabilities to Manifest based on API usage
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | None |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-09-07T14:54:26.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.0.0 |
Components | Windows |
Labels | n/a |
Reporter | Fokke Zandbergen |
Assignee | Gary Mathews |
Created | 2016-04-06T06:22:05.000+0000 |
Updated | 2016-10-21T14:27:07.000+0000 |
Description
With TIMOB-18995 the user can now define Capabilities, as explained in [this guide](http://docs.appcelerator.com/platform/latest/#!/guide/tiapp.xml_and_timodule.xml_Reference-section-29004921_tiapp.xmlandtimodule.xmlReference-Windows-specificsection).
Just like we do for most of Android and iOS it would be great if we would automatically add the required Capabilities based on API usage. So if you use
Ti.Media.showCamera
in your code, it would automatically add the _microphone_ and _webcam_ Capabilities.
Test Case
var win = Ti.UI.createWindow({ backgroundColor: 'black' }),
lbl = Ti.UI.createLabel({ top: '5%', left: 5, color: 'white' }),
btn_a = Ti.UI.createButton({ top: '25%',color: 'white', title: 'showCamera()' }),
btn_b = Ti.UI.createButton({ top: '35%', color: 'white', title: 'openPhotoGallery()' });
Ti.Geolocation.getCurrentPosition(function (data) {
if (data.success) {
lbl.text += 'getCurrentPosition()' + data.coords.latitude + ',' + data.coords.longitude;
}
});
btn_a.addEventListener('click', function () {
Titanium.Media.showCamera({});
});
btn_b.addEventListener('click', function () {
Titanium.Media.openPhotoGallery({mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO]});
});
win.add(lbl);
win.add(btn_a);
win.add(btn_b);
win.open();
And then build it
appc ti build -p windows --wp-sdk 10.0 --target wp-device
Expected
PROJECT_ROOT/build/windows/win10.ARM/Package.appxmanifest
<Capability Name="internetClient" />
<uap:Capability Name="picturesLibrary" />
<DeviceCapability Name="location" />
<DeviceCapability Name="microphone" />
<DeviceCapability Name="webcam" />
master: https://github.com/appcelerator/titanium_mobile_windows/pull/761
Reopening ticket: OS: Windows 10 Pro Appc core: 6.0.0-38 Appc NPM: 4.2.8-6 Ti SDK: 6.0.0.v20160904203840 When the last file parsed does not contain any api usage that needs a capability then the appxmanifest will not contain all the required capabilities
Steps to reproduce
Create a file called z.js in your apps resources folder and paste the following
var win = Ti.UI.createWindow({ backgroundColor: 'black' });
Paste the test case from above into your app.js
Build the project using
appc run -p windows -T wp-device --wp-sdk 10.0 --build-only
Open the appxmanifest file in build\windows\win10.ARM
Rename the file to a.js
Build the project using
appc run -p windows -T wp-device --wp-sdk 10.0 --build-only
Open the appxmanifest file in build\windows\win10.ARM
Actual result
At step 4 the capabilities section in the appxmanifest file matches the belowAt step 7 the capabilities section in the appxmanifest file matches the below
Expected result
In both cases the capabilities section in the appxmanifest file should be the same as the belowmaster: https://github.com/appcelerator/titanium_mobile_windows/pull/853 6_0_X: https://github.com/appcelerator/titanium_mobile_windows/pull/854
Merged, will resolve this as Fixed once Jenkins 6_0_X build passes it.
Verified using: OS: Microsoft Windows 10 Pro 10.0.14393 Appc core: 6.0.0-63 Appc NPM: 4.2.8-9 Ti SDK: 6.1.0.v20161020155633 Appc Studio: 4.8.0.201610171310 Capabilities are now generated based off API usage in an app. Build process will merge user defined capabilities from the tiapp.xml with generated ones allowing cases like TIMOB-23981 to be worked around easily. Example from previous comment now works. Closing ticket.