diff --git a/.circleci/config.yml b/.circleci/config.yml
index d524fe69b..8b4834e92 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,85 +1,85 @@
-version: 2
-
-jobs:
- build:
- working_directory: ~/code
- docker:
- - image: circleci/android:api-29
- steps:
- - checkout
- - restore_cache:
- key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
- - run:
- name: Download dependencies
- command: ./gradlew androidDependencies
- - save_cache:
- paths:
- - ~/.gradle
- key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
- - run:
- name: Decrypt and unzip secrets
- command: |
- openssl aes-256-cbc -d -in secrets.tar.enc -md sha1 -k ${SECRETS_KEY} -iv ${SECRETS_IV} >> secrets.tar
- tar xvf secrets.tar
- - run:
- name: Gradle build
- command: ./gradlew :presentation:assembleWithAnalyticsRelease :presentation:bundleWithAnalyticsRelease
- - run:
- name: Flatten outputs
- command: find presentation/build/outputs -mindepth 2 -type f -exec mv -i '{}' presentation/build/outputs/ ';'
- - store_artifacts:
- path: presentation/build/outputs
- - persist_to_workspace:
- root: presentation/build/outputs
- paths: .
-
- test:
- working_directory: ~/code
- docker:
- - image: circleci/android:api-29
- steps:
- - checkout
- - restore_cache:
- key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
- - run:
- name: Download dependencies
- command: ./gradlew androidDependencies
- - save_cache:
- paths:
- - ~/.gradle
- key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
- - store_test_results:
- path: presentation/build/test-results
-
- deploy:
- docker:
- - image: cibuilds/github:0.10
- steps:
- - attach_workspace:
- at: presentation/build/outputs
- - run:
- name: "Publish Release on GitHub"
- command: ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} presentation/build/outputs/
-
-workflows:
- version: 2
- main:
- jobs:
- - build:
- filters:
- tags:
- only: /^v.*/
- - test:
- requires:
- - build
- filters:
- tags:
- only: /^v.*/
- - deploy:
- requires:
- - test
- filters:
- branches:
- ignore: /.*/
- tags:
- only: /^v.*/
+version: 2
+
+jobs:
+ build:
+ working_directory: ~/code
+ docker:
+ - image: circleci/android:api-29
+ steps:
+ - checkout
+ - restore_cache:
+ key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
+ - run:
+ name: Download dependencies
+ command: ./gradlew androidDependencies
+ - save_cache:
+ paths:
+ - ~/.gradle
+ key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
+ - run:
+ name: Decrypt and unzip secrets
+ command: |
+ openssl aes-256-cbc -d -in secrets.tar.enc -md sha1 -k ${SECRETS_KEY} -iv ${SECRETS_IV} >> secrets.tar
+ tar xvf secrets.tar
+ - run:
+ name: Gradle build
+ command: ./gradlew :presentation:assembleWithAnalyticsRelease :presentation:bundleWithAnalyticsRelease
+ - run:
+ name: Flatten outputs
+ command: find presentation/build/outputs -mindepth 2 -type f -exec mv -i '{}' presentation/build/outputs/ ';'
+ - store_artifacts:
+ path: presentation/build/outputs
+ - persist_to_workspace:
+ root: presentation/build/outputs
+ paths: .
+
+ test:
+ working_directory: ~/code
+ docker:
+ - image: circleci/android:api-29
+ steps:
+ - checkout
+ - restore_cache:
+ key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
+ - run:
+ name: Download dependencies
+ command: ./gradlew androidDependencies
+ - save_cache:
+ paths:
+ - ~/.gradle
+ key: jars-{{ checksum "build.gradle" }}-{{ checksum "presentation/build.gradle" }}-{{ checksum "data/build.gradle" }}-{{ checksum "domain/build.gradle" }}
+ - store_test_results:
+ path: presentation/build/test-results
+
+ deploy:
+ docker:
+ - image: cibuilds/github:0.10
+ steps:
+ - attach_workspace:
+ at: presentation/build/outputs
+ - run:
+ name: "Publish Release on GitHub"
+ command: ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} presentation/build/outputs/
+
+workflows:
+ version: 2
+ main:
+ jobs:
+ - build:
+ filters:
+ tags:
+ only: /^v.*/
+ - test:
+ requires:
+ - build
+ filters:
+ tags:
+ only: /^v.*/
+ - deploy:
+ requires:
+ - test
+ filters:
+ branches:
+ ignore: /.*/
+ tags:
+ only: /^v.*/
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 9db78b9a5..7acd8af8d 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,17 +1,17 @@
-### DESCRIPTION
-A short description of the issue.
-Example: Conversations aren't marked as read when they are opened from a notification.
-
-### STEPS
-1. Steps
-2. to
-3. reproduce
-4. the
-5. issue.
-
-### EXPECTED
-Describe the expected behaviour.
-
-### OBSERVATIONS
-Describe what happens instead of the expected behaviour.
-
+### DESCRIPTION
+A short description of the issue.
+Example: Conversations aren't marked as read when they are opened from a notification.
+
+### STEPS
+1. Steps
+2. to
+3. reproduce
+4. the
+5. issue.
+
+### EXPECTED
+Describe the expected behaviour.
+
+### OBSERVATIONS
+Describe what happens instead of the expected behaviour.
+
diff --git a/.gitignore b/.gitignore
index ca5f5f323..0187a4f44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,54 +1,54 @@
-# Built application files
-*.apk
-*.ap_
-
-# Files for the ART/Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-out/
-
-# Gradle files
-.gradle/
-build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Log Files
-*.log
-
-# Android Studio Navigation editor temp files
-.navigation/
-
-# Android Studio captures folder
-captures/
-
-# Intellij
-*.iml
-.idea/*
-
-# Keystore files
-*.jks
-
-# Mac .DS_STORE files
-*.DS_STORE
-
-# External native build folder generated in Android Studio 2.2 and later
-.externalNativeBuild
-
-# Google Services (e.g. APIs or Firebase)
-google-services.json
-
-# Freeline
-freeline.py
-freeline/
-freeline_project_description.json
+# Built application files
+*.apk
+*.ap_
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Intellij
+*.iml
+.idea/*
+
+# Keystore files
+*.jks
+
+# Mac .DS_STORE files
+*.DS_STORE
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+
+# Google Services (e.g. APIs or Firebase)
+google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
diff --git a/.travis.yml b/.travis.yml
index ae7f6a942..5b8523005 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,98 +1,98 @@
-language: android
-jdk: oraclejdk8
-sudo: false
-
-notifications:
- email:
- on_success: change
- on_failure: change
-
-env:
- global:
- - COMPILE_API_LEVEL=29
- - EMULATOR_API_LEVEL=24 # It seems emulator levels 25,26,27 from main repos have google_apis by default, and do not support armeabi-v7a. Check commit comment.
- - EMULATOR_TAG=default # Possible values are default, google_apis, android-tv, android-wear, android-wear-cn
- - EMULATOR_ABI=armeabi-v7a # Default is armeabi-v7a, possible options are: x86, x86_64, mips, arm64-v8a, armeabi-v7a. Note: check commit comment
- - EMULATOR_NAME=qksms3
- - ANDROID_BUILD_TOOLS_VERSION=29.0.2 # Match build-tools version used in build.gradle
- - EMULATOR="system-images;android-${EMULATOR_API_LEVEL};${EMULATOR_TAG};${EMULATOR_ABI}" # Used to install/create emulator
-
-android:
- components:
- - tools
- - platform-tools
- - tools
- - extra
-
- # The build tools used in the project
- - build-tools-${ANDROID_BUILD_TOOLS_VERSION}
-
- # The SDK used in the project
- - android-${COMPILE_API_LEVEL}
-
- # For running the emulator in Travis
- - android-${EMULATOR_API_LEVEL}
- - sys-img-${EMULATOR_ABI}-android-${EMULATOR_API_LEVEL}
-
-# Set up Android-sdk and the emulator
-before_install:
- # Decrypt keystore and google-services.json
- - openssl aes-256-cbc -K $encrypted_4d1d940e2c65_key -iv $encrypted_4d1d940e2c65_iv -in secrets.tar.enc -out secrets.tar -d
- - tar xvf secrets.tar
-
- - echo 'count=0' > /home/travis/.android/repositories.cfg # Avoid warning
- - ls -lar $HOME/**/*
-
- # List and delete unnecessary components to free space
- - sdkmanager --list || true # Print out package list for debug purposes
- - sdkmanager --uninstall "extras;google;google_play_services"
- - yes | sdkmanager "tools" # Update tools
- - yes | sdkmanager "platforms;android-${EMULATOR_API_LEVEL}" # Android platform required by emulator
- - yes | sdkmanager "platforms;android-${COMPILE_API_LEVEL}" # Android platform required by compiler
- - yes | sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" # Android build tools
- - yes | sdkmanager "${EMULATOR}" # Install emulator system image
- - sdkmanager --list || true # Print out package list for debug purposes
-
-# Run the emulator
-install:
- # emulator instance
- - echo no | android create avd --force -n ${EMULATOR_NAME} -k "${EMULATOR}"
- # Run emulator in a subshell, this seems to solve the travis QT issue
- - ( cd "$(dirname "$(which emulator)")" && ./emulator -avd ${EMULATOR_NAME} -verbose -show-kernel -selinux permissive -no-audio -no-window -no-boot-anim -wipe-data & )
- - android-wait-for-emulator
- - adb shell settings put global window_animation_scale 0 &
- - adb shell settings put global transition_animation_scale 0 &
- - adb shell settings put global animator_duration_scale 0 &
- - sleep 30
- - adb shell input keyevent 82 &
- - adb devices
-
-# Gradle setup
-before_script:
- - cd ${TRAVIS_BUILD_DIR}
- - ./gradlew --version
- - ./gradlew clean
-
-# Build APK
-script:
- - |
- ./gradlew :presentation:assembleWithAnalyticsRelease :presentation:bundleWithAnalyticsRelease assembleAndroidTest -PtestCoverageEnabled='true'
- retval=$?
- if [$retval -ne 0]; then
- echo "error on assembling, exit code: "$retval
- exit $retval
- fi
-
-# Deploy APK
-deploy:
- provider: releases
- skip_cleanup: true
- overwrite: true
- api_key:
- secure: XF7V/I02gpyOzCAFXEFyrThXVUUnKjSaWQ8lppO50mVtdugimjWIPtHrcYASaJQf9INhqo0lamk+khPxtKxc1BSCp8o+c22UKcpczyjD4kK27a3zKfuNQWteBRjCH34vIGnrRFSHSWYLIgeuoIK3q5Lq4IBK/Od3mfpRaDt1ER+IqMzR3L205x1H8dW3MVuxXgdnq3jHlRpq86oOe293+dnblVCtWUvAzwhZPnnbBc4JUaNomMI7dLJ/pAigByCoHHmG9pc2Cky1yyWVAnTZFAlf2PbzPDLRRnXmHuYKfHxiZgd/l8JTiZdhky9cXgFoSxvJyDABRqqLxVNfXt2ZwgdtiulZml8RB1FB0L37qL72mxWgi6y9IbQgt/FG20K2QpSBglk0bCGLS+h5Yz3kV4fhsBY7llpWGw14BvlAx9sUfl3Ej+IUsWoJgA00TFNGDG8sMyOFoCQVz/sB4Dv4h+JfynJZcmm8okcfYrWBHOoHY7cH3chBWp/2A736f2A/aqnBd6z8a03toe2ILC9eSOiIhrVxPyqLmEKBD1rCduVFNteqGwm9G9YwKpvFibTqu0gqEtfF7cmuMH6M5PYExI5EzoewZTYmgp02+lBuFAEMvycVvXcu8VfeeT6cgeLlmz2hsbo93UfoSQyP+gSojMOOkVUsl6mIp1STLiJ5IRY=
- file:
- - /home/travis/build/moezbhatti/qksms/presentation/build/outputs/bundle/withAnalyticsRelease/presentation.aab
- - /home/travis/build/moezbhatti/qksms/presentation/build/outputs/apk/withAnalytics/release/presentation-withAnalytics-release.apk
- on:
- repo: moezbhatti/qksms
+language: android
+jdk: oraclejdk8
+sudo: false
+
+notifications:
+ email:
+ on_success: change
+ on_failure: change
+
+env:
+ global:
+ - COMPILE_API_LEVEL=29
+ - EMULATOR_API_LEVEL=24 # It seems emulator levels 25,26,27 from main repos have google_apis by default, and do not support armeabi-v7a. Check commit comment.
+ - EMULATOR_TAG=default # Possible values are default, google_apis, android-tv, android-wear, android-wear-cn
+ - EMULATOR_ABI=armeabi-v7a # Default is armeabi-v7a, possible options are: x86, x86_64, mips, arm64-v8a, armeabi-v7a. Note: check commit comment
+ - EMULATOR_NAME=qksms3
+ - ANDROID_BUILD_TOOLS_VERSION=29.0.2 # Match build-tools version used in build.gradle
+ - EMULATOR="system-images;android-${EMULATOR_API_LEVEL};${EMULATOR_TAG};${EMULATOR_ABI}" # Used to install/create emulator
+
+android:
+ components:
+ - tools
+ - platform-tools
+ - tools
+ - extra
+
+ # The build tools used in the project
+ - build-tools-${ANDROID_BUILD_TOOLS_VERSION}
+
+ # The SDK used in the project
+ - android-${COMPILE_API_LEVEL}
+
+ # For running the emulator in Travis
+ - android-${EMULATOR_API_LEVEL}
+ - sys-img-${EMULATOR_ABI}-android-${EMULATOR_API_LEVEL}
+
+# Set up Android-sdk and the emulator
+before_install:
+ # Decrypt keystore and google-services.json
+ - openssl aes-256-cbc -K $encrypted_4d1d940e2c65_key -iv $encrypted_4d1d940e2c65_iv -in secrets.tar.enc -out secrets.tar -d
+ - tar xvf secrets.tar
+
+ - echo 'count=0' > /home/travis/.android/repositories.cfg # Avoid warning
+ - ls -lar $HOME/**/*
+
+ # List and delete unnecessary components to free space
+ - sdkmanager --list || true # Print out package list for debug purposes
+ - sdkmanager --uninstall "extras;google;google_play_services"
+ - yes | sdkmanager "tools" # Update tools
+ - yes | sdkmanager "platforms;android-${EMULATOR_API_LEVEL}" # Android platform required by emulator
+ - yes | sdkmanager "platforms;android-${COMPILE_API_LEVEL}" # Android platform required by compiler
+ - yes | sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" # Android build tools
+ - yes | sdkmanager "${EMULATOR}" # Install emulator system image
+ - sdkmanager --list || true # Print out package list for debug purposes
+
+# Run the emulator
+install:
+ # emulator instance
+ - echo no | android create avd --force -n ${EMULATOR_NAME} -k "${EMULATOR}"
+ # Run emulator in a subshell, this seems to solve the travis QT issue
+ - ( cd "$(dirname "$(which emulator)")" && ./emulator -avd ${EMULATOR_NAME} -verbose -show-kernel -selinux permissive -no-audio -no-window -no-boot-anim -wipe-data & )
+ - android-wait-for-emulator
+ - adb shell settings put global window_animation_scale 0 &
+ - adb shell settings put global transition_animation_scale 0 &
+ - adb shell settings put global animator_duration_scale 0 &
+ - sleep 30
+ - adb shell input keyevent 82 &
+ - adb devices
+
+# Gradle setup
+before_script:
+ - cd ${TRAVIS_BUILD_DIR}
+ - ./gradlew --version
+ - ./gradlew clean
+
+# Build APK
+script:
+ - |
+ ./gradlew :presentation:assembleWithAnalyticsRelease :presentation:bundleWithAnalyticsRelease assembleAndroidTest -PtestCoverageEnabled='true'
+ retval=$?
+ if [$retval -ne 0]; then
+ echo "error on assembling, exit code: "$retval
+ exit $retval
+ fi
+
+# Deploy APK
+deploy:
+ provider: releases
+ skip_cleanup: true
+ overwrite: true
+ api_key:
+ secure: XF7V/I02gpyOzCAFXEFyrThXVUUnKjSaWQ8lppO50mVtdugimjWIPtHrcYASaJQf9INhqo0lamk+khPxtKxc1BSCp8o+c22UKcpczyjD4kK27a3zKfuNQWteBRjCH34vIGnrRFSHSWYLIgeuoIK3q5Lq4IBK/Od3mfpRaDt1ER+IqMzR3L205x1H8dW3MVuxXgdnq3jHlRpq86oOe293+dnblVCtWUvAzwhZPnnbBc4JUaNomMI7dLJ/pAigByCoHHmG9pc2Cky1yyWVAnTZFAlf2PbzPDLRRnXmHuYKfHxiZgd/l8JTiZdhky9cXgFoSxvJyDABRqqLxVNfXt2ZwgdtiulZml8RB1FB0L37qL72mxWgi6y9IbQgt/FG20K2QpSBglk0bCGLS+h5Yz3kV4fhsBY7llpWGw14BvlAx9sUfl3Ej+IUsWoJgA00TFNGDG8sMyOFoCQVz/sB4Dv4h+JfynJZcmm8okcfYrWBHOoHY7cH3chBWp/2A736f2A/aqnBd6z8a03toe2ILC9eSOiIhrVxPyqLmEKBD1rCduVFNteqGwm9G9YwKpvFibTqu0gqEtfF7cmuMH6M5PYExI5EzoewZTYmgp02+lBuFAEMvycVvXcu8VfeeT6cgeLlmz2hsbo93UfoSQyP+gSojMOOkVUsl6mIp1STLiJ5IRY=
+ file:
+ - /home/travis/build/moezbhatti/qksms/presentation/build/outputs/bundle/withAnalyticsRelease/presentation.aab
+ - /home/travis/build/moezbhatti/qksms/presentation/build/outputs/apk/withAnalytics/release/presentation-withAnalytics-release.apk
+ on:
+ repo: moezbhatti/qksms
tags: true
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 9cecc1d46..c65825e32 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,674 +1,674 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- {one line to give the program's name and a brief idea of what it does.}
- Copyright (C) {year} {name of author}
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- {project} Copyright (C) {year} {fullname}
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {one line to give the program's name and a brief idea of what it does.}
+ Copyright (C) {year} {name of author}
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ {project} Copyright (C) {year} {fullname}
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/README.md b/README.md
index b8476a568..18e675c32 100644
--- a/README.md
+++ b/README.md
@@ -1,39 +1,39 @@
-![QKSMS](https://user-images.githubusercontent.com/4358785/39079306-a5a409b6-44e5-11e8-8589-b4acd63b636e.jpg)
-
-# QKSMS
-
-[![Build Status](https://circleci.com/gh/moezbhatti/qksms/tree/master.svg?style=svg)](https://circleci.com/gh/moezbhatti/qksms/tree/master)
-[![Crowdin](https://badges.crowdin.net/qksms/localized.svg)](https://crowdin.com/project/qksms)
-[![Liberapay donation](https://img.shields.io/badge/donate-liberapay-yellow.svg)](https://liberapay.com/moezbhatti/)
-[![Bitcoin donation](https://img.shields.io/badge/donate-bitcoin-yellow.svg)](https://qklabs.com/donate-btc/)
-[![PayPal donation](https://img.shields.io/badge/donate-paypal-yellow.svg)](https://qklabs.com/donate)
-
-QKSMS is an open source replacement to the [stock messaging app](https://github.com/android/platform_packages_apps_mms) on Android. It is currently available on the [Google Play Store](https://play.google.com/store/apps/details?id=com.moez.QKSMS) and on [F-Droid](https://f-droid.org/repository/browse/?fdid=com.moez.QKSMS)
-
-
-
-## Reporting bugs
-
-A great bug report contains a description of the problem and steps to reproduce the problem. We need to know what we're looking for and where to look for it.
-
-When reporting a bug, please make sure to provide the following information:
-- Steps to reproduce the issue
-- QKSMS version
-- Device / OS information
-
-## Translations
-
-If you'd like to add translations to QKSMS, please join the project on [Crowdin](https://crowdin.com/project/qksms). Translations that are committed directly to source files will not be accepted.
-
-## Thank you
-
-A special thank you to Jake ([@klinker41](https://github.com/klinker41)) and Luke Klinker ([@klinker24](https://github.com/klinker24)) for their work on [android-smsmms](https://github.com/klinker41/android-smsmms), which has been an unspeakably large help in implementing MMS into QKSMS.
-
-
-## Contact
-
-QKSMS is developed and maintained by [Moez Bhatti](https://github.com/moezbhatti). Feel free to reach out to moez@qklabs.com
-
-## License
-
-QKSMS is released under the **The GNU General Public License v3.0 (GPLv3)**, which can be found in the `LICENSE` file in the root of this project.
+![QKSMS](https://user-images.githubusercontent.com/4358785/39079306-a5a409b6-44e5-11e8-8589-b4acd63b636e.jpg)
+
+# QKSMS
+
+[![Build Status](https://circleci.com/gh/moezbhatti/qksms/tree/master.svg?style=svg)](https://circleci.com/gh/moezbhatti/qksms/tree/master)
+[![Crowdin](https://badges.crowdin.net/qksms/localized.svg)](https://crowdin.com/project/qksms)
+[![Liberapay donation](https://img.shields.io/badge/donate-liberapay-yellow.svg)](https://liberapay.com/moezbhatti/)
+[![Bitcoin donation](https://img.shields.io/badge/donate-bitcoin-yellow.svg)](https://qklabs.com/donate-btc/)
+[![PayPal donation](https://img.shields.io/badge/donate-paypal-yellow.svg)](https://qklabs.com/donate)
+
+QKSMS is an open source replacement to the [stock messaging app](https://github.com/android/platform_packages_apps_mms) on Android. It is currently available on the [Google Play Store](https://play.google.com/store/apps/details?id=com.moez.QKSMS) and on [F-Droid](https://f-droid.org/repository/browse/?fdid=com.moez.QKSMS)
+
+
+
+## Reporting bugs
+
+A great bug report contains a description of the problem and steps to reproduce the problem. We need to know what we're looking for and where to look for it.
+
+When reporting a bug, please make sure to provide the following information:
+- Steps to reproduce the issue
+- QKSMS version
+- Device / OS information
+
+## Translations
+
+If you'd like to add translations to QKSMS, please join the project on [Crowdin](https://crowdin.com/project/qksms). Translations that are committed directly to source files will not be accepted.
+
+## Thank you
+
+A special thank you to Jake ([@klinker41](https://github.com/klinker41)) and Luke Klinker ([@klinker24](https://github.com/klinker24)) for their work on [android-smsmms](https://github.com/klinker41/android-smsmms), which has been an unspeakably large help in implementing MMS into QKSMS.
+
+
+## Contact
+
+QKSMS is developed and maintained by [Moez Bhatti](https://github.com/moezbhatti). Feel free to reach out to moez@qklabs.com
+
+## License
+
+QKSMS is released under the **The GNU General Public License v3.0 (GPLv3)**, which can be found in the `LICENSE` file in the root of this project.
diff --git a/android-smsmms/build.gradle b/android-smsmms/build.gradle
index 505404cb3..14b0f168e 100644
--- a/android-smsmms/build.gradle
+++ b/android-smsmms/build.gradle
@@ -1,49 +1,49 @@
-/*
- * Copyright (C) 2017 Moez Bhatti
- *
- * This file is part of QKSMS.
- *
- * QKSMS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * QKSMS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with QKSMS. If not, see .
- */
-apply plugin: 'com.android.library'
-apply plugin: 'kotlin-android'
-
-android {
- compileSdkVersion 25
-
- defaultConfig {
- minSdkVersion 21
- targetSdkVersion 25
- versionCode 1
- versionName "1.0"
- }
-
- lintOptions {
- abortOnError false
- }
-
- useLibrary 'org.apache.http.legacy'
-}
-
-dependencies {
- implementation "androidx.core:core-ktx:$androidx_core_version"
- implementation "com.jakewharton.timber:timber:$timber_version"
- implementation 'com.squareup.okhttp:okhttp:2.5.0'
- implementation 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
-}
-
-repositories {
- mavenCentral()
+/*
+ * Copyright (C) 2017 Moez Bhatti
+ *
+ * This file is part of QKSMS.
+ *
+ * QKSMS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * QKSMS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with QKSMS. If not, see .
+ */
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+
+android {
+ compileSdkVersion 25
+
+ defaultConfig {
+ minSdkVersion 21
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+ }
+
+ lintOptions {
+ abortOnError false
+ }
+
+ useLibrary 'org.apache.http.legacy'
+}
+
+dependencies {
+ implementation "androidx.core:core-ktx:$androidx_core_version"
+ implementation "com.jakewharton.timber:timber:$timber_version"
+ implementation 'com.squareup.okhttp:okhttp:2.5.0'
+ implementation 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+}
+
+repositories {
+ mavenCentral()
}
\ No newline at end of file
diff --git a/android-smsmms/proguard-rules.pro b/android-smsmms/proguard-rules.pro
index f1b424510..6e7ffa997 100644
--- a/android-smsmms/proguard-rules.pro
+++ b/android-smsmms/proguard-rules.pro
@@ -1,21 +1,21 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/android-smsmms/src/main/AndroidManifest.xml b/android-smsmms/src/main/AndroidManifest.xml
index c87baa9a5..9a3a4d52c 100755
--- a/android-smsmms/src/main/AndroidManifest.xml
+++ b/android-smsmms/src/main/AndroidManifest.xml
@@ -1,15 +1,15 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/android-smsmms/src/main/java/android/database/sqlite/SqliteWrapper.java b/android-smsmms/src/main/java/android/database/sqlite/SqliteWrapper.java
index ebf980d33..3c41a3c99 100755
--- a/android-smsmms/src/main/java/android/database/sqlite/SqliteWrapper.java
+++ b/android-smsmms/src/main/java/android/database/sqlite/SqliteWrapper.java
@@ -1,99 +1,99 @@
-/*
- * Copyright (C) 2008 Esmertec AG.
- * Copyright (C) 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.
- * 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.
- */
-
-package android.database.sqlite;
-
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.net.Uri;
-import android.widget.Toast;
-import org.jetbrains.annotations.Nullable;
-import timber.log.Timber;
-
-/**
- * @hide
- */
-
-public final class SqliteWrapper {
- private static final String SQLITE_EXCEPTION_DETAIL_MESSAGE
- = "unable to open database file";
-
- private SqliteWrapper() {
- // Forbidden being instantiated.
- }
-
- // FIXME: need to optimize this method.
- private static boolean isLowMemory(SQLiteException e) {
- return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
- }
-
- public static void checkSQLiteException(Context context, SQLiteException e) {
- if (isLowMemory(e)) {
- Toast.makeText(context, "Low Memory",
- Toast.LENGTH_SHORT).show();
- } else {
- throw e;
- }
- }
-
- @Nullable
- public static Cursor query(Context context, ContentResolver resolver, Uri uri,
- String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- try {
- return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
- } catch (SQLiteException e) {
- Timber.e(e, "Catch a SQLiteException when query: ");
- checkSQLiteException(context, e);
- return null;
- }
- }
-
- public static int update(Context context, ContentResolver resolver, Uri uri,
- ContentValues values, String where, String[] selectionArgs) {
- try {
- return resolver.update(uri, values, where, selectionArgs);
- } catch (SQLiteException e) {
- Timber.e(e, "Catch a SQLiteException when update: ");
- checkSQLiteException(context, e);
- return -1;
- }
- }
-
- public static int delete(Context context, ContentResolver resolver, Uri uri,
- String where, String[] selectionArgs) {
- try {
- return resolver.delete(uri, where, selectionArgs);
- } catch (SQLiteException e) {
- Timber.e(e, "Catch a SQLiteException when delete: ");
- checkSQLiteException(context, e);
- return -1;
- }
- }
-
- public static Uri insert(Context context, ContentResolver resolver,
- Uri uri, ContentValues values) {
- try {
- return resolver.insert(uri, values);
- } catch (SQLiteException e) {
- Timber.e(e, "Catch a SQLiteException when insert: ");
- checkSQLiteException(context, e);
- return null;
- }
- }
-}
+/*
+ * Copyright (C) 2008 Esmertec AG.
+ * Copyright (C) 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.
+ * 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.
+ */
+
+package android.database.sqlite;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.widget.Toast;
+import org.jetbrains.annotations.Nullable;
+import timber.log.Timber;
+
+/**
+ * @hide
+ */
+
+public final class SqliteWrapper {
+ private static final String SQLITE_EXCEPTION_DETAIL_MESSAGE
+ = "unable to open database file";
+
+ private SqliteWrapper() {
+ // Forbidden being instantiated.
+ }
+
+ // FIXME: need to optimize this method.
+ private static boolean isLowMemory(SQLiteException e) {
+ return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
+ }
+
+ public static void checkSQLiteException(Context context, SQLiteException e) {
+ if (isLowMemory(e)) {
+ Toast.makeText(context, "Low Memory",
+ Toast.LENGTH_SHORT).show();
+ } else {
+ throw e;
+ }
+ }
+
+ @Nullable
+ public static Cursor query(Context context, ContentResolver resolver, Uri uri,
+ String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ try {
+ return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
+ } catch (SQLiteException e) {
+ Timber.e(e, "Catch a SQLiteException when query: ");
+ checkSQLiteException(context, e);
+ return null;
+ }
+ }
+
+ public static int update(Context context, ContentResolver resolver, Uri uri,
+ ContentValues values, String where, String[] selectionArgs) {
+ try {
+ return resolver.update(uri, values, where, selectionArgs);
+ } catch (SQLiteException e) {
+ Timber.e(e, "Catch a SQLiteException when update: ");
+ checkSQLiteException(context, e);
+ return -1;
+ }
+ }
+
+ public static int delete(Context context, ContentResolver resolver, Uri uri,
+ String where, String[] selectionArgs) {
+ try {
+ return resolver.delete(uri, where, selectionArgs);
+ } catch (SQLiteException e) {
+ Timber.e(e, "Catch a SQLiteException when delete: ");
+ checkSQLiteException(context, e);
+ return -1;
+ }
+ }
+
+ public static Uri insert(Context context, ContentResolver resolver,
+ Uri uri, ContentValues values) {
+ try {
+ return resolver.insert(uri, values);
+ } catch (SQLiteException e) {
+ Timber.e(e, "Catch a SQLiteException when insert: ");
+ checkSQLiteException(context, e);
+ return null;
+ }
+ }
+}
diff --git a/android-smsmms/src/main/java/android/net/DhcpInfoInternal.java b/android-smsmms/src/main/java/android/net/DhcpInfoInternal.java
index 1e0c7f63a..021aab594 100755
--- a/android-smsmms/src/main/java/android/net/DhcpInfoInternal.java
+++ b/android-smsmms/src/main/java/android/net/DhcpInfoInternal.java
@@ -1,167 +1,167 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package android.net;
-
-import android.text.TextUtils;
-import timber.log.Timber;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * A simple object for retrieving the results of a DHCP request.
- * Replaces (internally) the IPv4-only DhcpInfo class.
- *
- * @hide
- */
-public class DhcpInfoInternal {
- public String ipAddress;
- public int prefixLength;
-
- public String dns1;
- public String dns2;
-
- public String serverAddress;
- public int leaseDuration;
-
- /**
- * Vendor specific information (from RFC 2132).
- */
- public String vendorInfo;
-
- private Collection mRoutes;
-
- public DhcpInfoInternal() {
- mRoutes = new ArrayList();
- }
-
- public void addRoute(RouteInfo routeInfo) {
- mRoutes.add(routeInfo);
- }
-
- public Collection getRoutes() {
- return Collections.unmodifiableCollection(mRoutes);
- }
-
- private int convertToInt(String addr) {
- if (addr != null) {
- try {
- InetAddress inetAddress = NetworkUtilsHelper.numericToInetAddress(addr);
- if (inetAddress instanceof Inet4Address) {
- return NetworkUtilsHelper.inetAddressToInt(inetAddress);
- }
- } catch (IllegalArgumentException e) {
- }
- }
- return 0;
- }
-
- public DhcpInfo makeDhcpInfo() {
- DhcpInfo info = new DhcpInfo();
- info.ipAddress = convertToInt(ipAddress);
- for (RouteInfo route : mRoutes) {
- if (route.isDefaultRoute()) {
- info.gateway = convertToInt(route.getGateway().getHostAddress());
- break;
- }
- }
- try {
- info.netmask = NetworkUtilsHelper.prefixLengthToNetmaskInt(prefixLength);
- } catch (IllegalArgumentException e) {
- }
- info.dns1 = convertToInt(dns1);
- info.dns2 = convertToInt(dns2);
- info.serverAddress = convertToInt(serverAddress);
- info.leaseDuration = leaseDuration;
- return info;
- }
-
- public LinkAddress makeLinkAddress() {
- if (TextUtils.isEmpty(ipAddress)) {
- Timber.e("makeLinkAddress with empty ipAddress");
- return null;
- }
- return new LinkAddress(NetworkUtilsHelper.numericToInetAddress(ipAddress), prefixLength);
- }
-
- public LinkProperties makeLinkProperties() {
- LinkProperties p = new LinkProperties();
- p.addLinkAddress(makeLinkAddress());
- for (RouteInfo route : mRoutes) {
- p.addRoute(route);
- }
- //if empty, connectivity configures default DNS
- if (TextUtils.isEmpty(dns1) == false) {
- p.addDns(NetworkUtilsHelper.numericToInetAddress(dns1));
- } else {
- Timber.d("makeLinkProperties with empty dns1!");
- }
- if (TextUtils.isEmpty(dns2) == false) {
- p.addDns(NetworkUtilsHelper.numericToInetAddress(dns2));
- } else {
- Timber.d("makeLinkProperties with empty dns2!");
- }
- return p;
- }
-
- /* Updates the DHCP fields that need to be retained from
- * original DHCP request if the DHCP renewal shows them as
- * being empty
- */
- public void updateFromDhcpRequest(DhcpInfoInternal orig) {
- if (orig == null) return;
-
- if (TextUtils.isEmpty(dns1)) {
- dns1 = orig.dns1;
- }
-
- if (TextUtils.isEmpty(dns2)) {
- dns2 = orig.dns2;
- }
-
- if (mRoutes.size() == 0) {
- for (RouteInfo route : orig.getRoutes()) {
- addRoute(route);
- }
- }
- }
-
- /**
- * Test if this DHCP lease includes vendor hint that network link is
- * metered, and sensitive to heavy data transfers.
- */
- public boolean hasMeteredHint() {
- if (vendorInfo != null) {
- return vendorInfo.contains("ANDROID_METERED");
- } else {
- return false;
- }
- }
-
- public String toString() {
- String routeString = "";
- for (RouteInfo route : mRoutes) routeString += route.toString() + " | ";
- return "addr: " + ipAddress + "/" + prefixLength +
- " mRoutes: " + routeString +
- " dns: " + dns1 + "," + dns2 +
- " dhcpServer: " + serverAddress +
- " leaseDuration: " + leaseDuration;
- }
-}
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.net;
+
+import android.text.TextUtils;
+import timber.log.Timber;
+
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * A simple object for retrieving the results of a DHCP request.
+ * Replaces (internally) the IPv4-only DhcpInfo class.
+ *
+ * @hide
+ */
+public class DhcpInfoInternal {
+ public String ipAddress;
+ public int prefixLength;
+
+ public String dns1;
+ public String dns2;
+
+ public String serverAddress;
+ public int leaseDuration;
+
+ /**
+ * Vendor specific information (from RFC 2132).
+ */
+ public String vendorInfo;
+
+ private Collection mRoutes;
+
+ public DhcpInfoInternal() {
+ mRoutes = new ArrayList();
+ }
+
+ public void addRoute(RouteInfo routeInfo) {
+ mRoutes.add(routeInfo);
+ }
+
+ public Collection getRoutes() {
+ return Collections.unmodifiableCollection(mRoutes);
+ }
+
+ private int convertToInt(String addr) {
+ if (addr != null) {
+ try {
+ InetAddress inetAddress = NetworkUtilsHelper.numericToInetAddress(addr);
+ if (inetAddress instanceof Inet4Address) {
+ return NetworkUtilsHelper.inetAddressToInt(inetAddress);
+ }
+ } catch (IllegalArgumentException e) {
+ }
+ }
+ return 0;
+ }
+
+ public DhcpInfo makeDhcpInfo() {
+ DhcpInfo info = new DhcpInfo();
+ info.ipAddress = convertToInt(ipAddress);
+ for (RouteInfo route : mRoutes) {
+ if (route.isDefaultRoute()) {
+ info.gateway = convertToInt(route.getGateway().getHostAddress());
+ break;
+ }
+ }
+ try {
+ info.netmask = NetworkUtilsHelper.prefixLengthToNetmaskInt(prefixLength);
+ } catch (IllegalArgumentException e) {
+ }
+ info.dns1 = convertToInt(dns1);
+ info.dns2 = convertToInt(dns2);
+ info.serverAddress = convertToInt(serverAddress);
+ info.leaseDuration = leaseDuration;
+ return info;
+ }
+
+ public LinkAddress makeLinkAddress() {
+ if (TextUtils.isEmpty(ipAddress)) {
+ Timber.e("makeLinkAddress with empty ipAddress");
+ return null;
+ }
+ return new LinkAddress(NetworkUtilsHelper.numericToInetAddress(ipAddress), prefixLength);
+ }
+
+ public LinkProperties makeLinkProperties() {
+ LinkProperties p = new LinkProperties();
+ p.addLinkAddress(makeLinkAddress());
+ for (RouteInfo route : mRoutes) {
+ p.addRoute(route);
+ }
+ //if empty, connectivity configures default DNS
+ if (TextUtils.isEmpty(dns1) == false) {
+ p.addDns(NetworkUtilsHelper.numericToInetAddress(dns1));
+ } else {
+ Timber.d("makeLinkProperties with empty dns1!");
+ }
+ if (TextUtils.isEmpty(dns2) == false) {
+ p.addDns(NetworkUtilsHelper.numericToInetAddress(dns2));
+ } else {
+ Timber.d("makeLinkProperties with empty dns2!");
+ }
+ return p;
+ }
+
+ /* Updates the DHCP fields that need to be retained from
+ * original DHCP request if the DHCP renewal shows them as
+ * being empty
+ */
+ public void updateFromDhcpRequest(DhcpInfoInternal orig) {
+ if (orig == null) return;
+
+ if (TextUtils.isEmpty(dns1)) {
+ dns1 = orig.dns1;
+ }
+
+ if (TextUtils.isEmpty(dns2)) {
+ dns2 = orig.dns2;
+ }
+
+ if (mRoutes.size() == 0) {
+ for (RouteInfo route : orig.getRoutes()) {
+ addRoute(route);
+ }
+ }
+ }
+
+ /**
+ * Test if this DHCP lease includes vendor hint that network link is
+ * metered, and sensitive to heavy data transfers.
+ */
+ public boolean hasMeteredHint() {
+ if (vendorInfo != null) {
+ return vendorInfo.contains("ANDROID_METERED");
+ } else {
+ return false;
+ }
+ }
+
+ public String toString() {
+ String routeString = "";
+ for (RouteInfo route : mRoutes) routeString += route.toString() + " | ";
+ return "addr: " + ipAddress + "/" + prefixLength +
+ " mRoutes: " + routeString +
+ " dns: " + dns1 + "," + dns2 +
+ " dhcpServer: " + serverAddress +
+ " leaseDuration: " + leaseDuration;
+ }
+}
diff --git a/android-smsmms/src/main/java/android/net/INetworkPolicyListener.java b/android-smsmms/src/main/java/android/net/INetworkPolicyListener.java
index d6ec4e59c..d0fecf265 100755
--- a/android-smsmms/src/main/java/android/net/INetworkPolicyListener.java
+++ b/android-smsmms/src/main/java/android/net/INetworkPolicyListener.java
@@ -1,138 +1,138 @@
-/*
- * This file is auto-generated. DO NOT MODIFY.
- * Original file: frameworks/base/core/java/android/net/INetworkPolicyListener.aidl
- */
-package android.net;
-
-/**
- * {@hide}
- */
-public interface INetworkPolicyListener extends android.os.IInterface {
- /**
- * Local-side IPC implementation stub class.
- */
- public static abstract class Stub extends android.os.Binder implements android.net.INetworkPolicyListener {
- private static final java.lang.String DESCRIPTOR = "android.net.INetworkPolicyListener";
-
- /**
- * Construct the stub at attach it to the interface.
- */
- public Stub() {
- this.attachInterface(this, DESCRIPTOR);
- }
-
- /**
- * Cast an IBinder object into an android.net.INetworkPolicyListener interface,
- * generating a proxy if needed.
- */
- public static android.net.INetworkPolicyListener asInterface(android.os.IBinder obj) {
- if ((obj == null)) {
- return null;
- }
- android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
- if (((iin != null) && (iin instanceof android.net.INetworkPolicyListener))) {
- return ((android.net.INetworkPolicyListener) iin);
- }
- return new android.net.INetworkPolicyListener.Stub.Proxy(obj);
- }
-
- @Override
- public android.os.IBinder asBinder() {
- return this;
- }
-
- @Override
- public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException {
- switch (code) {
- case INTERFACE_TRANSACTION: {
- reply.writeString(DESCRIPTOR);
- return true;
- }
- case TRANSACTION_onUidRulesChanged: {
- data.enforceInterface(DESCRIPTOR);
- int _arg0;
- _arg0 = data.readInt();
- int _arg1;
- _arg1 = data.readInt();
- this.onUidRulesChanged(_arg0, _arg1);
- return true;
- }
- case TRANSACTION_onMeteredIfacesChanged: {
- data.enforceInterface(DESCRIPTOR);
- java.lang.String[] _arg0;
- _arg0 = data.createStringArray();
- this.onMeteredIfacesChanged(_arg0);
- return true;
- }
- case TRANSACTION_onRestrictBackgroundChanged: {
- data.enforceInterface(DESCRIPTOR);
- boolean _arg0;
- _arg0 = (0 != data.readInt());
- this.onRestrictBackgroundChanged(_arg0);
- return true;
- }
- }
- return super.onTransact(code, data, reply, flags);
- }
-
- private static class Proxy implements android.net.INetworkPolicyListener {
- private android.os.IBinder mRemote;
-
- Proxy(android.os.IBinder remote) {
- mRemote = remote;
- }
-
- @Override
- public android.os.IBinder asBinder() {
- return mRemote;
- }
-
- @Override
- public void onUidRulesChanged(int uid, int uidRules) throws android.os.RemoteException {
- android.os.Parcel _data = android.os.Parcel.obtain();
- try {
- _data.writeInterfaceToken(DESCRIPTOR);
- _data.writeInt(uid);
- _data.writeInt(uidRules);
- mRemote.transact(Stub.TRANSACTION_onUidRulesChanged, _data, null, android.os.IBinder.FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void onMeteredIfacesChanged(java.lang.String[] meteredIfaces) throws android.os.RemoteException {
- android.os.Parcel _data = android.os.Parcel.obtain();
- try {
- _data.writeInterfaceToken(DESCRIPTOR);
- _data.writeStringArray(meteredIfaces);
- mRemote.transact(Stub.TRANSACTION_onMeteredIfacesChanged, _data, null, android.os.IBinder.FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void onRestrictBackgroundChanged(boolean restrictBackground) throws android.os.RemoteException {
- android.os.Parcel _data = android.os.Parcel.obtain();
- try {
- _data.writeInterfaceToken(DESCRIPTOR);
- _data.writeInt(((restrictBackground) ? (1) : (0)));
- mRemote.transact(Stub.TRANSACTION_onRestrictBackgroundChanged, _data, null, android.os.IBinder.FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
- }
-
- static final int TRANSACTION_onUidRulesChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
- static final int TRANSACTION_onMeteredIfacesChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
- static final int TRANSACTION_onRestrictBackgroundChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
- }
-
- public void onUidRulesChanged(int uid, int uidRules) throws android.os.RemoteException;
-
- public void onMeteredIfacesChanged(java.lang.String[] meteredIfaces) throws android.os.RemoteException;
-
- public void onRestrictBackgroundChanged(boolean restrictBackground) throws android.os.RemoteException;
-}
+/*
+ * This file is auto-generated. DO NOT MODIFY.
+ * Original file: frameworks/base/core/java/android/net/INetworkPolicyListener.aidl
+ */
+package android.net;
+
+/**
+ * {@hide}
+ */
+public interface INetworkPolicyListener extends android.os.IInterface {
+ /**
+ * Local-side IPC implementation stub class.
+ */
+ public static abstract class Stub extends android.os.Binder implements android.net.INetworkPolicyListener {
+ private static final java.lang.String DESCRIPTOR = "android.net.INetworkPolicyListener";
+
+ /**
+ * Construct the stub at attach it to the interface.
+ */
+ public Stub() {
+ this.attachInterface(this, DESCRIPTOR);
+ }
+
+ /**
+ * Cast an IBinder object into an android.net.INetworkPolicyListener interface,
+ * generating a proxy if needed.
+ */
+ public static android.net.INetworkPolicyListener asInterface(android.os.IBinder obj) {
+ if ((obj == null)) {
+ return null;
+ }
+ android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
+ if (((iin != null) && (iin instanceof android.net.INetworkPolicyListener))) {
+ return ((android.net.INetworkPolicyListener) iin);
+ }
+ return new android.net.INetworkPolicyListener.Stub.Proxy(obj);
+ }
+
+ @Override
+ public android.os.IBinder asBinder() {
+ return this;
+ }
+
+ @Override
+ public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException {
+ switch (code) {
+ case INTERFACE_TRANSACTION: {
+ reply.writeString(DESCRIPTOR);
+ return true;
+ }
+ case TRANSACTION_onUidRulesChanged: {
+ data.enforceInterface(DESCRIPTOR);
+ int _arg0;
+ _arg0 = data.readInt();
+ int _arg1;
+ _arg1 = data.readInt();
+ this.onUidRulesChanged(_arg0, _arg1);
+ return true;
+ }
+ case TRANSACTION_onMeteredIfacesChanged: {
+ data.enforceInterface(DESCRIPTOR);
+ java.lang.String[] _arg0;
+ _arg0 = data.createStringArray();
+ this.onMeteredIfacesChanged(_arg0);
+ return true;
+ }
+ case TRANSACTION_onRestrictBackgroundChanged: {
+ data.enforceInterface(DESCRIPTOR);
+ boolean _arg0;
+ _arg0 = (0 != data.readInt());
+ this.onRestrictBackgroundChanged(_arg0);
+ return true;
+ }
+ }
+ return super.onTransact(code, data, reply, flags);
+ }
+
+ private static class Proxy implements android.net.INetworkPolicyListener {
+ private android.os.IBinder mRemote;
+
+ Proxy(android.os.IBinder remote) {
+ mRemote = remote;
+ }
+
+ @Override
+ public android.os.IBinder asBinder() {
+ return mRemote;
+ }
+
+ @Override
+ public void onUidRulesChanged(int uid, int uidRules) throws android.os.RemoteException {
+ android.os.Parcel _data = android.os.Parcel.obtain();
+ try {
+ _data.writeInterfaceToken(DESCRIPTOR);
+ _data.writeInt(uid);
+ _data.writeInt(uidRules);
+ mRemote.transact(Stub.TRANSACTION_onUidRulesChanged, _data, null, android.os.IBinder.FLAG_ONEWAY);
+ } finally {
+ _data.recycle();
+ }
+ }
+
+ @Override
+ public void onMeteredIfacesChanged(java.lang.String[] meteredIfaces) throws android.os.RemoteException {
+ android.os.Parcel _data = android.os.Parcel.obtain();
+ try {
+ _data.writeInterfaceToken(DESCRIPTOR);
+ _data.writeStringArray(meteredIfaces);
+ mRemote.transact(Stub.TRANSACTION_onMeteredIfacesChanged, _data, null, android.os.IBinder.FLAG_ONEWAY);
+ } finally {
+ _data.recycle();
+ }
+ }
+
+ @Override
+ public void onRestrictBackgroundChanged(boolean restrictBackground) throws android.os.RemoteException {
+ android.os.Parcel _data = android.os.Parcel.obtain();
+ try {
+ _data.writeInterfaceToken(DESCRIPTOR);
+ _data.writeInt(((restrictBackground) ? (1) : (0)));
+ mRemote.transact(Stub.TRANSACTION_onRestrictBackgroundChanged, _data, null, android.os.IBinder.FLAG_ONEWAY);
+ } finally {
+ _data.recycle();
+ }
+ }
+ }
+
+ static final int TRANSACTION_onUidRulesChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
+ static final int TRANSACTION_onMeteredIfacesChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
+ static final int TRANSACTION_onRestrictBackgroundChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
+ }
+
+ public void onUidRulesChanged(int uid, int uidRules) throws android.os.RemoteException;
+
+ public void onMeteredIfacesChanged(java.lang.String[] meteredIfaces) throws android.os.RemoteException;
+
+ public void onRestrictBackgroundChanged(boolean restrictBackground) throws android.os.RemoteException;
+}
diff --git a/android-smsmms/src/main/java/android/net/LinkAddress.java b/android-smsmms/src/main/java/android/net/LinkAddress.java
index 21a5fe3fb..b433630c8 100755
--- a/android-smsmms/src/main/java/android/net/LinkAddress.java
+++ b/android-smsmms/src/main/java/android/net/LinkAddress.java
@@ -1,152 +1,152 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package android.net;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.InterfaceAddress;
-import java.net.UnknownHostException;
-
-/**
- * Identifies an address of a network link
- *
- * @hide
- */
-public class LinkAddress implements Parcelable {
- /**
- * IPv4 or IPv6 address.
- */
- private final InetAddress address;
-
- /**
- * Network prefix length
- */
- private final int prefixLength;
-
- public LinkAddress(InetAddress address, int prefixLength) {
- if (address == null || prefixLength < 0 ||
- ((address instanceof Inet4Address) && prefixLength > 32) ||
- (prefixLength > 128)) {
- throw new IllegalArgumentException("Bad LinkAddress haloParams " + address +
- prefixLength);
- }
- this.address = address;
- this.prefixLength = prefixLength;
- }
-
- public LinkAddress(InterfaceAddress interfaceAddress) {
- this.address = interfaceAddress.getAddress();
- this.prefixLength = interfaceAddress.getNetworkPrefixLength();
- }
-
- @Override
- public String toString() {
- return (address == null ? "" : (address.getHostAddress() + "/" + prefixLength));
- }
-
- /**
- * Compares this {@code LinkAddress} instance against the specified address
- * in {@code obj}. Two addresses are equal if their InetAddress and prefixLength
- * are equal
- *
- * @param obj the object to be tested for equality.
- * @return {@code true} if both objects are equal, {@code false} otherwise.
- */
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof LinkAddress)) {
- return false;
- }
- LinkAddress linkAddress = (LinkAddress) obj;
- return this.address.equals(linkAddress.address) &&
- this.prefixLength == linkAddress.prefixLength;
- }
-
- @Override
- /*
- * generate hashcode based on significant fields
- */
- public int hashCode() {
- return ((null == address) ? 0 : address.hashCode()) + prefixLength;
- }
-
- /**
- * Returns the InetAddress for this address.
- */
- public InetAddress getAddress() {
- return address;
- }
-
- /**
- * Get network prefix length
- */
- public int getNetworkPrefixLength() {
- return prefixLength;
- }
-
- /**
- * Implement the Parcelable interface
- *
- * @hide
- */
- public int describeContents() {
- return 0;
- }
-
- /**
- * Implement the Parcelable interface.
- *
- * @hide
- */
- public void writeToParcel(Parcel dest, int flags) {
- if (address != null) {
- dest.writeByte((byte) 1);
- dest.writeByteArray(address.getAddress());
- dest.writeInt(prefixLength);
- } else {
- dest.writeByte((byte) 0);
- }
- }
-
- /**
- * Implement the Parcelable interface.
- *
- * @hide
- */
- public static final Creator CREATOR =
- new Creator() {
- public LinkAddress createFromParcel(Parcel in) {
- InetAddress address = null;
- int prefixLength = 0;
- if (in.readByte() == 1) {
- try {
- address = InetAddress.getByAddress(in.createByteArray());
- prefixLength = in.readInt();
- } catch (UnknownHostException e) {
- }
- }
- return new LinkAddress(address, prefixLength);
- }
-
- public LinkAddress[] newArray(int size) {
- return new LinkAddress[size];
- }
- };
-}
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.net;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.InterfaceAddress;
+import java.net.UnknownHostException;
+
+/**
+ * Identifies an address of a network link
+ *
+ * @hide
+ */
+public class LinkAddress implements Parcelable {
+ /**
+ * IPv4 or IPv6 address.
+ */
+ private final InetAddress address;
+
+ /**
+ * Network prefix length
+ */
+ private final int prefixLength;
+
+ public LinkAddress(InetAddress address, int prefixLength) {
+ if (address == null || prefixLength < 0 ||
+ ((address instanceof Inet4Address) && prefixLength > 32) ||
+ (prefixLength > 128)) {
+ throw new IllegalArgumentException("Bad LinkAddress haloParams " + address +
+ prefixLength);
+ }
+ this.address = address;
+ this.prefixLength = prefixLength;
+ }
+
+ public LinkAddress(InterfaceAddress interfaceAddress) {
+ this.address = interfaceAddress.getAddress();
+ this.prefixLength = interfaceAddress.getNetworkPrefixLength();
+ }
+
+ @Override
+ public String toString() {
+ return (address == null ? "" : (address.getHostAddress() + "/" + prefixLength));
+ }
+
+ /**
+ * Compares this {@code LinkAddress} instance against the specified address
+ * in {@code obj}. Two addresses are equal if their InetAddress and prefixLength
+ * are equal
+ *
+ * @param obj the object to be tested for equality.
+ * @return {@code true} if both objects are equal, {@code false} otherwise.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof LinkAddress)) {
+ return false;
+ }
+ LinkAddress linkAddress = (LinkAddress) obj;
+ return this.address.equals(linkAddress.address) &&
+ this.prefixLength == linkAddress.prefixLength;
+ }
+
+ @Override
+ /*
+ * generate hashcode based on significant fields
+ */
+ public int hashCode() {
+ return ((null == address) ? 0 : address.hashCode()) + prefixLength;
+ }
+
+ /**
+ * Returns the InetAddress for this address.
+ */
+ public InetAddress getAddress() {
+ return address;
+ }
+
+ /**
+ * Get network prefix length
+ */
+ public int getNetworkPrefixLength() {
+ return prefixLength;
+ }
+
+ /**
+ * Implement the Parcelable interface
+ *
+ * @hide
+ */
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Implement the Parcelable interface.
+ *
+ * @hide
+ */
+ public void writeToParcel(Parcel dest, int flags) {
+ if (address != null) {
+ dest.writeByte((byte) 1);
+ dest.writeByteArray(address.getAddress());
+ dest.writeInt(prefixLength);
+ } else {
+ dest.writeByte((byte) 0);
+ }
+ }
+
+ /**
+ * Implement the Parcelable interface.
+ *
+ * @hide
+ */
+ public static final Creator CREATOR =
+ new Creator() {
+ public LinkAddress createFromParcel(Parcel in) {
+ InetAddress address = null;
+ int prefixLength = 0;
+ if (in.readByte() == 1) {
+ try {
+ address = InetAddress.getByAddress(in.createByteArray());
+ prefixLength = in.readInt();
+ } catch (UnknownHostException e) {
+ }
+ }
+ return new LinkAddress(address, prefixLength);
+ }
+
+ public LinkAddress[] newArray(int size) {
+ return new LinkAddress[size];
+ }
+ };
+}
diff --git a/android-smsmms/src/main/java/android/net/LinkCapabilities.java b/android-smsmms/src/main/java/android/net/LinkCapabilities.java
index 1c8be5c64..7c30373f4 100755
--- a/android-smsmms/src/main/java/android/net/LinkCapabilities.java
+++ b/android-smsmms/src/main/java/android/net/LinkCapabilities.java
@@ -1,392 +1,392 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package android.net;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import timber.log.Timber;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * A class representing the capabilities of a link
- *
- * @hide
- */
-public class LinkCapabilities implements Parcelable {
- private static final boolean DBG = false;
-
- /**
- * The Map of Keys to Values
- */
- private HashMap mCapabilities;
-
-
- /**
- * The set of keys defined for a links capabilities.
- *
- * Keys starting with RW are read + write, i.e. the application
- * can request for a certain requirement corresponding to that key.
- * Keys starting with RO are read only, i.e. the the application
- * can read the value of that key from the socket but cannot request
- * a corresponding requirement.
- *
- * TODO: Provide a documentation technique for concisely and precisely
- * define the syntax for each value string associated with a key.
- */
- public static final class Key {
- /**
- * No constructor
- */
- private Key() {
- }
-
- /**
- * An integer representing the network type.
- *
- * @see ConnectivityManager
- */
- public final static int RO_NETWORK_TYPE = 1;
-
- /**
- * Desired minimum forward link (download) bandwidth for the
- * in kilobits per second (kbps). Values should be strings such
- * "50", "100", "1500", etc.
- */
- public final static int RW_DESIRED_FWD_BW = 2;
-
- /**
- * Required minimum forward link (download) bandwidth, in
- * per second (kbps), below which the socket cannot function.
- * Values should be strings such as "50", "100", "1500", etc.
- */
- public final static int RW_REQUIRED_FWD_BW = 3;
-
- /**
- * Available forward link (download) bandwidth for the socket.
- * This value is in kilobits per second (kbps).
- * Values will be strings such as "50", "100", "1500", etc.
- */
- public final static int RO_AVAILABLE_FWD_BW = 4;
-
- /**
- * Desired minimum reverse link (upload) bandwidth for the socket
- * in kilobits per second (kbps).
- * Values should be strings such as "50", "100", "1500", etc.
- *
- * This key is set via the needs map.
- */
- public final static int RW_DESIRED_REV_BW = 5;
-
- /**
- * Required minimum reverse link (upload) bandwidth, in kilobits
- * per second (kbps), below which the socket cannot function.
- * If a rate is not specified, the default rate of kbps will be
- * Values should be strings such as "50", "100", "1500", etc.
- */
- public final static int RW_REQUIRED_REV_BW = 6;
-
- /**
- * Available reverse link (upload) bandwidth for the socket.
- * This value is in kilobits per second (kbps).
- * Values will be strings such as "50", "100", "1500", etc.
- */
- public final static int RO_AVAILABLE_REV_BW = 7;
-
- /**
- * Maximum latency for the socket, in milliseconds, above which
- * socket cannot function.
- * Values should be strings such as "50", "300", "500", etc.
- */
- public final static int RW_MAX_ALLOWED_LATENCY = 8;
-
- /**
- * Interface that the socket is bound to. This can be a virtual
- * interface (e.g. VPN or Mobile IP) or a physical interface
- * (e.g. wlan0 or rmnet0).
- * Values will be strings such as "wlan0", "rmnet0"
- */
- public final static int RO_BOUND_INTERFACE = 9;
-
- /**
- * Physical interface that the socket is routed on.
- * This can be different from BOUND_INTERFACE in cases such as
- * VPN or Mobile IP. The physical interface may change over time
- * if seamless mobility is supported.
- * Values will be strings such as "wlan0", "rmnet0"
- */
- public final static int RO_PHYSICAL_INTERFACE = 10;
- }
-
- /**
- * Role informs the LinkSocket about the data usage patterns of your
- * application.
- *
- * {@code Role.DEFAULT} is the default role, and is used whenever
- * a role isn't set.
- */
- public static final class Role {
- /**
- * No constructor
- */
- private Role() {
- }
-
- // examples only, discuss which roles should be defined, and then
- // code these to match
-
- /**
- * Default Role
- */
- public static final String DEFAULT = "default";
- /**
- * Bulk down load
- */
- public static final String BULK_DOWNLOAD = "bulk.download";
- /**
- * Bulk upload
- */
- public static final String BULK_UPLOAD = "bulk.upload";
-
- /**
- * VoIP Application at 24kbps
- */
- public static final String VOIP_24KBPS = "voip.24k";
- /**
- * VoIP Application at 32kbps
- */
- public static final String VOIP_32KBPS = "voip.32k";
-
- /**
- * Video Streaming at 480p
- */
- public static final String VIDEO_STREAMING_480P = "video.streaming.480p";
- /**
- * Video Streaming at 720p
- */
- public static final String VIDEO_STREAMING_720I = "video.streaming.720i";
-
- /**
- * Video Chat Application at 360p
- */
- public static final String VIDEO_CHAT_360P = "video.chat.360p";
- /**
- * Video Chat Application at 480p
- */
- public static final String VIDEO_CHAT_480P = "video.chat.480i";
- }
-
- /**
- * Constructor
- */
- public LinkCapabilities() {
- mCapabilities = new HashMap();
- }
-
- /**
- * Copy constructor.
- *
- * @param source
- */
- public LinkCapabilities(LinkCapabilities source) {
- if (source != null) {
- mCapabilities = new HashMap(source.mCapabilities);
- } else {
- mCapabilities = new HashMap();
- }
- }
-
- /**
- * Create the {@code LinkCapabilities} with values depending on role type.
- *
- * @param applicationRole a {@code LinkSocket.Role}
- * @return the {@code LinkCapabilities} associated with the applicationRole, empty if none
- */
- public static LinkCapabilities createNeedsMap(String applicationRole) {
- if (DBG) log("createNeededCapabilities(applicationRole) EX");
- return new LinkCapabilities();
- }
-
- /**
- * Remove all capabilities
- */
- public void clear() {
- mCapabilities.clear();
- }
-
- /**
- * Returns whether this map is empty.
- */
- public boolean isEmpty() {
- return mCapabilities.isEmpty();
- }
-
- /**
- * Returns the number of elements in this map.
- *
- * @return the number of elements in this map.
- */
- public int size() {
- return mCapabilities.size();
- }
-
- /**
- * Given the key return the capability string
- *
- * @param key
- * @return the capability string
- */
- public String get(int key) {
- return mCapabilities.get(key);
- }
-
- /**
- * Store the key/value capability pair
- *
- * @param key
- * @param value
- */
- public void put(int key, String value) {
- mCapabilities.put(key, value);
- }
-
- /**
- * Returns whether this map contains the specified key.
- *
- * @param key to search for.
- * @return {@code true} if this map contains the specified key,
- * {@code false} otherwise.
- */
- public boolean containsKey(int key) {
- return mCapabilities.containsKey(key);
- }
-
- /**
- * Returns whether this map contains the specified value.
- *
- * @param value to search for.
- * @return {@code true} if this map contains the specified value,
- * {@code false} otherwise.
- */
- public boolean containsValue(String value) {
- return mCapabilities.containsValue(value);
- }
-
- /**
- * Returns a set containing all of the mappings in this map. Each mapping is
- * an instance of {@link Map.Entry}. As the set is backed by this map,
- * changes in one will be reflected in the other.
- *
- * @return a set of the mappings.
- */
- public Set> entrySet() {
- return mCapabilities.entrySet();
- }
-
- /**
- * @return the set of the keys.
- */
- public Set keySet() {
- return mCapabilities.keySet();
- }
-
- /**
- * @return the set of values
- */
- public Collection values() {
- return mCapabilities.values();
- }
-
- /**
- * Implement the Parcelable interface
- *
- * @hide
- */
- public int describeContents() {
- return 0;
- }
-
- /**
- * Convert to string for debugging
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("{");
- boolean firstTime = true;
- for (Entry entry : mCapabilities.entrySet()) {
- if (firstTime) {
- firstTime = false;
- } else {
- sb.append(",");
- }
- sb.append(entry.getKey());
- sb.append(":\"");
- sb.append(entry.getValue());
- sb.append("\"");
- return mCapabilities.toString();
- }
- return sb.toString();
- }
-
- /**
- * Implement the Parcelable interface.
- *
- * @hide
- */
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mCapabilities.size());
- for (Entry entry : mCapabilities.entrySet()) {
- dest.writeInt(entry.getKey().intValue());
- dest.writeString(entry.getValue());
- }
- }
-
- /**
- * Implement the Parcelable interface.
- *
- * @hide
- */
- public static final Creator CREATOR =
- new Creator() {
- public LinkCapabilities createFromParcel(Parcel in) {
- LinkCapabilities capabilities = new LinkCapabilities();
- int size = in.readInt();
- while (size-- != 0) {
- int key = in.readInt();
- String value = in.readString();
- capabilities.mCapabilities.put(key, value);
- }
- return capabilities;
- }
-
- public LinkCapabilities[] newArray(int size) {
- return new LinkCapabilities[size];
- }
- };
-
- /**
- * Debug logging
- */
- protected static void log(String s) {
- Timber.d(s);
- }
-}
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.net;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import timber.log.Timber;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * A class representing the capabilities of a link
+ *
+ * @hide
+ */
+public class LinkCapabilities implements Parcelable {
+ private static final boolean DBG = false;
+
+ /**
+ * The Map of Keys to Values
+ */
+ private HashMap mCapabilities;
+
+
+ /**
+ * The set of keys defined for a links capabilities.
+ *
+ * Keys starting with RW are read + write, i.e. the application
+ * can request for a certain requirement corresponding to that key.
+ * Keys starting with RO are read only, i.e. the the application
+ * can read the value of that key from the socket but cannot request
+ * a corresponding requirement.
+ *
+ * TODO: Provide a documentation technique for concisely and precisely
+ * define the syntax for each value string associated with a key.
+ */
+ public static final class Key {
+ /**
+ * No constructor
+ */
+ private Key() {
+ }
+
+ /**
+ * An integer representing the network type.
+ *
+ * @see ConnectivityManager
+ */
+ public final static int RO_NETWORK_TYPE = 1;
+
+ /**
+ * Desired minimum forward link (download) bandwidth for the
+ * in kilobits per second (kbps). Values should be strings such
+ * "50", "100", "1500", etc.
+ */
+ public final static int RW_DESIRED_FWD_BW = 2;
+
+ /**
+ * Required minimum forward link (download) bandwidth, in
+ * per second (kbps), below which the socket cannot function.
+ * Values should be strings such as "50", "100", "1500", etc.
+ */
+ public final static int RW_REQUIRED_FWD_BW = 3;
+
+ /**
+ * Available forward link (download) bandwidth for the socket.
+ * This value is in kilobits per second (kbps).
+ * Values will be strings such as "50", "100", "1500", etc.
+ */
+ public final static int RO_AVAILABLE_FWD_BW = 4;
+
+ /**
+ * Desired minimum reverse link (upload) bandwidth for the socket
+ * in kilobits per second (kbps).
+ * Values should be strings such as "50", "100", "1500", etc.
+ *
+ * This key is set via the needs map.
+ */
+ public final static int RW_DESIRED_REV_BW = 5;
+
+ /**
+ * Required minimum reverse link (upload) bandwidth, in kilobits
+ * per second (kbps), below which the socket cannot function.
+ * If a rate is not specified, the default rate of kbps will be
+ * Values should be strings such as "50", "100", "1500", etc.
+ */
+ public final static int RW_REQUIRED_REV_BW = 6;
+
+ /**
+ * Available reverse link (upload) bandwidth for the socket.
+ * This value is in kilobits per second (kbps).
+ * Values will be strings such as "50", "100", "1500", etc.
+ */
+ public final static int RO_AVAILABLE_REV_BW = 7;
+
+ /**
+ * Maximum latency for the socket, in milliseconds, above which
+ * socket cannot function.
+ * Values should be strings such as "50", "300", "500", etc.
+ */
+ public final static int RW_MAX_ALLOWED_LATENCY = 8;
+
+ /**
+ * Interface that the socket is bound to. This can be a virtual
+ * interface (e.g. VPN or Mobile IP) or a physical interface
+ * (e.g. wlan0 or rmnet0).
+ * Values will be strings such as "wlan0", "rmnet0"
+ */
+ public final static int RO_BOUND_INTERFACE = 9;
+
+ /**
+ * Physical interface that the socket is routed on.
+ * This can be different from BOUND_INTERFACE in cases such as
+ * VPN or Mobile IP. The physical interface may change over time
+ * if seamless mobility is supported.
+ * Values will be strings such as "wlan0", "rmnet0"
+ */
+ public final static int RO_PHYSICAL_INTERFACE = 10;
+ }
+
+ /**
+ * Role informs the LinkSocket about the data usage patterns of your
+ * application.
+ *
+ * {@code Role.DEFAULT} is the default role, and is used whenever
+ * a role isn't set.
+ */
+ public static final class Role {
+ /**
+ * No constructor
+ */
+ private Role() {
+ }
+
+ // examples only, discuss which roles should be defined, and then
+ // code these to match
+
+ /**
+ * Default Role
+ */
+ public static final String DEFAULT = "default";
+ /**
+ * Bulk down load
+ */
+ public static final String BULK_DOWNLOAD = "bulk.download";
+ /**
+ * Bulk upload
+ */
+ public static final String BULK_UPLOAD = "bulk.upload";
+
+ /**
+ * VoIP Application at 24kbps
+ */
+ public static final String VOIP_24KBPS = "voip.24k";
+ /**
+ * VoIP Application at 32kbps
+ */
+ public static final String VOIP_32KBPS = "voip.32k";
+
+ /**
+ * Video Streaming at 480p
+ */
+ public static final String VIDEO_STREAMING_480P = "video.streaming.480p";
+ /**
+ * Video Streaming at 720p
+ */
+ public static final String VIDEO_STREAMING_720I = "video.streaming.720i";
+
+ /**
+ * Video Chat Application at 360p
+ */
+ public static final String VIDEO_CHAT_360P = "video.chat.360p";
+ /**
+ * Video Chat Application at 480p
+ */
+ public static final String VIDEO_CHAT_480P = "video.chat.480i";
+ }
+
+ /**
+ * Constructor
+ */
+ public LinkCapabilities() {
+ mCapabilities = new HashMap();
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param source
+ */
+ public LinkCapabilities(LinkCapabilities source) {
+ if (source != null) {
+ mCapabilities = new HashMap(source.mCapabilities);
+ } else {
+ mCapabilities = new HashMap();
+ }
+ }
+
+ /**
+ * Create the {@code LinkCapabilities} with values depending on role type.
+ *
+ * @param applicationRole a {@code LinkSocket.Role}
+ * @return the {@code LinkCapabilities} associated with the applicationRole, empty if none
+ */
+ public static LinkCapabilities createNeedsMap(String applicationRole) {
+ if (DBG) log("createNeededCapabilities(applicationRole) EX");
+ return new LinkCapabilities();
+ }
+
+ /**
+ * Remove all capabilities
+ */
+ public void clear() {
+ mCapabilities.clear();
+ }
+
+ /**
+ * Returns whether this map is empty.
+ */
+ public boolean isEmpty() {
+ return mCapabilities.isEmpty();
+ }
+
+ /**
+ * Returns the number of elements in this map.
+ *
+ * @return the number of elements in this map.
+ */
+ public int size() {
+ return mCapabilities.size();
+ }
+
+ /**
+ * Given the key return the capability string
+ *
+ * @param key
+ * @return the capability string
+ */
+ public String get(int key) {
+ return mCapabilities.get(key);
+ }
+
+ /**
+ * Store the key/value capability pair
+ *
+ * @param key
+ * @param value
+ */
+ public void put(int key, String value) {
+ mCapabilities.put(key, value);
+ }
+
+ /**
+ * Returns whether this map contains the specified key.
+ *
+ * @param key to search for.
+ * @return {@code true} if this map contains the specified key,
+ * {@code false} otherwise.
+ */
+ public boolean containsKey(int key) {
+ return mCapabilities.containsKey(key);
+ }
+
+ /**
+ * Returns whether this map contains the specified value.
+ *
+ * @param value to search for.
+ * @return {@code true} if this map contains the specified value,
+ * {@code false} otherwise.
+ */
+ public boolean containsValue(String value) {
+ return mCapabilities.containsValue(value);
+ }
+
+ /**
+ * Returns a set containing all of the mappings in this map. Each mapping is
+ * an instance of {@link Map.Entry}. As the set is backed by this map,
+ * changes in one will be reflected in the other.
+ *
+ * @return a set of the mappings.
+ */
+ public Set> entrySet() {
+ return mCapabilities.entrySet();
+ }
+
+ /**
+ * @return the set of the keys.
+ */
+ public Set keySet() {
+ return mCapabilities.keySet();
+ }
+
+ /**
+ * @return the set of values
+ */
+ public Collection values() {
+ return mCapabilities.values();
+ }
+
+ /**
+ * Implement the Parcelable interface
+ *
+ * @hide
+ */
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Convert to string for debugging
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ boolean firstTime = true;
+ for (Entry entry : mCapabilities.entrySet()) {
+ if (firstTime) {
+ firstTime = false;
+ } else {
+ sb.append(",");
+ }
+ sb.append(entry.getKey());
+ sb.append(":\"");
+ sb.append(entry.getValue());
+ sb.append("\"");
+ return mCapabilities.toString();
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Implement the Parcelable interface.
+ *
+ * @hide
+ */
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mCapabilities.size());
+ for (Entry entry : mCapabilities.entrySet()) {
+ dest.writeInt(entry.getKey().intValue());
+ dest.writeString(entry.getValue());
+ }
+ }
+
+ /**
+ * Implement the Parcelable interface.
+ *
+ * @hide
+ */
+ public static final Creator CREATOR =
+ new Creator() {
+ public LinkCapabilities createFromParcel(Parcel in) {
+ LinkCapabilities capabilities = new LinkCapabilities();
+ int size = in.readInt();
+ while (size-- != 0) {
+ int key = in.readInt();
+ String value = in.readString();
+ capabilities.mCapabilities.put(key, value);
+ }
+ return capabilities;
+ }
+
+ public LinkCapabilities[] newArray(int size) {
+ return new LinkCapabilities[size];
+ }
+ };
+
+ /**
+ * Debug logging
+ */
+ protected static void log(String s) {
+ Timber.d(s);
+ }
+}
diff --git a/android-smsmms/src/main/java/android/net/LinkProperties.java b/android-smsmms/src/main/java/android/net/LinkProperties.java
index d00be14db..662fe3567 100755
--- a/android-smsmms/src/main/java/android/net/LinkProperties.java
+++ b/android-smsmms/src/main/java/android/net/LinkProperties.java
@@ -1,441 +1,441 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package android.net;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.TextUtils;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Describes the properties of a network link.
- *
- * A link represents a connection to a network.
- * It may have multiple addresses and multiple gateways,
- * multiple dns servers but only one http proxy.
- *
- * Because it's a single network, the dns's
- * are interchangeable and don't need associating with
- * particular addresses. The gateways similarly don't
- * need associating with particular addresses.
- *
- * A dual stack interface works fine in this model:
- * each address has it's own prefix length to describe
- * the local network. The dns servers all return
- * both v4 addresses and v6 addresses regardless of the
- * address family of the server itself (rfc4213) and we
- * don't care which is used. The gateways will be
- * selected based on the destination address and the
- * source address has no relavence.
- *
- * @hide
- */
-public class LinkProperties implements Parcelable {
-
- String mIfaceName;
- private Collection mLinkAddresses = new ArrayList();
- private Collection mDnses = new ArrayList();
- private Collection mRoutes = new ArrayList();
- private ProxyProperties mHttpProxy;
-
- public static class CompareResult {
- public Collection removed = new ArrayList();
- public Collection added = new ArrayList();
-
- @Override
- public String toString() {
- String retVal = "removed=[";
- for (T addr : removed) retVal += addr.toString() + ",";
- retVal += "] added=[";
- for (T addr : added) retVal += addr.toString() + ",";
- retVal += "]";
- return retVal;
- }
- }
-
- public LinkProperties() {
- clear();
- }
-
- // copy constructor instead of clone
- public LinkProperties(LinkProperties source) {
- if (source != null) {
- mIfaceName = source.getInterfaceName();
- for (LinkAddress l : source.getLinkAddresses()) mLinkAddresses.add(l);
- for (InetAddress i : source.getDnses()) mDnses.add(i);
- for (RouteInfo r : source.getRoutes()) mRoutes.add(r);
- mHttpProxy = (source.getHttpProxy() == null) ?
- null : new ProxyProperties(source.getHttpProxy());
- }
- }
-
- public void setInterfaceName(String iface) {
- mIfaceName = iface;
- }
-
- public String getInterfaceName() {
- return mIfaceName;
- }
-
- public Collection getAddresses() {
- Collection addresses = new ArrayList();
- for (LinkAddress linkAddress : mLinkAddresses) {
- addresses.add(linkAddress.getAddress());
- }
- return Collections.unmodifiableCollection(addresses);
- }
-
- public void addLinkAddress(LinkAddress address) {
- if (address != null) mLinkAddresses.add(address);
- }
-
- public Collection getLinkAddresses() {
- return Collections.unmodifiableCollection(mLinkAddresses);
- }
-
- public void addDns(InetAddress dns) {
- if (dns != null) mDnses.add(dns);
- }
-
- public Collection getDnses() {
- return Collections.unmodifiableCollection(mDnses);
- }
-
- public void addRoute(RouteInfo route) {
- if (route != null) mRoutes.add(route);
- }
-
- public Collection getRoutes() {
- return Collections.unmodifiableCollection(mRoutes);
- }
-
- public void setHttpProxy(ProxyProperties proxy) {
- mHttpProxy = proxy;
- }
-
- public ProxyProperties getHttpProxy() {
- return mHttpProxy;
- }
-
- public void clear() {
- mIfaceName = null;
- mLinkAddresses.clear();
- mDnses.clear();
- mRoutes.clear();
- mHttpProxy = null;
- }
-
- /**
- * Implement the Parcelable interface
- *
- * @hide
- */
- public int describeContents() {
- return 0;
- }
-
- @Override
- public String toString() {
- String ifaceName = (mIfaceName == null ? "" : "InterfaceName: " + mIfaceName + " ");
-
- String linkAddresses = "LinkAddresses: [";
- for (LinkAddress addr : mLinkAddresses) linkAddresses += addr.toString() + ",";
- linkAddresses += "] ";
-
- String dns = "DnsAddresses: [";
- for (InetAddress addr : mDnses) dns += addr.getHostAddress() + ",";
- dns += "] ";
-
- String routes = "Routes: [";
- for (RouteInfo route : mRoutes) routes += route.toString() + ",";
- routes += "] ";
- String proxy = (mHttpProxy == null ? "" : "HttpProxy: " + mHttpProxy.toString() + " ");
-
- return ifaceName + linkAddresses + routes + dns + proxy;
- }
-
- /**
- * Compares this {@code LinkProperties} interface name against the target
- *
- * @param target LinkProperties to compare.
- * @return {@code true} if both are identical, {@code false} otherwise.
- */
- public boolean isIdenticalInterfaceName(LinkProperties target) {
- return TextUtils.equals(getInterfaceName(), target.getInterfaceName());
- }
-
- /**
- * Compares this {@code LinkProperties} interface name against the target
- *
- * @param target LinkProperties to compare.
- * @return {@code true} if both are identical, {@code false} otherwise.
- */
- public boolean isIdenticalAddresses(LinkProperties target) {
- Collection targetAddresses = target.getAddresses();
- Collection sourceAddresses = getAddresses();
- return (sourceAddresses.size() == targetAddresses.size()) ?
- sourceAddresses.containsAll(targetAddresses) : false;
- }
-
- /**
- * Compares this {@code LinkProperties} DNS addresses against the target
- *
- * @param target LinkProperties to compare.
- * @return {@code true} if both are identical, {@code false} otherwise.
- */
- public boolean isIdenticalDnses(LinkProperties target) {
- Collection targetDnses = target.getDnses();
- return (mDnses.size() == targetDnses.size()) ?
- mDnses.containsAll(targetDnses) : false;
- }
-
- /**
- * Compares this {@code LinkProperties} Routes against the target
- *
- * @param target LinkProperties to compare.
- * @return {@code true} if both are identical, {@code false} otherwise.
- */
- public boolean isIdenticalRoutes(LinkProperties target) {
- Collection targetRoutes = target.getRoutes();
- return (mRoutes.size() == targetRoutes.size()) ?
- mRoutes.containsAll(targetRoutes) : false;
- }
-
- /**
- * Compares this {@code LinkProperties} HttpProxy against the target
- *
- * @param target LinkProperties to compare.
- * @return {@code true} if both are identical, {@code false} otherwise.
- */
- public boolean isIdenticalHttpProxy(LinkProperties target) {
- return getHttpProxy() == null ? target.getHttpProxy() == null :
- getHttpProxy().equals(target.getHttpProxy());
- }
-
- @Override
- /**
- * Compares this {@code LinkProperties} instance against the target
- * LinkProperties in {@code obj}. Two LinkPropertieses are equal if
- * all their fields are equal in values.
- *
- * For collection fields, such as mDnses, containsAll() is used to check
- * if two collections contains the same elements, independent of order.
- * There are two thoughts regarding containsAll()
- * 1. Duplicated elements. eg, (A, B, B) and (A, A, B) are equal.
- * 2. Worst case performance is O(n^2).
- *
- * @param obj the object to be tested for equality.
- * @return {@code true} if both objects are equal, {@code false} otherwise.
- */
- public boolean equals(Object obj) {
- if (this == obj) return true;
-
- if (!(obj instanceof LinkProperties)) return false;
-
- LinkProperties target = (LinkProperties) obj;
-
- return isIdenticalInterfaceName(target) &&
- isIdenticalAddresses(target) &&
- isIdenticalDnses(target) &&
- isIdenticalRoutes(target) &&
- isIdenticalHttpProxy(target);
- }
-
- /**
- * Return two lists, a list of addresses that would be removed from
- * mLinkAddresses and a list of addresses that would be added to
- * mLinkAddress which would then result in target and mLinkAddresses
- * being the same list.
- *
- * @param target is a LinkProperties with the new list of addresses
- * @return the removed and added lists.
- */
- public CompareResult compareAddresses(LinkProperties target) {
- /*
- * Duplicate the LinkAddresses into removed, we will be removing
- * address which are common between mLinkAddresses and target
- * leaving the addresses that are different. And address which
- * are in target but not in mLinkAddresses are placed in the
- * addedAddresses.
- */
- CompareResult result = new CompareResult();
- result.removed = new ArrayList(mLinkAddresses);
- result.added.clear();
- if (target != null) {
- for (LinkAddress newAddress : target.getLinkAddresses()) {
- if (!result.removed.remove(newAddress)) {
- result.added.add(newAddress);
- }
- }
- }
- return result;
- }
-
- /**
- * Return two lists, a list of dns addresses that would be removed from
- * mDnses and a list of addresses that would be added to
- * mDnses which would then result in target and mDnses
- * being the same list.
- *
- * @param target is a LinkProperties with the new list of dns addresses
- * @return the removed and added lists.
- */
- public CompareResult compareDnses(LinkProperties target) {
- /*
- * Duplicate the InetAddresses into removed, we will be removing
- * dns address which are common between mDnses and target
- * leaving the addresses that are different. And dns address which
- * are in target but not in mDnses are placed in the
- * addedAddresses.
- */
- CompareResult result = new CompareResult();
-
- result.removed = new ArrayList(mDnses);
- result.added.clear();
- if (target != null) {
- for (InetAddress newAddress : target.getDnses()) {
- if (!result.removed.remove(newAddress)) {
- result.added.add(newAddress);
- }
- }
- }
- return result;
- }
-
- /**
- * Return two lists, a list of routes that would be removed from
- * mRoutes and a list of routes that would be added to
- * mRoutes which would then result in target and mRoutes
- * being the same list.
- *
- * @param target is a LinkProperties with the new list of routes
- * @return the removed and added lists.
- */
- public CompareResult compareRoutes(LinkProperties target) {
- /*
- * Duplicate the RouteInfos into removed, we will be removing
- * routes which are common between mDnses and target
- * leaving the routes that are different. And route address which
- * are in target but not in mRoutes are placed in added.
- */
- CompareResult result = new CompareResult();
-
- result.removed = new ArrayList(mRoutes);
- result.added.clear();
- if (target != null) {
- for (RouteInfo r : target.getRoutes()) {
- if (!result.removed.remove(r)) {
- result.added.add(r);
- }
- }
- }
- return result;
- }
-
-
- @Override
- /**
- * generate hashcode based on significant fields
- * Equal objects must produce the same hash code, while unequal objects
- * may have the same hash codes.
- */
- public int hashCode() {
- return ((null == mIfaceName) ? 0 : mIfaceName.hashCode()
- + mLinkAddresses.size() * 31
- + mDnses.size() * 37
- + mRoutes.size() * 41
- + ((null == mHttpProxy) ? 0 : mHttpProxy.hashCode()));
- }
-
- /**
- * Implement the Parcelable interface.
- *
- * @hide
- */
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(getInterfaceName());
- dest.writeInt(mLinkAddresses.size());
- for (LinkAddress linkAddress : mLinkAddresses) {
- dest.writeParcelable(linkAddress, flags);
- }
-
- dest.writeInt(mDnses.size());
- for (InetAddress d : mDnses) {
- dest.writeByteArray(d.getAddress());
- }
-
- dest.writeInt(mRoutes.size());
- for (RouteInfo route : mRoutes) {
- dest.writeParcelable(route, flags);
- }
-
- if (mHttpProxy != null) {
- dest.writeByte((byte) 1);
- dest.writeParcelable(mHttpProxy, flags);
- } else {
- dest.writeByte((byte) 0);
- }
- }
-
- /**
- * Implement the Parcelable interface.
- *
- * @hide
- */
- public static final Creator CREATOR =
- new Creator() {
- public LinkProperties createFromParcel(Parcel in) {
- LinkProperties netProp = new LinkProperties();
- String iface = in.readString();
- if (iface != null) {
- try {
- netProp.setInterfaceName(iface);
- } catch (Exception e) {
- return null;
- }
- }
- int addressCount = in.readInt();
- for (int i = 0; i < addressCount; i++) {
- netProp.addLinkAddress((LinkAddress) in.readParcelable(null));
- }
- addressCount = in.readInt();
- for (int i = 0; i < addressCount; i++) {
- try {
- netProp.addDns(InetAddress.getByAddress(in.createByteArray()));
- } catch (UnknownHostException e) {
- }
- }
- addressCount = in.readInt();
- for (int i = 0; i < addressCount; i++) {
- netProp.addRoute((RouteInfo) in.readParcelable(null));
- }
- if (in.readByte() == 1) {
- netProp.setHttpProxy((ProxyProperties) in.readParcelable(null));
- }
- return netProp;
- }
-
- public LinkProperties[] newArray(int size) {
- return new LinkProperties[size];
- }
- };
-}
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.net;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextUtils;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Describes the properties of a network link.
+ *
+ * A link represents a connection to a network.
+ * It may have multiple addresses and multiple gateways,
+ * multiple dns servers but only one http proxy.
+ *
+ * Because it's a single network, the dns's
+ * are interchangeable and don't need associating with
+ * particular addresses. The gateways similarly don't
+ * need associating with particular addresses.
+ *
+ * A dual stack interface works fine in this model:
+ * each address has it's own prefix length to describe
+ * the local network. The dns servers all return
+ * both v4 addresses and v6 addresses regardless of the
+ * address family of the server itself (rfc4213) and we
+ * don't care which is used. The gateways will be
+ * selected based on the destination address and the
+ * source address has no relavence.
+ *
+ * @hide
+ */
+public class LinkProperties implements Parcelable {
+
+ String mIfaceName;
+ private Collection mLinkAddresses = new ArrayList();
+ private Collection mDnses = new ArrayList();
+ private Collection mRoutes = new ArrayList();
+ private ProxyProperties mHttpProxy;
+
+ public static class CompareResult {
+ public Collection removed = new ArrayList();
+ public Collection added = new ArrayList();
+
+ @Override
+ public String toString() {
+ String retVal = "removed=[";
+ for (T addr : removed) retVal += addr.toString() + ",";
+ retVal += "] added=[";
+ for (T addr : added) retVal += addr.toString() + ",";
+ retVal += "]";
+ return retVal;
+ }
+ }
+
+ public LinkProperties() {
+ clear();
+ }
+
+ // copy constructor instead of clone
+ public LinkProperties(LinkProperties source) {
+ if (source != null) {
+ mIfaceName = source.getInterfaceName();
+ for (LinkAddress l : source.getLinkAddresses()) mLinkAddresses.add(l);
+ for (InetAddress i : source.getDnses()) mDnses.add(i);
+ for (RouteInfo r : source.getRoutes()) mRoutes.add(r);
+ mHttpProxy = (source.getHttpProxy() == null) ?
+ null : new ProxyProperties(source.getHttpProxy());
+ }
+ }
+
+ public void setInterfaceName(String iface) {
+ mIfaceName = iface;
+ }
+
+ public String getInterfaceName() {
+ return mIfaceName;
+ }
+
+ public Collection getAddresses() {
+ Collection addresses = new ArrayList();
+ for (LinkAddress linkAddress : mLinkAddresses) {
+ addresses.add(linkAddress.getAddress());
+ }
+ return Collections.unmodifiableCollection(addresses);
+ }
+
+ public void addLinkAddress(LinkAddress address) {
+ if (address != null) mLinkAddresses.add(address);
+ }
+
+ public Collection getLinkAddresses() {
+ return Collections.unmodifiableCollection(mLinkAddresses);
+ }
+
+ public void addDns(InetAddress dns) {
+ if (dns != null) mDnses.add(dns);
+ }
+
+ public Collection getDnses() {
+ return Collections.unmodifiableCollection(mDnses);
+ }
+
+ public void addRoute(RouteInfo route) {
+ if (route != null) mRoutes.add(route);
+ }
+
+ public Collection getRoutes() {
+ return Collections.unmodifiableCollection(mRoutes);
+ }
+
+ public void setHttpProxy(ProxyProperties proxy) {
+ mHttpProxy = proxy;
+ }
+
+ public ProxyProperties getHttpProxy() {
+ return mHttpProxy;
+ }
+
+ public void clear() {
+ mIfaceName = null;
+ mLinkAddresses.clear();
+ mDnses.clear();
+ mRoutes.clear();
+ mHttpProxy = null;
+ }
+
+ /**
+ * Implement the Parcelable interface
+ *
+ * @hide
+ */
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ String ifaceName = (mIfaceName == null ? "" : "InterfaceName: " + mIfaceName + " ");
+
+ String linkAddresses = "LinkAddresses: [";
+ for (LinkAddress addr : mLinkAddresses) linkAddresses += addr.toString() + ",";
+ linkAddresses += "] ";
+
+ String dns = "DnsAddresses: [";
+ for (InetAddress addr : mDnses) dns += addr.getHostAddress() + ",";
+ dns += "] ";
+
+ String routes = "Routes: [";
+ for (RouteInfo route : mRoutes) routes += route.toString() + ",";
+ routes += "] ";
+ String proxy = (mHttpProxy == null ? "" : "HttpProxy: " + mHttpProxy.toString() + " ");
+
+ return ifaceName + linkAddresses + routes + dns + proxy;
+ }
+
+ /**
+ * Compares this {@code LinkProperties} interface name against the target
+ *
+ * @param target LinkProperties to compare.
+ * @return {@code true} if both are identical, {@code false} otherwise.
+ */
+ public boolean isIdenticalInterfaceName(LinkProperties target) {
+ return TextUtils.equals(getInterfaceName(), target.getInterfaceName());
+ }
+
+ /**
+ * Compares this {@code LinkProperties} interface name against the target
+ *
+ * @param target LinkProperties to compare.
+ * @return {@code true} if both are identical, {@code false} otherwise.
+ */
+ public boolean isIdenticalAddresses(LinkProperties target) {
+ Collection targetAddresses = target.getAddresses();
+ Collection sourceAddresses = getAddresses();
+ return (sourceAddresses.size() == targetAddresses.size()) ?
+ sourceAddresses.containsAll(targetAddresses) : false;
+ }
+
+ /**
+ * Compares this {@code LinkProperties} DNS addresses against the target
+ *
+ * @param target LinkProperties to compare.
+ * @return {@code true} if both are identical, {@code false} otherwise.
+ */
+ public boolean isIdenticalDnses(LinkProperties target) {
+ Collection targetDnses = target.getDnses();
+ return (mDnses.size() == targetDnses.size()) ?
+ mDnses.containsAll(targetDnses) : false;
+ }
+
+ /**
+ * Compares this {@code LinkProperties} Routes against the target
+ *
+ * @param target LinkProperties to compare.
+ * @return {@code true} if both are identical, {@code false} otherwise.
+ */
+ public boolean isIdenticalRoutes(LinkProperties target) {
+ Collection targetRoutes = target.getRoutes();
+ return (mRoutes.size() == targetRoutes.size()) ?
+ mRoutes.containsAll(targetRoutes) : false;
+ }
+
+ /**
+ * Compares this {@code LinkProperties} HttpProxy against the target
+ *
+ * @param target LinkProperties to compare.
+ * @return {@code true} if both are identical, {@code false} otherwise.
+ */
+ public boolean isIdenticalHttpProxy(LinkProperties target) {
+ return getHttpProxy() == null ? target.getHttpProxy() == null :
+ getHttpProxy().equals(target.getHttpProxy());
+ }
+
+ @Override
+ /**
+ * Compares this {@code LinkProperties} instance against the target
+ * LinkProperties in {@code obj}. Two LinkPropertieses are equal if
+ * all their fields are equal in values.
+ *
+ * For collection fields, such as mDnses, containsAll() is used to check
+ * if two collections contains the same elements, independent of order.
+ * There are two thoughts regarding containsAll()
+ * 1. Duplicated elements. eg, (A, B, B) and (A, A, B) are equal.
+ * 2. Worst case performance is O(n^2).
+ *
+ * @param obj the object to be tested for equality.
+ * @return {@code true} if both objects are equal, {@code false} otherwise.
+ */
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+
+ if (!(obj instanceof LinkProperties)) return false;
+
+ LinkProperties target = (LinkProperties) obj;
+
+ return isIdenticalInterfaceName(target) &&
+ isIdenticalAddresses(target) &&
+ isIdenticalDnses(target) &&
+ isIdenticalRoutes(target) &&
+ isIdenticalHttpProxy(target);
+ }
+
+ /**
+ * Return two lists, a list of addresses that would be removed from
+ * mLinkAddresses and a list of addresses that would be added to
+ * mLinkAddress which would then result in target and mLinkAddresses
+ * being the same list.
+ *
+ * @param target is a LinkProperties with the new list of addresses
+ * @return the removed and added lists.
+ */
+ public CompareResult compareAddresses(LinkProperties target) {
+ /*
+ * Duplicate the LinkAddresses into removed, we will be removing
+ * address which are common between mLinkAddresses and target
+ * leaving the addresses that are different. And address which
+ * are in target but not in mLinkAddresses are placed in the
+ * addedAddresses.
+ */
+ CompareResult result = new CompareResult();
+ result.removed = new ArrayList(mLinkAddresses);
+ result.added.clear();
+ if (target != null) {
+ for (LinkAddress newAddress : target.getLinkAddresses()) {
+ if (!result.removed.remove(newAddress)) {
+ result.added.add(newAddress);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return two lists, a list of dns addresses that would be removed from
+ * mDnses and a list of addresses that would be added to
+ * mDnses which would then result in target and mDnses
+ * being the same list.
+ *
+ * @param target is a LinkProperties with the new list of dns addresses
+ * @return the removed and added lists.
+ */
+ public CompareResult compareDnses(LinkProperties target) {
+ /*
+ * Duplicate the InetAddresses into removed, we will be removing
+ * dns address which are common between mDnses and target
+ * leaving the addresses that are different. And dns address which
+ * are in target but not in mDnses are placed in the
+ * addedAddresses.
+ */
+ CompareResult result = new CompareResult();
+
+ result.removed = new ArrayList(mDnses);
+ result.added.clear();
+ if (target != null) {
+ for (InetAddress newAddress : target.getDnses()) {
+ if (!result.removed.remove(newAddress)) {
+ result.added.add(newAddress);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return two lists, a list of routes that would be removed from
+ * mRoutes and a list of routes that would be added to
+ * mRoutes which would then result in target and mRoutes
+ * being the same list.
+ *
+ * @param target is a LinkProperties with the new list of routes
+ * @return the removed and added lists.
+ */
+ public CompareResult compareRoutes(LinkProperties target) {
+ /*
+ * Duplicate the RouteInfos into removed, we will be removing
+ * routes which are common between mDnses and target
+ * leaving the routes that are different. And route address which
+ * are in target but not in mRoutes are placed in added.
+ */
+ CompareResult result = new CompareResult();
+
+ result.removed = new ArrayList(mRoutes);
+ result.added.clear();
+ if (target != null) {
+ for (RouteInfo r : target.getRoutes()) {
+ if (!result.removed.remove(r)) {
+ result.added.add(r);
+ }
+ }
+ }
+ return result;
+ }
+
+
+ @Override
+ /**
+ * generate hashcode based on significant fields
+ * Equal objects must produce the same hash code, while unequal objects
+ * may have the same hash codes.
+ */
+ public int hashCode() {
+ return ((null == mIfaceName) ? 0 : mIfaceName.hashCode()
+ + mLinkAddresses.size() * 31
+ + mDnses.size() * 37
+ + mRoutes.size() * 41
+ + ((null == mHttpProxy) ? 0 : mHttpProxy.hashCode()));
+ }
+
+ /**
+ * Implement the Parcelable interface.
+ *
+ * @hide
+ */
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(getInterfaceName());
+ dest.writeInt(mLinkAddresses.size());
+ for (LinkAddress linkAddress : mLinkAddresses) {
+ dest.writeParcelable(linkAddress, flags);
+ }
+
+ dest.writeInt(mDnses.size());
+ for (InetAddress d : mDnses) {
+ dest.writeByteArray(d.getAddress());
+ }
+
+ dest.writeInt(mRoutes.size());
+ for (RouteInfo route : mRoutes) {
+ dest.writeParcelable(route, flags);
+ }
+
+ if (mHttpProxy != null) {
+ dest.writeByte((byte) 1);
+ dest.writeParcelable(mHttpProxy, flags);
+ } else {
+ dest.writeByte((byte) 0);
+ }
+ }
+
+ /**
+ * Implement the Parcelable interface.
+ *
+ * @hide
+ */
+ public static final Creator CREATOR =
+ new Creator() {
+ public LinkProperties createFromParcel(Parcel in) {
+ LinkProperties netProp = new LinkProperties();
+ String iface = in.readString();
+ if (iface != null) {
+ try {
+ netProp.setInterfaceName(iface);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ int addressCount = in.readInt();
+ for (int i = 0; i < addressCount; i++) {
+ netProp.addLinkAddress((LinkAddress) in.readParcelable(null));
+ }
+ addressCount = in.readInt();
+ for (int i = 0; i < addressCount; i++) {
+ try {
+ netProp.addDns(InetAddress.getByAddress(in.createByteArray()));
+ } catch (UnknownHostException e) {
+ }
+ }
+ addressCount = in.readInt();
+ for (int i = 0; i < addressCount; i++) {
+ netProp.addRoute((RouteInfo) in.readParcelable(null));
+ }
+ if (in.readByte() == 1) {
+ netProp.setHttpProxy((ProxyProperties) in.readParcelable(null));
+ }
+ return netProp;
+ }
+
+ public LinkProperties[] newArray(int size) {
+ return new LinkProperties[size];
+ }
+ };
+}
diff --git a/android-smsmms/src/main/java/android/net/NetworkQuotaInfo.java b/android-smsmms/src/main/java/android/net/NetworkQuotaInfo.java
index b67d41c7b..3666610f7 100755
--- a/android-smsmms/src/main/java/android/net/NetworkQuotaInfo.java
+++ b/android-smsmms/src/main/java/android/net/NetworkQuotaInfo.java
@@ -1,87 +1,87 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package android.net;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Information about quota status on a specific network.
- *
- * @hide
- */
-public class NetworkQuotaInfo implements Parcelable {
- private final long mEstimatedBytes;
- private final long mSoftLimitBytes;
- private final long mHardLimitBytes;
-
- public static final long NO_LIMIT = -1;
-
- /**
- * {@hide}
- */
- public NetworkQuotaInfo(long estimatedBytes, long softLimitBytes, long hardLimitBytes) {
- mEstimatedBytes = estimatedBytes;
- mSoftLimitBytes = softLimitBytes;
- mHardLimitBytes = hardLimitBytes;
- }
-
- /**
- * {@hide}
- */
- public NetworkQuotaInfo(Parcel in) {
- mEstimatedBytes = in.readLong();
- mSoftLimitBytes = in.readLong();
- mHardLimitBytes = in.readLong();
- }
-
- public long getEstimatedBytes() {
- return mEstimatedBytes;
- }
-
- public long getSoftLimitBytes() {
- return mSoftLimitBytes;
- }
-
- public long getHardLimitBytes() {
- return mHardLimitBytes;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeLong(mEstimatedBytes);
- out.writeLong(mSoftLimitBytes);
- out.writeLong(mHardLimitBytes);
- }
-
- public static final Creator CREATOR = new Creator() {
- @Override
- public NetworkQuotaInfo createFromParcel(Parcel in) {
- return new NetworkQuotaInfo(in);
- }
-
- @Override
- public NetworkQuotaInfo[] newArray(int size) {
- return new NetworkQuotaInfo[size];
- }
- };
-}
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package android.net;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Information about quota status on a specific network.
+ *
+ * @hide
+ */
+public class NetworkQuotaInfo implements Parcelable {
+ private final long mEstimatedBytes;
+ private final long mSoftLimitBytes;
+ private final long mHardLimitBytes;
+
+ public static final long NO_LIMIT = -1;
+
+ /**
+ * {@hide}
+ */
+ public NetworkQuotaInfo(long estimatedBytes, long softLimitBytes, long hardLimitBytes) {
+ mEstimatedBytes = estimatedBytes;
+ mSoftLimitBytes = softLimitBytes;
+ mHardLimitBytes = hardLimitBytes;
+ }
+
+ /**
+ * {@hide}
+ */
+ public NetworkQuotaInfo(Parcel in) {
+ mEstimatedBytes = in.readLong();
+ mSoftLimitBytes = in.readLong();
+ mHardLimitBytes = in.readLong();
+ }
+
+ public long getEstimatedBytes() {
+ return mEstimatedBytes;
+ }
+
+ public long getSoftLimitBytes() {
+ return mSoftLimitBytes;
+ }
+
+ public long getHardLimitBytes() {
+ return mHardLimitBytes;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeLong(mEstimatedBytes);
+ out.writeLong(mSoftLimitBytes);
+ out.writeLong(mHardLimitBytes);
+ }
+
+ public static final Creator CREATOR = new Creator() {
+ @Override
+ public NetworkQuotaInfo createFromParcel(Parcel in) {
+ return new NetworkQuotaInfo(in);
+ }
+
+ @Override
+ public NetworkQuotaInfo[] newArray(int size) {
+ return new NetworkQuotaInfo[size];
+ }
+ };
+}
diff --git a/android-smsmms/src/main/java/android/net/NetworkState.java b/android-smsmms/src/main/java/android/net/NetworkState.java
index 30f137010..aa4c4902a 100755
--- a/android-smsmms/src/main/java/android/net/NetworkState.java
+++ b/android-smsmms/src/main/java/android/net/NetworkState.java
@@ -1,86 +1,86 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package android.net;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Snapshot of network state.
- *
- * @hide
- */
-public class NetworkState implements Parcelable {
-
- public final NetworkInfo networkInfo;
- public final LinkProperties linkProperties;
- public final LinkCapabilities linkCapabilities;
- /**
- * Currently only used by testing.
- */
- public final String subscriberId;
- public final String networkId;
-
- public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
- LinkCapabilities linkCapabilities) {
- this(networkInfo, linkProperties, linkCapabilities, null, null);
- }
-
- public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
- LinkCapabilities linkCapabilities, String subscriberId, String networkId) {
- this.networkInfo = networkInfo;
- this.linkProperties = linkProperties;
- this.linkCapabilities = linkCapabilities;
- this.subscriberId = subscriberId;
- this.networkId = networkId;
- }
-
- public NetworkState(Parcel in) {
- networkInfo = in.readParcelable(null);
- linkProperties = in.readParcelable(null);
- linkCapabilities = in.readParcelable(null);
- subscriberId = in.readString();
- networkId = in.readString();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeParcelable(networkInfo, flags);
- out.writeParcelable(linkProperties, flags);
- out.writeParcelable(linkCapabilities, flags);
- out.writeString(subscriberId);
- out.writeString(networkId);
- }
-
- public static final Creator CREATOR = new Creator() {
- @Override
- public NetworkState createFromParcel(Parcel in) {
- return new NetworkState(in);
- }
-
- @Override
- public NetworkState[] newArray(int size) {
- return new NetworkState[size];
- }
- };
-
-}
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package android.net;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Snapshot of network state.
+ *
+ * @hide
+ */
+public class NetworkState implements Parcelable {
+
+ public final NetworkInfo networkInfo;
+ public final LinkProperties linkProperties;
+ public final LinkCapabilities linkCapabilities;
+ /**
+ * Currently only used by testing.
+ */
+ public final String subscriberId;
+ public final String networkId;
+
+ public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
+ LinkCapabilities linkCapabilities) {
+ this(networkInfo, linkProperties, linkCapabilities, null, null);
+ }
+
+ public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
+ LinkCapabilities linkCapabilities, String subscriberId, String networkId) {
+ this.networkInfo = networkInfo;
+ this.linkProperties = linkProperties;
+ this.linkCapabilities = linkCapabilities;
+ this.subscriberId = subscriberId;
+ this.networkId = networkId;
+ }
+
+ public NetworkState(Parcel in) {
+ networkInfo = in.readParcelable(null);
+ linkProperties = in.readParcelable(null);
+ linkCapabilities = in.readParcelable(null);
+ subscriberId = in.readString();
+ networkId = in.readString();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(networkInfo, flags);
+ out.writeParcelable(linkProperties, flags);
+ out.writeParcelable(linkCapabilities, flags);
+ out.writeString(subscriberId);
+ out.writeString(networkId);
+ }
+
+ public static final Creator CREATOR = new Creator() {
+ @Override
+ public NetworkState createFromParcel(Parcel in) {
+ return new NetworkState(in);
+ }
+
+ @Override
+ public NetworkState[] newArray(int size) {
+ return new NetworkState[size];
+ }
+ };
+
+}
diff --git a/android-smsmms/src/main/java/android/net/NetworkUtilsHelper.java b/android-smsmms/src/main/java/android/net/NetworkUtilsHelper.java
index 601f73571..0848b6ad2 100755
--- a/android-smsmms/src/main/java/android/net/NetworkUtilsHelper.java
+++ b/android-smsmms/src/main/java/android/net/NetworkUtilsHelper.java
@@ -1,304 +1,304 @@
-/*
- * Copyright (C) 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.
- * 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.
- */
-
-package android.net;
-
-import timber.log.Timber;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Collection;
-
-/**
- * Native methods for managing network interfaces.
- *
- * {@hide}
- */
-public class NetworkUtilsHelper {
-
- /**
- * Bring the named network interface up.
- */
- public native static int enableInterface(String interfaceName);
-
- /**
- * Bring the named network interface down.
- */
- public native static int disableInterface(String interfaceName);
-
- /**
- * Setting bit 0 indicates reseting of IPv4 addresses required
- */
- public static final int RESET_IPV4_ADDRESSES = 0x01;
-
- /**
- * Setting bit 1 indicates reseting of IPv4 addresses required
- */
- public static final int RESET_IPV6_ADDRESSES = 0x02;
-
- /**
- * Reset all addresses
- */
- public static final int RESET_ALL_ADDRESSES = RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES;
-
- /**
- * Reset IPv6 or IPv4 sockets that are connected via the named interface.
- *
- * @param interfaceName is the interface to reset
- * @param mask {@see #RESET_IPV4_ADDRESSES} and {@see #RESET_IPV6_ADDRESSES}
- */
- public native static int resetConnections(String interfaceName, int mask);
-
- /**
- * Start the DHCP client daemon, in order to have it request addresses
- * for the named interface, and then configure the interface with those
- * addresses. This call blocks until it obtains a result (either success
- * or failure) from the daemon.
- *
- * @param interfaceName the name of the interface to configure
- * @param ipInfo if the request succeeds, this object is filled in with
- * the IP address information.
- * @return {@code true} for success, {@code false} for failure
- */
- public native static boolean runDhcp(String interfaceName, DhcpInfoInternal ipInfo);
-
- /**
- * Initiate renewal on the Dhcp client daemon. This call blocks until it obtains
- * a result (either success or failure) from the daemon.
- *
- * @param interfaceName the name of the interface to configure
- * @param ipInfo if the request succeeds, this object is filled in with
- * the IP address information.
- * @return {@code true} for success, {@code false} for failure
- */
- public native static boolean runDhcpRenew(String interfaceName, DhcpInfoInternal ipInfo);
-
- /**
- * Shut down the DHCP client daemon.
- *
- * @param interfaceName the name of the interface for which the daemon
- * should be stopped
- * @return {@code true} for success, {@code false} for failure
- */
- public native static boolean stopDhcp(String interfaceName);
-
- /**
- * Release the current DHCP lease.
- *
- * @param interfaceName the name of the interface for which the lease should
- * be released
- * @return {@code true} for success, {@code false} for failure
- */
- public native static boolean releaseDhcpLease(String interfaceName);
-
- /**
- * Return the last DHCP-related error message that was recorded.
- * NOTE: This string is not localized, but currently it is only
- * used in logging.
- *
- * @return the most recent error message, if any
- */
- public native static String getDhcpError();
-
- /**
- * Convert a IPv4 address from an integer to an InetAddress.
- *
- * @param hostAddress an int corresponding to the IPv4 address in network byte order
- */
- public static InetAddress intToInetAddress(int hostAddress) {
- byte[] addressBytes = {(byte) (0xff & hostAddress),
- (byte) (0xff & (hostAddress >> 8)),
- (byte) (0xff & (hostAddress >> 16)),
- (byte) (0xff & (hostAddress >> 24))};
-
- try {
- return InetAddress.getByAddress(addressBytes);
- } catch (UnknownHostException e) {
- throw new AssertionError();
- }
- }
-
- /**
- * Convert a IPv4 address from an InetAddress to an integer
- *
- * @param inetAddr is an InetAddress corresponding to the IPv4 address
- * @return the IP address as an integer in network byte order
- */
- public static int inetAddressToInt(InetAddress inetAddr)
- throws IllegalArgumentException {
- byte[] addr = inetAddr.getAddress();
- if (addr.length != 4) {
- throw new IllegalArgumentException("Not an IPv4 address");
- }
- return ((addr[3] & 0xff) << 24) | ((addr[2] & 0xff) << 16) |
- ((addr[1] & 0xff) << 8) | (addr[0] & 0xff);
- }
-
- /**
- * Convert a network prefix length to an IPv4 netmask integer
- *
- * @param prefixLength
- * @return the IPv4 netmask as an integer in network byte order
- */
- public static int prefixLengthToNetmaskInt(int prefixLength)
- throws IllegalArgumentException {
- if (prefixLength < 0 || prefixLength > 32) {
- throw new IllegalArgumentException("Invalid prefix length (0 <= prefix <= 32)");
- }
- int value = 0xffffffff << (32 - prefixLength);
- return Integer.reverseBytes(value);
- }
-
- /**
- * Convert a IPv4 netmask integer to a prefix length
- *
- * @param netmask as an integer in network byte order
- * @return the network prefix length
- */
- public static int netmaskIntToPrefixLength(int netmask) {
- return Integer.bitCount(netmask);
- }
-
- /**
- * Create an InetAddress from a string where the string must be a standard
- * representation of a V4 or V6 address. Avoids doing a DNS lookup on failure
- * but it will throw an IllegalArgumentException in that case.
- *
- * @param addrString
- * @return the InetAddress
- * @hide
- */
- public static InetAddress numericToInetAddress(String addrString)
- throws IllegalArgumentException {
- return null;
- }
-
- /**
- * Get InetAddress masked with prefixLength. Will never return null.
- *
- * @param IP address which will be masked with specified prefixLength
- * @param prefixLength the prefixLength used to mask the IP
- */
- public static InetAddress getNetworkPart(InetAddress address, int prefixLength) {
- if (address == null) {
- throw new RuntimeException("getNetworkPart doesn't accept null address");
- }
-
- byte[] array = address.getAddress();
-
- if (prefixLength < 0 || prefixLength > array.length * 8) {
- throw new RuntimeException("getNetworkPart - bad prefixLength");
- }
-
- int offset = prefixLength / 8;
- int reminder = prefixLength % 8;
- byte mask = (byte) (0xFF << (8 - reminder));
-
- if (offset < array.length) array[offset] = (byte) (array[offset] & mask);
-
- offset++;
-
- for (; offset < array.length; offset++) {
- array[offset] = 0;
- }
-
- InetAddress netPart = null;
- try {
- netPart = InetAddress.getByAddress(array);
- } catch (UnknownHostException e) {
- throw new RuntimeException("getNetworkPart error - " + e.toString());
- }
- return netPart;
- }
-
- /**
- * Check if IP address type is consistent between two InetAddress.
- *
- * @return true if both are the same type. False otherwise.
- */
- public static boolean addressTypeMatches(InetAddress left, InetAddress right) {
- return (((left instanceof Inet4Address) && (right instanceof Inet4Address)) ||
- ((left instanceof Inet6Address) && (right instanceof Inet6Address)));
- }
-
- /**
- * Convert a 32 char hex string into a Inet6Address.
- * throws a runtime exception if the string isn't 32 chars, isn't hex or can't be
- * made into an Inet6Address
- *
- * @param addrHexString a 32 character hex string representing an IPv6 addr
- * @return addr an InetAddress representation for the string
- */
- public static InetAddress hexToInet6Address(String addrHexString)
- throws IllegalArgumentException {
- try {
- return numericToInetAddress(String.format("%s:%s:%s:%s:%s:%s:%s:%s",
- addrHexString.substring(0, 4), addrHexString.substring(4, 8),
- addrHexString.substring(8, 12), addrHexString.substring(12, 16),
- addrHexString.substring(16, 20), addrHexString.substring(20, 24),
- addrHexString.substring(24, 28), addrHexString.substring(28, 32)));
- } catch (Exception e) {
- Timber.e("error in hexToInet6Address(" + addrHexString + "): " + e);
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Create a string array of host addresses from a collection of InetAddresses
- *
- * @param addrs a Collection of InetAddresses
- * @return an array of Strings containing their host addresses
- */
- public static String[] makeStrings(Collection addrs) {
- String[] result = new String[addrs.size()];
- int i = 0;
- for (InetAddress addr : addrs) {
- result[i++] = addr.getHostAddress();
- }
- return result;
- }
-
- /**
- * Trim leading zeros from IPv4 address strings
- * Our base libraries will interpret that as octel..
- * Must leave non v4 addresses and host names alone.
- * For example, 192.168.000.010 -> 192.168.0.10
- * TODO - fix base libraries and remove this function
- *
- * @param addr a string representing an ip addr
- * @return a string propertly trimmed
- */
- public static String trimV4AddrZeros(String addr) {
- if (addr == null) return null;
- String[] octets = addr.split("\\.");
- if (octets.length != 4) return addr;
- StringBuilder builder = new StringBuilder(16);
- String result = null;
- for (int i = 0; i < 4; i++) {
- try {
- if (octets[i].length() > 3) return addr;
- builder.append(Integer.parseInt(octets[i]));
- } catch (NumberFormatException e) {
- return addr;
- }
- if (i < 3) builder.append('.');
- }
- result = builder.toString();
- return result;
- }
-}
+/*
+ * Copyright (C) 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.
+ * 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.
+ */
+
+package android.net;
+
+import timber.log.Timber;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+
+/**
+ * Native methods for managing network interfaces.
+ *
+ * {@hide}
+ */
+public class NetworkUtilsHelper {
+
+ /**
+ * Bring the named network interface up.
+ */
+ public native static int enableInterface(String interfaceName);
+
+ /**
+ * Bring the named network interface down.
+ */
+ public native static int disableInterface(String interfaceName);
+
+ /**
+ * Setting bit 0 indicates reseting of IPv4 addresses required
+ */
+ public static final int RESET_IPV4_ADDRESSES = 0x01;
+
+ /**
+ * Setting bit 1 indicates reseting of IPv4 addresses required
+ */
+ public static final int RESET_IPV6_ADDRESSES = 0x02;
+
+ /**
+ * Reset all addresses
+ */
+ public static final int RESET_ALL_ADDRESSES = RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES;
+
+ /**
+ * Reset IPv6 or IPv4 sockets that are connected via the named interface.
+ *
+ * @param interfaceName is the interface to reset
+ * @param mask {@see #RESET_IPV4_ADDRESSES} and {@see #RESET_IPV6_ADDRESSES}
+ */
+ public native static int resetConnections(String interfaceName, int mask);
+
+ /**
+ * Start the DHCP client daemon, in order to have it request addresses
+ * for the named interface, and then configure the interface with those
+ * addresses. This call blocks until it obtains a result (either success
+ * or failure) from the daemon.
+ *
+ * @param interfaceName the name of the interface to configure
+ * @param ipInfo if the request succeeds, this object is filled in with
+ * the IP address information.
+ * @return {@code true} for success, {@code false} for failure
+ */
+ public native static boolean runDhcp(String interfaceName, DhcpInfoInternal ipInfo);
+
+ /**
+ * Initiate renewal on the Dhcp client daemon. This call blocks until it obtains
+ * a result (either success or failure) from the daemon.
+ *
+ * @param interfaceName the name of the interface to configure
+ * @param ipInfo if the request succeeds, this object is filled in with
+ * the IP address information.
+ * @return {@code true} for success, {@code false} for failure
+ */
+ public native static boolean runDhcpRenew(String interfaceName, DhcpInfoInternal ipInfo);
+
+ /**
+ * Shut down the DHCP client daemon.
+ *
+ * @param interfaceName the name of the interface for which the daemon
+ * should be stopped
+ * @return {@code true} for success, {@code false} for failure
+ */
+ public native static boolean stopDhcp(String interfaceName);
+
+ /**
+ * Release the current DHCP lease.
+ *
+ * @param interfaceName the name of the interface for which the lease should
+ * be released
+ * @return {@code true} for success, {@code false} for failure
+ */
+ public native static boolean releaseDhcpLease(String interfaceName);
+
+ /**
+ * Return the last DHCP-related error message that was recorded.
+ * NOTE: This string is not localized, but currently it is only
+ * used in logging.
+ *
+ * @return the most recent error message, if any
+ */
+ public native static String getDhcpError();
+
+ /**
+ * Convert a IPv4 address from an integer to an InetAddress.
+ *
+ * @param hostAddress an int corresponding to the IPv4 address in network byte order
+ */
+ public static InetAddress intToInetAddress(int hostAddress) {
+ byte[] addressBytes = {(byte) (0xff & hostAddress),
+ (byte) (0xff & (hostAddress >> 8)),
+ (byte) (0xff & (hostAddress >> 16)),
+ (byte) (0xff & (hostAddress >> 24))};
+
+ try {
+ return InetAddress.getByAddress(addressBytes);
+ } catch (UnknownHostException e) {
+ throw new AssertionError();
+ }
+ }
+
+ /**
+ * Convert a IPv4 address from an InetAddress to an integer
+ *
+ * @param inetAddr is an InetAddress corresponding to the IPv4 address
+ * @return the IP address as an integer in network byte order
+ */
+ public static int inetAddressToInt(InetAddress inetAddr)
+ throws IllegalArgumentException {
+ byte[] addr = inetAddr.getAddress();
+ if (addr.length != 4) {
+ throw new IllegalArgumentException("Not an IPv4 address");
+ }
+ return ((addr[3] & 0xff) << 24) | ((addr[2] & 0xff) << 16) |
+ ((addr[1] & 0xff) << 8) | (addr[0] & 0xff);
+ }
+
+ /**
+ * Convert a network prefix length to an IPv4 netmask integer
+ *
+ * @param prefixLength
+ * @return the IPv4 netmask as an integer in network byte order
+ */
+ public static int prefixLengthToNetmaskInt(int prefixLength)
+ throws IllegalArgumentException {
+ if (prefixLength < 0 || prefixLength > 32) {
+ throw new IllegalArgumentException("Invalid prefix length (0 <= prefix <= 32)");
+ }
+ int value = 0xffffffff << (32 - prefixLength);
+ return Integer.reverseBytes(value);
+ }
+
+ /**
+ * Convert a IPv4 netmask integer to a prefix length
+ *
+ * @param netmask as an integer in network byte order
+ * @return the network prefix length
+ */
+ public static int netmaskIntToPrefixLength(int netmask) {
+ return Integer.bitCount(netmask);
+ }
+
+ /**
+ * Create an InetAddress from a string where the string must be a standard
+ * representation of a V4 or V6 address. Avoids doing a DNS lookup on failure
+ * but it will throw an IllegalArgumentException in that case.
+ *
+ * @param addrString
+ * @return the InetAddress
+ * @hide
+ */
+ public static InetAddress numericToInetAddress(String addrString)
+ throws IllegalArgumentException {
+ return null;
+ }
+
+ /**
+ * Get InetAddress masked with prefixLength. Will never return null.
+ *
+ * @param IP address which will be masked with specified prefixLength
+ * @param prefixLength the prefixLength used to mask the IP
+ */
+ public static InetAddress getNetworkPart(InetAddress address, int prefixLength) {
+ if (address == null) {
+ throw new RuntimeException("getNetworkPart doesn't accept null address");
+ }
+
+ byte[] array = address.getAddress();
+
+ if (prefixLength < 0 || prefixLength > array.length * 8) {
+ throw new RuntimeException("getNetworkPart - bad prefixLength");
+ }
+
+ int offset = prefixLength / 8;
+ int reminder = prefixLength % 8;
+ byte mask = (byte) (0xFF << (8 - reminder));
+
+ if (offset < array.length) array[offset] = (byte) (array[offset] & mask);
+
+ offset++;
+
+ for (; offset < array.length; offset++) {
+ array[offset] = 0;
+ }
+
+ InetAddress netPart = null;
+ try {
+ netPart = InetAddress.getByAddress(array);
+ } catch (UnknownHostException e) {
+ throw new RuntimeException("getNetworkPart error - " + e.toString());
+ }
+ return netPart;
+ }
+
+ /**
+ * Check if IP address type is consistent between two InetAddress.
+ *
+ * @return true if both are the same type. False otherwise.
+ */
+ public static boolean addressTypeMatches(InetAddress left, InetAddress right) {
+ return (((left instanceof Inet4Address) && (right instanceof Inet4Address)) ||
+ ((left instanceof Inet6Address) && (right instanceof Inet6Address)));
+ }
+
+ /**
+ * Convert a 32 char hex string into a Inet6Address.
+ * throws a runtime exception if the string isn't 32 chars, isn't hex or can't be
+ * made into an Inet6Address
+ *
+ * @param addrHexString a 32 character hex string representing an IPv6 addr
+ * @return addr an InetAddress representation for the string
+ */
+ public static InetAddress hexToInet6Address(String addrHexString)
+ throws IllegalArgumentException {
+ try {
+ return numericToInetAddress(String.format("%s:%s:%s:%s:%s:%s:%s:%s",
+ addrHexString.substring(0, 4), addrHexString.substring(4, 8),
+ addrHexString.substring(8, 12), addrHexString.substring(12, 16),
+ addrHexString.substring(16, 20), addrHexString.substring(20, 24),
+ addrHexString.substring(24, 28), addrHexString.substring(28, 32)));
+ } catch (Exception e) {
+ Timber.e("error in hexToInet6Address(" + addrHexString + "): " + e);
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Create a string array of host addresses from a collection of InetAddresses
+ *
+ * @param addrs a Collection of InetAddresses
+ * @return an array of Strings containing their host addresses
+ */
+ public static String[] makeStrings(Collection addrs) {
+ String[] result = new String[addrs.size()];
+ int i = 0;
+ for (InetAddress addr : addrs) {
+ result[i++] = addr.getHostAddress();
+ }
+ return result;
+ }
+
+ /**
+ * Trim leading zeros from IPv4 address strings
+ * Our base libraries will interpret that as octel..
+ * Must leave non v4 addresses and host names alone.
+ * For example, 192.168.000.010 -> 192.168.0.10
+ * TODO - fix base libraries and remove this function
+ *
+ * @param addr a string representing an ip addr
+ * @return a string propertly trimmed
+ */
+ public static String trimV4AddrZeros(String addr) {
+ if (addr == null) return null;
+ String[] octets = addr.split("\\.");
+ if (octets.length != 4) return addr;
+ StringBuilder builder = new StringBuilder(16);
+ String result = null;
+ for (int i = 0; i < 4; i++) {
+ try {
+ if (octets[i].length() > 3) return addr;
+ builder.append(Integer.parseInt(octets[i]));
+ } catch (NumberFormatException e) {
+ return addr;
+ }
+ if (i < 3) builder.append('.');
+ }
+ result = builder.toString();
+ return result;
+ }
+}
diff --git a/android-smsmms/src/main/java/android/net/ProxyProperties.java b/android-smsmms/src/main/java/android/net/ProxyProperties.java
index 9d6068f50..ca6af4757 100755
--- a/android-smsmms/src/main/java/android/net/ProxyProperties.java
+++ b/android-smsmms/src/main/java/android/net/ProxyProperties.java
@@ -1,222 +1,222 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package android.net;
-
-
-import android.annotation.SuppressLint;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.TextUtils;
-
-import java.net.InetSocketAddress;
-
-/**
- * A container class for the http proxy info
- *
- * @hide
- */
-public class ProxyProperties implements Parcelable {
-
- private String mHost;
- private int mPort;
- private String mExclusionList;
- private String[] mParsedExclusionList;
-
- public ProxyProperties(String host, int port, String exclList) {
- mHost = host;
- mPort = port;
- setExclusionList(exclList);
- }
-
- private ProxyProperties(String host, int port, String exclList, String[] parsedExclList) {
- mHost = host;
- mPort = port;
- mExclusionList = exclList;
- mParsedExclusionList = parsedExclList;
- }
-
- // copy constructor instead of clone
- public ProxyProperties(ProxyProperties source) {
- if (source != null) {
- mHost = source.getHost();
- mPort = source.getPort();
- mExclusionList = source.getExclusionList();
- mParsedExclusionList = source.mParsedExclusionList;
- }
- }
-
- public InetSocketAddress getSocketAddress() {
- InetSocketAddress inetSocketAddress = null;
- try {
- inetSocketAddress = new InetSocketAddress(mHost, mPort);
- } catch (IllegalArgumentException e) {
- }
- return inetSocketAddress;
- }
-
- public String getHost() {
- return mHost;
- }
-
- public int getPort() {
- return mPort;
- }
-
- // comma separated
- public String getExclusionList() {
- return mExclusionList;
- }
-
- // comma separated
- @SuppressLint("DefaultLocale")
- private void setExclusionList(String exclusionList) {
- mExclusionList = exclusionList;
- if (mExclusionList == null) {
- mParsedExclusionList = new String[0];
- } else {
- String splitExclusionList[] = exclusionList.toLowerCase().split(",");
- mParsedExclusionList = new String[splitExclusionList.length * 2];
- for (int i = 0; i < splitExclusionList.length; i++) {
- String s = splitExclusionList[i].trim();
- if (s.startsWith(".")) s = s.substring(1);
- mParsedExclusionList[i * 2] = s;
- mParsedExclusionList[(i * 2) + 1] = "." + s;
- }
- }
- }
-
- public boolean isExcluded(String url) {
- if (TextUtils.isEmpty(url) || mParsedExclusionList == null ||
- mParsedExclusionList.length == 0) return false;
-
- Uri u = Uri.parse(url);
- String urlDomain = u.getHost();
- if (urlDomain == null) return false;
- for (int i = 0; i < mParsedExclusionList.length; i += 2) {
- if (urlDomain.equals(mParsedExclusionList[i]) ||
- urlDomain.endsWith(mParsedExclusionList[i + 1])) {
- return true;
- }
- }
- return false;
- }
-
- public java.net.Proxy makeProxy() {
- java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
- if (mHost != null) {
- try {
- InetSocketAddress inetSocketAddress = new InetSocketAddress(mHost, mPort);
- proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, inetSocketAddress);
- } catch (IllegalArgumentException e) {
- }
- }
- return proxy;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- if (mHost != null) {
- sb.append("[");
- sb.append(mHost);
- sb.append("] ");
- sb.append(Integer.toString(mPort));
- if (mExclusionList != null) {
- sb.append(" xl=").append(mExclusionList);
- }
- } else {
- sb.append("[ProxyProperties.mHost == null]");
- }
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof ProxyProperties)) return false;
- ProxyProperties p = (ProxyProperties) o;
- if (mExclusionList != null && !mExclusionList.equals(p.getExclusionList())) return false;
- if (mHost != null && p.getHost() != null && mHost.equals(p.getHost()) == false) {
- return false;
- }
- if (mHost != null && p.mHost == null) return false;
- if (mHost == null && p.mHost != null) return false;
- if (mPort != p.mPort) return false;
- return true;
- }
-
- /**
- * Implement the Parcelable interface
- *
- * @hide
- */
- public int describeContents() {
- return 0;
- }
-
- @Override
- /*
- * generate hashcode based on significant fields
- */
- public int hashCode() {
- return ((null == mHost) ? 0 : mHost.hashCode())
- + ((null == mExclusionList) ? 0 : mExclusionList.hashCode())
- + mPort;
- }
-
- /**
- * Implement the Parcelable interface.
- *
- * @hide
- */
- public void writeToParcel(Parcel dest, int flags) {
- if (mHost != null) {
- dest.writeByte((byte) 1);
- dest.writeString(mHost);
- dest.writeInt(mPort);
- } else {
- dest.writeByte((byte) 0);
- }
- dest.writeString(mExclusionList);
- dest.writeStringArray(mParsedExclusionList);
- }
-
- /**
- * Implement the Parcelable interface.
- *
- * @hide
- */
- public static final Creator CREATOR =
- new Creator() {
- public ProxyProperties createFromParcel(Parcel in) {
- String host = null;
- int port = 0;
- if (in.readByte() == 1) {
- host = in.readString();
- port = in.readInt();
- }
- String exclList = in.readString();
- //String[] parsedExclList = in.readStringArray();
- ProxyProperties proxyProperties =
- new ProxyProperties(host, port, exclList, null);
- return proxyProperties;
- }
-
- public ProxyProperties[] newArray(int size) {
- return new ProxyProperties[size];
- }
- };
-}
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package android.net;
+
+
+import android.annotation.SuppressLint;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextUtils;
+
+import java.net.InetSocketAddress;
+
+/**
+ * A container class for the http proxy info
+ *
+ * @hide
+ */
+public class ProxyProperties implements Parcelable {
+
+ private String mHost;
+ private int mPort;
+ private String mExclusionList;
+ private String[] mParsedExclusionList;
+
+ public ProxyProperties(String host, int port, String exclList) {
+ mHost = host;
+ mPort = port;
+ setExclusionList(exclList);
+ }
+
+ private ProxyProperties(String host, int port, String exclList, String[] parsedExclList) {
+ mHost = host;
+ mPort = port;
+ mExclusionList = exclList;
+ mParsedExclusionList = parsedExclList;
+ }
+
+ // copy constructor instead of clone
+ public ProxyProperties(ProxyProperties source) {
+ if (source != null) {
+ mHost = source.getHost();
+ mPort = source.getPort();
+ mExclusionList = source.getExclusionList();
+ mParsedExclusionList = source.mParsedExclusionList;
+ }
+ }
+
+ public InetSocketAddress getSocketAddress() {
+ InetSocketAddress inetSocketAddress = null;
+ try {
+ inetSocketAddress = new InetSocketAddress(mHost, mPort);
+ } catch (IllegalArgumentException e) {
+ }
+ return inetSocketAddress;
+ }
+
+ public String getHost() {
+ return mHost;
+ }
+
+ public int getPort() {
+ return mPort;
+ }
+
+ // comma separated
+ public String getExclusionList() {
+ return mExclusionList;
+ }
+
+ // comma separated
+ @SuppressLint("DefaultLocale")
+ private void setExclusionList(String exclusionList) {
+ mExclusionList = exclusionList;
+ if (mExclusionList == null) {
+ mParsedExclusionList = new String[0];
+ } else {
+ String splitExclusionList[] = exclusionList.toLowerCase().split(",");
+ mParsedExclusionList = new String[splitExclusionList.length * 2];
+ for (int i = 0; i < splitExclusionList.length; i++) {
+ String s = splitExclusionList[i].trim();
+ if (s.startsWith(".")) s = s.substring(1);
+ mParsedExclusionList[i * 2] = s;
+ mParsedExclusionList[(i * 2) + 1] = "." + s;
+ }
+ }
+ }
+
+ public boolean isExcluded(String url) {
+ if (TextUtils.isEmpty(url) || mParsedExclusionList == null ||
+ mParsedExclusionList.length == 0) return false;
+
+ Uri u = Uri.parse(url);
+ String urlDomain = u.getHost();
+ if (urlDomain == null) return false;
+ for (int i = 0; i < mParsedExclusionList.length; i += 2) {
+ if (urlDomain.equals(mParsedExclusionList[i]) ||
+ urlDomain.endsWith(mParsedExclusionList[i + 1])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public java.net.Proxy makeProxy() {
+ java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
+ if (mHost != null) {
+ try {
+ InetSocketAddress inetSocketAddress = new InetSocketAddress(mHost, mPort);
+ proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, inetSocketAddress);
+ } catch (IllegalArgumentException e) {
+ }
+ }
+ return proxy;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ if (mHost != null) {
+ sb.append("[");
+ sb.append(mHost);
+ sb.append("] ");
+ sb.append(Integer.toString(mPort));
+ if (mExclusionList != null) {
+ sb.append(" xl=").append(mExclusionList);
+ }
+ } else {
+ sb.append("[ProxyProperties.mHost == null]");
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof ProxyProperties)) return false;
+ ProxyProperties p = (ProxyProperties) o;
+ if (mExclusionList != null && !mExclusionList.equals(p.getExclusionList())) return false;
+ if (mHost != null && p.getHost() != null && mHost.equals(p.getHost()) == false) {
+ return false;
+ }
+ if (mHost != null && p.mHost == null) return false;
+ if (mHost == null && p.mHost != null) return false;
+ if (mPort != p.mPort) return false;
+ return true;
+ }
+
+ /**
+ * Implement the Parcelable interface
+ *
+ * @hide
+ */
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ /*
+ * generate hashcode based on significant fields
+ */
+ public int hashCode() {
+ return ((null == mHost) ? 0 : mHost.hashCode())
+ + ((null == mExclusionList) ? 0 : mExclusionList.hashCode())
+ + mPort;
+ }
+
+ /**
+ * Implement the Parcelable interface.
+ *
+ * @hide
+ */
+ public void writeToParcel(Parcel dest, int flags) {
+ if (mHost != null) {
+ dest.writeByte((byte) 1);
+ dest.writeString(mHost);
+ dest.writeInt(mPort);
+ } else {
+ dest.writeByte((byte) 0);
+ }
+ dest.writeString(mExclusionList);
+ dest.writeStringArray(mParsedExclusionList);
+ }
+
+ /**
+ * Implement the Parcelable interface.
+ *
+ * @hide
+ */
+ public static final Creator CREATOR =
+ new Creator() {
+ public ProxyProperties createFromParcel(Parcel in) {
+ String host = null;
+ int port = 0;
+ if (in.readByte() == 1) {
+ host = in.readString();
+ port = in.readInt();
+ }
+ String exclList = in.readString();
+ //String[] parsedExclList = in.readStringArray();
+ ProxyProperties proxyProperties =
+ new ProxyProperties(host, port, exclList, null);
+ return proxyProperties;
+ }
+
+ public ProxyProperties[] newArray(int size) {
+ return new ProxyProperties[size];
+ }
+ };
+}
diff --git a/android-smsmms/src/main/java/android/net/RouteInfo.java b/android-smsmms/src/main/java/android/net/RouteInfo.java
index 1aa3ea8cb..1de76185b 100755
--- a/android-smsmms/src/main/java/android/net/RouteInfo.java
+++ b/android-smsmms/src/main/java/android/net/RouteInfo.java
@@ -1,285 +1,285 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package android.net;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import timber.log.Timber;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Collection;
-
-/**
- * A simple container for route information.
- *
- * @hide
- */
-public class RouteInfo implements Parcelable {
- /**
- * The IP destination address for this route.
- */
- private final LinkAddress mDestination;
-
- /**
- * The gateway address for this route.
- */
- private final InetAddress mGateway;
-
- private final boolean mIsDefault;
- private final boolean mIsHost;
-
- public RouteInfo(LinkAddress destination, InetAddress gateway) {
- if (destination == null) {
- if (gateway != null) {
- if (gateway instanceof Inet4Address) {
- try {
- destination = new LinkAddress(Inet4Address.getLocalHost(), 0);
- } catch (UnknownHostException e) {
- // TODO Auto-generated catch block
- Timber.e(e, "exception thrown");
- }
- } else {
- try {
- destination = new LinkAddress(Inet6Address.getLocalHost(), 0);
- } catch (UnknownHostException e) {
- // TODO Auto-generated catch block
- Timber.e(e, "exception thrown");
- }
- }
- } else {
- // no destination, no gateway. invalid.
- throw new RuntimeException("Invalid arguments passed in.");
- }
- }
- if (gateway == null) {
- if (destination.getAddress() instanceof Inet4Address) {
- try {
- gateway = Inet4Address.getLocalHost();
- } catch (UnknownHostException e) {
- // TODO Auto-generated catch block
- Timber.e(e, "exception thrown");
- }
- } else {
- try {
- gateway = Inet6Address.getLocalHost();
- } catch (UnknownHostException e) {
- // TODO Auto-generated catch block
- Timber.e(e, "exception thrown");
- }
- }
- }
- mDestination = new LinkAddress(NetworkUtilsHelper.getNetworkPart(destination.getAddress(),
- destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength());
- mGateway = gateway;
- mIsDefault = isDefault();
- mIsHost = isHost();
- }
-
- public RouteInfo(InetAddress gateway) {
- this(null, gateway);
- }
-
- public static RouteInfo makeHostRoute(InetAddress host) {
- return makeHostRoute(host, null);
- }
-
- public static RouteInfo makeHostRoute(InetAddress host, InetAddress gateway) {
- if (host == null) return null;
-
- if (host instanceof Inet4Address) {
- return new RouteInfo(new LinkAddress(host, 32), gateway);
- } else {
- return new RouteInfo(new LinkAddress(host, 128), gateway);
- }
- }
-
- private boolean isHost() {
- try {
- return (mGateway.equals(Inet4Address.getLocalHost()) || mGateway.equals(Inet6Address.getLocalHost()));
- } catch (UnknownHostException e) {
- // TODO Auto-generated catch block
- return false;
- }
- }
-
- private boolean isDefault() {
- boolean val = false;
- if (mGateway != null) {
- if (mGateway instanceof Inet4Address) {
- val = (mDestination == null || mDestination.getNetworkPrefixLength() == 0);
- } else {
- val = (mDestination == null || mDestination.getNetworkPrefixLength() == 0);
- }
- }
- return val;
- }
-
-
- public LinkAddress getDestination() {
- return mDestination;
- }
-
- public InetAddress getGateway() {
- return mGateway;
- }
-
- public boolean isDefaultRoute() {
- return mIsDefault;
- }
-
- public boolean isHostRoute() {
- return mIsHost;
- }
-
- public String toString() {
- String val = "";
- if (mDestination != null) val = mDestination.toString();
- if (mGateway != null) val += " -> " + mGateway.getHostAddress();
- return val;
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel dest, int flags) {
- if (mDestination == null) {
- dest.writeByte((byte) 0);
- } else {
- dest.writeByte((byte) 1);
- dest.writeByteArray(mDestination.getAddress().getAddress());
- dest.writeInt(mDestination.getNetworkPrefixLength());
- }
-
- if (mGateway == null) {
- dest.writeByte((byte) 0);
- } else {
- dest.writeByte((byte) 1);
- dest.writeByteArray(mGateway.getAddress());
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
-
- if (!(obj instanceof RouteInfo)) return false;
-
- RouteInfo target = (RouteInfo) obj;
-
- boolean sameDestination = (mDestination == null) ?
- target.getDestination() == null
- : mDestination.equals(target.getDestination());
-
- boolean sameAddress = (mGateway == null) ?
- target.getGateway() == null
- : mGateway.equals(target.getGateway());
-
- return sameDestination && sameAddress
- && mIsDefault == target.mIsDefault;
- }
-
- @Override
- public int hashCode() {
- return (mDestination == null ? 0 : mDestination.hashCode())
- + (mGateway == null ? 0 : mGateway.hashCode())
- + (mIsDefault ? 3 : 7);
- }
-
- public static final Creator CREATOR =
- new Creator() {
- public RouteInfo createFromParcel(Parcel in) {
- InetAddress destAddr = null;
- int prefix = 0;
- InetAddress gateway = null;
-
- if (in.readByte() == 1) {
- byte[] addr = in.createByteArray();
- prefix = in.readInt();
-
- try {
- destAddr = InetAddress.getByAddress(addr);
- } catch (UnknownHostException e) {
- }
- }
-
- if (in.readByte() == 1) {
- byte[] addr = in.createByteArray();
-
- try {
- gateway = InetAddress.getByAddress(addr);
- } catch (UnknownHostException e) {
- }
- }
-
- LinkAddress dest = null;
-
- if (destAddr != null) {
- dest = new LinkAddress(destAddr, prefix);
- }
-
- return new RouteInfo(dest, gateway);
- }
-
- public RouteInfo[] newArray(int size) {
- return new RouteInfo[size];
- }
- };
-
- private boolean matches(InetAddress destination) {
- if (destination == null) return false;
-
- // if the destination is present and the route is default.
- // return true
- if (isDefault()) return true;
-
- // match the route destination and destination with prefix length
- InetAddress dstNet = NetworkUtilsHelper.getNetworkPart(destination,
- mDestination.getNetworkPrefixLength());
-
- return mDestination.getAddress().equals(dstNet);
- }
-
- /**
- * Find the route from a Collection of routes that best matches a given address.
- * May return null if no routes are applicable.
- *
- * @param routes a Collection of RouteInfos to chose from
- * @param dest the InetAddress your trying to get to
- * @return the RouteInfo from the Collection that best fits the given address
- */
- public static RouteInfo selectBestRoute(Collection routes, InetAddress dest) {
- if ((routes == null) || (dest == null)) return null;
-
- RouteInfo bestRoute = null;
- // pick a longest prefix match under same address type
- for (RouteInfo route : routes) {
- if (NetworkUtilsHelper.addressTypeMatches(route.mDestination.getAddress(), dest)) {
- if ((bestRoute != null) &&
- (bestRoute.mDestination.getNetworkPrefixLength() >=
- route.mDestination.getNetworkPrefixLength())) {
- continue;
- }
- if (route.matches(dest)) bestRoute = route;
- }
- }
- return bestRoute;
- }
-}
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package android.net;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import timber.log.Timber;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+
+/**
+ * A simple container for route information.
+ *
+ * @hide
+ */
+public class RouteInfo implements Parcelable {
+ /**
+ * The IP destination address for this route.
+ */
+ private final LinkAddress mDestination;
+
+ /**
+ * The gateway address for this route.
+ */
+ private final InetAddress mGateway;
+
+ private final boolean mIsDefault;
+ private final boolean mIsHost;
+
+ public RouteInfo(LinkAddress destination, InetAddress gateway) {
+ if (destination == null) {
+ if (gateway != null) {
+ if (gateway instanceof Inet4Address) {
+ try {
+ destination = new LinkAddress(Inet4Address.getLocalHost(), 0);
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ Timber.e(e, "exception thrown");
+ }
+ } else {
+ try {
+ destination = new LinkAddress(Inet6Address.getLocalHost(), 0);
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ Timber.e(e, "exception thrown");
+ }
+ }
+ } else {
+ // no destination, no gateway. invalid.
+ throw new RuntimeException("Invalid arguments passed in.");
+ }
+ }
+ if (gateway == null) {
+ if (destination.getAddress() instanceof Inet4Address) {
+ try {
+ gateway = Inet4Address.getLocalHost();
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ Timber.e(e, "exception thrown");
+ }
+ } else {
+ try {
+ gateway = Inet6Address.getLocalHost();
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ Timber.e(e, "exception thrown");
+ }
+ }
+ }
+ mDestination = new LinkAddress(NetworkUtilsHelper.getNetworkPart(destination.getAddress(),
+ destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength());
+ mGateway = gateway;
+ mIsDefault = isDefault();
+ mIsHost = isHost();
+ }
+
+ public RouteInfo(InetAddress gateway) {
+ this(null, gateway);
+ }
+
+ public static RouteInfo makeHostRoute(InetAddress host) {
+ return makeHostRoute(host, null);
+ }
+
+ public static RouteInfo makeHostRoute(InetAddress host, InetAddress gateway) {
+ if (host == null) return null;
+
+ if (host instanceof Inet4Address) {
+ return new RouteInfo(new LinkAddress(host, 32), gateway);
+ } else {
+ return new RouteInfo(new LinkAddress(host, 128), gateway);
+ }
+ }
+
+ private boolean isHost() {
+ try {
+ return (mGateway.equals(Inet4Address.getLocalHost()) || mGateway.equals(Inet6Address.getLocalHost()));
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
+ return false;
+ }
+ }
+
+ private boolean isDefault() {
+ boolean val = false;
+ if (mGateway != null) {
+ if (mGateway instanceof Inet4Address) {
+ val = (mDestination == null || mDestination.getNetworkPrefixLength() == 0);
+ } else {
+ val = (mDestination == null || mDestination.getNetworkPrefixLength() == 0);
+ }
+ }
+ return val;
+ }
+
+
+ public LinkAddress getDestination() {
+ return mDestination;
+ }
+
+ public InetAddress getGateway() {
+ return mGateway;
+ }
+
+ public boolean isDefaultRoute() {
+ return mIsDefault;
+ }
+
+ public boolean isHostRoute() {
+ return mIsHost;
+ }
+
+ public String toString() {
+ String val = "";
+ if (mDestination != null) val = mDestination.toString();
+ if (mGateway != null) val += " -> " + mGateway.getHostAddress();
+ return val;
+ }
+
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ if (mDestination == null) {
+ dest.writeByte((byte) 0);
+ } else {
+ dest.writeByte((byte) 1);
+ dest.writeByteArray(mDestination.getAddress().getAddress());
+ dest.writeInt(mDestination.getNetworkPrefixLength());
+ }
+
+ if (mGateway == null) {
+ dest.writeByte((byte) 0);
+ } else {
+ dest.writeByte((byte) 1);
+ dest.writeByteArray(mGateway.getAddress());
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+
+ if (!(obj instanceof RouteInfo)) return false;
+
+ RouteInfo target = (RouteInfo) obj;
+
+ boolean sameDestination = (mDestination == null) ?
+ target.getDestination() == null
+ : mDestination.equals(target.getDestination());
+
+ boolean sameAddress = (mGateway == null) ?
+ target.getGateway() == null
+ : mGateway.equals(target.getGateway());
+
+ return sameDestination && sameAddress
+ && mIsDefault == target.mIsDefault;
+ }
+
+ @Override
+ public int hashCode() {
+ return (mDestination == null ? 0 : mDestination.hashCode())
+ + (mGateway == null ? 0 : mGateway.hashCode())
+ + (mIsDefault ? 3 : 7);
+ }
+
+ public static final Creator CREATOR =
+ new Creator() {
+ public RouteInfo createFromParcel(Parcel in) {
+ InetAddress destAddr = null;
+ int prefix = 0;
+ InetAddress gateway = null;
+
+ if (in.readByte() == 1) {
+ byte[] addr = in.createByteArray();
+ prefix = in.readInt();
+
+ try {
+ destAddr = InetAddress.getByAddress(addr);
+ } catch (UnknownHostException e) {
+ }
+ }
+
+ if (in.readByte() == 1) {
+ byte[] addr = in.createByteArray();
+
+ try {
+ gateway = InetAddress.getByAddress(addr);
+ } catch (UnknownHostException e) {
+ }
+ }
+
+ LinkAddress dest = null;
+
+ if (destAddr != null) {
+ dest = new LinkAddress(destAddr, prefix);
+ }
+
+ return new RouteInfo(dest, gateway);
+ }
+
+ public RouteInfo[] newArray(int size) {
+ return new RouteInfo[size];
+ }
+ };
+
+ private boolean matches(InetAddress destination) {
+ if (destination == null) return false;
+
+ // if the destination is present and the route is default.
+ // return true
+ if (isDefault()) return true;
+
+ // match the route destination and destination with prefix length
+ InetAddress dstNet = NetworkUtilsHelper.getNetworkPart(destination,
+ mDestination.getNetworkPrefixLength());
+
+ return mDestination.getAddress().equals(dstNet);
+ }
+
+ /**
+ * Find the route from a Collection of routes that best matches a given address.
+ * May return null if no routes are applicable.
+ *
+ * @param routes a Collection of RouteInfos to chose from
+ * @param dest the InetAddress your trying to get to
+ * @return the RouteInfo from the Collection that best fits the given address
+ */
+ public static RouteInfo selectBestRoute(Collection routes, InetAddress dest) {
+ if ((routes == null) || (dest == null)) return null;
+
+ RouteInfo bestRoute = null;
+ // pick a longest prefix match under same address type
+ for (RouteInfo route : routes) {
+ if (NetworkUtilsHelper.addressTypeMatches(route.mDestination.getAddress(), dest)) {
+ if ((bestRoute != null) &&
+ (bestRoute.mDestination.getNetworkPrefixLength() >=
+ route.mDestination.getNetworkPrefixLength())) {
+ continue;
+ }
+ if (route.matches(dest)) bestRoute = route;
+ }
+ }
+ return bestRoute;
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/i18n/phonenumbers/NumberParseException.java b/android-smsmms/src/main/java/com/android/i18n/phonenumbers/NumberParseException.java
index bdb3cf4e5..b0855857e 100755
--- a/android-smsmms/src/main/java/com/android/i18n/phonenumbers/NumberParseException.java
+++ b/android-smsmms/src/main/java/com/android/i18n/phonenumbers/NumberParseException.java
@@ -1,20 +1,20 @@
-/*
- * Copyright (C) 2015 Jacob Klinker
- *
- * 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.
- */
-
-package com.android.i18n.phonenumbers;
-
-public class NumberParseException extends Exception {
-}
+/*
+ * Copyright (C) 2015 Jacob Klinker
+ *
+ * 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.
+ */
+
+package com.android.i18n.phonenumbers;
+
+public class NumberParseException extends Exception {
+}
diff --git a/android-smsmms/src/main/java/com/android/i18n/phonenumbers/PhoneNumberUtil.java b/android-smsmms/src/main/java/com/android/i18n/phonenumbers/PhoneNumberUtil.java
index 863263917..49f8939bf 100755
--- a/android-smsmms/src/main/java/com/android/i18n/phonenumbers/PhoneNumberUtil.java
+++ b/android-smsmms/src/main/java/com/android/i18n/phonenumbers/PhoneNumberUtil.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (C) 2015 Jacob Klinker
- *
- * 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.
- */
-
-package com.android.i18n.phonenumbers;
-
-public class PhoneNumberUtil {
- private static PhoneNumberUtil instance;
-
- public static PhoneNumberUtil getInstance() {
- return instance;
- }
-
- public String format(Phonenumber.PhoneNumber parsed, PhoneNumberFormat format) {
- return null;
- }
-
- public Phonenumber.PhoneNumber parse(String s, String s2) throws NumberParseException {
- return new Phonenumber.PhoneNumber();
- }
-
- public boolean isValidNumber(Phonenumber.PhoneNumber phoneNumber) {
- return true;
- }
-
- public enum PhoneNumberFormat {
- E164,
- INTERNATIONAL,
- NATIONAL,
- RFC3966
- }
-}
+/*
+ * Copyright (C) 2015 Jacob Klinker
+ *
+ * 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.
+ */
+
+package com.android.i18n.phonenumbers;
+
+public class PhoneNumberUtil {
+ private static PhoneNumberUtil instance;
+
+ public static PhoneNumberUtil getInstance() {
+ return instance;
+ }
+
+ public String format(Phonenumber.PhoneNumber parsed, PhoneNumberFormat format) {
+ return null;
+ }
+
+ public Phonenumber.PhoneNumber parse(String s, String s2) throws NumberParseException {
+ return new Phonenumber.PhoneNumber();
+ }
+
+ public boolean isValidNumber(Phonenumber.PhoneNumber phoneNumber) {
+ return true;
+ }
+
+ public enum PhoneNumberFormat {
+ E164,
+ INTERNATIONAL,
+ NATIONAL,
+ RFC3966
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/i18n/phonenumbers/Phonenumber.java b/android-smsmms/src/main/java/com/android/i18n/phonenumbers/Phonenumber.java
index 86fdafdd6..2a1904a64 100755
--- a/android-smsmms/src/main/java/com/android/i18n/phonenumbers/Phonenumber.java
+++ b/android-smsmms/src/main/java/com/android/i18n/phonenumbers/Phonenumber.java
@@ -1,22 +1,22 @@
-/*
- * Copyright (C) 2015 Jacob Klinker
- *
- * 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.
- */
-
-package com.android.i18n.phonenumbers;
-
-public class Phonenumber {
- public static class PhoneNumber {
- }
-}
+/*
+ * Copyright (C) 2015 Jacob Klinker
+ *
+ * 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.
+ */
+
+package com.android.i18n.phonenumbers;
+
+public class Phonenumber {
+ public static class PhoneNumber {
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/internal/telephony/TelephonyProperties.java b/android-smsmms/src/main/java/com/android/internal/telephony/TelephonyProperties.java
index 61aaaa366..ab230e614 100755
--- a/android-smsmms/src/main/java/com/android/internal/telephony/TelephonyProperties.java
+++ b/android-smsmms/src/main/java/com/android/internal/telephony/TelephonyProperties.java
@@ -1,207 +1,207 @@
-/*
- * Copyright (C) 2006 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.
- */
-
-package com.android.internal.telephony;
-
-/**
- * Contains a list of string constants used to get or set telephone properties
- * in the system. You can use {@link android.os.SystemProperties os.SystemProperties}
- * to get and set these values.
- *
- * @hide
- */
-public interface TelephonyProperties {
- //****** Baseband and Radio Interface version
-
- //TODO T: property strings do not have to be gsm specific
- // change gsm.*operator.*" properties to "operator.*" properties
-
- /**
- * Baseband version
- * Availability: property is available any time radio is on
- */
- static final String PROPERTY_BASEBAND_VERSION = "gsm.version.baseband";
-
- /**
- * Radio Interface Layer (RIL) library implementation.
- */
- static final String PROPERTY_RIL_IMPL = "gsm.version.ril-impl";
-
- //****** Current Network
-
- /**
- * Alpha name of current registered operator.
- * Availability: when registered to a network. Result may be unreliable on
- * CDMA networks.
- */
- static final String PROPERTY_OPERATOR_ALPHA = "gsm.operator.alpha";
- //TODO: most of these properties are generic, substitute gsm. with phone. bug 1856959
-
- /**
- * Numeric name (MCC+MNC) of current registered operator.
- * Availability: when registered to a network. Result may be unreliable on
- * CDMA networks.
- */
- static final String PROPERTY_OPERATOR_NUMERIC = "gsm.operator.numeric";
-
- /**
- * 'true' if the device is on a manually selected network
- *
- * Availability: when registered to a network
- */
- static final String PROPERTY_OPERATOR_ISMANUAL = "operator.ismanual";
-
- /**
- * 'true' if the device is considered roaming on this network for GSM
- * purposes.
- * Availability: when registered to a network
- */
- static final String PROPERTY_OPERATOR_ISROAMING = "gsm.operator.isroaming";
-
- /**
- * The ISO country code equivalent of the current registered operator's
- * MCC (Mobile Country Code)
- * Availability: when registered to a network. Result may be unreliable on
- * CDMA networks.
- */
- static final String PROPERTY_OPERATOR_ISO_COUNTRY = "gsm.operator.iso-country";
-
- /**
- * The contents of this property is the value of the kernel command line
- * product_type variable that corresponds to a product that supports LTE on CDMA.
- * {@see BaseCommands#getLteOnCdmaMode()}
- */
- static final String PROPERTY_LTE_ON_CDMA_PRODUCT_TYPE = "telephony.lteOnCdmaProductType";
-
- /**
- * The contents of this property is the one of {@link Phone#LTE_ON_CDMA_TRUE} or
- * {@link Phone#LTE_ON_CDMA_FALSE}. If absent the value will assumed to be false
- * and the {@see #PROPERTY_LTE_ON_CDMA_PRODUCT_TYPE} will be used to determine its
- * final value which could also be {@link Phone#LTE_ON_CDMA_FALSE}.
- * {@see BaseCommands#getLteOnCdmaMode()}
- */
- static final String PROPERTY_LTE_ON_CDMA_DEVICE = "telephony.lteOnCdmaDevice";
-
- static final String CURRENT_ACTIVE_PHONE = "gsm.current.phone-type";
-
- //****** SIM Card
- /**
- * One of "UNKNOWN""ABSENT""PIN_REQUIRED"
- * "PUK_REQUIRED""NETWORK_LOCKED" or "READY"
- */
- static String PROPERTY_SIM_STATE = "gsm.sim.state";
-
- /**
- * The MCC+MNC (mobile country code+mobile network code) of the
- * provider of the SIM. 5 or 6 decimal digits.
- * Availability: SIM state must be "READY"
- */
- static String PROPERTY_ICC_OPERATOR_NUMERIC = "gsm.sim.operator.numeric";
-
- /**
- * PROPERTY_ICC_OPERATOR_ALPHA is also known as the SPN, or Service Provider Name.
- * Availability: SIM state must be "READY"
- */
- static String PROPERTY_ICC_OPERATOR_ALPHA = "gsm.sim.operator.alpha";
-
- /**
- * ISO country code equivalent for the SIM provider's country code
- */
- static String PROPERTY_ICC_OPERATOR_ISO_COUNTRY = "gsm.sim.operator.iso-country";
-
- /**
- * Indicates the available radio technology. Values include: "unknown",
- * "GPRS", "EDGE" and "UMTS".
- */
- static String PROPERTY_DATA_NETWORK_TYPE = "gsm.network.type";
-
- /**
- * Indicate if phone is in emergency callback mode
- */
- static final String PROPERTY_INECM_MODE = "ril.cdma.inecmmode";
-
- /**
- * Indicate the timer value for exiting emergency callback mode
- */
- static final String PROPERTY_ECM_EXIT_TIMER = "ro.cdma.ecmexittimer";
-
- /**
- * The international dialing prefix conversion string
- */
- static final String PROPERTY_IDP_STRING = "ro.cdma.idpstring";
-
- /**
- * Defines the schema for the carrier specified OTASP number
- */
- static final String PROPERTY_OTASP_NUM_SCHEMA = "ro.cdma.otaspnumschema";
-
- /**
- * Disable all calls including Emergency call when it set to true.
- */
- static final String PROPERTY_DISABLE_CALL = "ro.telephony.disable-call";
-
- /**
- * Set to true for vendor RIL's that send multiple UNSOL_CALL_RING notifications.
- */
- static final String PROPERTY_RIL_SENDS_MULTIPLE_CALL_RING =
- "ro.telephony.call_ring.multiple";
-
- /**
- * The number of milliseconds between CALL_RING notifications.
- */
- static final String PROPERTY_CALL_RING_DELAY = "ro.telephony.call_ring.delay";
-
- /**
- * Track CDMA SMS message id numbers to ensure they increment
- * monotonically, regardless of reboots.
- */
- static final String PROPERTY_CDMA_MSG_ID = "persist.radio.cdma.msgid";
-
- /**
- * Property to override DEFAULT_WAKE_LOCK_TIMEOUT
- */
- static final String PROPERTY_WAKE_LOCK_TIMEOUT = "ro.ril.wake_lock_timeout";
-
- /**
- * Set to true to indicate that the modem needs to be reset
- * when there is a radio technology change.
- */
- static final String PROPERTY_RESET_ON_RADIO_TECH_CHANGE = "persist.radio.reset_on_switch";
-
- /**
- * Set to false to disable SMS receiving, default is
- * the value of config_sms_capable
- */
- static final String PROPERTY_SMS_RECEIVE = "telephony.sms.receive";
-
- /**
- * Set to false to disable SMS sending, default is
- * the value of config_sms_capable
- */
- static final String PROPERTY_SMS_SEND = "telephony.sms.send";
-
- /**
- * Set to true to indicate a test CSIM card is used in the device.
- * This property is for testing purpose only. This should not be defined
- * in commercial configuration.
- */
- static final String PROPERTY_TEST_CSIM = "persist.radio.test-csim";
-
- /**
- * Ignore RIL_UNSOL_NITZ_TIME_RECEIVED completely, used for debugging/testing.
- */
- static final String PROPERTY_IGNORE_NITZ = "telephony.test.ignore.nitz";
-}
+/*
+ * Copyright (C) 2006 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.
+ */
+
+package com.android.internal.telephony;
+
+/**
+ * Contains a list of string constants used to get or set telephone properties
+ * in the system. You can use {@link android.os.SystemProperties os.SystemProperties}
+ * to get and set these values.
+ *
+ * @hide
+ */
+public interface TelephonyProperties {
+ //****** Baseband and Radio Interface version
+
+ //TODO T: property strings do not have to be gsm specific
+ // change gsm.*operator.*" properties to "operator.*" properties
+
+ /**
+ * Baseband version
+ * Availability: property is available any time radio is on
+ */
+ static final String PROPERTY_BASEBAND_VERSION = "gsm.version.baseband";
+
+ /**
+ * Radio Interface Layer (RIL) library implementation.
+ */
+ static final String PROPERTY_RIL_IMPL = "gsm.version.ril-impl";
+
+ //****** Current Network
+
+ /**
+ * Alpha name of current registered operator.
+ * Availability: when registered to a network. Result may be unreliable on
+ * CDMA networks.
+ */
+ static final String PROPERTY_OPERATOR_ALPHA = "gsm.operator.alpha";
+ //TODO: most of these properties are generic, substitute gsm. with phone. bug 1856959
+
+ /**
+ * Numeric name (MCC+MNC) of current registered operator.
+ * Availability: when registered to a network. Result may be unreliable on
+ * CDMA networks.
+ */
+ static final String PROPERTY_OPERATOR_NUMERIC = "gsm.operator.numeric";
+
+ /**
+ * 'true' if the device is on a manually selected network
+ *
+ * Availability: when registered to a network
+ */
+ static final String PROPERTY_OPERATOR_ISMANUAL = "operator.ismanual";
+
+ /**
+ * 'true' if the device is considered roaming on this network for GSM
+ * purposes.
+ * Availability: when registered to a network
+ */
+ static final String PROPERTY_OPERATOR_ISROAMING = "gsm.operator.isroaming";
+
+ /**
+ * The ISO country code equivalent of the current registered operator's
+ * MCC (Mobile Country Code)
+ * Availability: when registered to a network. Result may be unreliable on
+ * CDMA networks.
+ */
+ static final String PROPERTY_OPERATOR_ISO_COUNTRY = "gsm.operator.iso-country";
+
+ /**
+ * The contents of this property is the value of the kernel command line
+ * product_type variable that corresponds to a product that supports LTE on CDMA.
+ * {@see BaseCommands#getLteOnCdmaMode()}
+ */
+ static final String PROPERTY_LTE_ON_CDMA_PRODUCT_TYPE = "telephony.lteOnCdmaProductType";
+
+ /**
+ * The contents of this property is the one of {@link Phone#LTE_ON_CDMA_TRUE} or
+ * {@link Phone#LTE_ON_CDMA_FALSE}. If absent the value will assumed to be false
+ * and the {@see #PROPERTY_LTE_ON_CDMA_PRODUCT_TYPE} will be used to determine its
+ * final value which could also be {@link Phone#LTE_ON_CDMA_FALSE}.
+ * {@see BaseCommands#getLteOnCdmaMode()}
+ */
+ static final String PROPERTY_LTE_ON_CDMA_DEVICE = "telephony.lteOnCdmaDevice";
+
+ static final String CURRENT_ACTIVE_PHONE = "gsm.current.phone-type";
+
+ //****** SIM Card
+ /**
+ * One of "UNKNOWN""ABSENT""PIN_REQUIRED"
+ * "PUK_REQUIRED""NETWORK_LOCKED" or "READY"
+ */
+ static String PROPERTY_SIM_STATE = "gsm.sim.state";
+
+ /**
+ * The MCC+MNC (mobile country code+mobile network code) of the
+ * provider of the SIM. 5 or 6 decimal digits.
+ * Availability: SIM state must be "READY"
+ */
+ static String PROPERTY_ICC_OPERATOR_NUMERIC = "gsm.sim.operator.numeric";
+
+ /**
+ * PROPERTY_ICC_OPERATOR_ALPHA is also known as the SPN, or Service Provider Name.
+ * Availability: SIM state must be "READY"
+ */
+ static String PROPERTY_ICC_OPERATOR_ALPHA = "gsm.sim.operator.alpha";
+
+ /**
+ * ISO country code equivalent for the SIM provider's country code
+ */
+ static String PROPERTY_ICC_OPERATOR_ISO_COUNTRY = "gsm.sim.operator.iso-country";
+
+ /**
+ * Indicates the available radio technology. Values include: "unknown",
+ * "GPRS", "EDGE" and "UMTS".
+ */
+ static String PROPERTY_DATA_NETWORK_TYPE = "gsm.network.type";
+
+ /**
+ * Indicate if phone is in emergency callback mode
+ */
+ static final String PROPERTY_INECM_MODE = "ril.cdma.inecmmode";
+
+ /**
+ * Indicate the timer value for exiting emergency callback mode
+ */
+ static final String PROPERTY_ECM_EXIT_TIMER = "ro.cdma.ecmexittimer";
+
+ /**
+ * The international dialing prefix conversion string
+ */
+ static final String PROPERTY_IDP_STRING = "ro.cdma.idpstring";
+
+ /**
+ * Defines the schema for the carrier specified OTASP number
+ */
+ static final String PROPERTY_OTASP_NUM_SCHEMA = "ro.cdma.otaspnumschema";
+
+ /**
+ * Disable all calls including Emergency call when it set to true.
+ */
+ static final String PROPERTY_DISABLE_CALL = "ro.telephony.disable-call";
+
+ /**
+ * Set to true for vendor RIL's that send multiple UNSOL_CALL_RING notifications.
+ */
+ static final String PROPERTY_RIL_SENDS_MULTIPLE_CALL_RING =
+ "ro.telephony.call_ring.multiple";
+
+ /**
+ * The number of milliseconds between CALL_RING notifications.
+ */
+ static final String PROPERTY_CALL_RING_DELAY = "ro.telephony.call_ring.delay";
+
+ /**
+ * Track CDMA SMS message id numbers to ensure they increment
+ * monotonically, regardless of reboots.
+ */
+ static final String PROPERTY_CDMA_MSG_ID = "persist.radio.cdma.msgid";
+
+ /**
+ * Property to override DEFAULT_WAKE_LOCK_TIMEOUT
+ */
+ static final String PROPERTY_WAKE_LOCK_TIMEOUT = "ro.ril.wake_lock_timeout";
+
+ /**
+ * Set to true to indicate that the modem needs to be reset
+ * when there is a radio technology change.
+ */
+ static final String PROPERTY_RESET_ON_RADIO_TECH_CHANGE = "persist.radio.reset_on_switch";
+
+ /**
+ * Set to false to disable SMS receiving, default is
+ * the value of config_sms_capable
+ */
+ static final String PROPERTY_SMS_RECEIVE = "telephony.sms.receive";
+
+ /**
+ * Set to false to disable SMS sending, default is
+ * the value of config_sms_capable
+ */
+ static final String PROPERTY_SMS_SEND = "telephony.sms.send";
+
+ /**
+ * Set to true to indicate a test CSIM card is used in the device.
+ * This property is for testing purpose only. This should not be defined
+ * in commercial configuration.
+ */
+ static final String PROPERTY_TEST_CSIM = "persist.radio.test-csim";
+
+ /**
+ * Ignore RIL_UNSOL_NITZ_TIME_RECEIVED completely, used for debugging/testing.
+ */
+ static final String PROPERTY_IGNORE_NITZ = "telephony.test.ignore.nitz";
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/MmsConfig.java b/android-smsmms/src/main/java/com/android/mms/MmsConfig.java
index 7e7ab62a5..2ac5d00c9 100755
--- a/android-smsmms/src/main/java/com/android/mms/MmsConfig.java
+++ b/android-smsmms/src/main/java/com/android/mms/MmsConfig.java
@@ -1,334 +1,334 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-package com.android.mms;
-
-import android.content.Context;
-import android.content.res.XmlResourceParser;
-import com.klinker.android.send_message.R;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import timber.log.Timber;
-
-import java.io.IOException;
-
-public class MmsConfig {
- private static final boolean DEBUG = true;
- private static final boolean LOCAL_LOGV = false;
-
- public static final String DEFAULT_HTTP_KEY_X_WAP_PROFILE = "x-wap-profile";
- public static final String DEFAULT_USER_AGENT = "Android-Mms/2.0";
-
- private static final int MAX_IMAGE_HEIGHT = 480;
- private static final int MAX_IMAGE_WIDTH = 640;
- private static final int MAX_TEXT_LENGTH = 2000;
-
- /**
- * Whether to hide MMS functionality from the user (i.e. SMS only).
- */
- private static boolean mTransIdEnabled = false;
- private static boolean mMmsEnabled = true; // default to true
- private static int mMaxMessageSize = 800 * 1024; // default to 800k max size
- private static String mUserAgent = DEFAULT_USER_AGENT;
- private static String mUaProfTagName = DEFAULT_HTTP_KEY_X_WAP_PROFILE;
- private static String mUaProfUrl = null;
- private static String mHttpParams = null;
- private static String mHttpParamsLine1Key = null;
- private static String mEmailGateway = null;
- private static int mMaxImageHeight = MAX_IMAGE_HEIGHT; // default value
- private static int mMaxImageWidth = MAX_IMAGE_WIDTH; // default value
- private static int mRecipientLimit = Integer.MAX_VALUE; // default value
- private static int mDefaultSMSMessagesPerThread = 10000; // default value
- private static int mDefaultMMSMessagesPerThread = 1000; // default value
- private static int mMinMessageCountPerThread = 2; // default value
- private static int mMaxMessageCountPerThread = 5000; // default value
- private static int mHttpSocketTimeout = 60*1000; // default to 1 min
- private static int mMinimumSlideElementDuration = 7; // default to 7 sec
- private static boolean mNotifyWapMMSC = false;
- private static boolean mAllowAttachAudio = true;
-
- // If mEnableMultipartSMS is true, long sms messages are always sent as multi-part sms
- // messages, with no checked limit on the number of segments.
- // If mEnableMultipartSMS is false, then as soon as the user types a message longer
- // than a single segment (i.e. 140 chars), then the message will turn into and be sent
- // as an mms message. This feature exists for carriers that don't support multi-part sms's.
- private static boolean mEnableMultipartSMS = true;
-
- // By default, the radio splits multipart sms, not the application. If the carrier or radio
- // does not support this, and the recipient gets garbled text, set this to true. If this is
- // true and mEnableMultipartSMS is false, the mSmsToMmsTextThreshold will be observed,
- // converting to mms if we reach the required number of segments.
- private static boolean mEnableSplitSMS = false;
-
- // If mEnableMultipartSMS is true and mSmsToMmsTextThreshold > 1, then multi-part SMS messages
- // will be converted into a single mms message. For example, if the mms_config.xml file
- // specifies 4, then on the 5th sms segment, the
- // message will be converted to an mms.
- private static int mSmsToMmsTextThreshold = -1;
-
- private static boolean mEnableSlideDuration = true;
- private static boolean mEnableMMSReadReports = true; // key: "enableMMSReadReports"
- private static boolean mEnableSMSDeliveryReports = true; // key: "enableSMSDeliveryReports"
- private static boolean mEnableMMSDeliveryReports = true; // key: "enableMMSDeliveryReports"
- private static int mMaxTextLength = -1;
-
- // This is the max amount of storage multiplied by mMaxMessageSize that we
- // allow of unsent messages before blocking the user from sending any more
- // MMS's.
- private static int mMaxSizeScaleForPendingMmsAllowed = 4; // default value
-
- // Email gateway alias support, including the master switch and different rules
- private static boolean mAliasEnabled = false;
- private static int mAliasRuleMinChars = 2;
- private static int mAliasRuleMaxChars = 48;
-
- private static int mMaxSubjectLength = 40; // maximum number of characters allowed for mms
- // subject
-
- // If mEnableGroupMms is true, a message with multiple recipients, regardless of contents,
- // will be sent as a single MMS message with multiple "TO" fields set for each recipient.
- // If mEnableGroupMms is false, the group MMS setting/preference will be hidden in the settings
- // activity.
- private static boolean mEnableGroupMms = true;
-
- public static void init(Context context) {
- if (LOCAL_LOGV) {
- Timber.v("MmsConfig.init()");
- }
- // Always put the mnc/mcc in the log so we can tell which mms_config.xml was loaded.
-
- loadMmsSettings(context);
- }
-
- public static boolean getMmsEnabled() {
- return mMmsEnabled;
- }
-
- public static int getMaxMessageSize() {
- if (LOCAL_LOGV) {
- Timber.v("MmsConfig.getMaxMessageSize(): " + mMaxMessageSize);
- }
- return mMaxMessageSize;
- }
-
- /**
- * This function returns the value of "enabledTransID" present in mms_config file.
- * In case of single segment wap push message, this "enabledTransID" indicates whether
- * TransactionID should be appended to URI or not.
- */
- public static boolean getTransIdEnabled() {
- return mTransIdEnabled;
- }
-
- public static String getUserAgent() {
- return mUserAgent;
- }
-
- public static String getUaProfTagName() {
- return mUaProfTagName;
- }
-
- public static String getUaProfUrl() {
- return mUaProfUrl;
- }
-
- public static String getHttpParams() {
- return mHttpParams;
- }
-
- public static String getHttpParamsLine1Key() {
- return mHttpParamsLine1Key;
- }
-
- public static int getHttpSocketTimeout() {
- return mHttpSocketTimeout;
- }
-
- public static boolean getNotifyWapMMSC() {
- return mNotifyWapMMSC;
- }
-
- public static final void beginDocument(XmlPullParser parser, String firstElementName) throws XmlPullParserException, IOException
- {
- int type;
- while ((type=parser.next()) != parser.START_TAG
- && type != parser.END_DOCUMENT) {
- ;
- }
-
- if (type != parser.START_TAG) {
- throw new XmlPullParserException("No start tag found");
- }
-
- if (!parser.getName().equals(firstElementName)) {
- throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() +
- ", expected " + firstElementName);
- }
- }
-
- public static final void nextElement(XmlPullParser parser) throws XmlPullParserException, IOException
- {
- int type;
- while ((type=parser.next()) != parser.START_TAG
- && type != parser.END_DOCUMENT) {
- ;
- }
- }
-
- private static void loadMmsSettings(Context context) {
- XmlResourceParser parser = context.getResources().getXml(R.xml.mms_config);
-
- try {
- beginDocument(parser, "mms_config");
-
- while (true) {
- nextElement(parser);
- String tag = parser.getName();
- if (tag == null) {
- break;
- }
- String name = parser.getAttributeName(0);
- String value = parser.getAttributeValue(0);
- String text = null;
- if (parser.next() == XmlPullParser.TEXT) {
- text = parser.getText();
- }
-
- if (DEBUG) {
- Timber.v("tag: " + tag + " value: " + value + " - " +
- text);
- }
- if ("name".equalsIgnoreCase(name)) {
- if ("bool".equals(tag)) {
- // bool config tags go here
- if ("enabledMMS".equalsIgnoreCase(value)) {
- mMmsEnabled = "true".equalsIgnoreCase(text);
- } else if ("enabledTransID".equalsIgnoreCase(value)) {
- mTransIdEnabled = "true".equalsIgnoreCase(text);
- } else if ("enabledNotifyWapMMSC".equalsIgnoreCase(value)) {
- mNotifyWapMMSC = "true".equalsIgnoreCase(text);
- } else if ("aliasEnabled".equalsIgnoreCase(value)) {
- mAliasEnabled = "true".equalsIgnoreCase(text);
- } else if ("allowAttachAudio".equalsIgnoreCase(value)) {
- mAllowAttachAudio = "true".equalsIgnoreCase(text);
- } else if ("enableMultipartSMS".equalsIgnoreCase(value)) {
- mEnableMultipartSMS = "true".equalsIgnoreCase(text);
- } else if ("enableSplitSMS".equalsIgnoreCase(value)) {
- mEnableSplitSMS = "true".equalsIgnoreCase(text);
- } else if ("enableSlideDuration".equalsIgnoreCase(value)) {
- mEnableSlideDuration = "true".equalsIgnoreCase(text);
- } else if ("enableMMSReadReports".equalsIgnoreCase(value)) {
- mEnableMMSReadReports = "true".equalsIgnoreCase(text);
- } else if ("enableSMSDeliveryReports".equalsIgnoreCase(value)) {
- mEnableSMSDeliveryReports = "true".equalsIgnoreCase(text);
- } else if ("enableMMSDeliveryReports".equalsIgnoreCase(value)) {
- mEnableMMSDeliveryReports = "true".equalsIgnoreCase(text);
- } else if ("enableGroupMms".equalsIgnoreCase(value)) {
- mEnableGroupMms = "true".equalsIgnoreCase(text);
- }
- } else if ("int".equals(tag)) {
- // int config tags go here
- if ("maxMessageSize".equalsIgnoreCase(value)) {
- mMaxMessageSize = Integer.parseInt(text);
- } else if ("maxImageHeight".equalsIgnoreCase(value)) {
- mMaxImageHeight = Integer.parseInt(text);
- } else if ("maxImageWidth".equalsIgnoreCase(value)) {
- mMaxImageWidth = Integer.parseInt(text);
- } else if ("defaultSMSMessagesPerThread".equalsIgnoreCase(value)) {
- mDefaultSMSMessagesPerThread = Integer.parseInt(text);
- } else if ("defaultMMSMessagesPerThread".equalsIgnoreCase(value)) {
- mDefaultMMSMessagesPerThread = Integer.parseInt(text);
- } else if ("minMessageCountPerThread".equalsIgnoreCase(value)) {
- mMinMessageCountPerThread = Integer.parseInt(text);
- } else if ("maxMessageCountPerThread".equalsIgnoreCase(value)) {
- mMaxMessageCountPerThread = Integer.parseInt(text);
- } else if ("recipientLimit".equalsIgnoreCase(value)) {
- mRecipientLimit = Integer.parseInt(text);
- if (mRecipientLimit < 0) {
- mRecipientLimit = Integer.MAX_VALUE;
- }
- } else if ("httpSocketTimeout".equalsIgnoreCase(value)) {
- mHttpSocketTimeout = Integer.parseInt(text);
- } else if ("minimumSlideElementDuration".equalsIgnoreCase(value)) {
- mMinimumSlideElementDuration = Integer.parseInt(text);
- } else if ("maxSizeScaleForPendingMmsAllowed".equalsIgnoreCase(value)) {
- mMaxSizeScaleForPendingMmsAllowed = Integer.parseInt(text);
- } else if ("aliasMinChars".equalsIgnoreCase(value)) {
- mAliasRuleMinChars = Integer.parseInt(text);
- } else if ("aliasMaxChars".equalsIgnoreCase(value)) {
- mAliasRuleMaxChars = Integer.parseInt(text);
- } else if ("smsToMmsTextThreshold".equalsIgnoreCase(value)) {
- mSmsToMmsTextThreshold = Integer.parseInt(text);
- } else if ("maxMessageTextSize".equalsIgnoreCase(value)) {
- mMaxTextLength = Integer.parseInt(text);
- } else if ("maxSubjectLength".equalsIgnoreCase(value)) {
- mMaxSubjectLength = Integer.parseInt(text);
- }
- } else if ("string".equals(tag)) {
- // string config tags go here
- if ("userAgent".equalsIgnoreCase(value)) {
- mUserAgent = text;
- } else if ("uaProfTagName".equalsIgnoreCase(value)) {
- mUaProfTagName = text;
- } else if ("uaProfUrl".equalsIgnoreCase(value)) {
- mUaProfUrl = text;
- } else if ("httpParams".equalsIgnoreCase(value)) {
- mHttpParams = text;
- } else if ("httpParamsLine1Key".equalsIgnoreCase(value)) {
- mHttpParamsLine1Key = text;
- } else if ("emailGatewayNumber".equalsIgnoreCase(value)) {
- mEmailGateway = text;
- }
- }
- }
- }
- } catch (XmlPullParserException e) {
- Timber.e(e, "loadMmsSettings caught ");
- } catch (NumberFormatException e) {
- Timber.e(e, "loadMmsSettings caught ");
- } catch (IOException e) {
- Timber.e(e, "loadMmsSettings caught ");
- } finally {
- parser.close();
- }
-
- String errorStr = null;
-
- if (getMmsEnabled() && mUaProfUrl == null) {
- errorStr = "uaProfUrl";
- }
-
- if (errorStr != null) {
- String err =
- String.format("MmsConfig.loadMmsSettings mms_config.xml missing %s setting",
- errorStr);
- Timber.e(err);
- }
- }
-
- public static void setUserAgent(String userAgent) {
- MmsConfig.mUserAgent = userAgent;
- }
-
- public static void setUaProfUrl(String url) {
- MmsConfig.mUaProfUrl = url;
- }
-
- public static void setUaProfTagName(String tagName) {
- MmsConfig.mUaProfTagName = tagName;
- }
-
-}
+/*
+ * Copyright (C) 2009 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.
+ */
+
+package com.android.mms;
+
+import android.content.Context;
+import android.content.res.XmlResourceParser;
+import com.klinker.android.send_message.R;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import timber.log.Timber;
+
+import java.io.IOException;
+
+public class MmsConfig {
+ private static final boolean DEBUG = true;
+ private static final boolean LOCAL_LOGV = false;
+
+ public static final String DEFAULT_HTTP_KEY_X_WAP_PROFILE = "x-wap-profile";
+ public static final String DEFAULT_USER_AGENT = "Android-Mms/2.0";
+
+ private static final int MAX_IMAGE_HEIGHT = 480;
+ private static final int MAX_IMAGE_WIDTH = 640;
+ private static final int MAX_TEXT_LENGTH = 2000;
+
+ /**
+ * Whether to hide MMS functionality from the user (i.e. SMS only).
+ */
+ private static boolean mTransIdEnabled = false;
+ private static boolean mMmsEnabled = true; // default to true
+ private static int mMaxMessageSize = 800 * 1024; // default to 800k max size
+ private static String mUserAgent = DEFAULT_USER_AGENT;
+ private static String mUaProfTagName = DEFAULT_HTTP_KEY_X_WAP_PROFILE;
+ private static String mUaProfUrl = null;
+ private static String mHttpParams = null;
+ private static String mHttpParamsLine1Key = null;
+ private static String mEmailGateway = null;
+ private static int mMaxImageHeight = MAX_IMAGE_HEIGHT; // default value
+ private static int mMaxImageWidth = MAX_IMAGE_WIDTH; // default value
+ private static int mRecipientLimit = Integer.MAX_VALUE; // default value
+ private static int mDefaultSMSMessagesPerThread = 10000; // default value
+ private static int mDefaultMMSMessagesPerThread = 1000; // default value
+ private static int mMinMessageCountPerThread = 2; // default value
+ private static int mMaxMessageCountPerThread = 5000; // default value
+ private static int mHttpSocketTimeout = 60*1000; // default to 1 min
+ private static int mMinimumSlideElementDuration = 7; // default to 7 sec
+ private static boolean mNotifyWapMMSC = false;
+ private static boolean mAllowAttachAudio = true;
+
+ // If mEnableMultipartSMS is true, long sms messages are always sent as multi-part sms
+ // messages, with no checked limit on the number of segments.
+ // If mEnableMultipartSMS is false, then as soon as the user types a message longer
+ // than a single segment (i.e. 140 chars), then the message will turn into and be sent
+ // as an mms message. This feature exists for carriers that don't support multi-part sms's.
+ private static boolean mEnableMultipartSMS = true;
+
+ // By default, the radio splits multipart sms, not the application. If the carrier or radio
+ // does not support this, and the recipient gets garbled text, set this to true. If this is
+ // true and mEnableMultipartSMS is false, the mSmsToMmsTextThreshold will be observed,
+ // converting to mms if we reach the required number of segments.
+ private static boolean mEnableSplitSMS = false;
+
+ // If mEnableMultipartSMS is true and mSmsToMmsTextThreshold > 1, then multi-part SMS messages
+ // will be converted into a single mms message. For example, if the mms_config.xml file
+ // specifies 4, then on the 5th sms segment, the
+ // message will be converted to an mms.
+ private static int mSmsToMmsTextThreshold = -1;
+
+ private static boolean mEnableSlideDuration = true;
+ private static boolean mEnableMMSReadReports = true; // key: "enableMMSReadReports"
+ private static boolean mEnableSMSDeliveryReports = true; // key: "enableSMSDeliveryReports"
+ private static boolean mEnableMMSDeliveryReports = true; // key: "enableMMSDeliveryReports"
+ private static int mMaxTextLength = -1;
+
+ // This is the max amount of storage multiplied by mMaxMessageSize that we
+ // allow of unsent messages before blocking the user from sending any more
+ // MMS's.
+ private static int mMaxSizeScaleForPendingMmsAllowed = 4; // default value
+
+ // Email gateway alias support, including the master switch and different rules
+ private static boolean mAliasEnabled = false;
+ private static int mAliasRuleMinChars = 2;
+ private static int mAliasRuleMaxChars = 48;
+
+ private static int mMaxSubjectLength = 40; // maximum number of characters allowed for mms
+ // subject
+
+ // If mEnableGroupMms is true, a message with multiple recipients, regardless of contents,
+ // will be sent as a single MMS message with multiple "TO" fields set for each recipient.
+ // If mEnableGroupMms is false, the group MMS setting/preference will be hidden in the settings
+ // activity.
+ private static boolean mEnableGroupMms = true;
+
+ public static void init(Context context) {
+ if (LOCAL_LOGV) {
+ Timber.v("MmsConfig.init()");
+ }
+ // Always put the mnc/mcc in the log so we can tell which mms_config.xml was loaded.
+
+ loadMmsSettings(context);
+ }
+
+ public static boolean getMmsEnabled() {
+ return mMmsEnabled;
+ }
+
+ public static int getMaxMessageSize() {
+ if (LOCAL_LOGV) {
+ Timber.v("MmsConfig.getMaxMessageSize(): " + mMaxMessageSize);
+ }
+ return mMaxMessageSize;
+ }
+
+ /**
+ * This function returns the value of "enabledTransID" present in mms_config file.
+ * In case of single segment wap push message, this "enabledTransID" indicates whether
+ * TransactionID should be appended to URI or not.
+ */
+ public static boolean getTransIdEnabled() {
+ return mTransIdEnabled;
+ }
+
+ public static String getUserAgent() {
+ return mUserAgent;
+ }
+
+ public static String getUaProfTagName() {
+ return mUaProfTagName;
+ }
+
+ public static String getUaProfUrl() {
+ return mUaProfUrl;
+ }
+
+ public static String getHttpParams() {
+ return mHttpParams;
+ }
+
+ public static String getHttpParamsLine1Key() {
+ return mHttpParamsLine1Key;
+ }
+
+ public static int getHttpSocketTimeout() {
+ return mHttpSocketTimeout;
+ }
+
+ public static boolean getNotifyWapMMSC() {
+ return mNotifyWapMMSC;
+ }
+
+ public static final void beginDocument(XmlPullParser parser, String firstElementName) throws XmlPullParserException, IOException
+ {
+ int type;
+ while ((type=parser.next()) != parser.START_TAG
+ && type != parser.END_DOCUMENT) {
+ ;
+ }
+
+ if (type != parser.START_TAG) {
+ throw new XmlPullParserException("No start tag found");
+ }
+
+ if (!parser.getName().equals(firstElementName)) {
+ throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() +
+ ", expected " + firstElementName);
+ }
+ }
+
+ public static final void nextElement(XmlPullParser parser) throws XmlPullParserException, IOException
+ {
+ int type;
+ while ((type=parser.next()) != parser.START_TAG
+ && type != parser.END_DOCUMENT) {
+ ;
+ }
+ }
+
+ private static void loadMmsSettings(Context context) {
+ XmlResourceParser parser = context.getResources().getXml(R.xml.mms_config);
+
+ try {
+ beginDocument(parser, "mms_config");
+
+ while (true) {
+ nextElement(parser);
+ String tag = parser.getName();
+ if (tag == null) {
+ break;
+ }
+ String name = parser.getAttributeName(0);
+ String value = parser.getAttributeValue(0);
+ String text = null;
+ if (parser.next() == XmlPullParser.TEXT) {
+ text = parser.getText();
+ }
+
+ if (DEBUG) {
+ Timber.v("tag: " + tag + " value: " + value + " - " +
+ text);
+ }
+ if ("name".equalsIgnoreCase(name)) {
+ if ("bool".equals(tag)) {
+ // bool config tags go here
+ if ("enabledMMS".equalsIgnoreCase(value)) {
+ mMmsEnabled = "true".equalsIgnoreCase(text);
+ } else if ("enabledTransID".equalsIgnoreCase(value)) {
+ mTransIdEnabled = "true".equalsIgnoreCase(text);
+ } else if ("enabledNotifyWapMMSC".equalsIgnoreCase(value)) {
+ mNotifyWapMMSC = "true".equalsIgnoreCase(text);
+ } else if ("aliasEnabled".equalsIgnoreCase(value)) {
+ mAliasEnabled = "true".equalsIgnoreCase(text);
+ } else if ("allowAttachAudio".equalsIgnoreCase(value)) {
+ mAllowAttachAudio = "true".equalsIgnoreCase(text);
+ } else if ("enableMultipartSMS".equalsIgnoreCase(value)) {
+ mEnableMultipartSMS = "true".equalsIgnoreCase(text);
+ } else if ("enableSplitSMS".equalsIgnoreCase(value)) {
+ mEnableSplitSMS = "true".equalsIgnoreCase(text);
+ } else if ("enableSlideDuration".equalsIgnoreCase(value)) {
+ mEnableSlideDuration = "true".equalsIgnoreCase(text);
+ } else if ("enableMMSReadReports".equalsIgnoreCase(value)) {
+ mEnableMMSReadReports = "true".equalsIgnoreCase(text);
+ } else if ("enableSMSDeliveryReports".equalsIgnoreCase(value)) {
+ mEnableSMSDeliveryReports = "true".equalsIgnoreCase(text);
+ } else if ("enableMMSDeliveryReports".equalsIgnoreCase(value)) {
+ mEnableMMSDeliveryReports = "true".equalsIgnoreCase(text);
+ } else if ("enableGroupMms".equalsIgnoreCase(value)) {
+ mEnableGroupMms = "true".equalsIgnoreCase(text);
+ }
+ } else if ("int".equals(tag)) {
+ // int config tags go here
+ if ("maxMessageSize".equalsIgnoreCase(value)) {
+ mMaxMessageSize = Integer.parseInt(text);
+ } else if ("maxImageHeight".equalsIgnoreCase(value)) {
+ mMaxImageHeight = Integer.parseInt(text);
+ } else if ("maxImageWidth".equalsIgnoreCase(value)) {
+ mMaxImageWidth = Integer.parseInt(text);
+ } else if ("defaultSMSMessagesPerThread".equalsIgnoreCase(value)) {
+ mDefaultSMSMessagesPerThread = Integer.parseInt(text);
+ } else if ("defaultMMSMessagesPerThread".equalsIgnoreCase(value)) {
+ mDefaultMMSMessagesPerThread = Integer.parseInt(text);
+ } else if ("minMessageCountPerThread".equalsIgnoreCase(value)) {
+ mMinMessageCountPerThread = Integer.parseInt(text);
+ } else if ("maxMessageCountPerThread".equalsIgnoreCase(value)) {
+ mMaxMessageCountPerThread = Integer.parseInt(text);
+ } else if ("recipientLimit".equalsIgnoreCase(value)) {
+ mRecipientLimit = Integer.parseInt(text);
+ if (mRecipientLimit < 0) {
+ mRecipientLimit = Integer.MAX_VALUE;
+ }
+ } else if ("httpSocketTimeout".equalsIgnoreCase(value)) {
+ mHttpSocketTimeout = Integer.parseInt(text);
+ } else if ("minimumSlideElementDuration".equalsIgnoreCase(value)) {
+ mMinimumSlideElementDuration = Integer.parseInt(text);
+ } else if ("maxSizeScaleForPendingMmsAllowed".equalsIgnoreCase(value)) {
+ mMaxSizeScaleForPendingMmsAllowed = Integer.parseInt(text);
+ } else if ("aliasMinChars".equalsIgnoreCase(value)) {
+ mAliasRuleMinChars = Integer.parseInt(text);
+ } else if ("aliasMaxChars".equalsIgnoreCase(value)) {
+ mAliasRuleMaxChars = Integer.parseInt(text);
+ } else if ("smsToMmsTextThreshold".equalsIgnoreCase(value)) {
+ mSmsToMmsTextThreshold = Integer.parseInt(text);
+ } else if ("maxMessageTextSize".equalsIgnoreCase(value)) {
+ mMaxTextLength = Integer.parseInt(text);
+ } else if ("maxSubjectLength".equalsIgnoreCase(value)) {
+ mMaxSubjectLength = Integer.parseInt(text);
+ }
+ } else if ("string".equals(tag)) {
+ // string config tags go here
+ if ("userAgent".equalsIgnoreCase(value)) {
+ mUserAgent = text;
+ } else if ("uaProfTagName".equalsIgnoreCase(value)) {
+ mUaProfTagName = text;
+ } else if ("uaProfUrl".equalsIgnoreCase(value)) {
+ mUaProfUrl = text;
+ } else if ("httpParams".equalsIgnoreCase(value)) {
+ mHttpParams = text;
+ } else if ("httpParamsLine1Key".equalsIgnoreCase(value)) {
+ mHttpParamsLine1Key = text;
+ } else if ("emailGatewayNumber".equalsIgnoreCase(value)) {
+ mEmailGateway = text;
+ }
+ }
+ }
+ }
+ } catch (XmlPullParserException e) {
+ Timber.e(e, "loadMmsSettings caught ");
+ } catch (NumberFormatException e) {
+ Timber.e(e, "loadMmsSettings caught ");
+ } catch (IOException e) {
+ Timber.e(e, "loadMmsSettings caught ");
+ } finally {
+ parser.close();
+ }
+
+ String errorStr = null;
+
+ if (getMmsEnabled() && mUaProfUrl == null) {
+ errorStr = "uaProfUrl";
+ }
+
+ if (errorStr != null) {
+ String err =
+ String.format("MmsConfig.loadMmsSettings mms_config.xml missing %s setting",
+ errorStr);
+ Timber.e(err);
+ }
+ }
+
+ public static void setUserAgent(String userAgent) {
+ MmsConfig.mUserAgent = userAgent;
+ }
+
+ public static void setUaProfUrl(String url) {
+ MmsConfig.mUaProfUrl = url;
+ }
+
+ public static void setUaProfTagName(String tagName) {
+ MmsConfig.mUaProfTagName = tagName;
+ }
+
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/AttrImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/AttrImpl.java
index ead639c41..8ff7c442b 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/AttrImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/AttrImpl.java
@@ -1,108 +1,108 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.TypeInfo;
-
-public class AttrImpl extends NodeImpl implements Attr {
- private String mName;
- private String mValue;
-
- /*
- * Internal methods
- */
-
- protected AttrImpl(DocumentImpl owner, String name) {
- super(owner);
- mName = name;
- }
-
- /*
- * Attr Interface Methods
- */
-
- public String getName() {
- return mName;
- }
-
- public Element getOwnerElement() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean getSpecified() {
- return mValue != null;
- }
-
- public String getValue() {
- return mValue;
- }
-
- // Instead of setting a Text> with the content of the
- // String value as defined in the specs, we directly set here the
- // internal mValue member.
- public void setValue(String value) throws DOMException {
- mValue = value;
- }
-
- /*
- * Node Interface Methods
- */
-
- @Override
- public String getNodeName() {
- return mName;
- }
-
- @Override
- public short getNodeType() {
- return Node.ATTRIBUTE_NODE;
- }
-
- @Override
- public Node getParentNode() {
- return null;
- }
-
- @Override
- public Node getPreviousSibling() {
- return null;
- }
-
- @Override
- public Node getNextSibling() {
- return null;
- }
-
- @Override
- public void setNodeValue(String nodeValue) throws DOMException {
- setValue(nodeValue);
- }
-
- public TypeInfo getSchemaTypeInfo() {
- return null;
- }
-
- public boolean isId() {
- return false;
- }
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.TypeInfo;
+
+public class AttrImpl extends NodeImpl implements Attr {
+ private String mName;
+ private String mValue;
+
+ /*
+ * Internal methods
+ */
+
+ protected AttrImpl(DocumentImpl owner, String name) {
+ super(owner);
+ mName = name;
+ }
+
+ /*
+ * Attr Interface Methods
+ */
+
+ public String getName() {
+ return mName;
+ }
+
+ public Element getOwnerElement() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean getSpecified() {
+ return mValue != null;
+ }
+
+ public String getValue() {
+ return mValue;
+ }
+
+ // Instead of setting a Text> with the content of the
+ // String value as defined in the specs, we directly set here the
+ // internal mValue member.
+ public void setValue(String value) throws DOMException {
+ mValue = value;
+ }
+
+ /*
+ * Node Interface Methods
+ */
+
+ @Override
+ public String getNodeName() {
+ return mName;
+ }
+
+ @Override
+ public short getNodeType() {
+ return Node.ATTRIBUTE_NODE;
+ }
+
+ @Override
+ public Node getParentNode() {
+ return null;
+ }
+
+ @Override
+ public Node getPreviousSibling() {
+ return null;
+ }
+
+ @Override
+ public Node getNextSibling() {
+ return null;
+ }
+
+ @Override
+ public void setNodeValue(String nodeValue) throws DOMException {
+ setValue(nodeValue);
+ }
+
+ public TypeInfo getSchemaTypeInfo() {
+ return null;
+ }
+
+ public boolean isId() {
+ return false;
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/DocumentImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/DocumentImpl.java
index aeeb51e37..5d0da1c42 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/DocumentImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/DocumentImpl.java
@@ -1,194 +1,194 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DOMConfiguration;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-public abstract class DocumentImpl extends NodeImpl implements Document {
-
- /*
- * Internal methods
- */
-
- public DocumentImpl() {
- super(null);
- }
-
- /*
- * Document Interface Methods
- */
-
- public Attr createAttribute(String name) throws DOMException {
- return new AttrImpl(this, name);
- }
-
- public Attr createAttributeNS(String namespaceURI, String qualifiedName)
- throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public CDATASection createCDATASection(String data) throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Comment createComment(String data) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public DocumentFragment createDocumentFragment() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public abstract Element createElement(String tagName) throws DOMException;
-
- public Element createElementNS(String namespaceURI, String qualifiedName)
- throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public EntityReference createEntityReference(String name) throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public ProcessingInstruction createProcessingInstruction(String target, String data)
- throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Text createTextNode(String data) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public DocumentType getDoctype() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public abstract Element getDocumentElement();
-
- public Element getElementById(String elementId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NodeList getElementsByTagName(String tagname) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public DOMImplementation getImplementation() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Node importNode(Node importedNode, boolean deep) throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * Node Interface methods
- */
-
- @Override
- public short getNodeType() {
- return Node.DOCUMENT_NODE;
- }
-
- @Override
- public String getNodeName() {
- // The value of nodeName is "#document" when Node is a Document
- return "#document";
- }
-
- public String getInputEncoding() {
- return null;
- }
-
- public String getXmlEncoding() {
- return null;
- }
-
- public boolean getXmlStandalone() {
- return false;
- }
-
- public void setXmlStandalone(boolean xmlStandalone) throws DOMException {}
-
- public String getXmlVersion() {
- return null;
- }
-
- public void setXmlVersion(String xmlVersion) throws DOMException {}
-
- public boolean getStrictErrorChecking() {
- return true;
- }
-
- public void setStrictErrorChecking(boolean strictErrorChecking) {}
-
- public String getDocumentURI() {
- return null;
- }
-
- public void setDocumentURI(String documentURI) {}
-
- public Node adoptNode(Node source) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public DOMConfiguration getDomConfig() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public void normalizeDocument() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public Node renameNode(Node n, String namespaceURI, String qualifiedName)
- throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+
+public abstract class DocumentImpl extends NodeImpl implements Document {
+
+ /*
+ * Internal methods
+ */
+
+ public DocumentImpl() {
+ super(null);
+ }
+
+ /*
+ * Document Interface Methods
+ */
+
+ public Attr createAttribute(String name) throws DOMException {
+ return new AttrImpl(this, name);
+ }
+
+ public Attr createAttributeNS(String namespaceURI, String qualifiedName)
+ throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public CDATASection createCDATASection(String data) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Comment createComment(String data) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DocumentFragment createDocumentFragment() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public abstract Element createElement(String tagName) throws DOMException;
+
+ public Element createElementNS(String namespaceURI, String qualifiedName)
+ throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public EntityReference createEntityReference(String name) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ProcessingInstruction createProcessingInstruction(String target, String data)
+ throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Text createTextNode(String data) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DocumentType getDoctype() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public abstract Element getDocumentElement();
+
+ public Element getElementById(String elementId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NodeList getElementsByTagName(String tagname) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DOMImplementation getImplementation() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Node importNode(Node importedNode, boolean deep) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * Node Interface methods
+ */
+
+ @Override
+ public short getNodeType() {
+ return Node.DOCUMENT_NODE;
+ }
+
+ @Override
+ public String getNodeName() {
+ // The value of nodeName is "#document" when Node is a Document
+ return "#document";
+ }
+
+ public String getInputEncoding() {
+ return null;
+ }
+
+ public String getXmlEncoding() {
+ return null;
+ }
+
+ public boolean getXmlStandalone() {
+ return false;
+ }
+
+ public void setXmlStandalone(boolean xmlStandalone) throws DOMException {}
+
+ public String getXmlVersion() {
+ return null;
+ }
+
+ public void setXmlVersion(String xmlVersion) throws DOMException {}
+
+ public boolean getStrictErrorChecking() {
+ return true;
+ }
+
+ public void setStrictErrorChecking(boolean strictErrorChecking) {}
+
+ public String getDocumentURI() {
+ return null;
+ }
+
+ public void setDocumentURI(String documentURI) {}
+
+ public Node adoptNode(Node source) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public DOMConfiguration getDomConfig() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public void normalizeDocument() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public Node renameNode(Node n, String namespaceURI, String qualifiedName)
+ throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/ElementImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/ElementImpl.java
index bad35ef7b..41512df6f 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/ElementImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/ElementImpl.java
@@ -1,172 +1,172 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.TypeInfo;
-
-public class ElementImpl extends NodeImpl implements Element {
- private String mTagName;
- private NamedNodeMap mAttributes = new NamedNodeMapImpl();
-
- /*
- * Internal methods
- */
-
- protected ElementImpl(DocumentImpl owner, String tagName) {
- super(owner);
- mTagName = tagName;
- }
-
- /*
- * Element Interface methods
- */
-
- public String getAttribute(String name) {
- Attr attrNode = getAttributeNode(name);
- String attrValue = "";
- if (attrNode != null) {
- attrValue = attrNode.getValue();
- }
- return attrValue;
- }
-
- public String getAttributeNS(String namespaceURI, String localName) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Attr getAttributeNode(String name) {
- return (Attr)mAttributes.getNamedItem(name);
- }
-
- public Attr getAttributeNodeNS(String namespaceURI, String localName) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NodeList getElementsByTagName(String name) {
- return new NodeListImpl(this, name, true);
- }
-
- public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getTagName() {
- return mTagName;
- }
-
- public boolean hasAttribute(String name) {
- return (getAttributeNode(name) != null);
- }
-
- public boolean hasAttributeNS(String namespaceURI, String localName) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void removeAttribute(String name) throws DOMException {
- // TODO Auto-generated method stub
-
- }
-
- public void removeAttributeNS(String namespaceURI, String localName)
- throws DOMException {
- // TODO Auto-generated method stub
-
- }
-
- public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setAttribute(String name, String value) throws DOMException {
- Attr attribute = getAttributeNode(name);
- if (attribute == null) {
- attribute = mOwnerDocument.createAttribute(name);
- }
- attribute.setNodeValue(value);
- mAttributes.setNamedItem(attribute);
- }
-
- public void setAttributeNS(String namespaceURI, String qualifiedName,
- String value) throws DOMException {
- // TODO Auto-generated method stub
-
- }
-
- public Attr setAttributeNode(Attr newAttr) throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * Node Interface methods
- */
-
- @Override
- public short getNodeType() {
- return ELEMENT_NODE;
- }
-
- @Override
- public String getNodeName() {
- // The value of nodeName is tagName when Node is an Element
- return mTagName;
- }
-
- @Override
- public NamedNodeMap getAttributes() {
- return mAttributes;
- }
-
- @Override
- public boolean hasAttributes() {
- return (mAttributes.getLength() > 0);
- }
-
- public TypeInfo getSchemaTypeInfo() {
- return null;
- }
-
- public void setIdAttribute(String name, boolean isId) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public void setIdAttributeNS(String namespaceURI, String localName,
- boolean isId) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public void setIdAttributeNode(Attr idAttr, boolean isId)
- throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.TypeInfo;
+
+public class ElementImpl extends NodeImpl implements Element {
+ private String mTagName;
+ private NamedNodeMap mAttributes = new NamedNodeMapImpl();
+
+ /*
+ * Internal methods
+ */
+
+ protected ElementImpl(DocumentImpl owner, String tagName) {
+ super(owner);
+ mTagName = tagName;
+ }
+
+ /*
+ * Element Interface methods
+ */
+
+ public String getAttribute(String name) {
+ Attr attrNode = getAttributeNode(name);
+ String attrValue = "";
+ if (attrNode != null) {
+ attrValue = attrNode.getValue();
+ }
+ return attrValue;
+ }
+
+ public String getAttributeNS(String namespaceURI, String localName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Attr getAttributeNode(String name) {
+ return (Attr)mAttributes.getNamedItem(name);
+ }
+
+ public Attr getAttributeNodeNS(String namespaceURI, String localName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NodeList getElementsByTagName(String name) {
+ return new NodeListImpl(this, name, true);
+ }
+
+ public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getTagName() {
+ return mTagName;
+ }
+
+ public boolean hasAttribute(String name) {
+ return (getAttributeNode(name) != null);
+ }
+
+ public boolean hasAttributeNS(String namespaceURI, String localName) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void removeAttribute(String name) throws DOMException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeAttributeNS(String namespaceURI, String localName)
+ throws DOMException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setAttribute(String name, String value) throws DOMException {
+ Attr attribute = getAttributeNode(name);
+ if (attribute == null) {
+ attribute = mOwnerDocument.createAttribute(name);
+ }
+ attribute.setNodeValue(value);
+ mAttributes.setNamedItem(attribute);
+ }
+
+ public void setAttributeNS(String namespaceURI, String qualifiedName,
+ String value) throws DOMException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Attr setAttributeNode(Attr newAttr) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * Node Interface methods
+ */
+
+ @Override
+ public short getNodeType() {
+ return ELEMENT_NODE;
+ }
+
+ @Override
+ public String getNodeName() {
+ // The value of nodeName is tagName when Node is an Element
+ return mTagName;
+ }
+
+ @Override
+ public NamedNodeMap getAttributes() {
+ return mAttributes;
+ }
+
+ @Override
+ public boolean hasAttributes() {
+ return (mAttributes.getLength() > 0);
+ }
+
+ public TypeInfo getSchemaTypeInfo() {
+ return null;
+ }
+
+ public void setIdAttribute(String name, boolean isId) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public void setIdAttributeNS(String namespaceURI, String localName,
+ boolean isId) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public void setIdAttributeNode(Attr idAttr, boolean isId)
+ throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/NamedNodeMapImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/NamedNodeMapImpl.java
index c08d44c47..617528fc1 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/NamedNodeMapImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/NamedNodeMapImpl.java
@@ -1,87 +1,87 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom;
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-import java.util.Vector;
-
-public class NamedNodeMapImpl implements NamedNodeMap {
-
- private Vector mNodes = new Vector();
-
- public int getLength() {
- return mNodes.size();
- }
-
- public Node getNamedItem(String name) {
- Node node = null;
- for (int i = 0; i < mNodes.size(); i++) {
- if (name.equals(mNodes.elementAt(i).getNodeName())) {
- node = mNodes.elementAt(i);
- break;
- }
- }
- return node;
- }
-
- public Node getNamedItemNS(String namespaceURI, String localName) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Node item(int index) {
- if (index < mNodes.size()) {
- return mNodes.elementAt(index);
- }
- return null;
- }
-
- public Node removeNamedItem(String name) throws DOMException {
- Node node = getNamedItem(name);
- if (node == null) {
- throw new DOMException(DOMException.NOT_FOUND_ERR, "Not found");
- } else {
- mNodes.remove(node);
- }
- return node;
- }
-
- public Node removeNamedItemNS(String namespaceURI, String localName)
- throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Node setNamedItem(Node arg) throws DOMException {
- Node existing = getNamedItem(arg.getNodeName());
- if (existing != null) {
- mNodes.remove(existing);
- }
- mNodes.add(arg);
- return existing;
- }
-
- public Node setNamedItemNS(Node arg) throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import java.util.Vector;
+
+public class NamedNodeMapImpl implements NamedNodeMap {
+
+ private Vector mNodes = new Vector();
+
+ public int getLength() {
+ return mNodes.size();
+ }
+
+ public Node getNamedItem(String name) {
+ Node node = null;
+ for (int i = 0; i < mNodes.size(); i++) {
+ if (name.equals(mNodes.elementAt(i).getNodeName())) {
+ node = mNodes.elementAt(i);
+ break;
+ }
+ }
+ return node;
+ }
+
+ public Node getNamedItemNS(String namespaceURI, String localName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Node item(int index) {
+ if (index < mNodes.size()) {
+ return mNodes.elementAt(index);
+ }
+ return null;
+ }
+
+ public Node removeNamedItem(String name) throws DOMException {
+ Node node = getNamedItem(name);
+ if (node == null) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "Not found");
+ } else {
+ mNodes.remove(node);
+ }
+ return node;
+ }
+
+ public Node removeNamedItemNS(String namespaceURI, String localName)
+ throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Node setNamedItem(Node arg) throws DOMException {
+ Node existing = getNamedItem(arg.getNodeName());
+ if (existing != null) {
+ mNodes.remove(existing);
+ }
+ mNodes.add(arg);
+ return existing;
+ }
+
+ public Node setNamedItemNS(Node arg) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/NodeImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/NodeImpl.java
index d21bfa1a0..42599713e 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/NodeImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/NodeImpl.java
@@ -1,272 +1,272 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom;
-
-import com.android.mms.dom.events.EventTargetImpl;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.UserDataHandler;
-import org.w3c.dom.events.Event;
-import org.w3c.dom.events.EventException;
-import org.w3c.dom.events.EventListener;
-import org.w3c.dom.events.EventTarget;
-
-import java.util.NoSuchElementException;
-import java.util.Vector;
-
-public abstract class NodeImpl implements Node, EventTarget {
- private Node mParentNode;
- private final Vector mChildNodes = new Vector();
- DocumentImpl mOwnerDocument;
- private final EventTarget mEventTarget = new EventTargetImpl(this);
-
- /*
- * Internal methods
- */
-
- protected NodeImpl(DocumentImpl owner) {
- mOwnerDocument = owner;
- }
-
- /*
- * Node Interface Methods
- */
-
- public Node appendChild(Node newChild) throws DOMException {
- ((NodeImpl)newChild).setParentNode(this);
- mChildNodes.remove(newChild);
- mChildNodes.add(newChild);
- return newChild;
- }
-
- public Node cloneNode(boolean deep) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public NamedNodeMap getAttributes() {
- // Default. Override in Element.
- return null;
- }
-
- public NodeList getChildNodes() {
- return new NodeListImpl(this, null, false);
- }
-
- public Node getFirstChild() {
- Node firstChild = null;
- try {
- firstChild = mChildNodes.firstElement();
- }
- catch (NoSuchElementException e) {
- // Ignore and return null
- }
- return firstChild;
- }
-
- public Node getLastChild() {
- Node lastChild = null;
- try {
- lastChild = mChildNodes.lastElement();
- }
- catch (NoSuchElementException e) {
- // Ignore and return null
- }
- return lastChild;
- }
-
- public String getLocalName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getNamespaceURI() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Node getNextSibling() {
- if ((mParentNode != null) && (this != mParentNode.getLastChild())) {
- Vector siblings = ((NodeImpl)mParentNode).mChildNodes;
- int indexOfThis = siblings.indexOf(this);
- return siblings.elementAt(indexOfThis + 1);
- }
- return null;
- }
-
- public abstract String getNodeName();
-
- public abstract short getNodeType();
-
- public String getNodeValue() throws DOMException {
- // Default behaviour. Override if required.
- return null;
- }
-
- public Document getOwnerDocument() {
- return mOwnerDocument;
- }
-
- public Node getParentNode() {
- return mParentNode;
- }
-
- public String getPrefix() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Node getPreviousSibling() {
- if ((mParentNode != null) && (this != mParentNode.getFirstChild())) {
- Vector siblings = ((NodeImpl)mParentNode).mChildNodes;
- int indexOfThis = siblings.indexOf(this);
- return siblings.elementAt(indexOfThis - 1);
- }
- return null;
- }
-
- public boolean hasAttributes() {
- // Default. Override in Element.
- return false;
- }
-
- public boolean hasChildNodes() {
- return !(mChildNodes.isEmpty());
- }
-
- public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isSupported(String feature, String version) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void normalize() {
- // TODO Auto-generated method stub
- }
-
- public Node removeChild(Node oldChild) throws DOMException {
- if (mChildNodes.contains(oldChild)) {
- mChildNodes.remove(oldChild);
- ((NodeImpl)oldChild).setParentNode(null);
- } else {
- throw new DOMException(DOMException.NOT_FOUND_ERR, "Child does not exist");
- }
- return null;
- }
-
- public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
- if (mChildNodes.contains(oldChild)) {
- // Try to remove the new child if available
- try {
- mChildNodes.remove(newChild);
- } catch (DOMException e) {
- // Ignore exception
- }
- mChildNodes.setElementAt(newChild, mChildNodes.indexOf(oldChild));
- ((NodeImpl)newChild).setParentNode(this);
- ((NodeImpl)oldChild).setParentNode(null);
- } else {
- throw new DOMException(DOMException.NOT_FOUND_ERR, "Old child does not exist");
- }
- return oldChild;
- }
-
- public void setNodeValue(String nodeValue) throws DOMException {
- // Default behaviour. Override if required.
- }
-
- public void setPrefix(String prefix) throws DOMException {
- // TODO Auto-generated method stub
- }
-
- private void setParentNode(Node parentNode) {
- mParentNode = parentNode;
- }
-
- /*
- * EventTarget Interface
- */
-
- public void addEventListener(String type, EventListener listener, boolean useCapture) {
- mEventTarget.addEventListener(type, listener, useCapture);
- }
-
- public void removeEventListener(String type, EventListener listener, boolean useCapture) {
- mEventTarget.removeEventListener(type, listener, useCapture);
- }
-
- public boolean dispatchEvent(Event evt) throws EventException {
- return mEventTarget.dispatchEvent(evt);
- }
-
- public String getBaseURI() {
- return null;
- }
-
- public short compareDocumentPosition(Node other) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public String getTextContent() throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public void setTextContent(String textContent) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public boolean isSameNode(Node other) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public String lookupPrefix(String namespaceURI) {
- return null;
- }
-
- public boolean isDefaultNamespace(String namespaceURI) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public String lookupNamespaceURI(String prefix) {
- return null;
- }
-
- public boolean isEqualNode(Node arg) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public Object getFeature(String feature, String version) {
- return null;
- }
-
- public Object setUserData(String key, Object data,
- UserDataHandler handler) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
- }
-
- public Object getUserData(String key) {
- return null;
- }
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom;
+
+import com.android.mms.dom.events.EventTargetImpl;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.UserDataHandler;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventException;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+
+import java.util.NoSuchElementException;
+import java.util.Vector;
+
+public abstract class NodeImpl implements Node, EventTarget {
+ private Node mParentNode;
+ private final Vector mChildNodes = new Vector();
+ DocumentImpl mOwnerDocument;
+ private final EventTarget mEventTarget = new EventTargetImpl(this);
+
+ /*
+ * Internal methods
+ */
+
+ protected NodeImpl(DocumentImpl owner) {
+ mOwnerDocument = owner;
+ }
+
+ /*
+ * Node Interface Methods
+ */
+
+ public Node appendChild(Node newChild) throws DOMException {
+ ((NodeImpl)newChild).setParentNode(this);
+ mChildNodes.remove(newChild);
+ mChildNodes.add(newChild);
+ return newChild;
+ }
+
+ public Node cloneNode(boolean deep) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public NamedNodeMap getAttributes() {
+ // Default. Override in Element.
+ return null;
+ }
+
+ public NodeList getChildNodes() {
+ return new NodeListImpl(this, null, false);
+ }
+
+ public Node getFirstChild() {
+ Node firstChild = null;
+ try {
+ firstChild = mChildNodes.firstElement();
+ }
+ catch (NoSuchElementException e) {
+ // Ignore and return null
+ }
+ return firstChild;
+ }
+
+ public Node getLastChild() {
+ Node lastChild = null;
+ try {
+ lastChild = mChildNodes.lastElement();
+ }
+ catch (NoSuchElementException e) {
+ // Ignore and return null
+ }
+ return lastChild;
+ }
+
+ public String getLocalName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getNamespaceURI() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Node getNextSibling() {
+ if ((mParentNode != null) && (this != mParentNode.getLastChild())) {
+ Vector siblings = ((NodeImpl)mParentNode).mChildNodes;
+ int indexOfThis = siblings.indexOf(this);
+ return siblings.elementAt(indexOfThis + 1);
+ }
+ return null;
+ }
+
+ public abstract String getNodeName();
+
+ public abstract short getNodeType();
+
+ public String getNodeValue() throws DOMException {
+ // Default behaviour. Override if required.
+ return null;
+ }
+
+ public Document getOwnerDocument() {
+ return mOwnerDocument;
+ }
+
+ public Node getParentNode() {
+ return mParentNode;
+ }
+
+ public String getPrefix() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Node getPreviousSibling() {
+ if ((mParentNode != null) && (this != mParentNode.getFirstChild())) {
+ Vector siblings = ((NodeImpl)mParentNode).mChildNodes;
+ int indexOfThis = siblings.indexOf(this);
+ return siblings.elementAt(indexOfThis - 1);
+ }
+ return null;
+ }
+
+ public boolean hasAttributes() {
+ // Default. Override in Element.
+ return false;
+ }
+
+ public boolean hasChildNodes() {
+ return !(mChildNodes.isEmpty());
+ }
+
+ public Node insertBefore(Node newChild, Node refChild) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isSupported(String feature, String version) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void normalize() {
+ // TODO Auto-generated method stub
+ }
+
+ public Node removeChild(Node oldChild) throws DOMException {
+ if (mChildNodes.contains(oldChild)) {
+ mChildNodes.remove(oldChild);
+ ((NodeImpl)oldChild).setParentNode(null);
+ } else {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "Child does not exist");
+ }
+ return null;
+ }
+
+ public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
+ if (mChildNodes.contains(oldChild)) {
+ // Try to remove the new child if available
+ try {
+ mChildNodes.remove(newChild);
+ } catch (DOMException e) {
+ // Ignore exception
+ }
+ mChildNodes.setElementAt(newChild, mChildNodes.indexOf(oldChild));
+ ((NodeImpl)newChild).setParentNode(this);
+ ((NodeImpl)oldChild).setParentNode(null);
+ } else {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "Old child does not exist");
+ }
+ return oldChild;
+ }
+
+ public void setNodeValue(String nodeValue) throws DOMException {
+ // Default behaviour. Override if required.
+ }
+
+ public void setPrefix(String prefix) throws DOMException {
+ // TODO Auto-generated method stub
+ }
+
+ private void setParentNode(Node parentNode) {
+ mParentNode = parentNode;
+ }
+
+ /*
+ * EventTarget Interface
+ */
+
+ public void addEventListener(String type, EventListener listener, boolean useCapture) {
+ mEventTarget.addEventListener(type, listener, useCapture);
+ }
+
+ public void removeEventListener(String type, EventListener listener, boolean useCapture) {
+ mEventTarget.removeEventListener(type, listener, useCapture);
+ }
+
+ public boolean dispatchEvent(Event evt) throws EventException {
+ return mEventTarget.dispatchEvent(evt);
+ }
+
+ public String getBaseURI() {
+ return null;
+ }
+
+ public short compareDocumentPosition(Node other) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public String getTextContent() throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public void setTextContent(String textContent) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public boolean isSameNode(Node other) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public String lookupPrefix(String namespaceURI) {
+ return null;
+ }
+
+ public boolean isDefaultNamespace(String namespaceURI) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public String lookupNamespaceURI(String prefix) {
+ return null;
+ }
+
+ public boolean isEqualNode(Node arg) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public Object getFeature(String feature, String version) {
+ return null;
+ }
+
+ public Object setUserData(String key, Object data,
+ UserDataHandler handler) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, null);
+ }
+
+ public Object getUserData(String key) {
+ return null;
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/NodeListImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/NodeListImpl.java
index 809388961..5a91cfce8 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/NodeListImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/NodeListImpl.java
@@ -1,128 +1,128 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.ArrayList;
-
-public class NodeListImpl implements NodeList {
- private ArrayList mSearchNodes;
- private ArrayList mStaticNodes;
- private Node mRootNode;
- private String mTagName;
- private boolean mDeepSearch;
-
- /*
- * Internal Interface
- */
-
- /**
- * Constructs a NodeList by searching for all descendants or the direct
- * children of a root node with a given tag name.
- * @param rootNode The root Node of the search.
- * @param tagName The tag name to be searched for. If null, all descendants
- * will be returned.
- * @param deep Limit the search to the direct children of rootNode if false,
- * to all descendants otherwise.
- */
- public NodeListImpl(Node rootNode, String tagName, boolean deepSearch) {
- mRootNode = rootNode;
- mTagName = tagName;
- mDeepSearch = deepSearch;
- }
-
- /**
- * Constructs a NodeList for a given static node list.
- * @param nodes The static node list.
- */
- public NodeListImpl(ArrayList nodes) {
- mStaticNodes = nodes;
- }
-
- /*
- * NodeListImpl Interface
- */
-
- public int getLength() {
- if (mStaticNodes == null) {
- fillList(mRootNode);
- return mSearchNodes.size();
- } else {
- return mStaticNodes.size();
- }
- }
-
- public Node item(int index) {
- Node node = null;
- if (mStaticNodes == null) {
- fillList(mRootNode);
- try {
- node = mSearchNodes.get(index);
- } catch (IndexOutOfBoundsException e) {
- // Do nothing and return null
- }
- } else {
- try {
- node = mStaticNodes.get(index);
- } catch (IndexOutOfBoundsException e) {
- // Do nothing and return null
- }
- }
- return node;
- }
-
- /**
- * A preorder traversal is done in the following order:
- *
- *
Visit root.
- *
Traverse children from left to right in preorder.
- *
- * This method fills the live node list.
- * @param The root of preorder traversal
- * @return The next match
- */
- private void fillList(Node node) {
- // (Re)-initialize the container if this is the start of the search.
- // Visit the root of this iteration otherwise.
- if (node == mRootNode) {
- mSearchNodes = new ArrayList();
- } else {
- if ((mTagName == null) || node.getNodeName().equals(mTagName)) {
- mSearchNodes.add(node);
- }
- }
-
- // Descend one generation...
- node = node.getFirstChild();
-
- // ...and visit in preorder the children if we are in deep search
- // or directly add the children to the list otherwise.
- while (node != null) {
- if (mDeepSearch) {
- fillList(node);
- } else {
- if ((mTagName == null) || node.getNodeName().equals(mTagName)) {
- mSearchNodes.add(node);
- }
- }
- node = node.getNextSibling();
- }
- }
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.ArrayList;
+
+public class NodeListImpl implements NodeList {
+ private ArrayList mSearchNodes;
+ private ArrayList mStaticNodes;
+ private Node mRootNode;
+ private String mTagName;
+ private boolean mDeepSearch;
+
+ /*
+ * Internal Interface
+ */
+
+ /**
+ * Constructs a NodeList by searching for all descendants or the direct
+ * children of a root node with a given tag name.
+ * @param rootNode The root Node of the search.
+ * @param tagName The tag name to be searched for. If null, all descendants
+ * will be returned.
+ * @param deep Limit the search to the direct children of rootNode if false,
+ * to all descendants otherwise.
+ */
+ public NodeListImpl(Node rootNode, String tagName, boolean deepSearch) {
+ mRootNode = rootNode;
+ mTagName = tagName;
+ mDeepSearch = deepSearch;
+ }
+
+ /**
+ * Constructs a NodeList for a given static node list.
+ * @param nodes The static node list.
+ */
+ public NodeListImpl(ArrayList nodes) {
+ mStaticNodes = nodes;
+ }
+
+ /*
+ * NodeListImpl Interface
+ */
+
+ public int getLength() {
+ if (mStaticNodes == null) {
+ fillList(mRootNode);
+ return mSearchNodes.size();
+ } else {
+ return mStaticNodes.size();
+ }
+ }
+
+ public Node item(int index) {
+ Node node = null;
+ if (mStaticNodes == null) {
+ fillList(mRootNode);
+ try {
+ node = mSearchNodes.get(index);
+ } catch (IndexOutOfBoundsException e) {
+ // Do nothing and return null
+ }
+ } else {
+ try {
+ node = mStaticNodes.get(index);
+ } catch (IndexOutOfBoundsException e) {
+ // Do nothing and return null
+ }
+ }
+ return node;
+ }
+
+ /**
+ * A preorder traversal is done in the following order:
+ *
+ *
Visit root.
+ *
Traverse children from left to right in preorder.
+ *
+ * This method fills the live node list.
+ * @param The root of preorder traversal
+ * @return The next match
+ */
+ private void fillList(Node node) {
+ // (Re)-initialize the container if this is the start of the search.
+ // Visit the root of this iteration otherwise.
+ if (node == mRootNode) {
+ mSearchNodes = new ArrayList();
+ } else {
+ if ((mTagName == null) || node.getNodeName().equals(mTagName)) {
+ mSearchNodes.add(node);
+ }
+ }
+
+ // Descend one generation...
+ node = node.getFirstChild();
+
+ // ...and visit in preorder the children if we are in deep search
+ // or directly add the children to the list otherwise.
+ while (node != null) {
+ if (mDeepSearch) {
+ fillList(node);
+ } else {
+ if ((mTagName == null) || node.getNodeName().equals(mTagName)) {
+ mSearchNodes.add(node);
+ }
+ }
+ node = node.getNextSibling();
+ }
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/events/EventImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/events/EventImpl.java
index 24fc908fa..2cfb88b40 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/events/EventImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/events/EventImpl.java
@@ -1,127 +1,127 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom.events;
-
-import org.w3c.dom.events.Event;
-import org.w3c.dom.events.EventTarget;
-
-public class EventImpl implements Event {
-
- // Event type informations
- private String mEventType;
- private boolean mCanBubble;
- private boolean mCancelable;
-
- // Flags whether the event type information was set
- // FIXME: Can we use mEventType for this purpose?
- private boolean mInitialized;
-
- // Target of this event
- private EventTarget mTarget;
-
- // Event status variables
- private short mEventPhase;
- private boolean mStopPropagation;
- private boolean mPreventDefault;
- private EventTarget mCurrentTarget;
- private int mSeekTo;
-
- private final long mTimeStamp = System.currentTimeMillis();
-
- public boolean getBubbles() {
- return mCanBubble;
- }
-
- public boolean getCancelable() {
- return mCancelable;
- }
-
- public EventTarget getCurrentTarget() {
- return mCurrentTarget;
- }
-
- public short getEventPhase() {
- return mEventPhase;
- }
-
- public EventTarget getTarget() {
- return mTarget;
- }
-
- public long getTimeStamp() {
- return mTimeStamp;
- }
-
- public String getType() {
- return mEventType;
- }
-
- public void initEvent(String eventTypeArg, boolean canBubbleArg,
- boolean cancelableArg) {
- mEventType = eventTypeArg;
- mCanBubble = canBubbleArg;
- mCancelable = cancelableArg;
- mInitialized = true;
- }
-
- public void initEvent(String eventTypeArg, boolean canBubbleArg, boolean cancelableArg,
- int seekTo) {
- mSeekTo = seekTo;
- initEvent(eventTypeArg, canBubbleArg, cancelableArg);
- }
-
- public void preventDefault() {
- mPreventDefault = true;
- }
-
- public void stopPropagation() {
- mStopPropagation = true;
- }
-
- /*
- * Internal Interface
- */
-
- boolean isInitialized() {
- return mInitialized;
- }
-
- boolean isPreventDefault() {
- return mPreventDefault;
- }
-
- boolean isPropogationStopped() {
- return mStopPropagation;
- }
-
- void setTarget(EventTarget target) {
- mTarget = target;
- }
-
- void setEventPhase(short eventPhase) {
- mEventPhase = eventPhase;
- }
-
- void setCurrentTarget(EventTarget currentTarget) {
- mCurrentTarget = currentTarget;
- }
-
- public int getSeekTo() {
- return mSeekTo;
- }
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom.events;
+
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventTarget;
+
+public class EventImpl implements Event {
+
+ // Event type informations
+ private String mEventType;
+ private boolean mCanBubble;
+ private boolean mCancelable;
+
+ // Flags whether the event type information was set
+ // FIXME: Can we use mEventType for this purpose?
+ private boolean mInitialized;
+
+ // Target of this event
+ private EventTarget mTarget;
+
+ // Event status variables
+ private short mEventPhase;
+ private boolean mStopPropagation;
+ private boolean mPreventDefault;
+ private EventTarget mCurrentTarget;
+ private int mSeekTo;
+
+ private final long mTimeStamp = System.currentTimeMillis();
+
+ public boolean getBubbles() {
+ return mCanBubble;
+ }
+
+ public boolean getCancelable() {
+ return mCancelable;
+ }
+
+ public EventTarget getCurrentTarget() {
+ return mCurrentTarget;
+ }
+
+ public short getEventPhase() {
+ return mEventPhase;
+ }
+
+ public EventTarget getTarget() {
+ return mTarget;
+ }
+
+ public long getTimeStamp() {
+ return mTimeStamp;
+ }
+
+ public String getType() {
+ return mEventType;
+ }
+
+ public void initEvent(String eventTypeArg, boolean canBubbleArg,
+ boolean cancelableArg) {
+ mEventType = eventTypeArg;
+ mCanBubble = canBubbleArg;
+ mCancelable = cancelableArg;
+ mInitialized = true;
+ }
+
+ public void initEvent(String eventTypeArg, boolean canBubbleArg, boolean cancelableArg,
+ int seekTo) {
+ mSeekTo = seekTo;
+ initEvent(eventTypeArg, canBubbleArg, cancelableArg);
+ }
+
+ public void preventDefault() {
+ mPreventDefault = true;
+ }
+
+ public void stopPropagation() {
+ mStopPropagation = true;
+ }
+
+ /*
+ * Internal Interface
+ */
+
+ boolean isInitialized() {
+ return mInitialized;
+ }
+
+ boolean isPreventDefault() {
+ return mPreventDefault;
+ }
+
+ boolean isPropogationStopped() {
+ return mStopPropagation;
+ }
+
+ void setTarget(EventTarget target) {
+ mTarget = target;
+ }
+
+ void setEventPhase(short eventPhase) {
+ mEventPhase = eventPhase;
+ }
+
+ void setCurrentTarget(EventTarget currentTarget) {
+ mCurrentTarget = currentTarget;
+ }
+
+ public int getSeekTo() {
+ return mSeekTo;
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/events/EventTargetImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/events/EventTargetImpl.java
index 9317d1f40..8cbe72b72 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/events/EventTargetImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/events/EventTargetImpl.java
@@ -1,128 +1,128 @@
-/*
- * Copyright 2014 Jacob Klinker
- *
- * 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.
- */
-
-package com.android.mms.dom.events;
-
-import org.w3c.dom.events.Event;
-import org.w3c.dom.events.EventException;
-import org.w3c.dom.events.EventListener;
-import org.w3c.dom.events.EventTarget;
-import timber.log.Timber;
-
-import java.util.ArrayList;
-
-public class EventTargetImpl implements EventTarget {
- private ArrayList mListenerEntries;
- private EventTarget mNodeTarget;
-
- static class EventListenerEntry
- {
- final String mType;
- final EventListener mListener;
- final boolean mUseCapture;
-
- EventListenerEntry(String type, EventListener listener, boolean useCapture)
- {
- mType = type;
- mListener = listener;
- mUseCapture = useCapture;
- }
- }
-
- public EventTargetImpl(EventTarget target) {
- mNodeTarget = target;
- }
-
- public void addEventListener(String type, EventListener listener, boolean useCapture) {
- if ((type == null) || type.equals("") || (listener == null)) {
- return;
- }
-
- // Make sure we have only one entry
- removeEventListener(type, listener, useCapture);
-
- if (mListenerEntries == null) {
- mListenerEntries = new ArrayList();
- }
- mListenerEntries.add(new EventListenerEntry(type, listener, useCapture));
- }
-
- public boolean dispatchEvent(Event evt) throws EventException {
- // We need to use the internal APIs to modify and access the event status
- EventImpl eventImpl = (EventImpl)evt;
-
- if (!eventImpl.isInitialized()) {
- throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR,
- "Event not initialized");
- } else if ((eventImpl.getType() == null) || eventImpl.getType().equals("")) {
- throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR,
- "Unspecified even type");
- }
-
- // Initialize event status
- eventImpl.setTarget(mNodeTarget);
-
- // TODO: At this point, to support event capturing and bubbling, we should
- // establish the chain of EventTargets from the top of the tree to this
- // event's target.
-
- // TODO: CAPTURING_PHASE skipped
-
- // Handle AT_TARGET
- // Invoke handleEvent of non-capturing listeners on this EventTarget.
- eventImpl.setEventPhase(Event.AT_TARGET);
- eventImpl.setCurrentTarget(mNodeTarget);
- if (!eventImpl.isPropogationStopped() && (mListenerEntries != null)) {
- for (int i = 0; i < mListenerEntries.size(); i++) {
- EventListenerEntry listenerEntry = mListenerEntries.get(i);
- if (!listenerEntry.mUseCapture
- && listenerEntry.mType.equals(eventImpl.getType())) {
- try {
- listenerEntry.mListener.handleEvent(eventImpl);
- }
- catch (Exception e) {
- // Any exceptions thrown inside an EventListener will
- // not stop propagation of the event
- Timber.w(e, "Catched EventListener exception");
- }
- }
- }
- }
-
- if (eventImpl.getBubbles()) {
- // TODO: BUBBLING_PHASE skipped
- }
-
- return eventImpl.isPreventDefault();
- }
-
- public void removeEventListener(String type, EventListener listener,
- boolean useCapture) {
- if (null == mListenerEntries) {
- return;
- }
- for (int i = 0; i < mListenerEntries.size(); i ++) {
- EventListenerEntry listenerEntry = mListenerEntries.get(i);
- if ((listenerEntry.mUseCapture == useCapture)
- && (listenerEntry.mListener == listener)
- && listenerEntry.mType.equals(type)) {
- mListenerEntries.remove(i);
- break;
- }
- }
- }
-
-}
+/*
+ * Copyright 2014 Jacob Klinker
+ *
+ * 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.
+ */
+
+package com.android.mms.dom.events;
+
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventException;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;
+import timber.log.Timber;
+
+import java.util.ArrayList;
+
+public class EventTargetImpl implements EventTarget {
+ private ArrayList mListenerEntries;
+ private EventTarget mNodeTarget;
+
+ static class EventListenerEntry
+ {
+ final String mType;
+ final EventListener mListener;
+ final boolean mUseCapture;
+
+ EventListenerEntry(String type, EventListener listener, boolean useCapture)
+ {
+ mType = type;
+ mListener = listener;
+ mUseCapture = useCapture;
+ }
+ }
+
+ public EventTargetImpl(EventTarget target) {
+ mNodeTarget = target;
+ }
+
+ public void addEventListener(String type, EventListener listener, boolean useCapture) {
+ if ((type == null) || type.equals("") || (listener == null)) {
+ return;
+ }
+
+ // Make sure we have only one entry
+ removeEventListener(type, listener, useCapture);
+
+ if (mListenerEntries == null) {
+ mListenerEntries = new ArrayList();
+ }
+ mListenerEntries.add(new EventListenerEntry(type, listener, useCapture));
+ }
+
+ public boolean dispatchEvent(Event evt) throws EventException {
+ // We need to use the internal APIs to modify and access the event status
+ EventImpl eventImpl = (EventImpl)evt;
+
+ if (!eventImpl.isInitialized()) {
+ throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR,
+ "Event not initialized");
+ } else if ((eventImpl.getType() == null) || eventImpl.getType().equals("")) {
+ throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR,
+ "Unspecified even type");
+ }
+
+ // Initialize event status
+ eventImpl.setTarget(mNodeTarget);
+
+ // TODO: At this point, to support event capturing and bubbling, we should
+ // establish the chain of EventTargets from the top of the tree to this
+ // event's target.
+
+ // TODO: CAPTURING_PHASE skipped
+
+ // Handle AT_TARGET
+ // Invoke handleEvent of non-capturing listeners on this EventTarget.
+ eventImpl.setEventPhase(Event.AT_TARGET);
+ eventImpl.setCurrentTarget(mNodeTarget);
+ if (!eventImpl.isPropogationStopped() && (mListenerEntries != null)) {
+ for (int i = 0; i < mListenerEntries.size(); i++) {
+ EventListenerEntry listenerEntry = mListenerEntries.get(i);
+ if (!listenerEntry.mUseCapture
+ && listenerEntry.mType.equals(eventImpl.getType())) {
+ try {
+ listenerEntry.mListener.handleEvent(eventImpl);
+ }
+ catch (Exception e) {
+ // Any exceptions thrown inside an EventListener will
+ // not stop propagation of the event
+ Timber.w(e, "Catched EventListener exception");
+ }
+ }
+ }
+ }
+
+ if (eventImpl.getBubbles()) {
+ // TODO: BUBBLING_PHASE skipped
+ }
+
+ return eventImpl.isPreventDefault();
+ }
+
+ public void removeEventListener(String type, EventListener listener,
+ boolean useCapture) {
+ if (null == mListenerEntries) {
+ return;
+ }
+ for (int i = 0; i < mListenerEntries.size(); i ++) {
+ EventListenerEntry listenerEntry = mListenerEntries.get(i);
+ if ((listenerEntry.mUseCapture == useCapture)
+ && (listenerEntry.mListener == listener)
+ && listenerEntry.mType.equals(type)) {
+ mListenerEntries.remove(i);
+ break;
+ }
+ }
+ }
+
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementParallelTimeContainerImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementParallelTimeContainerImpl.java
index 13be9f2c5..a8acbaf09 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementParallelTimeContainerImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementParallelTimeContainerImpl.java
@@ -1,154 +1,154 @@
-/*
- * Copyright (C) 2007-2008 Esmertec AG.
- * Copyright (C) 2007-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.
- * 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.
- */
-
-package com.android.mms.dom.smil;
-
-import com.android.mms.dom.NodeListImpl;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.smil.ElementParallelTimeContainer;
-import org.w3c.dom.smil.ElementTime;
-import org.w3c.dom.smil.SMILElement;
-import org.w3c.dom.smil.Time;
-import org.w3c.dom.smil.TimeList;
-
-import java.util.ArrayList;
-
-public abstract class ElementParallelTimeContainerImpl extends ElementTimeContainerImpl
- implements ElementParallelTimeContainer {
- private final static String ENDSYNC_ATTRIBUTE_NAME = "endsync";
- private final static String ENDSYNC_FIRST = "first";
- private final static String ENDSYNC_LAST = "last";
- private final static String ENDSYNC_ALL = "all";
- private final static String ENDSYNC_MEDIA = "media";
-
- /*
- * Internal Interface
- */
-
- ElementParallelTimeContainerImpl(SMILElement element) {
- super(element);
- }
-
- public String getEndSync() {
- String endsync = mSmilElement.getAttribute(ENDSYNC_ATTRIBUTE_NAME);
- if ((endsync == null) || (endsync.length() == 0)) {
- setEndSync(ENDSYNC_LAST);
- return ENDSYNC_LAST;
- }
- if (ENDSYNC_FIRST.equals(endsync) || ENDSYNC_LAST.equals(endsync) ||
- ENDSYNC_ALL.equals(endsync) || ENDSYNC_MEDIA.equals(endsync)) {
- return endsync;
- }
-
- // FIXME add the checking for ID-Value and smil1.0-Id-value.
-
- setEndSync(ENDSYNC_LAST);
- return ENDSYNC_LAST;
- }
-
- public void setEndSync(String endSync) throws DOMException {
- if (ENDSYNC_FIRST.equals(endSync) || ENDSYNC_LAST.equals(endSync) ||
- ENDSYNC_ALL.equals(endSync) || ENDSYNC_MEDIA.equals(endSync)) {
- mSmilElement.setAttribute(ENDSYNC_ATTRIBUTE_NAME, endSync);
- } else { // FIXME add the support for ID-Value and smil1.0-Id-value.
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
- "Unsupported endsync value" + endSync);
- }
- }
-
- @Override
- public float getDur() {
- float dur = super.getDur();
- if (dur == 0) {
- dur = getImplicitDuration();
- }
- return dur;
- }
-
- public float getImplicitDuration() {
- float dur = -1.0F;
- if (ENDSYNC_LAST.equals(getEndSync())) {
- NodeList children = getTimeChildren();
- for (int i = 0; i < children.getLength(); ++i) {
- ElementTime child = (ElementTime) children.item(i);
- TimeList endTimeList = child.getEnd();
- for (int j = 0; j < endTimeList.getLength(); ++j) {
- Time endTime = endTimeList.item(j);
- if (endTime.getTimeType() == Time.SMIL_TIME_INDEFINITE) {
- // Return "indefinite" here.
- return -1.0F;
- }
- if (endTime.getResolved()) {
- float end = (float)endTime.getResolvedOffset();
- dur = (end > dur) ? end : dur;
- }
- }
- }
- } // Other endsync types are not supported now.
-
- return dur;
- }
-
- public NodeList getActiveChildrenAt(float instant) {
- /*
- * Find the closest Time of ElementTime before instant.
- * Add ElementTime to list of active elements if the Time belongs to the begin-list,
- * do not add it otherwise.
- */
- ArrayList activeChildren = new ArrayList();
- NodeList children = getTimeChildren();
- int childrenLen = children.getLength();
- for (int i = 0; i < childrenLen; ++i) {
- double maxOffset = 0.0;
- boolean active = false;
- ElementTime child = (ElementTime) children.item(i);
-
- TimeList beginList = child.getBegin();
- int len = beginList.getLength();
- for (int j = 0; j < len; ++j) {
- Time begin = beginList.item(j);
- if (begin.getResolved()) {
- double resolvedOffset = begin.getResolvedOffset() * 1000.0;
- if ((resolvedOffset <= instant) && (resolvedOffset >= maxOffset)) {
- maxOffset = resolvedOffset;
- active = true;
- }
- }
- }
-
- TimeList endList = child.getEnd();
- len = endList.getLength();
- for (int j = 0; j < len; ++j) {
- Time end = endList.item(j);
- if (end.getResolved()) {
- double resolvedOffset = end.getResolvedOffset() * 1000.0;
- if ((resolvedOffset <= instant) && (resolvedOffset >= maxOffset)) {
- maxOffset = resolvedOffset;
- active = false;
- }
- }
- }
-
- if (active) {
- activeChildren.add((Node) child);
- }
- }
- return new NodeListImpl(activeChildren);
- }
-}
+/*
+ * Copyright (C) 2007-2008 Esmertec AG.
+ * Copyright (C) 2007-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.
+ * 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.
+ */
+
+package com.android.mms.dom.smil;
+
+import com.android.mms.dom.NodeListImpl;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.smil.ElementParallelTimeContainer;
+import org.w3c.dom.smil.ElementTime;
+import org.w3c.dom.smil.SMILElement;
+import org.w3c.dom.smil.Time;
+import org.w3c.dom.smil.TimeList;
+
+import java.util.ArrayList;
+
+public abstract class ElementParallelTimeContainerImpl extends ElementTimeContainerImpl
+ implements ElementParallelTimeContainer {
+ private final static String ENDSYNC_ATTRIBUTE_NAME = "endsync";
+ private final static String ENDSYNC_FIRST = "first";
+ private final static String ENDSYNC_LAST = "last";
+ private final static String ENDSYNC_ALL = "all";
+ private final static String ENDSYNC_MEDIA = "media";
+
+ /*
+ * Internal Interface
+ */
+
+ ElementParallelTimeContainerImpl(SMILElement element) {
+ super(element);
+ }
+
+ public String getEndSync() {
+ String endsync = mSmilElement.getAttribute(ENDSYNC_ATTRIBUTE_NAME);
+ if ((endsync == null) || (endsync.length() == 0)) {
+ setEndSync(ENDSYNC_LAST);
+ return ENDSYNC_LAST;
+ }
+ if (ENDSYNC_FIRST.equals(endsync) || ENDSYNC_LAST.equals(endsync) ||
+ ENDSYNC_ALL.equals(endsync) || ENDSYNC_MEDIA.equals(endsync)) {
+ return endsync;
+ }
+
+ // FIXME add the checking for ID-Value and smil1.0-Id-value.
+
+ setEndSync(ENDSYNC_LAST);
+ return ENDSYNC_LAST;
+ }
+
+ public void setEndSync(String endSync) throws DOMException {
+ if (ENDSYNC_FIRST.equals(endSync) || ENDSYNC_LAST.equals(endSync) ||
+ ENDSYNC_ALL.equals(endSync) || ENDSYNC_MEDIA.equals(endSync)) {
+ mSmilElement.setAttribute(ENDSYNC_ATTRIBUTE_NAME, endSync);
+ } else { // FIXME add the support for ID-Value and smil1.0-Id-value.
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
+ "Unsupported endsync value" + endSync);
+ }
+ }
+
+ @Override
+ public float getDur() {
+ float dur = super.getDur();
+ if (dur == 0) {
+ dur = getImplicitDuration();
+ }
+ return dur;
+ }
+
+ public float getImplicitDuration() {
+ float dur = -1.0F;
+ if (ENDSYNC_LAST.equals(getEndSync())) {
+ NodeList children = getTimeChildren();
+ for (int i = 0; i < children.getLength(); ++i) {
+ ElementTime child = (ElementTime) children.item(i);
+ TimeList endTimeList = child.getEnd();
+ for (int j = 0; j < endTimeList.getLength(); ++j) {
+ Time endTime = endTimeList.item(j);
+ if (endTime.getTimeType() == Time.SMIL_TIME_INDEFINITE) {
+ // Return "indefinite" here.
+ return -1.0F;
+ }
+ if (endTime.getResolved()) {
+ float end = (float)endTime.getResolvedOffset();
+ dur = (end > dur) ? end : dur;
+ }
+ }
+ }
+ } // Other endsync types are not supported now.
+
+ return dur;
+ }
+
+ public NodeList getActiveChildrenAt(float instant) {
+ /*
+ * Find the closest Time of ElementTime before instant.
+ * Add ElementTime to list of active elements if the Time belongs to the begin-list,
+ * do not add it otherwise.
+ */
+ ArrayList activeChildren = new ArrayList();
+ NodeList children = getTimeChildren();
+ int childrenLen = children.getLength();
+ for (int i = 0; i < childrenLen; ++i) {
+ double maxOffset = 0.0;
+ boolean active = false;
+ ElementTime child = (ElementTime) children.item(i);
+
+ TimeList beginList = child.getBegin();
+ int len = beginList.getLength();
+ for (int j = 0; j < len; ++j) {
+ Time begin = beginList.item(j);
+ if (begin.getResolved()) {
+ double resolvedOffset = begin.getResolvedOffset() * 1000.0;
+ if ((resolvedOffset <= instant) && (resolvedOffset >= maxOffset)) {
+ maxOffset = resolvedOffset;
+ active = true;
+ }
+ }
+ }
+
+ TimeList endList = child.getEnd();
+ len = endList.getLength();
+ for (int j = 0; j < len; ++j) {
+ Time end = endList.item(j);
+ if (end.getResolved()) {
+ double resolvedOffset = end.getResolvedOffset() * 1000.0;
+ if ((resolvedOffset <= instant) && (resolvedOffset >= maxOffset)) {
+ maxOffset = resolvedOffset;
+ active = false;
+ }
+ }
+ }
+
+ if (active) {
+ activeChildren.add((Node) child);
+ }
+ }
+ return new NodeListImpl(activeChildren);
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementSequentialTimeContainerImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementSequentialTimeContainerImpl.java
index 801ae527d..6bfd20506 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementSequentialTimeContainerImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementSequentialTimeContainerImpl.java
@@ -1,72 +1,72 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom.smil;
-
-import com.android.mms.dom.NodeListImpl;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.smil.ElementSequentialTimeContainer;
-import org.w3c.dom.smil.ElementTime;
-import org.w3c.dom.smil.SMILElement;
-
-import java.util.ArrayList;
-
-public abstract class ElementSequentialTimeContainerImpl extends
- ElementTimeContainerImpl implements ElementSequentialTimeContainer {
-
- /*
- * Internal Interface
- */
-
- ElementSequentialTimeContainerImpl(SMILElement element) {
- super(element);
- }
-
- /*
- * ElementSequentialTimeContainer Interface
- */
-
- public NodeList getActiveChildrenAt(float instant) {
- NodeList allChildren = this.getTimeChildren();
- ArrayList nodes = new ArrayList();
- for (int i = 0; i < allChildren.getLength(); i++) {
- instant -= ((ElementTime) allChildren.item(i)).getDur();
- if (instant < 0) {
- nodes.add(allChildren.item(i));
- return new NodeListImpl(nodes);
- }
- }
- return new NodeListImpl(nodes);
- }
-
- public float getDur() {
- float dur = super.getDur();
- if (dur == 0) {
- NodeList children = getTimeChildren();
- for (int i = 0; i < children.getLength(); ++i) {
- ElementTime child = (ElementTime) children.item(i);
- if (child.getDur() < 0) {
- // Return "indefinite" since containing a child whose duration is indefinite.
- return -1.0F;
- }
- dur += child.getDur();
- }
- }
- return dur;
- }
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom.smil;
+
+import com.android.mms.dom.NodeListImpl;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.smil.ElementSequentialTimeContainer;
+import org.w3c.dom.smil.ElementTime;
+import org.w3c.dom.smil.SMILElement;
+
+import java.util.ArrayList;
+
+public abstract class ElementSequentialTimeContainerImpl extends
+ ElementTimeContainerImpl implements ElementSequentialTimeContainer {
+
+ /*
+ * Internal Interface
+ */
+
+ ElementSequentialTimeContainerImpl(SMILElement element) {
+ super(element);
+ }
+
+ /*
+ * ElementSequentialTimeContainer Interface
+ */
+
+ public NodeList getActiveChildrenAt(float instant) {
+ NodeList allChildren = this.getTimeChildren();
+ ArrayList nodes = new ArrayList();
+ for (int i = 0; i < allChildren.getLength(); i++) {
+ instant -= ((ElementTime) allChildren.item(i)).getDur();
+ if (instant < 0) {
+ nodes.add(allChildren.item(i));
+ return new NodeListImpl(nodes);
+ }
+ }
+ return new NodeListImpl(nodes);
+ }
+
+ public float getDur() {
+ float dur = super.getDur();
+ if (dur == 0) {
+ NodeList children = getTimeChildren();
+ for (int i = 0; i < children.getLength(); ++i) {
+ ElementTime child = (ElementTime) children.item(i);
+ if (child.getDur() < 0) {
+ // Return "indefinite" since containing a child whose duration is indefinite.
+ return -1.0F;
+ }
+ dur += child.getDur();
+ }
+ }
+ return dur;
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementTimeContainerImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementTimeContainerImpl.java
index eca14cf31..bcf9d6120 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementTimeContainerImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementTimeContainerImpl.java
@@ -1,33 +1,33 @@
-/*
- * Copyright (C) 2007 Esmertec AG.
- * Copyright (C) 2007 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.
- */
-
-package com.android.mms.dom.smil;
-
-import org.w3c.dom.smil.ElementTimeContainer;
-import org.w3c.dom.smil.SMILElement;
-
-public abstract class ElementTimeContainerImpl extends ElementTimeImpl implements
- ElementTimeContainer {
-
- /*
- * Internal Interface
- */
-
- ElementTimeContainerImpl(SMILElement element) {
- super(element);
- }
-}
+/*
+ * Copyright (C) 2007 Esmertec AG.
+ * Copyright (C) 2007 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.
+ */
+
+package com.android.mms.dom.smil;
+
+import org.w3c.dom.smil.ElementTimeContainer;
+import org.w3c.dom.smil.SMILElement;
+
+public abstract class ElementTimeContainerImpl extends ElementTimeImpl implements
+ ElementTimeContainer {
+
+ /*
+ * Internal Interface
+ */
+
+ ElementTimeContainerImpl(SMILElement element) {
+ super(element);
+ }
+}
diff --git a/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementTimeImpl.java b/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementTimeImpl.java
index 7bee39013..e78df88f5 100755
--- a/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementTimeImpl.java
+++ b/android-smsmms/src/main/java/com/android/mms/dom/smil/ElementTimeImpl.java
@@ -1,345 +1,345 @@
-/*
- * Copyright 2014 Jacob Klinker
- *
- * 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.
- */
-
-package com.android.mms.dom.smil;
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.smil.ElementTime;
-import org.w3c.dom.smil.SMILElement;
-import org.w3c.dom.smil.Time;
-import org.w3c.dom.smil.TimeList;
-import timber.log.Timber;
-
-import java.util.ArrayList;
-
-public abstract class ElementTimeImpl implements ElementTime {
-
- private static final String FILL_REMOVE_ATTRIBUTE = "remove";
- private static final String FILL_FREEZE_ATTRIBUTE = "freeze";
- private static final String FILL_HOLD_ATTRIBUTE = "hold";
- private static final String FILL_TRANSITION_ATTRIBUTE = "transition";
- private static final String FILL_AUTO_ATTRIBUTE = "auto";
- private static final String FILL_ATTRIBUTE_NAME = "fill";
- private static final String FILLDEFAULT_ATTRIBUTE_NAME = "fillDefault";
-
- final SMILElement mSmilElement;
-
- /*
- * Internal Interface
- */
- ElementTimeImpl(SMILElement element) {
- mSmilElement = element;
- }
-
- // Default implementation. Override if required.
- int getBeginConstraints() {
- return TimeImpl.ALLOW_ALL;
- }
-
- // Default implementation. Override if required
- int getEndConstraints() {
- return TimeImpl.ALLOW_ALL;
- }
-
- /**
- * To get the parent node on the ElementTime tree. It is in opposition to getTimeChildren.
- * @return the parent ElementTime. Returns null if there is no parent.
- */
- abstract ElementTime getParentElementTime();
-
- /*
- * ElementTime Interface
- */
-
- public TimeList getBegin() {
- String[] beginTimeStringList = mSmilElement.getAttribute("begin").split(";");
-
- // TODO: Check other constraints on parsed values, e.g., "single, non-negative offset values
- ArrayList