Initial checkin of AOSP Messaging app.

b/23110861

Change-Id: I11db999bd10656801e618f78ab2b2ef74136fff1
This commit is contained in:
Mike Dodd
2015-08-11 11:16:59 -07:00
parent ef8c7abbcf
commit d3b009ae55
1645 changed files with 186271 additions and 0 deletions

88
Android.mk Normal file
View File

@@ -0,0 +1,88 @@
# Copyright (C) 2015 The Android Open Source 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_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
ifeq ($(TARGET_BUILD_APPS),)
LOCAL_RESOURCE_DIR += frameworks/support/v7/appcompat/res
LOCAL_RESOURCE_DIR += frameworks/support/v7/recyclerview/res
else
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/appcompat/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/recyclerview/res
endif
LOCAL_RESOURCE_DIR += frameworks/opt/chips/res
LOCAL_RESOURCE_DIR += frameworks/opt/colorpicker/res
LOCAL_RESOURCE_DIR += frameworks/opt/photoviewer/res
LOCAL_RESOURCE_DIR += frameworks/opt/photoviewer/activity/res
LOCAL_STATIC_JAVA_LIBRARIES := android-common
LOCAL_STATIC_JAVA_LIBRARIES += android-common-framesequence
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-palette
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-recyclerview
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v13
LOCAL_STATIC_JAVA_LIBRARIES += com.android.vcard
LOCAL_STATIC_JAVA_LIBRARIES += guava
LOCAL_STATIC_JAVA_LIBRARIES += libchips
LOCAL_STATIC_JAVA_LIBRARIES += libphotoviewer
LOCAL_STATIC_JAVA_LIBRARIES += libphonenumber
LOCAL_STATIC_JAVA_LIBRARIES += colorpicker
include $(LOCAL_PATH)/version.mk
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --version-name "$(version_name_package)"
LOCAL_AAPT_FLAGS += --version-code $(version_code_package)
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.recyclerview
LOCAL_AAPT_FLAGS += --extra-packages com.android.ex.chips
LOCAL_AAPT_FLAGS += --extra-packages com.android.vcard
LOCAL_AAPT_FLAGS += --extra-packages com.android.ex.photo
LOCAL_AAPT_FLAGS += --extra-packages com.android.colorpicker
ifdef TARGET_BUILD_APPS
LOCAL_JNI_SHARED_LIBRARIES := libframesequence libgiftranscode
else
LOCAL_REQUIRED_MODULES:= libframesequence libgiftranscode
endif
LOCAL_PROGUARD_FLAGS := -ignorewarnings -include build/core/proguard_basic_keeps.flags
LOCAL_PROGUARD_ENABLED := nosystem
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
ifeq (eng,$(TARGET_BUILD_VARIANT))
LOCAL_PROGUARD_FLAG_FILES += proguard-test.flags
else
LOCAL_PROGUARD_FLAG_FILES += proguard-release.flags
endif
LOCAL_JACK_ENABLED := disabled
LOCAL_PACKAGE_NAME := messaging
LOCAL_CERTIFICATE := platform
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)
include $(call all-makefiles-under, $(LOCAL_PATH))

524
AndroidManifest.xml Normal file
View File

