Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16151] Android: Ti.Media.vibrate required permission not being added to androidManifest.xml

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2014-01-09T17:51:25.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2014 Sprint 01, 2014 Sprint 01 Core, Release 3.2.1, Release 3.3.0
ComponentsCLI
Labelsmodule_build, module_media, qe-testadded, regression, triage
ReporterStephen Feather
AssigneeChris Barber
Created2013-12-16T21:13:09.000+0000
Updated2014-02-12T07:46:27.000+0000

Description

Expectations

Required permissions for Ti modules to be inserted into androidManifest.xml on build

Reality

Required permissions are NOT being inserted into androidManifest.xml on build.

Replicate

Throw Ti.Media.vibrate into any project, build, check generated androidManifest, fail to find permission. Expect to find:
<uses-permission android:name="android.permission.VIBRATE"/>

Current Workaround

add require permission manually to tiapp.xml

Note: this is a regression, but I'm not sure when it last worked. Not a function we use on a regular basis.

Comments

  1. Mostafizur Rahman 2013-12-22

    Hello, We tested this issue with the code bellow. We can't reproduce this problem in latest release. Please try this sample code and let us know if the issue persists. If you use a different test case, please post it here.

    Testing Environment:

    Android SDK: 4.2.2 Titanium SDK: 3.2.0.GA, 3.3.0.v20131220192449 Titanium CLI Version: 3.2.0

    Test Code

       var win = Ti.UI.createWindow();
       win.backgroundColor = 'white';
        
        
        
       // Create a Button.
       var press = Ti.UI.createButton({
       	title : 'press',
       	height : '70',
       	width : '100',
       });
        
        
        
        press.addEventListener('singletap',function(e){
          Ti.Media.vibrate([0,500, 250, 500, 1000]);
        });
        
        
        
        
        
        win.add(press);
       // open window
       win.open();
       

    Steps to Test:

    1. Create a sample project, 2. Paste this code in app.js file. 3. Run this with testing environment. 4. Click on press button

    Actual/expected result

    Vibration working without modify androidManifest file
  2. Stephen Feather 2014-01-08

    Blah, beyond caring any more. When quality, knowledgable first tier folks start processing tickets, I might start resubmitting. http://stackoverflow.com/questions/13159386/android-does-notification-default-vibrate-require-vibrate-permission
  3. Tim Poulsen 2014-01-08

    Perhaps this is a larger issue? It seems for some folks the camera permission is no longer being added automatically. http://developer.appcelerator.com/question/161322/timediashowcamera-fails-on-genymotion-emulator-even-though-other-camera-apps-work-fine
  4. Stephen Feather 2014-01-08

    Can confirm that camera permissions are not being copied over in either. Titanium Command-Line Interface, CLI version 3.2.0, Titanium SDK version 3.3.0.v20140106195650 Copyright (c) 2012-2013, Appcelerator, Inc. All Rights Reserved.
       <uses-permission android:name="android.permission.INTERNET"/>
       <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
       <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
       <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
       <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
       <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
       <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
       
    Without the permission, showCamera error callback fires, with the permission, camera launches. These permissions are not optional, despite what 'Rahman' seems to think.
  5. Ingo Muschenetz 2014-01-08

    Not the same issue, but perhaps there is a related component during the manifest generation: TIMOB-16088.
  6. Chris Barber 2014-01-08

    I gave this a test and could not reproduce. The only thing that could throw this off are: 1) if you have a custom AndroidManifest.xml 2) you did something like: var tim = Ti.Media; tim.vibrate(); 3) you put the Ti.Media.vibrate() call in a file that does NOT have a .js extension So, what am I missing?
  7. Chris Barber 2014-01-08

    Ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh. It's an emulator only thang. Fix coming soon!
  8. Chris Barber 2014-01-09

    Master pull request: https://github.com/appcelerator/titanium_mobile/pull/5196 3.2.x pull request: https://github.com/appcelerator/titanium_mobile/pull/5197 To test: 1. create a project for ios and android 2. add Ti.Media.vibrate(); to app.js 3. run: ti build -p android --build-only 4. look at build/android/AndroidManifest.xml and confirm it contains the android.permission.VIBRATE permission
  9. Neeraj Gupta 2014-01-09

    [~cbarber] Additional comment from Stephen Feather: Permissions are not being generated for Ti proxy objects that DO require them. Additionally, in investigating the permissions issue for the end user, it appears that if an overlay is added to a camera proxy on android, the modules.titanium.media.tiCameraActivity class may not be being added to the androidManifest.xml either. Please make sure that your fix takes care of this scenario as well.
  10. Priya Agarwal 2014-01-09

    Test Environment: Appc-Studio: 3.2.1.201401081616 acs:1.0.11 alloy:1.3.1-beta npm:1.3.2 titanium:3.2.0-beta titanium-code-processor:1.1.0 Osx: Maverick 10.9 Xcode: xCode 5.0.2 Device: HTC Desire(v4.0.3) and IPhone4s(v7.0) Using both sdk build 3.2.1.v20140108194846 and 3.3.0.v20140108194850 Ti.Media.vibrate working fine. Used Above Test Code to test the issue. On runtime
        <uses-permission android:name="android.permission.VIBRATE"/>
        
    Required permission gets added in androidManifest file. Issue seems to be fixed and hence closing.
  11. Thomas Huelbert 2014-01-09

    Priya - please read the notes more carefully when you close bugs. This was an emulator issue and should _not_ have been closed against a device.
  12. Wilson Luu 2014-01-09

    Reopening ticket to validate against the Android emulator.
  13. Wilson Luu 2014-01-10

    Closing ticket as fixed. Verified the VIBRATE and CAMERA permissions are added to the build/android/AndroidManifest.xml file. Also, verified the ti.modules.titanium.media.TiCameraActivity gets added to the build/android/AndroidManifest.xml with camera overlay and without camera overlay (e.g. calling Ti.Media.showCamera() without setting the overlay property). Here is the app.js that I used to verify:
        var window = Ti.UI.createWindow({
        	backgroundColor:'white',
        	layout:'vertical'
        });
        
        var vibrateBtn = Ti.UI.createButton({
        	title:'vibrate'
        });
        
        var cameraBtn = Ti.UI.createButton({
        	title:'camera'
        });
        
        var cameraOverlayBtn = Ti.UI.createButton({
        	title:'camera overaly'
        });
        
        vibrateBtn.addEventListener('click', function(e){
        	Ti.API.info('### vibrate');
        	Ti.Media.vibrate();
        });
        
        cameraBtn.addEventListener('click', function(e){
        	Ti.API.info('### camera');
        	
        	Titanium.Media.showCamera({
        		success:function(success_event) {
        			Ti.API.info('### camera success');
        		},
        		
        		cancel:function(cancel_event) {
        			Ti.API.info('### camera cancel');
        		},
        		
        		error:function(error_event) {
        			Ti.API.info('### camera error');
        		}
        	});
        });
        
        cameraOverlayBtn.addEventListener('click', function(e){
        	// uncomment this section to verify if ti.modules.titanium.media.TiCameraActivity gets added to build/android/AndroidManifest.xml; 
        	// need to comment cameraBtn.addEventListener() section first
        	
        	// Ti.API.info('### camera overlay');
        // 	
        	// var customOverlay = Ti.UI.createView();
        // 	
        	// var takePhotoButton = Ti.UI.createButton({
        		// title:'Take Photo',
        		// backgroundColor : '#fff',
                // backgroundSelectedColor : '#efefef',
                // borderColor : '#000',
                // borderRadius : 17,
                // borderWidth : 1,
                // bottom : 65,
                // color : '#000',
                // height : 34,
                // opacity : 0.4,
                // width : '100dp'
            // });
        //     
            // takePhotoButton.addEventListener('click', function(e) {
                // Ti.Media.takePicture();
            // });
        // 	
        	// customOverlay.add(takePhotoButton);
        // 	
        	// Titanium.Media.showCamera({
        		// success:function(success_event) {
        			// Ti.API.info('### camera overlay success');
        		// },
        // 		
        		// cancel:function(cancel_event) {
        			// Ti.API.info('### camera overlay cancel');
        		// },
        // 		
        		// error:function(error_event) {
        			// Ti.API.info('### camera overlay error');
        		// },
        // 		
        		// overlay:customOverlay
        	// });
        });
        
        window.add(vibrateBtn);
        window.add(cameraBtn);
        window.add(cameraOverlayBtn);
        
        window.open();
        
    Tested on: Appcelerator Studio, build: 3.2.1.201401081616 SDK build: 3.2.1.v20140109120846, 3.3.0.v20140109120852 CLI: 3.2.1-beta Alloy: 1.3.1-beta2 Device: Android Emulator (2.3.3), Android Emulator (4.3)

JSON Source