# TMS Service

**Introduction**

In order to upload applications to server and deploy them successfully on devices, following conditions should be met:

* Manifest files should be adjusted to have required metadata
* apk files must be signed with appropriate keys

**Adjusting the Manifest File**

Fields below should be in AndroidManifest.xml, under manifest -> application -> meta-data tags, as name-value pairs.

<table><thead><tr><th>Name</th><th>Type</th><th>Length</th><th>Description</th><th width="233.15234375">Example</th><th>Required</th></tr></thead><tbody><tr><td>app_name</td><td>String</td><td>At most 20</td><td>Application name with application type prefix</td><td><p>“LYL_COMPANYNAME” </p><p>or</p><p>"BNK_ID_COMPANYNAME"</p></td><td>Yes</td></tr><tr><td>app_model_type</td><td>String</td><td>At most 8</td><td>Model type name (should match with model type name in ATMS)</td><td>“400TR”</td><td>Yes</td></tr><tr><td>app_version</td><td>Integer</td><td>-</td><td>Version of the application</td><td>"1"</td><td>Yes</td></tr></tbody></table>

Separate apks should be created for 400TR,  1000TR, X30TR devices. The apk prepared for 400TR should have 400TR information in the XML file. The apk prepared for 1000TR should have 1000TR information. The apk prepared for X30TR should have X30TR information.

```
// for app_name
// if you are Retail developer then "LYL_COPMANYNAME" 
// if you are an Bank developer "BNK_ID_COMPANYNAME"
```

**Example 400TR:**

**Retail:**

<pre><code>&#x3C;manifest ... >
    ...
    &#x3C;application ... >
        ...
        &#x3C;meta-data android:name="app_name" android:value="LYL_COMPANYNAME" /> 
        &#x3C;meta-data android:name="app_model_type" android:value="400TR" /> // For 400TR devices
<strong>        &#x3C;meta-data android:name="app_version" android:value="40000110" /> // Change Android  Version major/minor/build into integer. We kindly request this change. Version no must start with 400. Example: 40000110.
</strong>     &#x3C;/application>
<strong>...
</strong></code></pre>

**Bank**:

<pre><code>&#x3C;manifest ... >
    ...
    &#x3C;application ... >
        ...
        &#x3C;meta-data android:name="app_name" android:value="BNK_ID_COMPANYNAME" /> 
        &#x3C;meta-data android:name="app_model_type" android:value="400TR" /> // For 400TR devices
<strong>        &#x3C;meta-data android:name="app_version" android:value="40000110" /> // Change Android  Version major/minor/build into integer. We kindly request this change. Version no must start with 400. Example: 40000110.
</strong>     &#x3C;/application>
<strong>...
</strong></code></pre>

**Example 1000TR:**

**Bank**:

```
<manifest ... >
    ...
    <application ... >
        ...
        <meta-data android:name="app_name" android:value="LYL_COMPANYNAME" /> 
        <meta-data android:name="app_model_type" android:value="1000TR" /> // For 1000TR devices
        <meta-data android:name="app_version" android:value="100000110" /> // Change Android  Version major/minor/build into integer. We kindly request this change. Version no must start with 1000. Example: 100000110.
     </application>
...    
```

**Bank**:

```
<manifest ... >
    ...
    <application ... >
        ...
        <meta-data android:name="app_name" android:value="BNK_ID_COMPANYNAME" /> // if you are Retail developer then "LYL_COPMANYNAME" , if you are an Bank developer "BNK_ID_COMPANYNAME"
        <meta-data android:name="app_model_type" android:value="1000TR" /> // For 1000TR devices
        <meta-data android:name="app_version" android:value="100000110" /> // Change Android  Version major/minor/build into integer. We kindly request this change. Version no must start with 1000. Example: 100000110.
     </application>
...    
```

**Example X30TR:**

**Retail:**

```
<manifest ... >
    ...
    <application ... >
        ...
        <meta-data android:name="app_name" android:value="LYL_COMPANYNAME" /> // if you are Retail developer then "LYL_COPMANYNAME" , if you are an Bank developer "BNK_ID_COMPANYNAME"
        <meta-data android:name="app_model_type" android:value="330TR" /> // For 330TR devices
        <meta-data android:name="app_version" android:value="33000110" /> // Change Android  Version major/minor/build into integer. We kindly request this change. Version no must start with 330. Example: 33000110.
     </application>
...    
```

**Bank:**

```
<manifest ... >
    ...
    <application ... >
        ...
        <meta-data android:name="app_name" android:value="BNK_ID_COMPANYNAME" /> // if you are Retail developer then "LYL_COPMANYNAME" , if you are an Bank developer "BNK_ID_COMPANYNAME"
        <meta-data android:name="app_model_type" android:value="330TR" /> // For 330TR devices
        <meta-data android:name="app_version" android:value="33000110" /> // Change Android  Version major/minor/build into integer. We kindly request this change. Version no must start with 330. Example: 33000110.
     </application>
...    
```

**To convert version name to manifest data, you can use following example in your build.gradle**

```java
apply plugin: 'com.android.application'

// This section is parsing Android manifest file, reads version in the meta-data tag, writes it into version name in gradle
// so that the version shown in the android settinsg is same as version in the meta-tag
def versionFromManifest

task parseManifest() {
    def manifest = new XmlSlurper().parse(file(android.sourceSets.main.manifest.srcFile)).declareNamespace(android: 'http://schemas.android.com/apk/res/android');
    println manifest.@package
    manifest.application["meta-data"].each {
        def m = it.attributes()['android:name'] =~ /app_version/
        if (m.find()) {
            versionFromManifest = it.attributes()['android:value'].toString()
        }
    }
}

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.atms_alpha"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode versionFromManifest.toInteger()
        versionName "${versionFromManifest}"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        setProperty("archivesBaseName", "ATMS_Alpha_" + versionFromManifest)

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
```