@@ -0,0 +1,524 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source 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="com.android.messaging"
android:installLocation="internalOnly">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" />
<!-- Application holds CPU wakelock while working in background -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Application needs SMS/MMS permissions -->
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_MMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<!-- Application needs access to MMS network -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<!-- Application needs CONTACT permissions -->
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<!-- Application needs to read profiles for the user itself from CP2 -->
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Optional features -->
<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.microphone" android:required="false" />
<uses-feature android:name="android.hardware.screen.portrait" android:required="false" />
<application
android:name="com.android.messaging.BugleApplication"
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/BugleTheme"
android:supportsRtl="true">
<!-- Displays a list of conversations -->
<activity
android:name=".ui.conversationlist.ConversationListActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:label="@string/app_name"
android:theme="@style/BugleTheme.ConversationListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.APP_MESSAGING" />
</intent-filter>
</activity>
<activity
android:name=".ui.PermissionCheckActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|screenSize|keyboardHidden" />
<!-- Launches a conversation (ensures correct app name shown in recents) -->
<activity
android:name=".ui.conversation.LaunchConversationActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:theme="@style/Invisible"
android:noHistory="true"
android:documentLaunchMode="always">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</activity>
<!-- Displays a list of archived conversations -->
<activity
android:name=".ui.conversationlist.ArchivedConversationListActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:label="@string/archived_activity_title"
android:theme="@style/BugleTheme.ArchivedConversationListActivity"
android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversationlist.ConversationListActivity" />
</activity>
<!-- Displays the contents of a single conversation -->
<activity
android:name=".ui.conversation.ConversationActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:windowSoftInputMode="stateHidden|adjustResize"
android:theme="@style/BugleTheme.ConversationActivity"
android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversationlist.ConversationListActivity" />
</activity>
<!-- Blocked Participants -->
<activity
android:name=".ui.BlockedParticipantsActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:label="@string/blocked_contacts_title"
android:theme="@style/BugleTheme"
android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversationlist.ConversationListActivity" />
</activity>
<!-- Full-screen photo viewer -->
<activity
android:name=".ui.photoviewer.BuglePhotoViewActivity"
android:label="@string/photo_view_activity_title"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:theme="@style/BuglePhotoViewTheme"
/>
<!-- Settings -->
<activity
android:name=".ui.appsettings.SettingsActivity"
android:label="@string/settings_activity_title"
android:theme="@style/BugleTheme.SettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:parentActivityName="com.android.messaging.ui.conversationlist.ConversationListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversationlist.ConversationListActivity" />
</activity>
<activity
android:name=".ui.appsettings.PerSubscriptionSettingsActivity"
android:label="@string/advanced_settings_activity_title"
android:theme="@style/BugleTheme.SettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:parentActivityName="com.android.messaging.ui.appsettings.SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.appsettings.SettingsActivity" />
</activity>
<activity
android:name=".ui.appsettings.ApplicationSettingsActivity"
android:label="@string/general_settings_activity_title"
android:theme="@style/BugleTheme.SettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:parentActivityName="com.android.messaging.ui.appsettings.SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.appsettings.SettingsActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
</intent-filter>
</activity>
<!-- Handles sharing intent -->
<activity
android:name=".ui.conversationlist.ShareIntentActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:theme="@style/BugleTheme.DialogActivity"
android:excludeFromRecents="true"
android:documentLaunchMode="always">
<intent-filter
android:label="@string/share_intent_label">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
<data android:mimeType="text/x-vCard" />
<data android:mimeType="text/x-vcard" />
<data android:mimeType="image/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="application/ogg" />
</intent-filter>
<intent-filter
android:label="@string/share_intent_label">
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<!-- People & Options -->
<activity
android:name=".ui.conversationsettings.PeopleAndOptionsActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:label="@string/people_and_options_activity_title"
android:theme="@style/BugleTheme"
android:parentActivityName="com.android.messaging.ui.conversation.ConversationActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversation.ConversationActivity" />
</activity>
<!-- License -->
<activity android:name=".ui.LicenseActivity"
android:exported="true"
android:theme="@android:style/Theme.Holo.Light.Dialog"
android:label="@string/menu_license">
</activity>
<!-- Message Forwarding -->
<activity
android:name=".ui.conversationlist.ForwardMessageActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:label="@string/forward_message_activity_title"
android:theme="@style/BugleTheme.DialogActivity">
</activity>
<!-- Entry point for handling remote input/actions. Currently, this is only used by Android
Wear to send voice replies. Since that uses PendingIntents, we don't need to export
this activity. If we want other apps to be able to use this activity at will,
we'll need to guard it with a signature-matching protected permission. We would also
need to add an intent filter and remove the android:exported attribute. -->
<activity
android:name=".ui.RemoteInputEntrypointActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:exported="false"
android:theme="@style/Invisible">
</activity>
<!-- VCard details -->
<activity
android:name=".ui.VCardDetailActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:label="@string/vcard_detail_activity_title"
android:theme="@style/BugleTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.conversation.ConversationActivity" />
</activity>
<!-- Attachment chooser -->
<activity
android:name=".ui.attachmentchooser.AttachmentChooserActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:label="@string/attachment_chooser_activity_title"
android:theme="@style/BugleTheme"
android:parentActivityName="com.android.messaging.ui.conversation.ConversationActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.messaging.ui.conversation.ConversationActivity" />
</activity>
<!-- Test activity that we use to host fragments/views. Unfortunately, apparently necessary
because Android framework test cases want activity to be in the instrumented package.
See http://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2.html
-->
<activity
android:name=".ui.TestActivity"
android:configChanges="orientation|screenSize|keyboardHidden">
</activity>
<activity
android:name=".ui.debug.DebugMmsConfigActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:theme="@style/BugleTheme.DialogActivity"
android:exported="false">
</activity>
<provider android:name=".datamodel.MessagingContentProvider" android:label="@string/app_name"
android:authorities="com.android.messaging.datamodel.MessagingContentProvider"
android:exported="false" >
</provider>
<provider android:name=".datamodel.MmsFileProvider"
android:authorities="com.android.messaging.datamodel.MmsFileProvider"
android:grantUriPermissions="true" />
<provider android:name=".datamodel.MediaScratchFileProvider"
android:authorities="com.android.messaging.datamodel.MediaScratchFileProvider"
android:grantUriPermissions="true" />
<!-- Action Services -->
<service android:name=".datamodel.action.ActionServiceImpl"/>
<service android:name=".datamodel.action.BackgroundWorkerService"/>
<!-- Sms and Mms related items -->
<!-- Intents for Notification and Pre-KLP Delivery -->
<!-- Registered with the highest possible priority (max_int) -->
<receiver android:name=".receiver.MmsWapPushReceiver"
android:enabled="false"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.SmsReceiver"
android:enabled="false"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.MMS_DOWNLOADED" />
</intent-filter>
</receiver>
<!-- Intents for aborting SMS/MMS broadcasts pre-KLP -->
<!-- Registered for a priority just ahead of inbox Messaging apps (2) -->
<receiver android:name=".receiver.AbortMmsWapPushReceiver"
android:enabled="false"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter android:priority="3">
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.AbortSmsReceiver"
android:enabled="false"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="3">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<!-- Intents for KLP+ Delivery -->
<receiver android:name=".receiver.MmsWapPushDeliverReceiver"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.SmsDeliverReceiver"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_DELIVER" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.SendStatusReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.android.messaging.receiver.SendStatusReceiver.MESSAGE_SENT" />
<data android:scheme="content" />
</intent-filter>
<intent-filter>
<action android:name="com.android.messaging.receiver.SendStatusReceiver.MESSAGE_DELIVERED" />
</intent-filter>
<intent-filter>
<action android:name="com.android.messaging.receiver.SendStatusReceiver.MMS_SENT" />
<data android:scheme="content" />
</intent-filter>
<intent-filter>
<action android:name="com.android.messaging.receiver.SendStatusReceiver.MMS_DOWNLOADED" />
<data android:scheme="content" />
</intent-filter>
</receiver>
<service android:name=".datamodel.NoConfirmationSmsSendService"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
</intent-filter>
</service>
<activity android:name=".ui.ClassZeroActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:label="@string/class_0_message_activity"
android:theme="@style/BugleTheme.DialogActivity"
android:launchMode="singleTask"
android:excludeFromRecents="true">
</activity>
<activity android:name=".ui.SmsStorageLowWarningActivity"
android:theme="@style/Invisible"
android:configChanges="orientation|screenSize|keyboardHidden" />
<activity android:name=".ui.appsettings.ApnSettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:theme="@style/BugleTheme"
android:parentActivityName="com.android.messaging.ui.appsettings.SettingsActivity" />
<activity android:name=".ui.appsettings.ApnEditorActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="user"
android:theme="@style/BugleTheme"
android:parentActivityName="com.android.messaging.ui.appsettings.ApnSettingsActivity"/>
<receiver android:name=".receiver.StorageStatusReceiver">
<intent-filter>
<action android:name="android.intent.action.DEVICE_STORAGE_LOW" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.DEVICE_STORAGE_OK" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.BootAndPackageReplacedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<!-- Broadcast receiver that will be notified to reset notifications -->
<receiver
android:name=".receiver.NotificationReceiver"
android:exported="false">
</receiver>
<!-- Broadcast receiver that will be notified for ActionService alarms. -->
<receiver
android:name=".datamodel.action.ActionServiceImpl$PendingActionReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.android.messaging.datamodel.PENDING_ACTION" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.DefaultSmsSubscriptionChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED"/>
</intent-filter>
</receiver>
<!-- Widget that displays the conversation list -->
<receiver android:name=".widget.BugleWidgetProvider"
android:label="@string/widget_conversation_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<intent-filter>
<action android:name="com.android.Bugle.intent.action.ACTION_NOTIFY_CONVERSATIONS_CHANGED" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_conversation_list" />
</receiver>
<!-- Widget that displays the messages of a single conversation -->
<receiver android:name=".widget.WidgetConversationProvider"
android:label="@string/widget_conversation_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<intent-filter>
<action android:name="com.android.Bugle.intent.action.ACTION_NOTIFY_MESSAGES_CHANGED" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_conversation" />
</receiver>
<service android:name=".widget.WidgetConversationListService"
android:permission="android.permission.BIND_REMOTEVIEWS"
android:exported="false" />
<service android:name=".widget.WidgetConversationService"
android:permission="android.permission.BIND_REMOTEVIEWS"
android:exported="false" />
<activity android:name=".ui.WidgetPickConversationActivity"
android:theme="@style/BugleTheme"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<service android:name="android.support.v7.mms.MmsService"/>
</application>
</manifest>

40
ForceProguard.mk Executable file
View File

@@ -0,0 +1,40 @@
# Copyright (C) 2015 The Android Open Source 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.
# Check to see if we need to force proguard to re-run, typically after using tapas to
# switch to/from eng builds. This is determined by comparing the flag files used in the previous
# build. If the flag files have changed, proguard is rerun.
# If the LOCAL_MODULE being setup isn't a build target, then don't run ForceProguard.
ifneq (,$(findstring $(LOCAL_MODULE), $(TARGET_BUILD_APPS)))
PREVIOUS_FLAG_FILES_USED_DIR := $(call local-intermediates-dir,1)
# If the local intermediates dir doesn't exist, ForceProguard won't work.
ifneq ($(wildcard $(PREVIOUS_FLAG_FILES_USED_DIR)),)
PREVIOUS_FLAG_FILES_USED_FILE := $(PREVIOUS_FLAG_FILES_USED_DIR)/previous_proguard_flag_files
PREVIOUS_FLAG_FILES_USED := $(if $(wildcard $(PREVIOUS_FLAG_FILES_USED_FILE)), \
$(shell cat $(PREVIOUS_FLAG_FILES_USED_FILE)))
ifneq ($(strip $(PREVIOUS_FLAG_FILES_USED)), $(strip $(LOCAL_PROGUARD_FLAG_FILES)))
$(info *** Flag files used for proguard have changed; forcing proguard to rerun.)
$(shell touch $(LOCAL_PATH)/proguard.flags)
$(shell echo $(LOCAL_PROGUARD_FLAG_FILES) > $(PREVIOUS_FLAG_FILES_USED_FILE))
endif
endif
# End local intermediates directory existence check
endif
# End LOCAL_MODULE is a build target check

666
assets/licenses.html Normal file
View File

