├── settings.gradle ├── 1.png ├── 2.png ├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── answer_call.xml │ │ │ │ └── answer_message.xml │ │ ├── java │ │ │ └── com │ │ │ │ ├── jp │ │ │ │ └── autoanswercalls │ │ │ │ │ ├── receiver │ │ │ │ │ ├── AutoAnswerBootReceiver.java │ │ │ │ │ ├── AutoAnswerCallReceiver.java │ │ │ │ │ └── AutoAnswerMessageReceiver.java │ │ │ │ │ ├── activity │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ ├── AnswerCallActivity.java │ │ │ │ │ └── AnswerMessageActivity.java │ │ │ │ │ ├── utils │ │ │ │ │ ├── ToastUtils.java │ │ │ │ │ └── Constants.java │ │ │ │ │ └── service │ │ │ │ │ ├── AutoAnswerMessageIntentService.java │ │ │ │ │ └── AutoAnswerCallIntentService.java │ │ │ │ └── android │ │ │ │ └── internal │ │ │ │ └── telephony │ │ │ │ └── ITelephony.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── jp │ │ │ └── autoanswercalls │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── jp │ │ └── autoanswercalls │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── .gitignore ├── gradle.properties ├── .travis.yml ├── gradlew.bat ├── gradlew └── LICENSE /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp1017/AutoAnswerCalls/HEAD/1.png -------------------------------------------------------------------------------- /2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp1017/AutoAnswerCalls/HEAD/2.png -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | !/build/outputs/mapping/release/* 3 | *.iml -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AutoAnswerCalls 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp1017/AutoAnswerCalls/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp1017/AutoAnswerCalls/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp1017/AutoAnswerCalls/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp1017/AutoAnswerCalls/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp1017/AutoAnswerCalls/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jp1017/AutoAnswerCalls/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## AutoAnswerCalls 2 | --- 3 | 4 | [![Build Status](https://travis-ci.org/jp1017/AutoAnswerCalls.svg?branch=master)](https://travis-ci.org/jp1017/AutoAnswerCalls) 5 | 6 | ### Android answer calls and messages automatically —— 自动接听电话、自动回复短信 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /captures 3 | 4 | # Built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # Files for the Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | .idea 14 | 15 | # Generated files 16 | bin/ 17 | gen/ 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | 29 | # Log Files 30 | *.log 31 | 32 | # iml files 33 | *.iml 34 | libs/ 35 | -------------------------------------------------------------------------------- /app/src/test/java/com/jp/autoanswercalls/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/jp/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/receiver/AutoAnswerBootReceiver.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls.receiver; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences.Editor; 7 | 8 | import com.jp.autoanswercalls.utils.Constants; 9 | 10 | public class AutoAnswerBootReceiver extends BroadcastReceiver { 11 | 12 | public AutoAnswerBootReceiver() { 13 | } 14 | 15 | public void onReceive(Context context, Intent intent) { 16 | Editor editor = context.getSharedPreferences(Constants.SETTING_PREF, 0).edit(); 17 | editor.putBoolean(Constants.AUTO_ANSWER_CALL_SERVICE, false); 18 | editor.putBoolean(Constants.AUTO_ANSWER_MESSAGE_SERVICE, false); 19 | editor.apply(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/receiver/AutoAnswerCallReceiver.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls.receiver; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.util.Log; 7 | 8 | import com.jp.autoanswercalls.service.AutoAnswerCallIntentService; 9 | import com.jp.autoanswercalls.utils.Constants; 10 | 11 | public class AutoAnswerCallReceiver extends BroadcastReceiver { 12 | 13 | public AutoAnswerCallReceiver() { 14 | } 15 | 16 | public void onReceive(Context context, Intent intent) { 17 | Log.d("AutoAnswer", "I am now in call receiver"); 18 | if (context.getSharedPreferences(Constants.SETTING_PREF, 0).getBoolean(Constants.AUTO_ANSWER_CALL_SERVICE, false)) { 19 | context.startService(new Intent(context, AutoAnswerCallIntentService.class)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/jp/autoanswercalls/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.jp.autoanswercalls", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | defaultConfig { 7 | applicationId "com.jp.autoanswercalls" 8 | minSdkVersion 14 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.2.2" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | // compile 'com.android.support:appcompat-v7:23.4.0' 28 | testCompile 'junit:junit:4.12' 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | 17 | 18 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: openjdk7 3 | sudo: false 4 | android: 5 | components: 6 | - tools 7 | - platform-tools 8 | - build-tools-23.0.2 9 | - android-23 10 | - extra-google-m2repository 11 | - extra-android-m2repository 12 | git: 13 | submodules: false 14 | before_install: 15 | - chmod +x gradlew 16 | script: 17 | - "./gradlew assembleDebug" 18 | before_deploy: 19 | - mv app/build/outputs/apk/app-debug.apk app/build/outputs/apk/AutoAnswerCalls.apk 20 | deploy: 21 | provider: releases 22 | api_key: 23 | secure: PeR1088wtk6r70HR50YDJJYm+ns6ktPYFdWgcz5hm+q0DuCb3tr+BmeHLGaUECyodzf4aAirQEp9I8W4eEeWndOXvU+62rKH2QW6pnFJKw7dCNK5a+zY+9+5dswwieENWpUtjjCqRfKujzR93U29KsJWPHHC9wu0CqMRfTVvdohb+xwm6Gc6m9yvrk4Xj8tMjYmkZDzol758KIcitK2jwk7IkoVn8VFNbb9om4ra7o2K7P4qLBZvOxIHnYWw9PBY2/rqEMmY8WCcLquY28a+FxZ3A+L2tGrbEGGJYsvHmxFONXIN6RFupX+YiZARSm8ijrSV4DK3882bNkhaLcMOz/nY0Or7KnGdvFRJ1BDvE9J2BzrRY06AxM9oMc5BwwL7cSK5joPn6qHKnav3r79ERa/VZVwWVTqoL+9ObR6E0TGcpPjajzav0aHD1ijNGWAzHgvak9mU76cXLfUypj+HltJk5EQJx9Dgn885NONJtNRS7kmaJcEj1q5ax1wAEumPySEF4YatJaYbkLs4dFhyAZzW0snBMMkXAEZn1Ctd2fIKgxx2ZWvO/BzoIEXv9RikNJoBUNiylodQCmd90ieZv83YVEMwIzpH9IOm1OABKbrWHhT0mSIuHnUnKXcVEqBHqXpW8qnyBXdqPPBJtpBsObf+EaTt/Au7wqF/O1gPBCk= 24 | file: app/build/outputs/apk/AutoAnswerCalls.apk 25 | on: 26 | repo: jp1017/AutoAnswerCalls 27 | after_deploy: 28 | - fir p app/build/outputs/apk/UVCCameraZxing.apk -T $FIR_TOKEN -c "`git cat-file tag 29 | $TRAVIS_TAG`" 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls.activity; 2 | 3 | import android.app.ActivityGroup; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.widget.TabHost; 7 | import android.widget.TabHost.TabSpec; 8 | 9 | import com.jp.autoanswercalls.R; 10 | import com.jp.autoanswercalls.activity.AnswerCallActivity; 11 | import com.jp.autoanswercalls.activity.AnswerMessageActivity; 12 | 13 | import static com.jp.autoanswercalls.utils.Constants.SETTING_PREF; 14 | 15 | public class MainActivity extends ActivityGroup { 16 | public static TabHost mTabHost; 17 | 18 | 19 | public void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | 23 | mTabHost = (TabHost) findViewById(R.id.edit_item_tab_host); 24 | mTabHost.setup(getLocalActivityManager()); 25 | 26 | TabSpec tabCall = mTabHost.newTabSpec("TAB_Call"); 27 | tabCall.setIndicator("电话"); 28 | tabCall.setContent(new Intent(this, AnswerCallActivity.class)); 29 | mTabHost.addTab(tabCall); 30 | 31 | TabSpec tabMessage = mTabHost.newTabSpec("TAB_Message"); 32 | tabMessage.setIndicator("短信"); 33 | tabMessage.setContent(new Intent(this, AnswerMessageActivity.class)); 34 | mTabHost.addTab(tabMessage); 35 | 36 | mTabHost.setCurrentTab(0); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/res/layout/answer_call.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 10 | 14 | 15 | 19 | 20 | 21 | 22 | 26 | 27 | 34 | 35 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/receiver/AutoAnswerMessageReceiver.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls.receiver; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.telephony.SmsMessage; 8 | import android.util.Log; 9 | 10 | import com.jp.autoanswercalls.service.AutoAnswerMessageIntentService; 11 | import com.jp.autoanswercalls.utils.Constants; 12 | 13 | public class AutoAnswerMessageReceiver extends BroadcastReceiver { 14 | public AutoAnswerMessageReceiver() { 15 | } 16 | 17 | public void onReceive(Context context, Intent intent) { 18 | Log.d("AutoAnswer", "I am now in message receiver"); 19 | if (context.getSharedPreferences(Constants.SETTING_PREF, 0).getBoolean(Constants.AUTO_ANSWER_MESSAGE_SERVICE, false)) { 20 | try { 21 | Bundle bundle = intent.getExtras(); 22 | if (bundle != null) { 23 | Object[] pdus = (Object[]) bundle.get("pdus"); 24 | SmsMessage[] messages = new SmsMessage[pdus.length]; 25 | for (int i = 0; i < pdus.length; i++) { 26 | messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); 27 | } 28 | String msgFrom = messages[pdus.length - 1].getDisplayOriginatingAddress(); 29 | String msgBody = messages[pdus.length - 1].getDisplayMessageBody(); 30 | Log.d("AutoAnswer", "Msg From: " + msgFrom); 31 | Log.d("AutoAnswer", "Msg Body: " + msgBody); 32 | Intent receiveSMSIntent = new Intent(); 33 | receiveSMSIntent.setClass(context, AutoAnswerMessageIntentService.class); 34 | receiveSMSIntent.putExtra("msgFrom", msgFrom); 35 | receiveSMSIntent.putExtra("msgBody", msgBody); 36 | context.startService(receiveSMSIntent); 37 | } 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/utils/ToastUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | ******************* Copyright (c) ***********************\ 3 | ** 4 | ** (c) Copyright 2016, 蒋朋, china, sxkj. sd 5 | ** All Rights Reserved 6 | ** 7 | ** By(青岛世新科技有限公司) 8 | ** www.qdsxkj.com 9 | ** 10 | ** _oo0oo_ 11 | ** o8888888o 12 | ** 88" . "88 13 | ** (| -_- |) 14 | ** 0\ = /0 15 | ** ___/`---'\___ 16 | ** .' \\| |// '. 17 | ** / \\||| : |||// \ 18 | ** / _||||| -:- |||||- \ 19 | ** | | \\\ - /// | | 20 | ** | \_| ''\---/'' |_/ | 21 | ** \ .-\__ '-' ___/-. / 22 | ** ___'. .' /--.--\ `. .'___ 23 | ** ."" '< `.___\_<|>_/___.' >' "". 24 | ** | | : `- \`.;`\ _ /`;.`/ - ` : | | 25 | ** \ \ `_. \_ __\ /__ _/ .-` / / 26 | ** =====`-.____`.___ \_____/___.-`___.-'===== 27 | ** `=---=' 28 | ** 29 | ** 30 | ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31 | ** 32 | ** 佛祖保佑 永无BUG 33 | ** 34 | ** 35 | ** 南无本师释迦牟尼佛 36 | ** 37 | 38 | **----------------------版本信息------------------------ 39 | ** 版 本: V0.1 40 | ** 41 | ******************* End of Head **********************\ 42 | */ 43 | 44 | package com.jp.autoanswercalls.utils; 45 | 46 | import android.content.Context; 47 | import android.widget.Toast; 48 | 49 | /** 50 | * 文 件 名: ToastUtils 51 | * 创 建 人: 蒋朋 52 | * 创建日期: 16-10-30 16:15 53 | * 邮 箱: jp19891017@gmail.com 54 | * 博 客: https://jp1017.github.io/ 55 | * 描 述: 56 | * 修 改 人: 57 | * 修改时间: 58 | * 修改备注: 59 | */ 60 | 61 | public class ToastUtils { 62 | private static Toast mToast; 63 | 64 | public static void showToast(Context context, String message) { 65 | if (mToast == null) { 66 | mToast = Toast.makeText(context, message, Toast.LENGTH_SHORT); 67 | } else { 68 | mToast.setText(message); 69 | } 70 | 71 | mToast.show(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/service/AutoAnswerMessageIntentService.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls.service; 2 | 3 | import android.app.IntentService; 4 | import android.app.PendingIntent; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.SharedPreferences; 8 | import android.os.Bundle; 9 | import android.telephony.SmsManager; 10 | import android.text.TextUtils; 11 | import android.util.Log; 12 | 13 | import com.jp.autoanswercalls.utils.Constants; 14 | 15 | public class AutoAnswerMessageIntentService extends IntentService { 16 | private static final String ACTION_SMS_SEND = "com.SMSDemo.SMS.send"; 17 | 18 | public AutoAnswerMessageIntentService() { 19 | super("AutoAnswerMessageIntentService"); 20 | } 21 | 22 | protected void onHandleIntent(Intent intent) { 23 | Context context = getBaseContext(); 24 | SharedPreferences settings = context.getSharedPreferences(Constants.SETTING_PREF, 0); 25 | Log.d("AutoAnswer", "I'm now in message service!"); 26 | Bundle bundle = intent.getExtras(); 27 | if (bundle != null) { 28 | if (TextUtils.isEmpty(bundle.getString("msgBody")) 29 | || bundle.getString("msgBody").contains(settings.getString(Constants.REPLY_MESSAGE_TRIGGER, Constants.AUTO_ANSWER_TIGGER))) { 30 | try { 31 | Thread.sleep((long) (Integer.parseInt(settings.getString(Constants.ANSWER_MESSAGE_DURATION, "3")) * 1000)); 32 | sendSMS(context, bundle.getString("msgFrom")); 33 | } catch (Exception e) { 34 | e.printStackTrace(); 35 | } 36 | } 37 | } 38 | 39 | } 40 | 41 | private void sendSMS(Context context, String phoneNumber) throws Exception { 42 | Log.d("AutoAnswer", "Start to send SMS!"); 43 | SharedPreferences settings = context.getSharedPreferences(Constants.SETTING_PREF, 0); 44 | SmsManager smsManager = SmsManager.getDefault(); 45 | PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_SMS_SEND), 0); 46 | smsManager.sendTextMessage(phoneNumber, null, settings.getString(Constants.REPLY_MESSAGE_CONTENT, Constants.AUTO_ANSWER_MESSAGE), pi, null); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/utils/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | ******************* Copyright (c) ***********************\ 3 | ** 4 | ** (c) Copyright 2016, 蒋朋, china, sxkj. sd 5 | ** All Rights Reserved 6 | ** 7 | ** By(青岛世新科技有限公司) 8 | ** www.qdsxkj.com 9 | ** 10 | ** _oo0oo_ 11 | ** o8888888o 12 | ** 88" . "88 13 | ** (| -_- |) 14 | ** 0\ = /0 15 | ** ___/`---'\___ 16 | ** .' \\| |// '. 17 | ** / \\||| : |||// \ 18 | ** / _||||| -:- |||||- \ 19 | ** | | \\\ - /// | | 20 | ** | \_| ''\---/'' |_/ | 21 | ** \ .-\__ '-' ___/-. / 22 | ** ___'. .' /--.--\ `. .'___ 23 | ** ."" '< `.___\_<|>_/___.' >' "". 24 | ** | | : `- \`.;`\ _ /`;.`/ - ` : | | 25 | ** \ \ `_. \_ __\ /__ _/ .-` / / 26 | ** =====`-.____`.___ \_____/___.-`___.-'===== 27 | ** `=---=' 28 | ** 29 | ** 30 | ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31 | ** 32 | ** 佛祖保佑 永无BUG 33 | ** 34 | ** 35 | ** 南无本师释迦牟尼佛 36 | ** 37 | 38 | **----------------------版本信息------------------------ 39 | ** 版 本: V0.1 40 | ** 41 | ******************* End of Head **********************\ 42 | */ 43 | 44 | package com.jp.autoanswercalls.utils; 45 | 46 | /** 47 | * 文 件 名: Constants 48 | * 创 建 人: 蒋朋 49 | * 创建日期: 16-10-30 16:35 50 | * 邮 箱: jp19891017@gmail.com 51 | * 博 客: https://jp1017.github.io/ 52 | * 描 述: 53 | * 修 改 人: 54 | * 修改时间: 55 | * 修改备注: 56 | */ 57 | 58 | public class Constants { 59 | public static final String SETTING_PREF = "SETTING_Pref"; 60 | 61 | 62 | //电话 63 | public static final String AUTO_ANSWER_CALL_SERVICE = "isAutoAnswerCallServiceEnabled"; 64 | public static final String ANSWER_CALL_DURATION = "durationBeforeAnswerCall"; 65 | 66 | //短信 67 | public static final String AUTO_ANSWER_MESSAGE_SERVICE = "isAutoAnswerMessageServiceEnabled"; 68 | public static final String ANSWER_MESSAGE_DURATION = "durationBeforeAnswerMessage"; 69 | public static final String REPLY_MESSAGE_TRIGGER = "replyMessageTrigger"; 70 | public static final String REPLY_MESSAGE_CONTENT = "replyMessageContent"; 71 | 72 | public static final String AUTO_ANSWER_TIGGER = "你"; 73 | public static final String AUTO_ANSWER_MESSAGE = "已收到您的消息\n\t\t\t\t--自动回复"; 74 | 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/res/layout/answer_message.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 27 | 28 | 32 | 36 | 37 | 38 | 39 | 43 | 44 | 45 | 46 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/service/AutoAnswerCallIntentService.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls.service; 2 | 3 | import android.app.IntentService; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences; 7 | import android.telephony.TelephonyManager; 8 | import android.util.Log; 9 | import android.view.KeyEvent; 10 | 11 | 12 | import com.android.internal.telephony.ITelephony; 13 | import com.jp.autoanswercalls.utils.Constants; 14 | 15 | import java.lang.reflect.Method; 16 | 17 | public class AutoAnswerCallIntentService extends IntentService { 18 | 19 | public AutoAnswerCallIntentService() { 20 | super("AutoAnswerCallIntentService"); 21 | } 22 | 23 | protected void onHandleIntent(Intent intent) { 24 | Context context = getBaseContext(); 25 | SharedPreferences settings = context.getSharedPreferences(Constants.SETTING_PREF, 0); 26 | Log.d("AutoAnswer", "I'm now in call service!"); 27 | if (((TelephonyManager) context.getSystemService("phone")).getCallState() != 1) { 28 | Log.d("AutoAnswer", "CALL_STATE_RINGING didn't detected!"); 29 | return; 30 | } 31 | Log.d("AutoAnswer", "Phone receive an incoming call!"); 32 | try { 33 | Thread.sleep((long) (Integer.parseInt(settings.getString(Constants.ANSWER_CALL_DURATION, "1")) * 1000)); 34 | answerPhoneAidl(context); 35 | } catch (Exception e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | 40 | private void answerPhoneAidl(Context context) throws Exception { 41 | try { 42 | TelephonyManager tm = (TelephonyManager) getSystemService("phone"); 43 | Method m = Class.forName(tm.getClass().getName()).getDeclaredMethod("getITelephony", new Class[0]); 44 | m.setAccessible(true); 45 | ITelephony telephonyService = (ITelephony) m.invoke(tm, new Object[0]); 46 | Log.d("AutoAnswer", "Phone answer incoming call now!"); 47 | telephonyService.answerRingingCall(); 48 | } catch (Exception e) { 49 | Intent intent = new Intent("android.intent.action.MEDIA_BUTTON"); 50 | intent.putExtra("android.intent.extra.KEY_EVENT", new KeyEvent(0, 79)); 51 | context.sendOrderedBroadcast(intent, "android.permission.CALL_PRIVILEGED"); 52 | intent = new Intent("android.intent.action.MEDIA_BUTTON"); 53 | intent.putExtra("android.intent.extra.KEY_EVENT", new KeyEvent(1, 79)); 54 | context.sendOrderedBroadcast(intent, "android.permission.CALL_PRIVILEGED"); 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/activity/AnswerCallActivity.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls.activity; 2 | 3 | import android.app.Activity; 4 | import android.app.Notification; 5 | import android.app.NotificationManager; 6 | import android.app.PendingIntent; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | import android.content.SharedPreferences; 10 | import android.content.SharedPreferences.Editor; 11 | import android.os.Bundle; 12 | import android.text.Editable; 13 | import android.text.TextUtils; 14 | import android.text.TextWatcher; 15 | import android.text.method.DigitsKeyListener; 16 | import android.util.Log; 17 | import android.widget.CheckBox; 18 | import android.widget.CompoundButton; 19 | import android.widget.CompoundButton.OnCheckedChangeListener; 20 | import android.widget.EditText; 21 | 22 | import com.jp.autoanswercalls.R; 23 | import com.jp.autoanswercalls.utils.Constants; 24 | import com.jp.autoanswercalls.utils.ToastUtils; 25 | 26 | public class AnswerCallActivity extends Activity { 27 | public static String durationBeforeAnswerCall; 28 | public static boolean isAutoAnswerCallServiceEnabled; 29 | private CheckBox mCheckboxAutoAnswerCallEnableDisable; 30 | private EditText mDurationBeforeAnswerCallEditText; 31 | 32 | public AnswerCallActivity() { 33 | } 34 | 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(R.layout.answer_call); 38 | SharedPreferences settings = getSharedPreferences(Constants.SETTING_PREF, 0); 39 | mCheckboxAutoAnswerCallEnableDisable = (CheckBox) findViewById(R.id.checkboxAutoAnswerCallEnableDisable); 40 | mCheckboxAutoAnswerCallEnableDisable.setChecked(settings.getBoolean(Constants.AUTO_ANSWER_CALL_SERVICE, false)); 41 | mCheckboxAutoAnswerCallEnableDisable.setOnCheckedChangeListener(new OnCheckedChangeListener() { 42 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 43 | if (mCheckboxAutoAnswerCallEnableDisable.isChecked()) { 44 | mDurationBeforeAnswerCallEditText.setEnabled(false); 45 | enableAutoAnswerCallService(); 46 | return; 47 | } 48 | mDurationBeforeAnswerCallEditText.setEnabled(true); 49 | disableAutoAnswerCallService(); 50 | } 51 | }); 52 | mDurationBeforeAnswerCallEditText = (EditText) findViewById(R.id.durationBeforeAnswerCallEditText); 53 | mDurationBeforeAnswerCallEditText.setKeyListener(new DigitsKeyListener()); 54 | mDurationBeforeAnswerCallEditText.setText(settings.getString(Constants.ANSWER_CALL_DURATION, "1")); 55 | mDurationBeforeAnswerCallEditText.setEnabled(!settings.getBoolean(Constants.AUTO_ANSWER_CALL_SERVICE, false)); 56 | mDurationBeforeAnswerCallEditText.addTextChangedListener(new TextWatcher() { 57 | public void afterTextChanged(Editable s) { 58 | if (TextUtils.isEmpty(s.toString())) { 59 | mDurationBeforeAnswerCallEditText.setText("0"); 60 | mDurationBeforeAnswerCallEditText.selectAll(); 61 | } 62 | if (s.length() > 1 && "0".equals(String.valueOf(s.charAt(0)))) { 63 | mDurationBeforeAnswerCallEditText.setText("0"); 64 | ToastUtils.showToast(AnswerCallActivity.this, "The waiting time should no start with 0."); 65 | mDurationBeforeAnswerCallEditText.selectAll(); 66 | } 67 | if (Integer.parseInt(mDurationBeforeAnswerCallEditText.getText().toString()) > 60) { 68 | mDurationBeforeAnswerCallEditText.setText("60"); 69 | ToastUtils.showToast(AnswerCallActivity.this, "等候时间不能大于60秒"); 70 | } 71 | } 72 | 73 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { 74 | } 75 | 76 | public void onTextChanged(CharSequence s, int start, int before, int count) { 77 | } 78 | }); 79 | } 80 | 81 | private void enableAutoAnswerCallService() { 82 | Log.d("AutoAnswer", "Start call service!"); 83 | isAutoAnswerCallServiceEnabled = true; 84 | durationBeforeAnswerCall = this.mDurationBeforeAnswerCallEditText.getText().toString(); 85 | Editor editor = getSharedPreferences(Constants.SETTING_PREF, 0).edit(); 86 | editor.putBoolean(Constants.AUTO_ANSWER_CALL_SERVICE, isAutoAnswerCallServiceEnabled); 87 | editor.putString(Constants.ANSWER_CALL_DURATION, durationBeforeAnswerCall); 88 | if (editor.commit()) { 89 | addNotificaction(); 90 | ToastUtils.showToast(this, "自动接听已打开"); 91 | } 92 | } 93 | 94 | private void disableAutoAnswerCallService() { 95 | Log.d("AutoAnswer", "Stop call service!"); 96 | isAutoAnswerCallServiceEnabled = false; 97 | Editor editor = getSharedPreferences(Constants.SETTING_PREF, 0).edit(); 98 | editor.putBoolean(Constants.AUTO_ANSWER_CALL_SERVICE, isAutoAnswerCallServiceEnabled); 99 | if (editor.commit()) { 100 | removeNotificaction(); 101 | ToastUtils.showToast(this, "自动接听已关闭"); 102 | } 103 | } 104 | 105 | 106 | private void addNotificaction() { 107 | NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 108 | Notification.Builder builder = new Notification.Builder(this); 109 | 110 | builder.setSmallIcon(R.mipmap.ic_launcher) 111 | .setContentTitle("自动接听电话") 112 | .setContentText("自动接听已打开") 113 | .setTicker("自动接听已打开") 114 | .setDefaults(Notification.DEFAULT_SOUND) 115 | .setContentIntent(PendingIntent 116 | .getActivity(this, 0, new Intent(this, MainActivity.class), 0)); 117 | 118 | Notification notification = builder.getNotification(); 119 | manager.notify(0, notification); 120 | } 121 | 122 | private void removeNotificaction() { 123 | ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(0); 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /app/src/main/java/com/jp/autoanswercalls/activity/AnswerMessageActivity.java: -------------------------------------------------------------------------------- 1 | package com.jp.autoanswercalls.activity; 2 | 3 | import android.app.Activity; 4 | import android.app.Notification; 5 | import android.app.NotificationManager; 6 | import android.app.PendingIntent; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | import android.content.SharedPreferences; 10 | import android.content.SharedPreferences.Editor; 11 | import android.os.Bundle; 12 | import android.text.Editable; 13 | import android.text.TextWatcher; 14 | import android.text.method.DigitsKeyListener; 15 | import android.util.Log; 16 | import android.widget.CheckBox; 17 | import android.widget.CompoundButton; 18 | import android.widget.CompoundButton.OnCheckedChangeListener; 19 | import android.widget.EditText; 20 | 21 | import com.jp.autoanswercalls.R; 22 | import com.jp.autoanswercalls.utils.Constants; 23 | import com.jp.autoanswercalls.utils.ToastUtils; 24 | 25 | public class AnswerMessageActivity extends Activity { 26 | public static String durationBeforeAnswerMessage; 27 | public static boolean isAutoAnswerMessageServiceEnabled; 28 | public static String replyMessageContent; 29 | public static String replyMessageTrigger; 30 | private CheckBox mCheckboxAutoAnswerMessageEnableDisable; 31 | private EditText mDurationBeforeAnswerMessageEditText; 32 | private EditText mReplyIncomingMessageContentEditText; 33 | private EditText mReplyIncomingMessageTriggerEditText; 34 | 35 | public AnswerMessageActivity() { 36 | } 37 | 38 | protected void onCreate(Bundle savedInstanceState) { 39 | boolean z = false; 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.answer_message); 42 | SharedPreferences settings = getSharedPreferences(Constants.SETTING_PREF, 0); 43 | mCheckboxAutoAnswerMessageEnableDisable = (CheckBox) findViewById(R.id.checkboxAutoAnswerMessageEnableDisable); 44 | mCheckboxAutoAnswerMessageEnableDisable.setChecked(settings.getBoolean(Constants.AUTO_ANSWER_MESSAGE_SERVICE, false)); 45 | mCheckboxAutoAnswerMessageEnableDisable.setOnCheckedChangeListener(new OnCheckedChangeListener() { 46 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 47 | if (mCheckboxAutoAnswerMessageEnableDisable.isChecked()) { 48 | mDurationBeforeAnswerMessageEditText.setEnabled(false); 49 | mReplyIncomingMessageTriggerEditText.setEnabled(false); 50 | mReplyIncomingMessageContentEditText.setEnabled(false); 51 | enableAutoAnswerMessageService(); 52 | return; 53 | } 54 | mDurationBeforeAnswerMessageEditText.setEnabled(true); 55 | mReplyIncomingMessageTriggerEditText.setEnabled(true); 56 | mReplyIncomingMessageContentEditText.setEnabled(true); 57 | disableAutoAnswerMessageService(); 58 | } 59 | }); 60 | mDurationBeforeAnswerMessageEditText = (EditText) findViewById(R.id.durationBeforeAnswerMessageEditText); 61 | mDurationBeforeAnswerMessageEditText.setKeyListener(new DigitsKeyListener()); 62 | mDurationBeforeAnswerMessageEditText.setText(settings.getString(Constants.ANSWER_MESSAGE_DURATION, "3")); 63 | mDurationBeforeAnswerMessageEditText.setEnabled(!settings.getBoolean(Constants.AUTO_ANSWER_MESSAGE_SERVICE, false)); 64 | mDurationBeforeAnswerMessageEditText.addTextChangedListener(new TextWatcher() { 65 | public void afterTextChanged(Editable s) { 66 | if ("".equals(s.toString())) { 67 | mDurationBeforeAnswerMessageEditText.setText("0"); 68 | mDurationBeforeAnswerMessageEditText.selectAll(); 69 | } 70 | if (s.length() > 1 && "0".equals(String.valueOf(s.charAt(0)))) { 71 | mDurationBeforeAnswerMessageEditText.setText("0"); 72 | ToastUtils.showToast(AnswerMessageActivity.this, "时间非0开头"); 73 | mDurationBeforeAnswerMessageEditText.selectAll(); 74 | } 75 | if (Integer.parseInt(mDurationBeforeAnswerMessageEditText.getText().toString()) > 60) { 76 | mDurationBeforeAnswerMessageEditText.setText("60"); 77 | ToastUtils.showToast(AnswerMessageActivity.this, "等候时间不能大于60秒"); 78 | } 79 | } 80 | 81 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { 82 | } 83 | 84 | public void onTextChanged(CharSequence s, int start, int before, int count) { 85 | } 86 | }); 87 | mReplyIncomingMessageTriggerEditText = (EditText) findViewById(R.id.replyIncomingMessageTriggerEditText); 88 | mReplyIncomingMessageTriggerEditText.setText(settings.getString(Constants.REPLY_MESSAGE_TRIGGER, Constants.AUTO_ANSWER_TIGGER)); 89 | mReplyIncomingMessageTriggerEditText.setEnabled(!settings.getBoolean(Constants.AUTO_ANSWER_MESSAGE_SERVICE, false)); 90 | mReplyIncomingMessageTriggerEditText.selectAll(); 91 | mReplyIncomingMessageContentEditText = (EditText) findViewById(R.id.replyIncomingMessageContentEditText); 92 | mReplyIncomingMessageContentEditText.setText(settings.getString(Constants.REPLY_MESSAGE_CONTENT, Constants.AUTO_ANSWER_MESSAGE)); 93 | EditText editText = mReplyIncomingMessageContentEditText; 94 | if (!settings.getBoolean(Constants.AUTO_ANSWER_MESSAGE_SERVICE, false)) { 95 | z = true; 96 | } 97 | editText.setEnabled(z); 98 | mReplyIncomingMessageContentEditText.selectAll(); 99 | } 100 | 101 | private void enableAutoAnswerMessageService() { 102 | Log.d("AutoAnswer", "Start message service!"); 103 | isAutoAnswerMessageServiceEnabled = true; 104 | durationBeforeAnswerMessage = mDurationBeforeAnswerMessageEditText.getText().toString(); 105 | replyMessageTrigger = mReplyIncomingMessageTriggerEditText.getText().toString(); 106 | replyMessageContent = mReplyIncomingMessageContentEditText.getText().toString(); 107 | Editor editor = getSharedPreferences(Constants.SETTING_PREF, 0).edit(); 108 | editor.putBoolean(Constants.AUTO_ANSWER_MESSAGE_SERVICE, isAutoAnswerMessageServiceEnabled); 109 | editor.putString(Constants.ANSWER_MESSAGE_DURATION, durationBeforeAnswerMessage); 110 | editor.putString(Constants.REPLY_MESSAGE_TRIGGER, replyMessageTrigger); 111 | editor.putString(Constants.REPLY_MESSAGE_CONTENT, replyMessageContent); 112 | if (editor.commit()) { 113 | addNotificaction(); 114 | ToastUtils.showToast(this, "自动短信回复已打开"); 115 | } 116 | } 117 | 118 | private void disableAutoAnswerMessageService() { 119 | Log.d("AutoAnswer", "Stop message service!"); 120 | isAutoAnswerMessageServiceEnabled = false; 121 | Editor editor = getSharedPreferences(Constants.SETTING_PREF, 0).edit(); 122 | editor.putBoolean(Constants.AUTO_ANSWER_MESSAGE_SERVICE, isAutoAnswerMessageServiceEnabled); 123 | if (editor.commit()) { 124 | removeNotificaction(); 125 | ToastUtils.showToast(this, "自动短信回复已关闭"); 126 | } 127 | } 128 | 129 | 130 | private void addNotificaction() { 131 | NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 132 | Notification.Builder builder = new Notification.Builder(this); 133 | 134 | builder.setSmallIcon(R.mipmap.ic_launcher) 135 | .setContentTitle("自动回复短信") 136 | .setContentText("自动短信回复已打开") 137 | .setTicker("自动短信回复已打开") 138 | .setDefaults(Notification.DEFAULT_SOUND) 139 | .setContentIntent(PendingIntent 140 | .getActivity(this, 0, new Intent(this, MainActivity.class), 0)); 141 | 142 | Notification notification = builder.getNotification(); 143 | manager.notify(0, notification); 144 | } 145 | 146 | private void removeNotificaction() { 147 | ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(1); 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/internal/telephony/ITelephony.java: -------------------------------------------------------------------------------- 1 | package com.android.internal.telephony; 2 | 3 | import android.os.Binder; 4 | import android.os.IBinder; 5 | import android.os.IInterface; 6 | import android.os.Parcel; 7 | import android.os.RemoteException; 8 | 9 | public interface ITelephony extends IInterface { 10 | 11 | public static abstract class Stub extends Binder implements ITelephony { 12 | private static final String DESCRIPTOR = "com.android.internal.telephony.ITelephony"; 13 | static final int TRANSACTION_answerRingingCall = 2; 14 | static final int TRANSACTION_disableDataConnectivity = 4; 15 | static final int TRANSACTION_enableDataConnectivity = 3; 16 | static final int TRANSACTION_endCall = 1; 17 | static final int TRANSACTION_isDataConnectivityPossible = 5; 18 | 19 | private static class Proxy implements ITelephony { 20 | private IBinder mRemote; 21 | 22 | Proxy(IBinder remote) { 23 | this.mRemote = remote; 24 | } 25 | 26 | public IBinder asBinder() { 27 | return this.mRemote; 28 | } 29 | 30 | public String getInterfaceDescriptor() { 31 | return Stub.DESCRIPTOR; 32 | } 33 | 34 | public boolean endCall() throws RemoteException { 35 | boolean _result = true; 36 | Parcel _data = Parcel.obtain(); 37 | Parcel _reply = Parcel.obtain(); 38 | try { 39 | _data.writeInterfaceToken(Stub.DESCRIPTOR); 40 | this.mRemote.transact(Stub.TRANSACTION_endCall, _data, _reply, 0); 41 | _reply.readException(); 42 | if (_reply.readInt() == 0) { 43 | _result = false; 44 | } 45 | _reply.recycle(); 46 | _data.recycle(); 47 | return _result; 48 | } catch (Throwable th) { 49 | _reply.recycle(); 50 | _data.recycle(); 51 | } 52 | return _result; 53 | 54 | } 55 | 56 | public void answerRingingCall() throws RemoteException { 57 | Parcel _data = Parcel.obtain(); 58 | Parcel _reply = Parcel.obtain(); 59 | try { 60 | _data.writeInterfaceToken(Stub.DESCRIPTOR); 61 | this.mRemote.transact(Stub.TRANSACTION_answerRingingCall, _data, _reply, 0); 62 | _reply.readException(); 63 | } finally { 64 | _reply.recycle(); 65 | _data.recycle(); 66 | } 67 | } 68 | 69 | public boolean enableDataConnectivity() throws RemoteException { 70 | boolean _result = false; 71 | Parcel _data = Parcel.obtain(); 72 | Parcel _reply = Parcel.obtain(); 73 | try { 74 | _data.writeInterfaceToken(Stub.DESCRIPTOR); 75 | this.mRemote.transact(Stub.TRANSACTION_enableDataConnectivity, _data, _reply, 0); 76 | _reply.readException(); 77 | if (_reply.readInt() != 0) { 78 | _result = true; 79 | } 80 | _reply.recycle(); 81 | _data.recycle(); 82 | return _result; 83 | } catch (Throwable th) { 84 | _reply.recycle(); 85 | _data.recycle(); 86 | } 87 | return _result; 88 | 89 | } 90 | 91 | public boolean disableDataConnectivity() throws RemoteException { 92 | boolean _result = false; 93 | Parcel _data = Parcel.obtain(); 94 | Parcel _reply = Parcel.obtain(); 95 | try { 96 | _data.writeInterfaceToken(Stub.DESCRIPTOR); 97 | this.mRemote.transact(Stub.TRANSACTION_disableDataConnectivity, _data, _reply, 0); 98 | _reply.readException(); 99 | if (_reply.readInt() != 0) { 100 | _result = true; 101 | } 102 | _reply.recycle(); 103 | _data.recycle(); 104 | return _result; 105 | } catch (Throwable th) { 106 | _reply.recycle(); 107 | _data.recycle(); 108 | } 109 | return _result; 110 | 111 | } 112 | 113 | public boolean isDataConnectivityPossible() throws RemoteException { 114 | boolean _result = false; 115 | Parcel _data = Parcel.obtain(); 116 | Parcel _reply = Parcel.obtain(); 117 | try { 118 | _data.writeInterfaceToken(Stub.DESCRIPTOR); 119 | this.mRemote.transact(Stub.TRANSACTION_isDataConnectivityPossible, _data, _reply, 0); 120 | _reply.readException(); 121 | if (_reply.readInt() != 0) { 122 | _result = true; 123 | } 124 | _reply.recycle(); 125 | _data.recycle(); 126 | return _result; 127 | } catch (Throwable th) { 128 | _reply.recycle(); 129 | _data.recycle(); 130 | } 131 | return _result; 132 | 133 | } 134 | } 135 | 136 | public Stub() { 137 | attachInterface(this, DESCRIPTOR); 138 | } 139 | 140 | public static ITelephony asInterface(IBinder obj) { 141 | if (obj == null) { 142 | return null; 143 | } 144 | IInterface iin = obj.queryLocalInterface(DESCRIPTOR); 145 | if (iin == null || !(iin instanceof ITelephony)) { 146 | return new Proxy(obj); 147 | } 148 | return (ITelephony) iin; 149 | } 150 | 151 | public IBinder asBinder() { 152 | return this; 153 | } 154 | 155 | public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { 156 | int i = 0; 157 | boolean _result; 158 | switch (code) { 159 | case TRANSACTION_endCall /*1*/: 160 | data.enforceInterface(DESCRIPTOR); 161 | _result = endCall(); 162 | reply.writeNoException(); 163 | if (_result) { 164 | i = TRANSACTION_endCall; 165 | } 166 | reply.writeInt(i); 167 | return true; 168 | case TRANSACTION_answerRingingCall /*2*/: 169 | data.enforceInterface(DESCRIPTOR); 170 | answerRingingCall(); 171 | reply.writeNoException(); 172 | return true; 173 | case TRANSACTION_enableDataConnectivity /*3*/: 174 | data.enforceInterface(DESCRIPTOR); 175 | _result = enableDataConnectivity(); 176 | reply.writeNoException(); 177 | if (_result) { 178 | i = TRANSACTION_endCall; 179 | } 180 | reply.writeInt(i); 181 | return true; 182 | case TRANSACTION_disableDataConnectivity /*4*/: 183 | data.enforceInterface(DESCRIPTOR); 184 | _result = disableDataConnectivity(); 185 | reply.writeNoException(); 186 | if (_result) { 187 | i = TRANSACTION_endCall; 188 | } 189 | reply.writeInt(i); 190 | return true; 191 | case TRANSACTION_isDataConnectivityPossible /*5*/: 192 | data.enforceInterface(DESCRIPTOR); 193 | _result = isDataConnectivityPossible(); 194 | reply.writeNoException(); 195 | if (_result) { 196 | i = TRANSACTION_endCall; 197 | } 198 | reply.writeInt(i); 199 | return true; 200 | case 1598968902: 201 | reply.writeString(DESCRIPTOR); 202 | return true; 203 | default: 204 | return super.onTransact(code, data, reply, flags); 205 | } 206 | } 207 | } 208 | 209 | void answerRingingCall() throws RemoteException; 210 | 211 | boolean disableDataConnectivity() throws RemoteException; 212 | 213 | boolean enableDataConnectivity() throws RemoteException; 214 | 215 | boolean endCall() throws RemoteException; 216 | 217 | boolean isDataConnectivityPossible() throws RemoteException; 218 | } 219 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------