CMSDK: Setup initial check-api mechanism.

Change-Id: I05b6dc7bde4037fbbe1b41ebb3ade8226d274199
diff --git a/Android.mk b/Android.mk
index 0e577eb..1ea47e7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -53,13 +53,13 @@
 LOCAL_SRC_FILES += \
     $(call all-Iaidl-files-under, $(cyanogenmod_app_src))
 
-cmsdk_LOCAL_INTERMEDIATE_SOURCES := \
+cmplat_LOCAL_INTERMEDIATE_SOURCES := \
     $(cm_platform_res)/cyanogenmod/platform/R.java \
     $(cm_platform_res)/cyanogenmod/platform/Manifest.java \
     $(cm_platform_res)/org/cyanogenmod/platform/internal/R.java
 
 LOCAL_INTERMEDIATE_SOURCES := \
-    $(cmsdk_LOCAL_INTERMEDIATE_SOURCES)
+    $(cmplat_LOCAL_INTERMEDIATE_SOURCES)
 
 # Include aidl files from cyanogenmod.app namespace as well as internal src aidl files
 LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/src/java
@@ -101,8 +101,8 @@
 LOCAL_REQUIRED_MODULES := services
 
 LOCAL_SRC_FILES := \
-           $(call all-java-files-under, $(cyanogenmod_app_src)) \
-           $(call all-Iaidl-files-under, $(cyanogenmod_app_src))
+    $(call all-java-files-under, $(cyanogenmod_app_src)) \
+    $(call all-Iaidl-files-under, $(cyanogenmod_app_src))
 
 # Included aidl files from cyanogenmod.app namespace
 LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/src/java
@@ -112,40 +112,119 @@
 
 # ===========================================================
 # Common Droiddoc vars
-cmplat.docs.src_files := \
+cmplat_docs_src_files := \
     $(call all-java-files-under, $(cyanogenmod_app_src)) \
     $(call all-html-files-under, $(cyanogenmod_app_src))
-cmplat.docs.java_libraries := \
+
+cmplat_docs_java_libraries := \
     org.cyanogenmod.platform.sdk
 