@@ -0,0 +1,666 @@
<!DOCTYPE html>
<html>
<head>
<title>
</title>
<style>
body { font-family: sans-serif; }
pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; }
</style>
</head>
<body>
<h3>Notice for AOSP:</h3>
<pre>
Copyright (c) 2005-2008, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
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.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
</pre>
<h3>Notices for Guava: Google Core Libraries for Java</h3>
<pre>
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
</pre>
<h3>Notices for JSR 305</h3>
<pre>
Copyright (c) 2007-2009, JSR305 expert group
All rights reserved.
http://www.opensource.org/licenses/bsd-license.php
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the JSR305 expert group nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
</pre>
<h3>Notices for libphonenumber</h3>
<pre>
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
</pre>
<h3>Notices for GIFLIB</h3>
<pre>
The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</pre>
</body></html>

8
build/README Normal file
View File

@@ -0,0 +1,8 @@
Files in this folder are build extensions specific to the Bugle project, but currently could be merged into the core Android build.
gcheckstyle is a tool from google3 to validate java from google3. The config file is baked into the jar, but can be updated with a little hackery.
Files last pulled around CL 66008148:
gcheckstyle/tools/java/checkstyle/googlestyle-5.0.xml is the config file which came from /home/build/nonconf/google3/tools/java/checkstyle and was modified to use Android specific styles. It must keep the same name and path in order to correctly update the jar
google-style-checker_deploy.jar is pulled from the build share at /google/data/ro/teams/devtools/glint/linters/live/google-style-checker_deploy.jar and can be pulled from there as needed.

59
build/android_lint.mk Normal file
View File

@@ -0,0 +1,59 @@
# Copyright (C) 2015 The Android Open Source 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.
# Android lint checks for common code/resource errors specific to Android
# Lint tool expects the intermediates dir to match the project name Bugle rather
# than $(LOCAL_PACKAGE_NAME) which is messaging
# Create a symbolic link to redirect the tool
$(LOCAL_PACKAGE_NAME)BUGLE_RENAME := $(subst $(LOCAL_PACKAGE_NAME)_intermediates,Bugle_intermediates,$(intermediates.COMMON))
$($(LOCAL_PACKAGE_NAME)BUGLE_RENAME): SOURCE_PATH := $(abspath $(intermediates.COMMON)/)
$($(LOCAL_PACKAGE_NAME)BUGLE_RENAME): DST_PATH := $($(LOCAL_PACKAGE_NAME)BUGLE_RENAME)
$($(LOCAL_PACKAGE_NAME)BUGLE_RENAME) :
ln -f -s $(SOURCE_PATH) $(DST_PATH)
# Lint tool expects api-versions.xml from the SDK to be in development/sdk but
# it's not. Create a symbolic link to the android SDK to fix it
API_VERSIONS_XML := $(abspath development/sdk/api-versions.xml)
$(API_VERSIONS_XML):
ln -f -s $(abspath prebuilts/fullsdk/linux/platform-tools/api/api-versions.xml) $(API_VERSIONS_XML)
# The output xml file from the lint tool
$(LOCAL_PACKAGE_NAME)LINT_XML := $(intermediates.COMMON)/$(LOCAL_PACKAGE_NAME)_android_lint.xml
# The transformed text file from the output xml
$(LOCAL_PACKAGE_NAME)LINT_TXT := $(intermediates.COMMON)/$(LOCAL_PACKAGE_NAME)_android_lint.txt
# Creates the output xml from the lint tool by running the linting tool if the
# package has been updated
$($(LOCAL_PACKAGE_NAME)LINT_XML): PRIVATE_PATH := $(LOCAL_PATH)
$($(LOCAL_PACKAGE_NAME)LINT_XML): LINT_CMD = $(LINT) --quiet -Wall --disable UnusedIds,UnusedResources,MissingTranslation $(PRIVATE_PATH)
$($(LOCAL_PACKAGE_NAME)LINT_XML) : $(LOCAL_BUILT_MODULE) $($(LOCAL_PACKAGE_NAME)BUGLE_RENAME) $(API_VERSIONS_XML)
$(LINT_CMD) --xml $@ > /dev/null
# Creates the transformed text file from the output xml by running an xslt on it
# which filters out issues from the support library and formats it for console
# output
$($(LOCAL_PACKAGE_NAME)LINT_TXT): PRIVATE_PATH := $(LOCAL_PATH)
$($(LOCAL_PACKAGE_NAME)LINT_TXT): INPUT := $($(LOCAL_PACKAGE_NAME)LINT_XML)
$($(LOCAL_PACKAGE_NAME)LINT_TXT): XSLT_CMD = xsltproc $(PRIVATE_PATH)/build/android_lint.xslt $(INPUT)
$($(LOCAL_PACKAGE_NAME)LINT_TXT) : $($(LOCAL_PACKAGE_NAME)LINT_XML)
$(hide) $(XSLT_CMD) > $@
# The root of the lint rule which just prints the lint errors txt file to the
# console
$(LOCAL_PACKAGE_NAME)lint: PRIVATE_PATH := $(LOCAL_PATH)
$(LOCAL_PACKAGE_NAME)lint :: $($(LOCAL_PACKAGE_NAME)LINT_TXT)
$(hide) $(PRIVATE_PATH)/build/colorize_errors.py < $<

40
build/android_lint.xslt Normal file
View File

@@ -0,0 +1,40 @@
<!--
Copyright (C) 2015 The Android Open Source 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.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="/issues">
<xsl:for-each select="issue">
<!-- Exclude errors/warnings with
/android/support in the location, these are outside our control
/com/google/common in the location, these are outside our control
res/values- in the location, these are localized resources, and we only need to be notified of the neutral resource issues
.class in the location, these don't have source we can do anything about -->
<xsl:if test="not(./location) or (not(contains(./location/@file, '/android/support/')) and not(contains(./location/@file, '/com/google/common/')) and not(starts-with(./location/@file, 'res/values-')) and not(contains(./location/@file, '.class')))">
<xsl:value-of select="@severity" />: <xsl:value-of select="@message" disable-output-escaping="yes"/><xsl:text> </xsl:text>[<xsl:value-of select="@id" />]<xsl:text>&#xa;</xsl:text>
<xsl:for-each select="./location">
<xsl:text> </xsl:text><xsl:value-of select="@file" />
<xsl:if test="@line">
<xsl:text>:</xsl:text><xsl:value-of select="@line" />
<xsl:if test="@column">
<xsl:text>,</xsl:text><xsl:value-of select="@column" />
</xsl:if>
</xsl:if>
<xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

42
build/colorize_errors.py Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/python
# Copyright (C) 2015 The Android Open Source 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.
#
# Given an input stream look for Error: and Warning: lines and colorize those to
# the output
import fileinput
import re
import sys
RED = "\033[31m"
YELLOW = "\033[33m"
RESET = "\033[0m"
ERROR = re.compile(r"^Error:")
WARNING = re.compile(r"^Warning:")
STARTS_WITH_WS = re.compile(r"^\s")
for line in fileinput.input():
if ERROR.match(line):
print RED + line,
elif WARNING.match(line):
print YELLOW + line,
elif STARTS_WITH_WS.match(line):
# If the line starts with a space use the same coloring as the previous line
print line,
else:
print RESET + line,
print RESET

45
build/gcheckstyle.mk Normal file
View File

