1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-04 16:30:12 +02:00

prefer build.gradle with Android Plugin as source of package/version/code

These days, the location that overrides all the others is in the android{}
block of the build.gradle file that loads the com.android.application
plugin.  So this should be the preferred place to read these values.

test files GPL licensed: https://github.com/Integreight/1Sheeld-Android-App
This commit is contained in:
Hans-Christoph Steiner 2020-02-03 21:13:26 +01:00
parent d9722f4453
commit 83ffeb855f
17 changed files with 598 additions and 2 deletions

View File

@ -81,6 +81,7 @@ FDROID_PACKAGE_NAME_REGEX = re.compile(r'''^[a-f0-9]+$''', re.IGNORECASE)
STRICT_APPLICATION_ID_REGEX = re.compile(r'''(?:^[a-zA-Z]+(?:\d*[a-zA-Z_]*)*)(?:\.[a-zA-Z]+(?:\d*[a-zA-Z_]*)*)+$''')
VALID_APPLICATION_ID_REGEX = re.compile(r'''(?:^[a-z_]+(?:\d*[a-zA-Z_]*)*)(?:\.[a-z_]+(?:\d*[a-zA-Z_]*)*)*$''',
re.IGNORECASE)
ANDROID_PLUGIN_REGEX = re.compile(r'''\s*(:?apply plugin:|id)\(?\s*['"](android|com\.android\.application)['"]\s*\)?''')
MAX_VERSION_CODE = 0x7fffffff # Java's Integer.MAX_VALUE (2147483647)
@ -1421,6 +1422,7 @@ def parse_androidmanifests(paths, app):
if has_extension(path, 'gradle'):
with open(path, 'r') as f:
android_plugin_file = False
inside_flavour_group = 0
inside_required_flavour = 0
for line in f:
@ -1496,6 +1498,17 @@ def parse_androidmanifests(paths, app):
matches = vcsearch_g(line)
if matches:
vercode = matches.group(1)
if not android_plugin_file and ANDROID_PLUGIN_REGEX.match(line):
android_plugin_file = True
if android_plugin_file:
if package:
max_package = package
if version:
max_version = version
if vercode:
max_vercode = vercode
if max_package and max_version and max_vercode:
break
else:
try:
xml = parse_xml(path)

View File

@ -41,7 +41,6 @@ from .exception import FDroidException
SETTINGS_GRADLE = re.compile(r'settings\.gradle(?:\.kts)?')
GRADLE_SUBPROJECT = re.compile(r'''['"]:([^'"]+)['"]''')
ANDROID_PLUGIN = re.compile(r'''\s*(:?apply plugin:|id)\(?\s*['"](android|com\.android\.application)['"]\s*\)?''')
# Get the repo type and address from the given web page. The page is scanned
@ -197,7 +196,7 @@ def get_gradle_subdir(build_dir, paths):
line = fp.readline()
if not line:
break
if ANDROID_PLUGIN.match(line):
if common.ANDROID_PLUGIN_REGEX.match(line):
return os.path.relpath(os.path.dirname(f), build_dir)
if first_gradle_dir and first_gradle_dir != '.':
return first_gradle_dir

View File

@ -840,6 +840,27 @@ class CommonTest(unittest.TestCase):
self.assertEqual(('0.6.9', '23', 'cn.wildfirechat.chat'),
fdroidserver.common.parse_androidmanifests(paths, app))
app = fdroidserver.metadata.App()
app.Repo = 'https://github.com/Integreight/1Sheeld-Android-App'
paths = [
os.path.join('source-files', 'com.integreight.onesheeld', 'pagerIndicator', 'src', 'main', 'AndroidManifest.xml'),
os.path.join('source-files', 'com.integreight.onesheeld', 'pagerIndicator', 'build.gradle'),
os.path.join('source-files', 'com.integreight.onesheeld', 'oneSheeld', 'src', 'main', 'AndroidManifest.xml'),
os.path.join('source-files', 'com.integreight.onesheeld', 'oneSheeld', 'build.gradle'),
os.path.join('source-files', 'com.integreight.onesheeld', 'localeapi', 'src', 'main', 'AndroidManifest.xml'),
os.path.join('source-files', 'com.integreight.onesheeld', 'localeapi', 'build.gradle'),
os.path.join('source-files', 'com.integreight.onesheeld', 'build.gradle'),
os.path.join('source-files', 'com.integreight.onesheeld', 'settings.gradle'),
os.path.join('source-files', 'com.integreight.onesheeld', 'quickReturnHeader', 'src', 'main', 'AndroidManifest.xml'),
os.path.join('source-files', 'com.integreight.onesheeld', 'quickReturnHeader', 'build.gradle'),
os.path.join('source-files', 'com.integreight.onesheeld', 'pullToRefreshlibrary', 'src', 'main', 'AndroidManifest.xml'),
os.path.join('source-files', 'com.integreight.onesheeld', 'pullToRefreshlibrary', 'build.gradle'),
]
for path in paths:
self.assertTrue(os.path.isfile(path))
self.assertEqual(('1.9.0', '170521', 'com.integreight.onesheeld'),
fdroidserver.common.parse_androidmanifests(paths, app))
def test_parse_androidmanifests_ignore(self):
app = fdroidserver.metadata.App()
app.id = 'org.fdroid.fdroid'

