Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4737] Tooling: Allow substitution parameters for Android package name

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2011-08-29T13:28:20.000+0000
Affected Version/sRelease 1.7.2
Fix Version/sSprint 2011-34, Release 1.8.0
ComponentsTooling
Labelsn/a
ReporterJeff English
AssigneeBill Dawson
Created2011-07-20T17:07:07.000+0000
Updated2014-06-19T12:46:13.000+0000

Description

Enhance the build tools for android so that substitution parameters can be applied in the timodule.xml. The timodule.xml file contains manifest information that gets inserted into the android.manifest file during the build process. The Urban Airship module, for example, requires that the package name be set as part of the category name. Currently the user must update the timodule.xml with the package name, but it should be possible to automate this by allowing the specification of substitution parameters (for example, __PACKAGE_NAME__) so that the build process replaces __PACKAGE_NAME__ with the name of the package. Example:
  <manifest>
    <application>
	<!-- REQUIRED for C2DM and Hybrid -->
	<receiver android:name="com.urbanairship.push.c2dm.C2DMPushReceiver"
			android:permission="com.google.android.c2dm.permission.SEND">        
	  <!-- Receive the actual message -->
	  <intent-filter>
		  <action android:name="com.google.android.c2dm.intent.RECEIVE" />
		  <category android:name="__PACKAGE_NAME__" />
	  </intent-filter>
	  <!-- Receive the registration id -->
	  <intent-filter>
		  <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
		  <category android:name="__PACKAGE_NAME__" />
	  </intent-filter>
	</receiver>
    </application>

	<!-- REQUIRED for C2DM -->
	<!-- Only this application can receive the messages and registration result -->
	<permission android:name="__PACKAGE_NAME__.permission.C2D_MESSAGE"
		android:protectionLevel="signature" />
	<uses-permission android:name="__PACKAGE_NAME__.permission.C2D_MESSAGE" />		
	<!-- This app has permission to register and receive messages -->
	<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
		
  </manifest>
When built would be inserted into the android.manifest file as
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.appcelerator.urbanairshiptest"
      android:versionCode="1"
      android:versionName="1"
>
...

	<permission android:name="com.appcelerator.urbanairshiptest.permission.C2D_MESSAGE" android:protectionLevel="signature"/>

...
	  <intent-filter>
		  <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
		  <category android:name="com.appcelerator.urbanairshiptest"/>
	  </intent-filter>
	  <!-- Receive the registration id -->
	  <intent-filter>
		  <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
		  <category android:name="com.appcelerator.urbanairshiptest"/>
	  </intent-filter>
...
	<uses-permission android:name="com.appcelerator.urbanairshiptest.permission.C2D_MESSAGE"/>

Attachments

FileDateSize
ti.bogus-android-0.1.zip2011-08-22T13:28:22.000+000012361

Comments

  1. Jeff English 2011-08-15

    Use the ${...} notation instead of the notation shown in the initial example
  2. Bill Dawson 2011-08-22

    Bogus titanium module to use for testing
  3. Bill Dawson 2011-08-22

    Testing Notes: * Create a titanium project. * Dump the attached module zip into its root folder. * Build the project. * Open modules/android/ti.bogus/0.1/timodule.xml just so you can see what I put in there. You'll notice the mako (template engine) tokens in a few places, namely in the attribute values for the bogus and bogus2 elements. The idea here is that the token ${tiapp.properties\['id\]} will be replaced with the id of the app you create. * Now open build/android/AndroidManifest.xml and look for those bogus and bogus2 elements. Also make sure that the android.permission.DEVICE_POWER permission is in the AndroidManifest.xml. Because I touched that area of code, I want to be sure permissions still get in there correctly.
  4. Bill Dawson 2011-08-22

    Pull request ready: https://github.com/appcelerator/titanium_mobile/pull/403

JSON Source