@@ -0,0 +1,45 @@
# Copyright (C) 2015 The Android Open Source 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.
# The config file to use when checking style issues
STYLE_CONFIG := $(LOCAL_PATH)/build/gcheckstyle/tools/java/checkstyle/googlestyle-5.0.xml
# The jar file to use to perform the checking
STYLE_JAR := $(LOCAL_PATH)/build/gcheckstyle/google-style-checker_deploy.jar
# The output file to cache the results of style error checking
$(LOCAL_PACKAGE_NAME)STYLE_ERRORS_TXT := $(intermediates.COMMON)/$(LOCAL_PACKAGE_NAME)_style_errors.txt
# The set of input files to check
$(LOCAL_PACKAGE_NAME)JAVA_FILES = $(shell find $(LOCAL_PATH)/src/ -name '*.java')
# Updates the JAR file with the new config if the config has changed
# The config file has to be packaged into the jar, and jar uf command expects the current working directory
# to match the jar structure
$(STYLE_JAR): PRIVATE_PATH := $(LOCAL_PATH)
$(STYLE_JAR) : $(STYLE_CONFIG)
$(hide) pushd $(PRIVATE_PATH)/build/gcheckstyle && \
jar uf google-style-checker_deploy.jar tools/java/checkstyle/googlestyle-5.0.xml && \
popd
# Rebuilds the style errors text if the style checker or any of the java files have changed
# FLAG: It may be more efficient to cache individual file results rather than grouping them all together
$($(LOCAL_PACKAGE_NAME)STYLE_ERRORS_TXT): SOURCES := $($(LOCAL_PACKAGE_NAME)JAVA_FILES)
$($(LOCAL_PACKAGE_NAME)STYLE_ERRORS_TXT) : $($(LOCAL_PACKAGE_NAME)JAVA_FILES) $(STYLE_JAR)
$(hide) -/usr/local/buildtools/java/jdk/bin/java -jar $(STYLE_JAR) $(SOURCES) > $@
# The root of the lint rule which just prints the style errors txt file to the console
$(LOCAL_PACKAGE_NAME)lint :: $($(LOCAL_PACKAGE_NAME)STYLE_ERRORS_TXT)
$(hide) $(PRIVATE_PATH)/build/process_style_output.py -omit $(abspath $(PRIVATE_PATH))/ < $< | $(PRIVATE_PATH)/build/colorize_errors.py

Binary file not shown.

View File

@@ -0,0 +1,411 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2015 The Android Open Source 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.
-->
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- This is a checkstyle configuration file. For descriptions of
what the following rules do, please see the checkstyle configuration
page at http://checkstyle.sourceforge.net/config.html -->
<!-- Checks with numbered comments refer to recommendations made
by Joshua Bloch in his book Effective Java -->
<module name="Checker">
<property name="charset" value="UTF-8"/>
<module name="SuppressionCommentFilter"/>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="__Generated_"/>
<property name="onCommentFormat" value="END GENERATED CODE"/>
</module>
<module name="FileTabCharacter">
<!-- Checks that there are no tab characters in the file.
-->
</module>
<module name="RegexpSingleline">
<!-- Checks that FIXME is not used in comments. TODO is preferred.
-->
<property name="format" value="((//.*)|(\*.*))FIXME" />
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="RegexpSingleline">
<!-- Checks that TODOs are properly formatted.
The (?&lt;!TODO\(.{0,100}) makes the regex ignore any secondary TODO's on the line
so that things like //TODO(bob): remove this TODO on 1/1/2020 don't trigger a warning
because of the second TODO. (The {0,100} is because java doesn't recoginize arbitrary
length look backs, but we know each java line should be < 100 chars.)
-->
<property name="format" value="((//.*)|(\*.*))(?&lt;!TODO\(.{0,100})(TODO[^(])|(TODO\([^)]*$)" />
<property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<!-- All Java AST specific tests live under TreeWalker module. -->
<module name="TreeWalker">
<module name="FileContentsHolder"/>
<!--module name="SuppressWarningsFilter" /-->
<!--module name="SuppressWarningsHolder" /-->
<!--
IMPORT CHECKS
-->
<module name="RedundantImport">
<property name="severity" value="error"/>
</module>
<module name="AvoidStarImport">
<property name="severity" value="error"/>
</module>
<module name="UnusedImports">
<!-- DPL is a notable violator of this rule. -->
<property name="severity" value="error"/>
<!-- Imports used only in Javadoc are tolerated. See http://b/838496 -->
<property name="processJavadoc" value="true"/>
<message
key="import.unused"
value="Unused import: {0}." />
</module>
<module name="checkstyle.patches.checks.imports.ImportOrder">
<!-- Checks for out of order import statements. -->
<metadata name="altname" value="ImportOrder"/>
<property name="severity" value="warning"/>
<property name="groups" value="android,com.android,com.google,*,java,javax"/>
<!-- This ensures that static imports go first. -->
<property name="option" value="top"/>
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
<message
key="import.ordering"
value="Wrong order for {0} import." />
</module>
<!-- Checks that nested classes are not statically imported. -->
<module name="com.google.devtools.checkstyle.checks.imports.StaticImportNestedClassCheck">
<metadata name="altname" value="StaticImportNestedClass"/>
<property name="severity" value="warning"/>
<message key="import.staticNestedClass"
value="Use of static import for nested classes is disallowed."/>
</module>
<!--
JAVADOC CHECKS
-->
<module name="com.google.devtools.checkstyle.checks.javadoc.GoogleJavadocTypeCheck">
<!-- Item 28 - Write doc comments for all exposed API elements. -->
<!-- Ensure all classes with visability greater than or equal to
protected have class level documentation. -->
<property name="scope" value="protected"/>
<property name="severity" value="ignore"/>
<!-- Style guide doesn't prohibit custom tags. Typos will be caught by other tools. -->
<property name="allowUnknownTags" value="true"/>
<property name="allowMissingParamTags" value="true"/>
</module>
<!--
NAMING CHECKS
-->
<!-- Item 38 - Adhere to generally accepted naming conventions -->
<module name="PackageName">
<!-- Validates identifiers for package names against the
supplied expression. -->
<!-- Here the default checkstyle rule restricts package name parts to
seven characters, this is not in line with common practice at Google.
-->
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
<property name="severity" value="warning"/>
</module>
<module name="TypeNameCheck">
<!-- Validates static, final fields against the
expression "^[A-Z][a-zA-Z0-9]*$". -->
<metadata name="altname" value="TypeName"/>
<property name="severity" value="warning"/>
</module>
<module name="com.google.devtools.checkstyle.checks.coding.ConstantNameCheck">
<!-- Validates that constant fields are named in ALL_CAPS. -->
<metadata name="altname" value="ConstantName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^_?[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
<message key="name.invalidPattern"
value="Variable ''{0}'' is a constant and thus should be in ALL_CAPS."/>
<property name="severity" value="ignore"/>
</module>
<module name="StaticVariableNameCheck">
<!-- Validates static, non-final fields against the supplied
expression "^[a-z][a-zA-Z0-9]*_?$". -->
<metadata name="altname" value="StaticVariableName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
<property name="severity" value="ignore"/>
</module>
<module name="MemberNameCheck">
<!-- Validates non-static members against the supplied expression. -->
<metadata name="altname" value="MemberName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<!-- allows for googles deprecated foo_ member naming scheme -->
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
<property name="severity" value="ignore"/>
</module>
<module name="MethodNameCheck">
<!-- Validates identifiers for method names. -->
<metadata name="altname" value="MethodName"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
<property name="severity" value="warning"/>
</module>
<module name="ParameterName">
<!-- Validates identifiers for method parameters against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalFinalVariableName">
<!-- Validates identifiers for local final variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalVariableName">
<!-- Validates identifiers for local variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<!--
LENGTH and CODING CHECKS
-->
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="100"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
- certain JSNI method signatures used in GWT, see http://wiki/Nonconf/GwtInGoogle3Faq#JsniLineBreaks.
-->
<!--
The JSNI/GWT exemption only is for the JNI-style signature, that cannot be split across multiple lines.
Both the instance expression and the parameter list may and must go on separate lines.
These examples are exempt:
<pre>
private native void foo() /*-{
// Method call, signature as the only long line (> 100 chars)
this.
@com.google.gwt.foo.bar.baz.ClassUsingJsni::someMethod(Lcom/google/gwt/foo/bar/baz/ParameterType;)
(param);
// Static method call, signature as the only long line (> 100 chars)
@com.google.gwt.foo.bar.baz.ClassUsingJsni::staticMethod(Lcom/google/gwt/foo/bar/baz/ParameterType;)
(param);
// Method reference in dictionary, signature as the only long line
var dict = {
key:
@com.google.gwt.foo.bar.baz.ClassUsingJsni::otherMethod(Lcom/google/gwt/foo/bar/baz/ParameterType;Z),
}
}-*/;
</pre>
These exampls are NOT exempt, as the line can be broken further:
<pre>
private native void foo() /*-{
// Instance expression on same line
this.@com.google.gwt.foo.bar.baz.ClassUsingJsni::someMethod(Lcom/google/gwt/foo/bar/baz/ParameterType;)
(param);
// Parameters on same line
this.
@com.google.gwt.foo.bar.baz.ClassUsingJsni::someMethod(Lcom/google/gwt/foo/bar/baz/ParameterType;)(param);
// All on one line
this.@com.google.gwt.foo.bar.baz.ClassUsingJsni::someMethod(Lcom/google/gwt/foo/bar/baz/ParameterType;)(param);
}-*/;
</pre>
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)|(\s*@[\w\.\$]+::\w+(?:\([^\(]*\)|\(\)\(\))?[,;]?)|(\s+\* \{@(link|see) [^\s][^\}]*\}[\.,;]?)$"/>
</module>
<module name="LeftCurly">
<!-- Checks for placement of the left curly brace ('{'). -->
<property name="severity" value="warning"/>
</module>
<module name="RightCurly">
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
the same line. e.g., the following example is fine:
<pre>
if {
...
} else
</pre>
-->
<!-- This next example is not fine:
<pre>
if {
...
}
else
</pre>
-->
<property name="option" value="same"/>
<property name="severity" value="warning"/>
</module>
<!-- Checks for braces around if and else blocks -->
<module name="NeedBraces">
<property name="severity" value="warning"/>
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
</module>
<!-- Checks for empty catch blocks in non-test files. -->
<module name="com.google.devtools.checkstyle.checks.blocks.EmptyCatchBlockCheck">
<metadata name="altname" value="EmptyCatchBlock"/>
<property name="severity" value="error"/>
</module>
<module name="UpperEll">
<!-- Checks that long constants are defined with an upper ell.-->
<property name="severity" value="error"/>
</module>
<module name="FallThrough">
<!-- Warn about falling through to the next case statement. Similar to
javac -Xlint:fallthrough, but the check is suppressed if there is a single-line comment
on the last non-blank line preceding the fallen-into case.
-->
<property name="reliefPattern"
value=".*"/>
<property name="severity" value="error"/>
</module>
<!--
MODIFIERS CHECKS
-->
<module name="ModifierOrder">
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
8.4.3. The prescribed order is:
public, protected, private, abstract, static, final, transient, volatile,
synchronized, native, strictfp
-->
</module>
<!--
WHITESPACE CHECKS
-->
<module name="WhitespaceAround">
<!-- Checks that various tokens are surrounded by whitespace.
This includes most binary operators and keywords followed
by regular or curly braces.
-->
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
<property name="severity" value="error"/>
<property name="ignoreEnhancedForColon" value="false"/>
</module>
<module name="WhitespaceAfter">
<!-- Checks that commas, semicolons and typecasts are followed by
whitespace.
-->
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
</module>
<module name="NoWhitespaceAfter">
<!-- Checks that there is no whitespace after various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
UNARY_PLUS"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="NoWhitespaceBefore">
<!-- Checks that there is no whitespace before various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="ParenPad">
<!-- Checks that there is no whitespace before close parens or after
open parens.
-->
<property name="severity" value="warning"/>
</module>
<!--
MISC CHECKS
-->
</module>
</module>

