# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

ANDROID_MANIFEST_FILE := src/main/AndroidManifest.xml

JAVAFILES := \
  src/main/java/org/mozilla/b2gdroid/Apps.java \
  src/main/java/org/mozilla/b2gdroid/GeckoEventReceiver.java \
  src/main/java/org/mozilla/b2gdroid/HeadlessSmsSendService.java \
  src/main/java/org/mozilla/b2gdroid/Launcher.java \
  src/main/java/org/mozilla/b2gdroid/MmsService.java \
  src/main/java/org/mozilla/b2gdroid/NotificationObserver.java \
  src/main/java/org/mozilla/b2gdroid/RemoteGeckoEventProxy.java \
  src/main/java/org/mozilla/b2gdroid/ScreenStateObserver.java \
  src/main/java/org/mozilla/b2gdroid/SettingsMapper.java \
  src/main/java/org/mozilla/b2gdroid/GeckoEventReceiver.java \
  src/main/java/org/mozilla/b2gdroid/NotificationObserver.java \
  src/main/java/org/mozilla/b2gdroid/RemoteGeckoEventProxy.java \
  src/main/java/com/google/android/mms/ContentType.java \
  src/main/java/com/google/android/mms/InvalidHeaderValueException.java \
  src/main/java/com/google/android/mms/MmsException.java \
  src/main/java/com/google/android/mms/pdu/AcknowledgeInd.java \
  src/main/java/com/google/android/mms/pdu/Base64.java \
  src/main/java/com/google/android/mms/pdu/CharacterSets.java \
  src/main/java/com/google/android/mms/pdu/DeliveryInd.java \
  src/main/java/com/google/android/mms/pdu/EncodedStringValue.java \
  src/main/java/com/google/android/mms/pdu/GenericPdu.java \
  src/main/java/com/google/android/mms/pdu/MultimediaMessagePdu.java \
  src/main/java/com/google/android/mms/pdu/NotificationInd.java \
  src/main/java/com/google/android/mms/pdu/NotifyRespInd.java \
  src/main/java/com/google/android/mms/pdu/PduBody.java \
  src/main/java/com/google/android/mms/pdu/PduComposer.java \
  src/main/java/com/google/android/mms/pdu/PduContentTypes.java \
  src/main/java/com/google/android/mms/pdu/PduHeaders.java \
  src/main/java/com/google/android/mms/pdu/PduParser.java \
  src/main/java/com/google/android/mms/pdu/PduPart.java \
  src/main/java/com/google/android/mms/pdu/PduPersister.java \
  src/main/java/com/google/android/mms/pdu/QuotedPrintable.java \
  src/main/java/com/google/android/mms/pdu/ReadOrigInd.java \
  src/main/java/com/google/android/mms/pdu/ReadRecInd.java \
  src/main/java/com/google/android/mms/pdu/RetrieveConf.java \
  src/main/java/com/google/android/mms/pdu/SendConf.java \
  src/main/java/com/google/android/mms/pdu/SendReq.java \
  src/main/java/com/google/android/mms/util/AbstractCache.java \
  src/main/java/com/google/android/mms/util/PduCache.java \
  src/main/java/com/google/android/mms/util/PduCacheEntry.java \
  src/main/java/com/google/android/mms/util/SqliteWrapper.java \
  $(NULL)

# The GeckoView consuming APK depends on the GeckoView JAR files.  There are two
# issues: first, the GeckoView JAR files need to be built before they are
# consumed here.  This happens for delicate reasons.  In the (serial) libs tier,
# base/ is traversed before b2gdroid/app.  Since base/libs builds classes.dex,
# the underlying JAR files are built before the libs tier of b2gdroid/app is
# processed.  Second, there is a correctness issue: the GeckoView JAR providing
# org.mozilla.gecko.R does not have the correct resource IDs for the consuming
# application, so we skip it.  The b2gdroid APK builds a JAR containing
# org.mozilla.gecko.R itself.
jars_dir := $(DEPTH)/mobile/android/base
ANDROID_EXTRA_JARS := $(filter-out %gecko-R.jar,$(wildcard $(jars_dir)/*.jar))
# Needed for the UpdateService
ANDROID_EXTRA_JARS += $(ANDROID_COMPAT_LIB)

ANDROID_EXTRA_JARS += \
	$(ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB) \
	$(ANDROID_SUPPORT_V4_AAR_LIB) \
	$(ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB) \
	$(ANDROID_APPCOMPAT_V7_AAR_LIB) \
	$(ANDROID_DESIGN_AAR_LIB) \
	$(NULL)

# The GeckoView consuming APK depends on the GeckoView resources.  This hacks a
# type of poor man's AAR support.
.aapt.deps: .geckoview_resources.deps

.geckoview_resources.deps: $(DEPTH)/mobile/android/base/geckoview_resources.zip
	@$(TOUCH) $@
	$(UNZIP) -u -o $< -d $(CURDIR)/geckoview_resources

include $(topsrcdir)/config/rules.mk

libs:: $(ANDROID_APK_NAME).apk
