recall

/*
 * Copyright (c) 201020xxx BYD Corporation.  All rights reserved.
 *
 * BYD Corporation and its licensors retain all intellectual property
 * and proprietary rights in and to this software, related documentation
 * and any modifications thereto.  Any use, reproduction, disclosure or
 * distribution of this software and related documentation without an express
 * license agreement from BYD Corporation is strictly prohibited.
 *
 * File Name:  bp_log.c
 *
 * General Description: This file implements all the bp panic block log functions.
 *
 *
 *    Date               Author            CR/PR                Reference
 *    ========      ========     ==========      ==========================
 *    2010-12-13    Huang.jinhu             T601T_C000067     Add recall function
 *    2010-12-25 huangjinhu    T601T_P000199 Can not auto redial successfully after redial twice.
 */

package com.android.phone;

import android.app.Activity;
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.content.ContextWrapper;
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
import java.util.Timer;
import java.util.TimerTask;
import com.android.internal.telephony.Connection;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;

 

public class reCall extends AlertActivity implements DialogInterface.OnClickListener {
 private Timer timer=new Timer();
 private String numStr;
 private String cause;
 private long time;
 private PhoneApp app;
 WakeLock wakeLock;
 KeyguardManager mKeyguardManager=null;
 KeyguardLock mKeyguardLock=null;
 //send intent for recall
 Handler handler = new Handler(){  
        public void handleMessage(Message msg) {          
             Intent inte=new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+numStr));
       startActivity(inte);
       finish();         
            super.handleMessage(msg);  
        }  
          
    };
 private TimerTask timetask=new TimerTask() {
  public void run() {
   Message message = new Message();         
            handler.sendMessage(message);    
  }
 };
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  app=PhoneApp.getInstance();
  Log.i("reCall oncreate+","+");
  Bundle extras = getIntent().getExtras();
  cause = extras.getString("cause");
  numStr=extras.getString("num");
  time=extras.getLong("time");
  
  //key guard manager for dialog
  mKeyguardManager= (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
        mKeyguardLock= mKeyguardManager.newKeyguardLock("");
        createDialog(cause);
        timer.schedule(timetask, time);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
  
       
 }
  protected void onResume () {
   super.onResume();
   Log.i("reCall onResum cause+","+cause="+cause+" numStr="+numStr+" time="+time);
   acquireWakeLock();
   mKeyguardLock.disableKeyguard();
     }
  protected void onPause () {
   super.onPause();
   Log.i("reCall onPause+","+finish");
   mKeyguardLock.reenableKeyguard();
   releaseWakeLock();
     }
 
 //create dialog for recall
 public void createDialog(String causeStr)
 {
  AlertController.AlertParams p = mAlertParams;
  p.mIconId = android.R.drawable.ic_dialog_alert;
        p.mTitle = getResources().getString(R.string.reCall_title);
       
        //T601T_P000199 hjh change connection state from enumerate --begin
        if(causeStr.equals(String.valueOf(Connection.RedialFailCause.USER_BUSY)))
        {
         p.mMessage=getResources().getString(R.string.reCall_message_busy);
        }
        if(causeStr.equals(String.valueOf(Connection.RedialFailCause.TEMPORARY_FAILURE)))
        {
         p.mMessage=getResources().getString(R.string.reCall_message_no_response);
        }
        if(causeStr.equals(String.valueOf(Connection.RedialFailCause.PERMANENT_FAILURE)))
        {
         p.mMessage=getResources().getString(R.string.reCall_message_error);
        }
        //--end--
       
        p.mNegativeButtonText = getResources().getString(R.string.reCall_Cancel);
        p.mNegativeButtonListener = this;
        setupAlert();
 }
 
 
 public void onClick(DialogInterface dialog, int which)
 {
  app.notifier.setOristate();
 }
    public boolean onKeyDown(int keyCode, KeyEvent event) {  
     return false;
    } 
 private void acquireWakeLock() {
       if(wakeLock ==null) {
           PowerManager pm =(PowerManager) getSystemService(Context.POWER_SERVICE);
           wakeLock =pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP,  this.getClass().getCanonicalName());
           wakeLock.acquire();
          }
   }
 private void releaseWakeLock() {
        if(wakeLock !=null&&wakeLock.isHeld()) {
        wakeLock.release();
        wakeLock =null;
           }
   }
 protected void onStart () {
  Log.d("reCall onstart +","+");
  super.onStart();
    }
    protected void onStop () {
     Log.d("reCall onstop +","+");
     super.onStop();
     timer.cancel();
    }
    protected void onDestroy () {
     Log.d("reCall ondestroy +","+");
     super.onDestroy();
    }

}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值