38
build/process_style_output.py Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/python
# Copyright (C) 2015 The Android Open Source 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.
#
# Take the output from gstylechecker and clean up into a more friendly format
import argparse
import fileinput
import re
parser = argparse.ArgumentParser()
parser.add_argument('-omit')
args = parser.parse_args()
PATTERN = re.compile(r"(?P<file>[^:]+):(?P<line>\d+)(?P<column>:\d+)?:\s(?P<message>.*)")
for line in fileinput.input([]):
match = PATTERN.match(line)
if match:
filename = match.group("file");
if args.omit:
filename = filename.replace(args.omit, "")
message = match.group("message")
message = message[0].upper() + message[1:]
print message
print " " + filename + ':' + match.group("line") + (match.group("column") if match.group("column") else "")

35
jni/Android.mk Normal file
View File

@@ -0,0 +1,35 @@
# Copyright (C) 2015 The Android Open Source 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_STATIC_LIBRARIES += libgif
# Link to Android logging (liblog.so) and dynamic linker (libdl.so) libraries
LOCAL_LDFLAGS := -llog -ldl
LOCAL_C_INCLUDES := \
external/giflib
LOCAL_MODULE := libgiftranscode
LOCAL_SRC_FILES := GifTranscoder.cpp
LOCAL_CFLAGS += -Wall -Wno-unused-parameter -Wno-switch
LOCAL_SDK_VERSION := 8
LOCAL_NDK_STL_VARIANT := c++_static # LLVM libc++
include $(BUILD_SHARED_LIBRARY)

573
jni/GifTranscoder.cpp Normal file
View File