View File

@ -29,6 +29,7 @@ class ScannerTest(unittest.TestCase):
source_files = os.path.join(self.basedir, 'source-files')
projects = {
'cn.wildfirechat.chat': 4,
'com.integreight.onesheeld': 11,
'Zillode': 1,
'firebase-suspect': 1,
'org.mozilla.rocket': 3,

View File

@ -0,0 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}

View File

@ -0,0 +1,6 @@
#Wed Mar 15 14:07:53 EET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

View File

@ -0,0 +1,22 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:25.1.0'
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.twofortyfouram.locale.api" >
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
</manifest>

View File

@ -0,0 +1,129 @@
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.integreight.onesheeld"
minSdkVersion 9
targetSdkVersion 25
versionCode 170521
versionName "1.9.0"
archivesBaseName = "1Sheeld.v$versionName.$versionCode"
buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
}
buildTypes.all {
ext.enableCrashlytics = isCrashlyticsPropertiesAvailable()
}
buildTypes {
debug {
versionNameSuffix getWorkingBranchSuffix()
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile project(':localeapi')
compile project(':pullToRefreshlibrary')
compile project(':quickReturnHeader')
compile project(':pagerIndicator')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:25.3.1'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.google.android.gms:play-services-analytics:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'com.google.android.gms:play-services-vision:10.0.1'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.snappydb:snappydb-lib:0.5.0'
compile 'com.esotericsoftware.kryo:kryo:2.24.0'
compile 'com.github.hotchemi:android-rate:0.5.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
compile('com.google.android.gms:play-services-identity:10.0.1') {
transitive = true;
}
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-gmail:v1-rev48-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile 'org.twitter4j:twitter4j-core:4.0.4'
compile 'org.twitter4j:twitter4j-async:4.0.4'
compile 'org.twitter4j:twitter4j-stream:4.0.4'
compile 'cz.msebera.android:httpclient:4.4.1.1'
compile 'net.sf.supercsv:super-csv:2.4.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.github.emanzanoaxa:RippleEffect:52ea2a0ab6'
compile 'com.drewnoakes:metadata-extractor:2.8.1'
compile 'com.integreight.onesheeld:sdk:2.2.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
def isCrashlyticsPropertiesAvailable() {
return new File("./oneSheeld/fabric.properties").exists()
}
def getWorkingBranchSuffix() {
def workingBranchSuffix = ""
try {
def workingBranch = "git --git-dir=${rootDir}/.git --work-tree=${rootDir} rev-parse --abbrev-ref HEAD".execute().text.trim()
workingBranchSuffix = (workingBranch != "") ? " - branch:" + workingBranch : ""
}
catch (all) {
}
return workingBranchSuffix
}
def isGoogleServicesFileAvailable() {
return new File("./oneSheeld/google-services.json").exists()
}
if (isGoogleServicesFileAvailable()) {
apply plugin: 'com.google.gms.google-services'
}

View File

@ -0,0 +1,280 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.integreight.onesheeld">
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission
android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<permission
android:name="com.integreight.onesheeld.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.integreight.onesheeld.permission.C2D_MESSAGE" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.bluetooth"
android:required="true" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.front"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.flash"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-feature
android:name="android.hardware.microphone"
android:required="false" />
<uses-feature
android:name="android.hardware.nfc"
android:required="false" />
<application
android:name="com.integreight.onesheeld.OneSheeldApplication"
android:allowBackup="true"
android:allowClearUserData="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:resizeableActivity="false"
android:theme="@style/AppTheme">
<activity
android:name="com.integreight.onesheeld.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|locale|fontScale|layoutDirection|screenLayout|screenSize|smallestScreenSize|uiMode"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
<meta-data android:name="com.facebook.sdk.ApplicationName"
android:value="@string/app_name" />
<provider android:authorities="com.facebook.app.FacebookContentProvider1423548367865538"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
<receiver android:name="com.integreight.onesheeld.utils.FacebookBroadcastReceiver">
<intent-filter>
<action android:name="com.facebook.platform.AppCallResultBroadcast" />
</intent-filter>
</receiver>
<service
android:name="com.integreight.onesheeld.services.OneSheeldService"
android:exported="false"
android:singleUser="false" />
<activity
android:name="com.integreight.onesheeld.plugin.action.ActionActivity"
android:configChanges="orientation"
android:exported="true"
android:icon="@drawable/ic_launcher"
android:label="@string/plugin_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light"
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="adjustResize"
tools:ignore="ExportedActivity">
<!-- this Intent filter allows the plug-in to be discovered by Locale -->
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
</intent-filter>
</activity>
<activity
android:name="com.integreight.onesheeld.plugin.condition.ConditionActivity"
android:configChanges="orientation"
android:exported="true"
android:icon="@drawable/ic_launcher"
android:label="@string/plugin_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light"
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="adjustResize"
tools:ignore="ExportedActivity">
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_CONDITION" />
</intent-filter>
</activity>
<activity
android:name=".shields.controller.utils.NfcUtils"
android:allowTaskReparenting="true"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
android:taskAffinity=":nfc"
android:theme="@style/Theme.Transparent"/>
<activity-alias
android:name="NFCUtils-alias"
android:enabled="true"
android:exported="true"
android:targetActivity=".shields.controller.utils.NfcUtils">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:scheme="tel" />
<data android:scheme="mailto" />
<data android:scheme="ftp" />
<data android:scheme="ftps" />
<data android:scheme="sftp" />
<data android:scheme="smb" />
<data android:scheme="nfs" />
<data android:scheme="dav" />
<data android:scheme="news" />
<data android:scheme="telnet" />
<data android:scheme="imap" />
<data android:scheme="rtsp" />
<data android:scheme="urn" />
<data android:scheme="pop" />
<data android:scheme="sip" />
<data android:scheme="sips" />
<data android:scheme="tftp" />
<data android:scheme="btspp" />
<data android:scheme="btl2cap" />
<data android:scheme="btgoep" />
<data android:scheme="tcpobex" />
<data android:scheme="irdaobex" />
<data android:scheme="file" />
<data android:scheme="urn:epc:id" />
<data android:scheme="urn:epc:tag" />
<data android:scheme="urn:epc:pat" />
<data android:scheme="urn:epc:raw" />
<data android:scheme="urn:epc" />
<data android:scheme="urn:nfc" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_supported_technologies" />
</activity-alias>
<receiver
android:name="com.integreight.onesheeld.plugin.action.FireReceiver"
android:exported="true"
tools:ignore="ExportedReceiver">
<!-- this Intent filter allows the plug-in to discovered by Locale -->
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
</intent-filter>
</receiver>
<receiver
android:name="com.integreight.onesheeld.plugin.condition.QueryReceiver"
android:exported="true"
tools:ignore="ExportedReceiver">
<!-- this Intent filter allows the plug-in to discovered by Locale and be queried -->
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.QUERY_CONDITION" />
</intent-filter>
</receiver>
<service
android:name="com.integreight.onesheeld.shields.controller.utils.CameraHeadService"
android:label="My CameraHeadService"
android:process=":camera"
android:singleUser="true"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="Tutorial"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"/>
<service android:name="com.integreight.onesheeld.shields.controller.utils.SpeechRecognitionService" />
<service
android:name="com.integreight.onesheeld.push.PushMessagesReceiver">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application>
</manifest>

View File

@ -0,0 +1,22 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 9
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:25.1.0'
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.viewpagerindicator"
android:versionCode="65"
android:versionName="2.4.1">
<uses-sdk android:minSdkVersion="4" />
</manifest>

View File

@ -0,0 +1,20 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 9
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.handmark.pulltorefresh.library"
android:versionCode="2110"
android:versionName="2.1.1" >
<uses-sdk android:minSdkVersion="4" />
<application />
</manifest>

View File

@ -0,0 +1,22 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:25.1.0'
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.manuelpeinado.quickreturnheader"
android:versionCode="1"
android:versionName="0.1.1" >
<uses-sdk
android:minSdkVersion="5"
android:targetSdkVersion="17" />
</manifest>

View File

@ -0,0 +1,5 @@
include ':pagerIndicator'
include ':pullToRefreshlibrary'
include ':quickReturnHeader'
include ':localeapi'
include ':oneSheeld'