+# SDK version as defined
+cmplat_docs_SDK_VERSION := 0.1
+
+# release version
+cmplat_docs_SDK_REL_ID := 0
+
+cmplat_docs_LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+cmplat_docs_LOCAL_API_CHECK_ADDITIONAL_JAVA_DIR:= \
+    $(call intermediates-dir-for,JAVA_LIBRARIES,org.cyanogenmod.platform,,COMMON)
+
+cmplat_docs_LOCAL_ADDITIONAL_JAVA_DIR:= \
+    $(cmplat_docs_LOCAL_API_CHECK_ADDITIONAL_JAVA_DIR)
+
+cmplat_docs_LOCAL_DROIDDOC_SOURCE_PATH := \
+    $(cmplat_docs_src_files)
+
+intermediates.COMMON := $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS), org.cyanogenmod.platform.sdk,,COMMON)
+
+# ====  the api stubs and current.xml ===========================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+    $(cmplat_docs_src_files) \
+    $(call all-java-files-under, $(library_src))
+LOCAL_INTERMEDIATE_SOURCES:= $(cmplat_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_JAVA_LIBRARIES:= $(cmplat_docs_java_libraries)
+LOCAL_MODULE_CLASS:= $(cmplat_docs_LOCAL_MODULE_CLASS)
+LOCAL_DROIDDOC_SOURCE_PATH:= $(cmplat_docs_LOCAL_DROIDDOC_SOURCE_PATH)
+LOCAL_ADDITIONAL_JAVA_DIR:= $(intermediates.COMMON)/src
+LOCAL_ADDITIONAL_DEPENDENCIES:= $(cmplat_docs_LOCAL_ADDITIONAL_DEPENDENCIES)
+
+LOCAL_MODULE := cm-api-stubs
+
+LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:= build/tools/droiddoc/templates-sdk
+
+LOCAL_DROIDDOC_OPTIONS:= \
+        -stubs $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/cmsdk_stubs_current_intermediates/src \
+        -api $(INTERNAL_CM_PLATFORM_API_FILE) \
+        -removedApi $(INTERNAL_CM_PLATFORM_REMOVED_API_FILE) \
+        -nodocs
+
+LOCAL_UNINSTALLABLE_MODULE := true
+
+include $(BUILD_DROIDDOC)
+
+$(full_target): $(cm_framework_built) $(gen)
+$(INTERNAL_CM_PLATFORM_API_FILE): $(full_target)
+
+# ====  the system api stubs ===================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+    $(cmplat_docs_src_files) \
+    $(call all-java-files-under, $(library_src))
+LOCAL_INTERMEDIATE_SOURCES:= $(cmplat_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_JAVA_LIBRARIES:= $(cmplat_docs_java_libraries)
+LOCAL_MODULE_CLASS:= $(cmplat_docs_LOCAL_MODULE_CLASS)
+LOCAL_DROIDDOC_SOURCE_PATH:= $(cmplat_docs_LOCAL_DROIDDOC_SOURCE_PATH)
+LOCAL_ADDITIONAL_JAVA_DIR:= $(intermediates.COMMON)/src
+LOCAL_ADDITIONAL_DEPENDENCIES:= $(cmplat_docs_LOCAL_ADDITIONAL_DEPENDENCIES)
+
+LOCAL_MODULE := cm-system-api-stubs
+
+LOCAL_DROIDDOC_OPTIONS:=\
+        -stubs $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/cmsdk_system_stubs_current_intermediates/src \
+        -showAnnotation android.annotation.SystemApi \
+        -api $(INTERNAL_CM_PLATFORM_SYSTEM_API_FILE) \
+        -removedApi $(INTERNAL_CM_PLATFORM_SYSTEM_REMOVED_API_FILE) \
+        -nodocs
+
+LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:= build/tools/droiddoc/templates-sdk
+
+LOCAL_UNINSTALLABLE_MODULE := true
+
+include $(BUILD_DROIDDOC)
+
+$(full_target): $(cm_framework_built) $(gen)
+$(INTERNAL_CM_PLATFORM_API_FILE): $(full_target)
+
 # Documentation
 # ===========================================================
 include $(CLEAR_VARS)
 
 LOCAL_MODULE := org.cyanogenmod.platform.sdk
-LOCAL_INTERMEDIATE_SOURCES:=$(cmsdk_LOCAL_INTERMEDIATE_SOURCES)
+LOCAL_INTERMEDIATE_SOURCES:= $(cmplat_LOCAL_INTERMEDIATE_SOURCES)
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
 LOCAL_MODULE_TAGS := optional
 
-intermediates.COMMON := $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS), org.cyanogenmod.platform.sdk,,COMMON)
-
-LOCAL_SRC_FILES := $(cmplat.docs.src_files)
+LOCAL_SRC_FILES := $(cmplat_docs_src_files)
 LOCAL_ADDITONAL_JAVA_DIR := $(intermediates.COMMON)/src
 
-LOCAL_SDK_VERSION := 21
 LOCAL_IS_HOST_MODULE := false
 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := vendor/cm/build/tools/droiddoc/templates-cmsdk
 LOCAL_ADDITIONAL_DEPENDENCIES := \
-        services
+    services
 
-LOCAL_JAVA_LIBRARIES := $(cmplat.docs.java_libraries)
+LOCAL_JAVA_LIBRARIES := $(cmplat_docs_java_libraries)
 
 LOCAL_DROIDDOC_OPTIONS := \
-    -offlinemode \
-    -hidePackage org.cyanogenmod.platform.internal
-    -hdf android.whichdoc offline \
-    -federate Android http://developer.android.com \
-    -federationapi Android prebuilts/sdk/api/21.txt
+        -offlinemode \
+        -hidePackage org.cyanogenmod.platform.internal \
+        -hdf android.whichdoc offline \
+        -hdf sdk.version $(cmplat_docs_docs_SDK_VERSION) \
+        -hdf sdk.rel.id $(cmplat_docs_docs_SDK_REL_ID) \
+        -hdf sdk.preview 0 \
 
 $(full_target): $(cm_framework_built) $(gen)
 include $(BUILD_DROIDDOC)