@@ -0,0 +1,573 @@
/*
* Copyright (C) 2015 The Android Open Source 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.
*/
#include <jni.h>
#include <time.h>
#include <stdio.h>
#include <memory>
#include <vector>
#include <android/log.h>
#include "GifTranscoder.h"
#define SQUARE(a) (a)*(a)
// GIF does not support partial transparency, so our alpha channels are always 0x0 or 0xff.
static const ColorARGB TRANSPARENT = 0x0;
#define ALPHA(color) (((color) >> 24) & 0xff)
#define RED(color) (((color) >> 16) & 0xff)
#define GREEN(color) (((color) >> 8) & 0xff)
#define BLUE(color) (((color) >> 0) & 0xff)
#define MAKE_COLOR_ARGB(a, r, g, b) \
((a) << 24 | (r) << 16 | (g) << 8 | (b))
#define MAX_COLOR_DISTANCE 255 * 255 * 255
#define TAG "GifTranscoder.cpp"
#define LOGD_ENABLED 0
#if LOGD_ENABLED
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__))
#else
#define LOGD(...) ((void)0)
#endif
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__))
// This macro expects the assertion to pass, but logs a FATAL if not.
#define ASSERT(cond, ...) \
( (__builtin_expect((cond) == 0, 0)) \
? ((void)__android_log_assert(#cond, TAG, ## __VA_ARGS__)) \
: (void) 0 )
#define ASSERT_ENABLED 1
namespace {
// Current time in milliseconds since Unix epoch.
double now(void) {
struct timespec res;
clock_gettime(CLOCK_REALTIME, &res);
return 1000.0 * res.tv_sec + (double) res.tv_nsec / 1e6;
}
// Gets the pixel at position (x,y) from a buffer that uses row-major order to store an image with
// the specified width.
template <typename T>
T* getPixel(T* buffer, int width, int x, int y) {
return buffer + (y * width + x);
}
} // namespace
int GifTranscoder::transcode(const char* pathIn, const char* pathOut) {
int error;
double t0;
GifFileType* gifIn;
GifFileType* gifOut;
// Automatically closes the GIF files when this method returns
GifFilesCloser closer;
gifIn = DGifOpenFileName(pathIn, &error);
if (gifIn) {
closer.setGifIn(gifIn);
LOGD("Opened input GIF: %s", pathIn);
} else {
LOGE("Could not open input GIF: %s, error = %d", pathIn, error);
return GIF_ERROR;
}
gifOut = EGifOpenFileName(pathOut, false, &error);
if (gifOut) {
closer.setGifOut(gifOut);
LOGD("Opened output GIF: %s", pathOut);
} else {
LOGE("Could not open output GIF: %s, error = %d", pathOut, error);
return GIF_ERROR;
}
t0 = now();
if (resizeBoxFilter(gifIn, gifOut)) {
LOGD("Resized GIF in %.2f ms", now() - t0);
} else {
LOGE("Could not resize GIF");
return GIF_ERROR;
}
return GIF_OK;
}
bool GifTranscoder::resizeBoxFilter(GifFileType* gifIn, GifFileType* gifOut) {
ASSERT(gifIn != NULL, "gifIn cannot be NULL");
ASSERT(gifOut != NULL, "gifOut cannot be NULL");
if (gifIn->SWidth < 0 || gifIn->SHeight < 0) {
LOGE("Input GIF has invalid size: %d x %d", gifIn->SWidth, gifIn->SHeight);
return false;
}
// Output GIF will be 50% the size of the original.
if (EGifPutScreenDesc(gifOut,
gifIn->SWidth / 2,
gifIn->SHeight / 2,
gifIn->SColorResolution,
gifIn->SBackGroundColor,
gifIn->SColorMap) == GIF_ERROR) {
LOGE("Could not write screen descriptor");
return false;
}
LOGD("Wrote screen descriptor");
// Index of the current image.
int imageIndex = 0;
// Transparent color of the current image.
int transparentColor = NO_TRANSPARENT_COLOR;
// Buffer for reading raw images from the input GIF.
std::vector<GifByteType> srcBuffer(gifIn->SWidth * gifIn->SHeight);
// Buffer for rendering images from the input GIF.
std::unique_ptr<ColorARGB> renderBuffer(new ColorARGB[gifIn->SWidth * gifIn->SHeight]);
// Buffer for writing new images to output GIF (one row at a time).
std::unique_ptr<GifByteType> dstRowBuffer(new GifByteType[gifOut->SWidth]);
// Many GIFs use DISPOSE_DO_NOT to make images draw on top of previous images. They can also
// use DISPOSE_BACKGROUND to clear the last image region before drawing the next one. We need
// to keep track of the disposal mode as we go along to properly render the GIF.
int disposalMode = DISPOSAL_UNSPECIFIED;
int prevImageDisposalMode = DISPOSAL_UNSPECIFIED;
GifImageDesc prevImageDimens;
// Background color (applies to entire GIF).
ColorARGB bgColor = TRANSPARENT;
GifRecordType recordType;
do {
if (DGifGetRecordType(gifIn, &recordType) == GIF_ERROR) {
LOGE("Could not get record type");
return false;
}
LOGD("Read record type: %d", recordType);
switch (recordType) {
case IMAGE_DESC_RECORD_TYPE: {
if (DGifGetImageDesc(gifIn) == GIF_ERROR) {
LOGE("Could not read image descriptor (%d)", imageIndex);
return false;
}
// Sanity-check the current image position.
if (gifIn->Image.Left < 0 ||
gifIn->Image.Top < 0 ||
gifIn->Image.Left + gifIn->Image.Width > gifIn->SWidth ||
gifIn->Image.Top + gifIn->Image.Height > gifIn->SHeight) {
LOGE("GIF image extends beyond logical screen");
return false;
}
// Write the new image descriptor.
if (EGifPutImageDesc(gifOut,
0, // Left
0, // Top
gifOut->SWidth,
gifOut->SHeight,
false, // Interlace
gifIn->Image.ColorMap) == GIF_ERROR) {
LOGE("Could not write image descriptor (%d)", imageIndex);
return false;
}
// Read the image from the input GIF. The buffer is already initialized to the
// size of the GIF, which is usually equal to the size of all the images inside it.
// If not, the call to resize below ensures that the buffer is the right size.
srcBuffer.resize(gifIn->Image.Width * gifIn->Image.Height);
if (readImage(gifIn, srcBuffer.data()) == false) {
LOGE("Could not read image data (%d)", imageIndex);
return false;
}
LOGD("Read image data (%d)", imageIndex);
// Render the image from the input GIF.
if (renderImage(gifIn,
srcBuffer.data(),
imageIndex,
transparentColor,
renderBuffer.get(),
bgColor,
prevImageDimens,
prevImageDisposalMode) == false) {
LOGE("Could not render %d", imageIndex);
return false;
}
LOGD("Rendered image (%d)", imageIndex);
// Generate the image in the output GIF.
for (int y = 0; y < gifOut->SHeight; y++) {
for (int x = 0; x < gifOut->SWidth; x++) {
const GifByteType dstColorIndex = computeNewColorIndex(
gifIn, transparentColor, renderBuffer.get(), x, y);
*(dstRowBuffer.get() + x) = dstColorIndex;
}
if (EGifPutLine(gifOut, dstRowBuffer.get(), gifOut->SWidth) == GIF_ERROR) {
LOGE("Could not write raster data (%d)", imageIndex);
return false;
}
}
LOGD("Wrote raster data (%d)", imageIndex);
// Save the disposal mode for rendering the next image.
// We only support DISPOSE_DO_NOT and DISPOSE_BACKGROUND.
prevImageDisposalMode = disposalMode;
if (prevImageDisposalMode == DISPOSAL_UNSPECIFIED) {
prevImageDisposalMode = DISPOSE_DO_NOT;
} else if (prevImageDisposalMode == DISPOSE_PREVIOUS) {
prevImageDisposalMode = DISPOSE_BACKGROUND;
}
if (prevImageDisposalMode == DISPOSE_BACKGROUND) {
prevImageDimens.Left = gifIn->Image.Left;
prevImageDimens.Top = gifIn->Image.Top;
prevImageDimens.Width = gifIn->Image.Width;
prevImageDimens.Height = gifIn->Image.Height;
}
if (gifOut->Image.ColorMap) {
GifFreeMapObject(gifOut->Image.ColorMap);
gifOut->Image.ColorMap = NULL;
}
imageIndex++;
} break;
case EXTENSION_RECORD_TYPE: {
int extCode;
GifByteType* ext;
if (DGifGetExtension(gifIn, &extCode, &ext) == GIF_ERROR) {
LOGE("Could not read extension block");
return false;
}
LOGD("Read extension block, code: %d", extCode);
if (extCode == GRAPHICS_EXT_FUNC_CODE) {
GraphicsControlBlock gcb;
if (DGifExtensionToGCB(ext[0], ext + 1, &gcb) == GIF_ERROR) {
LOGE("Could not interpret GCB extension");
return false;
}
transparentColor = gcb.TransparentColor;
// This logic for setting the background color based on the first GCB
// doesn't quite match the GIF spec, but empirically it seems to work and it
// matches what libframesequence (Rastermill) does.
if (imageIndex == 0 && gifIn->SColorMap) {
if (gcb.TransparentColor == NO_TRANSPARENT_COLOR) {
GifColorType bgColorIndex =
gifIn->SColorMap->Colors[gifIn->SBackGroundColor];
bgColor = gifColorToColorARGB(bgColorIndex);
LOGD("Set background color based on first GCB");
}
}
// Record the original disposal mode and then update it.
disposalMode = gcb.DisposalMode;
gcb.DisposalMode = DISPOSE_BACKGROUND;
EGifGCBToExtension(&gcb, ext + 1);
}
if (EGifPutExtensionLeader(gifOut, extCode) == GIF_ERROR) {
LOGE("Could not write extension leader");
return false;
}
if (EGifPutExtensionBlock(gifOut, ext[0], ext + 1) == GIF_ERROR) {
LOGE("Could not write extension block");
return false;
}
LOGD("Wrote extension block");
while (ext != NULL) {
if (DGifGetExtensionNext(gifIn, &ext) == GIF_ERROR) {
LOGE("Could not read extension continuation");
return false;
}
if (ext != NULL) {
LOGD("Read extension continuation");
if (EGifPutExtensionBlock(gifOut, ext[0], ext + 1) == GIF_ERROR) {
LOGE("Could not write extension continuation");
return false;
}
LOGD("Wrote extension continuation");
}
}
if (EGifPutExtensionTrailer(gifOut) == GIF_ERROR) {
LOGE("Could not write extension trailer");
return false;
}
} break;
}
} while (recordType != TERMINATE_RECORD_TYPE);
LOGD("No more records");
return true;
}
bool GifTranscoder::readImage(GifFileType* gifIn, GifByteType* rasterBits) {
if (gifIn->Image.Interlace) {
int interlacedOffset[] = { 0, 4, 2, 1 };
int interlacedJumps[] = { 8, 8, 4, 2 };
// Need to perform 4 passes on the image
for (int i = 0; i < 4; i++) {
for (int j = interlacedOffset[i]; j < gifIn->Image.Height; j += interlacedJumps[i]) {
if (DGifGetLine(gifIn,
rasterBits + j * gifIn->Image.Width,
gifIn->Image.Width) == GIF_ERROR) {
LOGE("Could not read interlaced raster data");
return false;
}
}
}
} else {
if (DGifGetLine(gifIn, rasterBits, gifIn->Image.Width * gifIn->Image.Height) == GIF_ERROR) {
LOGE("Could not read raster data");
return false;
}
}
return true;
}
bool GifTranscoder::renderImage(GifFileType* gifIn,
GifByteType* rasterBits,
int imageIndex,
int transparentColorIndex,
ColorARGB* renderBuffer,
ColorARGB bgColor,
GifImageDesc prevImageDimens,
int prevImageDisposalMode) {
ASSERT(imageIndex < gifIn->ImageCount,
"Image index %d is out of bounds (count=%d)", imageIndex, gifIn->ImageCount);
ColorMapObject* colorMap = getColorMap(gifIn);
if (colorMap == NULL) {
LOGE("No GIF color map found");
return false;
}
// Clear all or part of the background, before drawing the first image and maybe before drawing
// subsequent images (depending on the DisposalMode).
if (imageIndex == 0) {
fillRect(renderBuffer, gifIn->SWidth, gifIn->SHeight,
0, 0, gifIn->SWidth, gifIn->SHeight, bgColor);
} else if (prevImageDisposalMode == DISPOSE_BACKGROUND) {
fillRect(renderBuffer, gifIn->SWidth, gifIn->SHeight,
prevImageDimens.Left, prevImageDimens.Top,
prevImageDimens.Width, prevImageDimens.Height, TRANSPARENT);
}
// Paint this image onto the canvas
for (int y = 0; y < gifIn->Image.Height; y++) {
for (int x = 0; x < gifIn->Image.Width; x++) {
GifByteType colorIndex = *getPixel(rasterBits, gifIn->Image.Width, x, y);
// This image may be smaller than the GIF's "logical screen"
int renderX = x + gifIn->Image.Left;
int renderY = y + gifIn->Image.Top;
// Skip drawing transparent pixels if this image renders on top of the last one
if (imageIndex > 0 && prevImageDisposalMode == DISPOSE_DO_NOT &&
colorIndex == transparentColorIndex) {
continue;
}
ColorARGB* renderPixel = getPixel(renderBuffer, gifIn->SWidth, renderX, renderY);
*renderPixel = getColorARGB(colorMap, transparentColorIndex, colorIndex);
}
}
return true;
}
void GifTranscoder::fillRect(ColorARGB* renderBuffer,
int imageWidth,
int imageHeight,
int left,
int top,
int width,
int height,
ColorARGB color) {
ASSERT(left + width <= imageWidth, "Rectangle is outside image bounds");
ASSERT(top + height <= imageHeight, "Rectangle is outside image bounds");
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
ColorARGB* renderPixel = getPixel(renderBuffer, imageWidth, x + left, y + top);
*renderPixel = color;
}
}
}
GifByteType GifTranscoder::computeNewColorIndex(GifFileType* gifIn,
int transparentColorIndex,
ColorARGB* renderBuffer,
int x,
int y) {
ColorMapObject* colorMap = getColorMap(gifIn);
// Compute the average color of 4 adjacent pixels from the input image.
ColorARGB c1 = *getPixel(renderBuffer, gifIn->SWidth, x * 2, y * 2);
ColorARGB c2 = *getPixel(renderBuffer, gifIn->SWidth, x * 2 + 1, y * 2);
ColorARGB c3 = *getPixel(renderBuffer, gifIn->SWidth, x * 2, y * 2 + 1);
ColorARGB c4 = *getPixel(renderBuffer, gifIn->SWidth, x * 2 + 1, y * 2 + 1);
ColorARGB avgColor = computeAverage(c1, c2, c3, c4);
// Search the color map for the best match.
return findBestColor(colorMap, transparentColorIndex, avgColor);
}
ColorARGB GifTranscoder::computeAverage(ColorARGB c1, ColorARGB c2, ColorARGB c3, ColorARGB c4) {
char avgAlpha = (char)(((int) ALPHA(c1) + (int) ALPHA(c2) +
(int) ALPHA(c3) + (int) ALPHA(c4)) / 4);
char avgRed = (char)(((int) RED(c1) + (int) RED(c2) +
(int) RED(c3) + (int) RED(c4)) / 4);
char avgGreen = (char)(((int) GREEN(c1) + (int) GREEN(c2) +
(int) GREEN(c3) + (int) GREEN(c4)) / 4);
char avgBlue = (char)(((int) BLUE(c1) + (int) BLUE(c2) +
(int) BLUE(c3) + (int) BLUE(c4)) / 4);
return MAKE_COLOR_ARGB(avgAlpha, avgRed, avgGreen, avgBlue);
}
GifByteType GifTranscoder::findBestColor(ColorMapObject* colorMap, int transparentColorIndex,
ColorARGB targetColor) {
// Return the transparent color if the average alpha is zero.
char alpha = ALPHA(targetColor);
if (alpha == 0 && transparentColorIndex != NO_TRANSPARENT_COLOR) {
return transparentColorIndex;
}
GifByteType closestColorIndex = 0;
int closestColorDistance = MAX_COLOR_DISTANCE;
for (int i = 0; i < colorMap->ColorCount; i++) {
// Skip the transparent color (we've already eliminated that option).
if (i == transparentColorIndex) {
continue;
}
ColorARGB indexedColor = gifColorToColorARGB(colorMap->Colors[i]);
int distance = computeDistance(targetColor, indexedColor);
if (distance < closestColorDistance) {
closestColorIndex = i;
closestColorDistance = distance;
}
}
return closestColorIndex;
}
int GifTranscoder::computeDistance(ColorARGB c1, ColorARGB c2) {
return SQUARE(RED(c1) - RED(c2)) +
SQUARE(GREEN(c1) - GREEN(c2)) +
SQUARE(BLUE(c1) - BLUE(c2));
}
ColorMapObject* GifTranscoder::getColorMap(GifFileType* gifIn) {
if (gifIn->Image.ColorMap) {
return gifIn->Image.ColorMap;
}
return gifIn->SColorMap;
}
ColorARGB GifTranscoder::getColorARGB(ColorMapObject* colorMap, int transparentColorIndex,
GifByteType colorIndex) {
if (colorIndex == transparentColorIndex) {
return TRANSPARENT;
}
return gifColorToColorARGB(colorMap->Colors[colorIndex]);
}
ColorARGB GifTranscoder::gifColorToColorARGB(const GifColorType& color) {
return MAKE_COLOR_ARGB(0xff, color.Red, color.Green, color.Blue);
}
GifFilesCloser::~GifFilesCloser() {
if (mGifIn) {
DGifCloseFile(mGifIn);
mGifIn = NULL;
}
if (mGifOut) {
EGifCloseFile(mGifOut);
mGifOut = NULL;
}
}
void GifFilesCloser::setGifIn(GifFileType* gifIn) {
ASSERT(mGifIn == NULL, "mGifIn is already set");
mGifIn = gifIn;
}
void GifFilesCloser::releaseGifIn() {
ASSERT(mGifIn != NULL, "mGifIn is already NULL");
mGifIn = NULL;
}
void GifFilesCloser::setGifOut(GifFileType* gifOut) {
ASSERT(mGifOut == NULL, "mGifOut is already set");
mGifOut = gifOut;
}
void GifFilesCloser::releaseGifOut() {
ASSERT(mGifOut != NULL, "mGifOut is already NULL");
mGifOut = NULL;
}
// JNI stuff
jboolean transcode(JNIEnv* env, jobject clazz, jstring filePath, jstring outFilePath) {
const char* pathIn = env->GetStringUTFChars(filePath, JNI_FALSE);
const char* pathOut = env->GetStringUTFChars(outFilePath, JNI_FALSE);
GifTranscoder transcoder;
int gifCode = transcoder.transcode(pathIn, pathOut);
env->ReleaseStringUTFChars(filePath, pathIn);
env->ReleaseStringUTFChars(outFilePath, pathOut);
return (gifCode == GIF_OK);
}
const char *kClassPathName = "com/android/messaging/util/GifTranscoder";
JNINativeMethod kMethods[] = {
{ "transcodeInternal", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)transcode },
};
int registerNativeMethods(JNIEnv* env, const char* className,
JNINativeMethod* gMethods, int numMethods) {
jclass clazz = env->FindClass(className);
if (clazz == NULL) {
return JNI_FALSE;
}
if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
return JNI_FALSE;
}
return JNI_TRUE;
}
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
JNIEnv* env;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
return -1;
}
if (!registerNativeMethods(env, kClassPathName,
kMethods, sizeof(kMethods) / sizeof(kMethods[0]))) {
return -1;
}
return JNI_VERSION_1_6;
}

