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
This commit is contained in:
Adnan Begovic 2015-05-05 17:37:05 -07:00
parent 8206b1352b
commit 37fc76fe96
7 changed files with 186 additions and 10 deletions

View File

@ -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 :=

View File

@ -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");
}

39
cm/res/Android.mk Normal file
View File

@ -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)

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright 2015, 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.
*/
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cyanogenmod"
coreApp="true" android:sharedUserId="android.uid.system"
android:sharedUserLabel="@string/cyanogenmod_system_label">
<!-- Must be required by an, to ensure that only the system can bind to it.
@hide -->
<permission android:name="cyanogenmod.permission.BIND_CUSTOM_TILE_LISTENER_SERVICE"
android:label="@string/permlab_bindCustomTileListenerService"
android:description="@string/permdesc_bindCustomTileListenerService"
android:protectionLevel="signature" />
<!-- Allows a 3rd party application to publish or unpublish a quick settings tile -->
<permission android:name="cyanogenmod.permission.PUBLISH_CUSTOM_TILE"
android:label="@string/permlab_publishCustomTile"
android:description="@string/permdesc_publishCustomTile"
android:protectionLevel="normal" />
<application android:process="system"
android:persistent="true"
android:hasCode="false"
android:label="@string/cyanogenmod_system_label"
android:allowClearUserData="false"
android:killAfterRestore="false"
android:supportsRtl="true"/>
</manifest>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Label for the CyanogenMod system components when they are shown to the user. -->
<string name="cyanogenmod_system_label">CyanogenMod System</string>
<string name="permlab_publishCustomTile">create a custom tile within qs tiles</string>
<string name="permdesc_publishCustomTile">Allows an app to publish a quick settings tile</string>
<string name="permlab_bindCustomTileListenerService">bind to a custom tile listener service</string>
<string name="permdesc_bindCustomTileListenerService">Allows the holder to bind to the top-level interface of a custom tile listener service.</string>
<!-- Label to show for a service that is running because it is observing the user's custom tiles. -->
<string name="custom_tile_listener_binding_label">Custom tile listener</string>
</resources>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<resources>
<!-- We don't want to publish private symbols in cyanogenmod.R as part of the
SDK. Instead, put them here. -->
<private-symbols package="org.cyanogenmod.platform.internal" />
<java-symbol type="string" name="custom_tile_listener_binding_label" />
</resources>

View File

@ -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)