Skip to content

Commit

Permalink
Merge branch 'master' into fix/ios-leaks-20201107
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysingh-axway committed Dec 7, 2020
2 parents cf458a1 + 55c14d7 commit 37c75ba
Show file tree
Hide file tree
Showing 328 changed files with 20,247 additions and 19,374 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"files": [ "android/runtime/common/src/js/**/*.js", "android/modules/**/src/js/**/*.js" ],
"parserOptions": {
"ecmaVersion": 6
"ecmaVersion": 2020
},
"globals": {
"kroll": "readonly",
Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ junit_report.xml
/iphone/TitaniumKit/Carthage
/iphone/TitaniumKit/docs
/iphone/TitaniumKit/build
/iphone/TitaniumKit/TitaniumKit/Sources/API/TopTiModule.bak
/iphone/lib/libTiCore.a

.vscode/*
Expand All @@ -48,6 +49,6 @@ coverage/

tests/diffs/
tests/generated/
# in-memory blobs written to disk as the expected image for image compariosn tests
tests/Resources/ios/snapshots/1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].png
tests/Resources/android/snapshots/1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].png
# in-memory blobs written to disk as the expected image for image comparison tests
tests/Resources/ios/snapshots/1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_*.png
tests/Resources/android/snapshots/1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_*.png
191 changes: 191 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,19 @@ def androidUnitTests(nodeVersion, npmVersion, testOnDevices) {
def zipName = getBuiltSDK()
sh label: 'Install SDK', script: "npm run deploy -- ${zipName} --select" // installs the sdk
try {
timeout(30) {
// Forcibly remove value for specific build tools version to use (set by module builds)
sh returnStatus: true, script: 'ti config android.buildTools.selectedVersion --remove'
// run main branch tests on devices
if (testOnDevices) {
sh label: 'Run Test Suite on device(s)', script: "npm run test:integration -- android -T device -C all"
// run PR tests on emulator
} else {
sh label: 'Run Test Suite on emulator', script: "npm run test:integration -- android -T emulator -D test -C android-30-playstore-x86"
}
} // timeout
withEnv(['CI=1']) {
timeout(30) {
// Forcibly remove value for specific build tools version to use (set by module builds)
sh returnStatus: true, script: 'ti config android.buildTools.selectedVersion --remove'
// run main branch tests on devices
if (testOnDevices) {
sh label: 'Run Test Suite on device(s)', script: "npm run test:integration -- android -T device -C all"
// run PR tests on emulator
} else {
sh label: 'Run Test Suite on emulator', script: "npm run test:integration -- android -T emulator -D test -C android-30-playstore-x86"
}
} // timeout
}
} catch (e) {
archiveArtifacts 'tmp/mocha/build/build_*.log' // save build log if build failed
gatherAndroidCrashReports()
Expand Down Expand Up @@ -152,8 +154,10 @@ def macosUnitTests(nodeVersion, npmVersion) {
def zipName = getBuiltSDK()
sh label: 'Install SDK', script: "npm run deploy -- ${zipName} --select" // installs the sdk
try {
timeout(20) {
sh label: 'Run Test Suite on macOS', script: 'npm run test:integration -- ios -T macos'
withEnv(['CI=1']) {
timeout(20) {
sh label: 'Run Test Suite on macOS', script: 'npm run test:integration -- ios -T macos'
}
}
} catch (e) {
gatherIOSCrashReports('mocha') // app name is mocha
Expand Down Expand Up @@ -193,11 +197,13 @@ def iosUnitTests(deviceFamily, nodeVersion, npmVersion, testOnDevices) {
def zipName = getBuiltSDK()
sh label: 'Install SDK', script: "npm run deploy -- ${zipName} --select" // installs the sdk
try {
timeout(40) {
if (testOnDevices && deviceFamily == 'iphone') {
sh label: 'Run Test Suite on device(s)', script: "npm run test:integration -- ios -F ${deviceFamily} -T device -C all"
} else { // run PR tests on simulator
sh label: 'Run Test Suite on simulator', script: "npm run test:integration -- ios -F ${deviceFamily}"
withEnv(['CI=1']) {
timeout(40) {
if (testOnDevices && deviceFamily == 'iphone') {
sh label: 'Run Test Suite on device(s)', script: "npm run test:integration -- ios -F ${deviceFamily} -T device -C all"
} else { // run PR tests on simulator
sh label: 'Run Test Suite on simulator', script: "npm run test:integration -- ios -F ${deviceFamily}"
}
}
}
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<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.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>

<!-- Permissions needed to test Ti.Geolocation module. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Expand Down
14 changes: 7 additions & 7 deletions android/app/src/main/assets/Resources/app.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict';

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
Titanium.UI.backgroundColor = '#000';

// create tab group
var tabGroup = Titanium.UI.createTabGroup();
const tabGroup = Titanium.UI.createTabGroup();

//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
const win1 = Titanium.UI.createWindow({
title: 'Tab 1',
backgroundColor: '#fff'
});
var tab1 = Titanium.UI.createTab({
const tab1 = Titanium.UI.createTab({
icon: 'KS_nav_views.png',
title: 'Tab 1',
window: win1
});

var label1 = Titanium.UI.createLabel({
const label1 = Titanium.UI.createLabel({
color: '#999',
text: 'I am Window 1',
font: { fontSize: 20, fontFamily: 'Helvetica Neue' },
Expand All @@ -32,11 +32,11 @@ win1.add(label1);
//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({
const win2 = Titanium.UI.createWindow({
title: 'Tab 2',
backgroundColor: '#fff'
});
var tab2 = Titanium.UI.createTab({
const tab2 = Titanium.UI.createTab({
icon: 'KS_nav_ui.png',
title: 'Tab 2',
window: win2
Expand Down
20 changes: 16 additions & 4 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3476,10 +3476,11 @@ AndroidBuilder.prototype.fetchNeededManifestSettings = function fetchNeededManif

// Define Android <uses-permission/> names needed by our core Titanium APIs.
const calendarPermissions = [ 'android.permission.READ_CALENDAR', 'android.permission.WRITE_CALENDAR' ];
const cameraPermissions = [ 'android.permission.CAMERA' ];
const cameraPermissions = [ 'android.permission.CAMERA', 'android.permission.WRITE_EXTERNAL_STORAGE' ];
const contactsPermissions = [ 'android.permission.READ_CONTACTS', 'android.permission.WRITE_CONTACTS' ];
const contactsReadPermissions = [ 'android.permission.READ_CONTACTS' ];
const geoPermissions = [ 'android.permission.ACCESS_COARSE_LOCATION', 'android.permission.ACCESS_FINE_LOCATION' ];
const storagePermissions = [ 'android.permission.WRITE_EXTERNAL_STORAGE' ];
const vibratePermissions = [ 'android.permission.VIBRATE' ];
const wallpaperPermissions = [ 'android.permission.SET_WALLPAPER' ];

Expand All @@ -3504,7 +3505,10 @@ AndroidBuilder.prototype.fetchNeededManifestSettings = function fetchNeededManif
'Contacts.getAllPeople': contactsReadPermissions,
'Contacts.getAllGroups': contactsReadPermissions,

'Filesystem.requestStoragePermissions': storagePermissions,

'Media.Android.setSystemWallpaper': wallpaperPermissions,
'Media.saveToPhotoGallery': storagePermissions,
'Media.showCamera': cameraPermissions,
'Media.vibrate': vibratePermissions,
};
Expand All @@ -3517,9 +3521,12 @@ AndroidBuilder.prototype.fetchNeededManifestSettings = function fetchNeededManif
neededPermissionDictionary['android.permission.INTERNET'] = true;
neededPermissionDictionary['android.permission.ACCESS_WIFI_STATE'] = true;
neededPermissionDictionary['android.permission.ACCESS_NETWORK_STATE'] = true;
neededPermissionDictionary['android.permission.WRITE_EXTERNAL_STORAGE'] = true;
}

// Set the max API Level the "WRITE_EXTERNAL_STORAGE" permission should use.
// Android 10 and higher doesn't need this permission unless requestStoragePermissions() method is used.
let storagePermissionMaxSdkVersion = 28;

// Define JavaScript methods that need manifest <queries> entries.
// The value strings are used as boolean property names in our "AndroidManifest.xml" EJS template.
const tiMethodQueries = {
Expand Down Expand Up @@ -3579,6 +3586,9 @@ AndroidBuilder.prototype.fetchNeededManifestSettings = function fetchNeededManif
for (const permission of permissionArray) {
neededPermissionDictionary[permission] = true;
}
if (symbol === 'Filesystem.requestStoragePermissions') {
storagePermissionMaxSdkVersion = undefined;
}
}
}

Expand All @@ -3592,8 +3602,9 @@ AndroidBuilder.prototype.fetchNeededManifestSettings = function fetchNeededManif

// Return the entries needed to be injected into the generated "AndroidManifest.xml" file.
const neededSettings = {
usesPermissions: Object.keys(neededPermissionDictionary),
queries: neededQueriesDictionary
queries: neededQueriesDictionary,
storagePermissionMaxSdkVersion: storagePermissionMaxSdkVersion,
usesPermissions: Object.keys(neededPermissionDictionary)
};
return neededSettings;
};
Expand Down Expand Up @@ -3688,6 +3699,7 @@ AndroidBuilder.prototype.generateAndroidManifest = async function generateAndroi
appLabel: this.tiapp.name,
appTheme: `@style/${this.defaultAppThemeName}`,
classname: this.classname,
storagePermissionMaxSdkVersion: neededManifestSettings.storagePermissionMaxSdkVersion,
packageName: this.appid,
queries: neededManifestSettings.queries,
usesPermissions: neededManifestSettings.usesPermissions
Expand Down
17 changes: 17 additions & 0 deletions android/cli/lib/android-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,23 @@ class AndroidManifest {
// Apply "tools:replace" attribute to <manifest/> element. (Must be done after setting namespace above.)
applyToolsReplaceToElement(manifestElement);

// Apply 'tools:node="replace"' to WRITE_EXTERNAL_STORAGE permission if no other tools attribute is set.
// Titanium adds "maxSdkVersion" attribute to this permission by default. This removes that attribute.
const permissionElement = getFirstChildElementByTagAndAndroidName(
manifestElement, 'uses-permission', 'android.permission.WRITE_EXTERNAL_STORAGE');
if (permissionElement) {
let hasToolsAttribute = false;
for (let index = 0; index < permissionElement.attributes.length; index++) {
if (permissionElement.attributes.item(index).name.startsWith('tools:')) {
hasToolsAttribute = true;
break;
}
}
if (!hasToolsAttribute) {
permissionElement.setAttribute('tools:node', 'replace');
}
}

// Fetch the <application/> element.
const appElement = getFirstChildElementByTagName(manifestElement, 'application');
if (!appElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public class KrollJSONGenerator extends AbstractProcessor
protected String jarJsonPackageName;
protected String jarJsonFileName;
protected String jsonFilePath;
protected boolean isTitaniumSdk = true;
protected boolean initialized = false;
private boolean hasPropertiesChanged = true;

Expand Down Expand Up @@ -189,6 +190,7 @@ protected void initialize()
if ((stringValue != null) && !stringValue.isEmpty()) {
this.jsonFilePath = stringValue;
}
isTitaniumSdk = (processingEnv.getOptions().get(OPTION_TI_BINDINGS_JSON_FILE_PATH_NAME) == null);

// If we're set up to generate a JSON file within a JAR,
// then attempt to read our previously generated JSON file if it exists.
Expand Down Expand Up @@ -327,6 +329,7 @@ public boolean visit(AnnotationMirror annotation, Object arg)
proxyProperties.put("superProxyClassName", superTypeName);
}

proxyProperties.put("isTitaniumSdk", isTitaniumSdk);
proxyProperties.put("isModule", isModule);
proxyProperties.put("packageName", packageName);
proxyProperties.put("proxyClassName", proxyClassName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,20 @@ void ${className}::${method.apiName}(const FunctionCallbackInfo<Value>& args)

<#if method.args?size == 0 && name[0..2] == "get" && isDynamic>
<#assign propertyName = name[3]?lower_case + name[4..]>
Proxy::logDeprecation(isolate, "Getter method deprecated, please use \"obj.${propertyName};\" or \"obj['${propertyName}'];\" instead.");
const char *deprecationMessage = "Getter method deprecated, please use \"obj.${propertyName};\" or \"obj['${propertyName}'];\" instead.";
<#if isTitaniumSdk>
Proxy::logDeprecation(isolate, deprecationMessage);
<#else>
LOGW(TAG, deprecationMessage);
</#if>
<#elseif method.args?size == 1 && name[0..2] == "set" && isDynamic>
<#assign propertyName = name[3]?lower_case + name[4..]>
Proxy::logDeprecation(isolate, "Setter method deprecated, please use \"obj.${propertyName} = val;\" or \"obj['${propertyName}'] = val;\" instead.");
const char *deprecationMessage = "Setter method deprecated, please use \"obj.${propertyName} = val;\" or \"obj['${propertyName}'] = val;\" instead.";
<#if isTitaniumSdk>
Proxy::logDeprecation(isolate, deprecationMessage);
<#else>
LOGW(TAG, deprecationMessage);
</#if>
</#if>

jobject javaProxy = proxy->getJavaObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;

import android.Manifest;
import android.app.Activity;
Expand All @@ -21,6 +20,7 @@
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.io.TiFileFactory;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiBaseActivity;
import org.appcelerator.titanium.TiC;
Expand All @@ -40,8 +40,6 @@ public class FilesystemModule extends KrollModule
@Kroll.constant
public static final int MODE_APPEND = 2;

private static String[] RESOURCES_DIR = { "app://" };

// Methods
public FilesystemModule()
{
Expand Down Expand Up @@ -145,7 +143,7 @@ public FileProxy getApplicationDirectory()
@Kroll.getProperty
public String getApplicationDataDirectory()
{
return "appdata-private://";
return TiFileFactory.APPDATA_PRIVATE_URL_SCHEME + "://";
}

@Kroll.method
Expand All @@ -155,39 +153,31 @@ public String getResRawDirectory()
return "android.resource://" + TiApplication.getInstance().getPackageName() + "/raw/";
}

@SuppressWarnings("deprecation")
@Kroll.method
@Kroll.getProperty
public String getApplicationCacheDirectory()
{
TiApplication app = TiApplication.getInstance();
if (app == null) {
return null;
}

File cacheDir = app.getCacheDir();

try {
return cacheDir.toURL().toString();

} catch (MalformedURLException e) {
Log.e(TAG, "Exception converting cache directory to URL", e);
return null;
}
return "file://" + TiApplication.getInstance().getCacheDir().getAbsolutePath();
}

@Kroll.method
@Kroll.getProperty
public String getResourcesDirectory()
{
return "app://";
return TiC.URL_APP_PREFIX;
}

@Kroll.getProperty
public String getExternalCacheDirectory()
{
return TiFileFactory.APPCACHE_EXTERNAL_URL_SCHEME + "://";
}

@Kroll.method
@Kroll.getProperty
public String getExternalStorageDirectory()
{
return "appdata://";
return TiFileFactory.APPDATA_URL_SCHEME + "://";
}

@Kroll.method
Expand Down

0 comments on commit 37c75ba

Please sign in to comment.