122
jni/GifTranscoder.h Normal file
View File

@@ -0,0 +1,122 @@
/*
* Copyright (C) 2015 The Android Open Source 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.
*/
#ifndef GIF_TRANSCODER_H
#define GIF_TRANSCODER_H
#include <sys/types.h>
#include "gif_lib.h"
// 24-bit color with alpha, stored in order: A, R, G, B.
// The internal GIF render buffer stores pixels using this format.
typedef uint32_t ColorARGB;
// Compresses a GIF (probably animated) so it can be sent via MMS, which generally has a 1 MB limit
// on attachments. GIF image data is already compressed (LZW), so to achieve further reduction in
// file size, we reduce the image dimensions.
//
// Helpful GIF references:
// GIF89A spec: http://www.w3.org/Graphics/GIF/spec-gif89a.txt
// What's in a GIF: http://giflib.sourceforge.net/whatsinagif/index.html
//
class GifTranscoder {
public:
GifTranscoder() {}
~GifTranscoder() {}
// Resizes a GIF's width and height to 50% of their original dimensions. The new file is
// written to pathOut.
//
// The image is resized using a box filter, which averages the colors in each 2x2 box of pixels
// in the source to generate the color of the pixel in the destination.
//
// Returns GIF_OK (1) on success, or GIF_ERROR (0) on failure.
int transcode(const char* pathIn, const char* pathOut);
private:
// Implementation of the box filter algorithm.
static bool resizeBoxFilter(GifFileType* gifIn, GifFileType* gifOut);
// Reads the raster data for the current image of the GIF.
static bool readImage(GifFileType* gifIn, GifByteType* rasterBits);
// Renders the current image of the GIF into the supplied render buffer.
static bool renderImage(GifFileType* gifIn,
GifByteType* rasterBits,
int imageIndex,
int transparentColorIndex,
ColorARGB* renderBuffer,
ColorARGB bgColor,
GifImageDesc prevImageDimens,
int prevImageDisposalMode);
// Fills a rectangle in the buffer with a solid color.
static void fillRect(ColorARGB* renderBuffer,
int imageWidth,
int imageHeight,
int left,
int top,
int width,
int height,
ColorARGB color);
// Computes the color for the pixel (x,y) in the current image in the output GIF.
static GifByteType computeNewColorIndex(GifFileType* gifIn,
int transparentColorIndex,
ColorARGB* renderBuffer,
int x,
int y);
// Computes the average color (by averaging the per-channel (ARGB) values).
static ColorARGB computeAverage(ColorARGB c1, ColorARGB c2, ColorARGB c3, ColorARGB c4);
// Searches a color map for the color closest (Euclidean distance) to the target color.
static GifByteType findBestColor(ColorMapObject* colorMap, int transparentColorIndex,
ColorARGB targetColor);
// Computes distance (squared) between 2 colors, considering each channel a separate dimension.
static int computeDistance(ColorARGB c1, ColorARGB c2);
// Returns the local color map of the current image (if any), or else the global color map.
static ColorMapObject* getColorMap(GifFileType* gifIn);
// Returns an indexed color from the color map.
static ColorARGB getColorARGB(ColorMapObject* colorMap, int transparentColorIndex,
GifByteType colorIndex);
// Converts a 24-bit GIF color (RGB) to a 32-bit ARGB color.
static ColorARGB gifColorToColorARGB(const GifColorType& color);
};
// Wrapper class that automatically closes the GIF files when the wrapper goes out of scope.
class GifFilesCloser {
public:
GifFilesCloser() {}
~GifFilesCloser();
void setGifIn(GifFileType* gifIn);
void releaseGifIn();
void setGifOut(GifFileType* gifOut);
void releaseGifOut();
private:
GifFileType* mGifIn = NULL;
GifFileType* mGifOut = NULL;
};
#endif // GIF_TRANSCODER_H

