From 37fc76fe96174402cdfbf02cf228639083c26bf7 Mon Sep 17 00:00:00 2001 From: Adnan Begovic Date: Tue, 5 May 2015 17:37:05 -0700 Subject: [PATCH] CMSDK: Create cyanogenmod platform resource package. org.cyanogenmod.platform-res provides resources that, if public, are globally accessible. This allows us to declare public and internal permissions as well as reference permissions declared by the android framework core Change-Id: Ia7d541f4b403585f7479ecd87895987b8471005b --- Android.mk | 39 +++++++++++++--- .../internal/CMStatusBarManagerService.java | 6 +-- cm/res/Android.mk | 39 ++++++++++++++++ cm/res/AndroidManifest.xml | 45 +++++++++++++++++++ cm/res/res/values/cm_strings.xml | 29 ++++++++++++ cm/res/res/values/cm_symbols.xml | 23 ++++++++++ tests/Android.mk | 15 +++++++ 7 files changed, 186 insertions(+), 10 deletions(-) create mode 100644 cm/res/Android.mk create mode 100644 cm/res/AndroidManifest.xml create mode 100644 cm/res/res/values/cm_strings.xml create mode 100644 cm/res/res/values/cm_symbols.xml diff --git a/Android.mk b/Android.mk index 8806a7c..7d7cffa 100644 --- a/Android.mk +++ b/Android.mk @@ -11,9 +11,18 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - LOCAL_PATH := $(call my-dir) +# We have a special case here where we build the library's resources +# independently from its code, so we need to find where the resource +# class source got placed in the course of building the resources. +# Thus, the magic here. +# Also, this module cannot depend directly on the R.java file; if it +# did, the PRIVATE_* vars for R.java wouldn't be guaranteed to be correct. +# Instead, it depends on the R.stamp file, which lists the corresponding +# R.java file as a prerequisite. +cm_platform_res := APPS/org.cyanogenmod.platform-res_intermediates/src + # The CyanogenMod Platform Framework Library # ============================================================ include $(CLEAR_VARS) @@ -23,12 +32,13 @@ library_src := cm/lib/main/java LOCAL_MODULE := org.cyanogenmod.platform LOCAL_MODULE_TAGS := optional -LOCAL_JAVA_LIBRARIES := services -LOCAL_REQUIRED_MODULES := services + +LOCAL_JAVA_LIBRARIES := \ + services LOCAL_SRC_FILES := \ - $(call all-java-files-under, $(cyanogenmod_app_src)) \ - $(call all-java-files-under, $(library_src)) + $(call all-java-files-under, $(cyanogenmod_app_src)) \ + $(call all-java-files-under, $(library_src)) ## READ ME: ######################################################## ## @@ -41,13 +51,26 @@ LOCAL_SRC_FILES := \ ## ## READ ME: ######################################################## LOCAL_SRC_FILES += \ - $(call all-Iaidl-files-under, $(cyanogemod_app_src)) + $(call all-Iaidl-files-under, $(cyanogenmod_app_src)) + +LOCAL_INTERMEDIATE_SOURCES := \ + $(cm_platform_res)/cyanogenmod/R.java \ + $(cm_platform_res)/cyanogenmod/Manifest.java \ + $(cm_platform_res)/org/cyanogenmod/platform/internal/R.java # Include aidl files from cyanogenmod.app namespace as well as internal src aidl files LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/src/java include $(BUILD_JAVA_LIBRARY) -framework_module := $(LOCAL_INSTALLED_MODULE) +cm_framework_module := $(LOCAL_INSTALLED_MODULE) + +# Make sure that R.java and Manifest.java are built before we build +# the source for this library. +cm_framework_res_R_stamp := \ + $(call intermediates-dir-for,APPS,org.cyanogenmod.platform-res,,COMMON)/src/R.stamp +$(full_classes_compiled_jar): $(cm_framework_res_R_stamp) + +$(cm_framework_module): | $(dir $(cm_framework_module))org.cyanogenmod.platform-res.apk cm_framework_built := $(call java-lib-deps, org.cyanogenmod.platform) @@ -122,6 +145,8 @@ LOCAL_DROIDDOC_OPTIONS := \ $(full_target): $(cm_framework_built) $(gen) include $(BUILD_DROIDDOC) +include $(call first-makefiles-under,$(LOCAL_PATH)) + # Cleanup temp vars # =========================================================== cmplat.docs.src_files := diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java index 433238a..6d9693c 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java @@ -45,7 +45,7 @@ import org.cyanogenmod.internal.statusbar.IStatusBarCustomTileHolder; import java.util.ArrayList; -import com.android.internal.R; +import org.cyanogenmod.platform.internal.R; /** * Internal service which manages interactions with system ui elements @@ -338,13 +338,13 @@ public class CMStatusBarManagerService extends SystemService { private void enforceCustomTilePublish() { mContext.enforceCallingOrSelfPermission( - android.Manifest.permission.PUBLISH_CUSTOM_TILE, + cyanogenmod.Manifest.permission.PUBLISH_CUSTOM_TILE, "StatusBarManagerService"); } private void enforceBindCustomTileListener() { mContext.enforceCallingOrSelfPermission( - android.Manifest.permission.BIND_CUSTOM_TILE_LISTENER_SERVICE, + cyanogenmod.Manifest.permission.BIND_CUSTOM_TILE_LISTENER_SERVICE, "StatusBarManagerService"); } diff --git a/cm/res/Android.mk b/cm/res/Android.mk new file mode 100644 index 0000000..b597d49 --- /dev/null +++ b/cm/res/Android.mk @@ -0,0 +1,39 @@ +# +# Copyright (C) 2015 The CyanogenMod Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_PACKAGE_NAME := org.cyanogenmod.platform-res +LOCAL_CERTIFICATE := platform +LOCAL_AAPT_FLAGS := --auto-add-overlay + +LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, res) + +# Tell aapt to create "extending (non-application)" resource IDs, +# since these resources will be used by many apps. +LOCAL_AAPT_FLAGS := -x + +LOCAL_MODULE_TAGS := optional + +# Install this alongside the libraries. +LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES) + +# Create package-export.apk, which other packages can use to get +# PRODUCT-agnostic resource data like IDs and type definitions. +LOCAL_EXPORT_PACKAGE_RESOURCES := true + +include $(BUILD_PACKAGE) diff --git a/cm/res/AndroidManifest.xml b/cm/res/AndroidManifest.xml new file mode 100644 index 0000000..69b15f2 --- /dev/null +++ b/cm/res/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + diff --git a/cm/res/res/values/cm_strings.xml b/cm/res/res/values/cm_strings.xml new file mode 100644 index 0000000..a961906 --- /dev/null +++ b/cm/res/res/values/cm_strings.xml @@ -0,0 +1,29 @@ + + + + + CyanogenMod System + + create a custom tile within qs tiles + Allows an app to publish a quick settings tile + + bind to a custom tile listener service + Allows the holder to bind to the top-level interface of a custom tile listener service. + + + Custom tile listener + \ No newline at end of file diff --git a/cm/res/res/values/cm_symbols.xml b/cm/res/res/values/cm_symbols.xml new file mode 100644 index 0000000..664c203 --- /dev/null +++ b/cm/res/res/values/cm_symbols.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/tests/Android.mk b/tests/Android.mk index 382e9cf..c6d67b5 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -1,3 +1,18 @@ +# +# Copyright (C) 2015 The CyanogenMod Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS)