My phone Butler (21) set up the center

Source: Internet
Author: User

My cell phone Butler (21) Set the center:

Includes three interfaces: four functions

(1) Telephone attribution to search

Use sqlitedatabase query address.db to query the attribution of the specified number

(2) Check app version updates

(3) Information about my phone Butler

(4) Opening and closing of blacklist service

Blacklist service:

Interception of text messages by binding broadcasts will intercept text messages before static registration

Monitor phone status via phone manager telephonymanager

Once a call is made, the blacklist is compared first.

 PackageCom.chb.myphonesave.service;ImportJava.lang.reflect.Method;ImportAndroid.app.Service;ImportAndroid.content.BroadcastReceiver;ImportAndroid.content.Context;Importandroid.content.Intent;ImportAndroid.content.IntentFilter;ImportAndroid.os.IBinder;ImportAndroid.telephony.PhoneStateListener;ImportAndroid.telephony.SmsMessage;ImportAndroid.telephony.TelephonyManager;ImportCom.android.internal.telephony.ITelephony;ImportCom.chb.myphonesave.dao.BlackNumberDao;/** *   */ Public classBlacknumberserviceextendsService {PrivateInnersmsreceiver Mreceiver; PrivateTelephonymanager MTM; PrivateMyphonestatelistener Mlistener; @Override Publicibinder onbind (Intent Intent) {return NULL; } @Override Public voidonCreate () {Super. OnCreate (); Context CTX=Getapplicationcontext (); MTM=(Telephonymanager) Ctx.getsystemservice (Telephony_service); Mlistener=NewMyphonestatelistener ();        Mtm.listen (Mlistener, phonestatelistener.listen_call_state); //Register SMS Broadcast monitorMreceiver =NewInnersmsreceiver (); Intentfilter Filter=NewIntentfilter ("Android.provider.Telephony.SMS_RECEIVED"); Filter.setpriority (integer.max_value);//setting the priority levelRegisterreceiver (mreceiver, filter); }    classMyphonestatelistenerextendsPhonestatelistener { Public voidOncallstatechanged (intState , String Incomingnumber) {            Switch(state) { Casetelephonymanager.call_state_ringing:intexist =blacknumberdao.getinstance (blacknumberservice. This). Find (Incomingnumber); if(Exist > 0) {                    //1, 3                    intmode =blacknumberdao.getinstance (blacknumberservice. This). Findmode (Incomingnumber); if(mode = = 1 | | mode = = 3) {//Intercept Phone//EndcallEndcall (); }                }                 Break; default:                 Break; }            Super. oncallstatechanged (State, Incomingnumber); }    }     Public voidOnDestroy () {Super. OnDestroy ();        Unregisterreceiver (Mreceiver); Mreceiver=NULL; //Stop incoming call monitoringMtm.listen (Mlistener, Phonestatelistener.listen_none); Mlistener=NULL; }    /*** You need permission to hang up the phone: <uses-permission * android:name= "Android.permission.CALL_PHONE"/>*/     Public voidEndcall () {//Android.os.ServiceManager//ITelephony.Stub.asInterface (Servicemanager.getservice (Context.telephony_service));        Try{Class Clazz= Blacknumberservice.class. getClassLoader (). LoadClass ("Android.os.ServiceManager");//get ServiceManager byte codemethod = Clazz.getdeclaredmethod ("GetService", String.class);//Get MethodIBinder binder = (ibinder) Method.invoke (NULL, context.telephony_service);//to get the IBinder proxy object through reflection call methodItelephony telephony =ITelephony.Stub.asInterface (binder); Telephony.endcall ();//Hang up the phone}Catch(Exception e) {e.printstacktrace (); }    }    //dynamically registered broadcasts intercept messages more than static registrations    classInnersmsreceiverextendsBroadcastreceiver { Public voidOnReceive (Context context, Intent Intent) {object[] Objs= (object[]) Intent.getextras (). Get ("PDUs");  for(Object Object:objs) {//140 Bytes, 70 characters,//when a text message exceeds 140 bytes, it will be sent in multiple messages, so it will be circulated several times,//In general, the For loop only goes one timeSmsmessage message = SMSMESSAGE.CREATEFROMPDU ((byte[]) object); String PhoneNumber= Message.getoriginatingaddress ();//Get SMS Call number                intexist =blacknumberdao.getinstance (blacknumberservice. This). Find (PhoneNumber); if(Exist > 0) {//if the number is within the blacklist range                    intmode =blacknumberdao.getinstance (blacknumberservice. This). Findmode (PhoneNumber); if(Mode > 1) {//If you find an intercept SMS or SMS + phoneAbortbroadcast ();//terminating broadcast delivery                    }                }            }        }    }}

My phone Butler (21) set up the center

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.