24
proguard-release.flags Normal file
View File

@@ -0,0 +1,24 @@
# Copyright (C) 2015 The Android Open Source 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.
-assumenosideeffects public class com.android.messaging.util.Trace {
public void beginSection(...);
public void endSection(...);
}
-assumenosideeffects public class com.android.messaging.util.Assert {
private void setIfEngBuild();
}
-assumenosideeffects public class com.android.messaging.util.DebugUtils {
public void logCurrentMethod(...);
}

41
proguard-test.flags Executable file
View File

@@ -0,0 +1,41 @@
# Copyright (C) 2015 The Android Open Source 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.
#
# These flags are in addition to the one in proguard.flags, which is included by the build
# directives in Android.mk.
-dontobfuscate
-dontoptimize
# FLAG(dnotario): Until we rationalize how to handle tests (extensive unit tests will want similar
# settings to these, but maybe we want to require VisibleForTesting attribute), just expose all
# non-private methods. This means we cannot run tests on user builds for the moment.
-keep class com.android.messaging.* {
!private *;
}
-keep class com.android.messaging.*.* {
!private *;
}
-keep class com.android.messaging.*.*.* {
!private *;
}
# Keep the classes needed by emma
-keep class com.vladium.** { *; }
# End of Test Rules

58
proguard.flags Normal file
View File

@@ -0,0 +1,58 @@
# Copyright (C) 2015 The Android Open Source 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.
#
# Keep enough data for stack traces
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable,*Annotation*
# Keep classes and methods that have the guava @VisibleForTesting annotation
-keep @com.google.common.annotations.VisibleForTesting class *
-keepclassmembers class * {
@com.google.common.annotations.VisibleForTesting *;
}
# Keep methods that have the @VisibleForAnimation annotation
-keep @interface com.android.messaging.annotation.VisibleForAnimation
-keepclassmembers class * {
@com.android.messaging.annotation.VisibleForAnimation *;
}
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class com.android.vcard.* { *; }
-keep class android.support.v4.* { *; }
-keep class android.support.v4.*.* { *; }
-keep class android.support.v7.* { *; }
-keep class android.support.v7.*.* { *; }
# Keep rastermill classes that need to be accessed from native code (JNI)
-keep class android.support.rastermill.** { *; }
# Preserve the name of the getCaller method so it can find itself in the stack trace it generates
-keepclassmembers public class com.android.messaging.util.DebugUtils {
public static java.lang.StackTraceElement getCaller(...);
}
# Keep the static fields of referenced inner classes of auto-generated R classes, in case we
# access those fields by reflection (e.g. EmojiMarkup)
-keepclassmembers class **.R$* {
public static <fields>;
}

37
res/animator/fab_anim.xml Normal file
View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:state_pressed="true">
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueTo="@dimen/fab_elevation_pressed"
android:valueType="floatType" />
</item>
<item>
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueTo="@dimen/fab_elevation"
android:valueType="floatType" />
</item>
</selector>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@android:color/white"
android:state_selected="true"/>
<item
android:color="@color/translucent_white" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 965 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Some files were not shown because too many files have changed in this diff Show More