1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.dialer.app.calllog; 18 19 import android.content.Intent; 20 import android.os.Bundle; 21 import android.support.v7.app.AppCompatActivity; 22 import com.android.dialer.common.LogUtil; 23 import com.android.dialer.util.PermissionsUtil; 24 25 /** 26 * Provides operations for managing call-related notifications. This is used to forward intent 27 * that's requiring to unlock screen and it will never be visible to user. 28 * 29 * <p>It handles the following actions: 30 * 31 * <ul> 32 * <li>Sending an SMS from a missed call 33 * </ul> 34 */ 35 public class CallLogNotificationsActivity extends AppCompatActivity { 36 37 public static final String ACTION_SEND_SMS_FROM_MISSED_CALL_NOTIFICATION = 38 "com.android.dialer.calllog.SEND_SMS_FROM_MISSED_CALL_NOTIFICATION"; 39 40 /** 41 * Extra to be included with {@link #ACTION_SEND_SMS_FROM_MISSED_CALL_NOTIFICATION} to identify 42 * the number to text back. 43 * 44 * <p>It must be a {@link String}. 45 */ 46 public static final String EXTRA_MISSED_CALL_NUMBER = "MISSED_CALL_NUMBER"; 47 48 @Override onCreate(Bundle savedInstanceState)49 protected void onCreate(Bundle savedInstanceState) { 50 super.onCreate(savedInstanceState); 51 Intent intent = getIntent(); 52 53 if (!PermissionsUtil.hasPermission(this, android.Manifest.permission.READ_CALL_LOG)) { 54 return; 55 } 56 57 String action = intent.getAction(); 58 switch (action) { 59 case ACTION_SEND_SMS_FROM_MISSED_CALL_NOTIFICATION: 60 MissedCallNotifier.getInstance(this) 61 .sendSmsFromMissedCall( 62 intent.getStringExtra(EXTRA_MISSED_CALL_NUMBER), intent.getData()); 63 break; 64 default: 65 LogUtil.d("CallLogNotificationsActivity.onCreate", "could not handle: " + intent); 66 break; 67 } 68 finish(); 69 } 70 } 71