23
DAFTAR PUSTAKA Ahmed, Ashfaque. 2011. Software Project Management: A Process-Driven Approach. United States of America: CRC Press. Ayers, M. L. 2012. Telecommunications System Reliability Engineering, Theory, and Practice. Canada: John Wiley & Sons, Inc. Chaudhuri, Anil Bikas. 2005. The Art of Programming Through Flowcharts & Algorithms. New Delhi: Firewall Media. Enterprise, J. 2010. Panduan Memilih Koneksi Internet untuk Pemula. Jakarta: PT Elex Media Komputindo. H, N.S. 2012. Android Pemrograman Aplikasi Mobile Smartphone dan Tablet PC Berbasis Android Edisi Revisi. Bandung: Informatika. Hillebrand, Friedhelm. 2010. Short Message Service The Creation of Personal Global Text. United Kingdom: John Wiley & Sons, Inc. 2010. Huda, A.A. 2012. 24 Jam Pintar Pemrograman Android. Yogyakarta: Penerbit Andi. Hunter, D, et al. 2011. Beginning XML, 4th Edition. United Kingdom: Wrox. Kasera, S. and Nishit Narang. 2008. 3G Networks Architecture, Protocols and Procedures Based on 3GPP Specifications for UMTS WCDMA Networks. New Delhi: Tata McGraw-Hill. Mednieks, Z, dkk. 2011. Programming Android. United States of America: O’Reilly Media,Inc. Milette, G. and Adam Stroud. 2012. Professional Android TM Sensor Programming Canada: John Wiley & Sons,Inc. Sangeeta, S. 2008. Software Engineering. United Kingdom: New Age International. Shalahuddin, M dan Rosa A.S. 2009. Belajar Pemrograman dengan Bahasa C++ dan Java Dari Nol Menjadi Andal. Bandung: Informatika. Shelly, Gary B., and Harry J. Rosenblatt. 2012. Systems Analysis and Design Nineth Edition. United States of America: Course Technology. Simarmata, Janner. 2010. Rekayasa Perangkat Lunak. Yogyakarta: Penerbit Andi. http://www.mercubuana.ac.id 75

DAFTAR PUSTAKA Ahmed, Ashfaque. 2011. Software Project Management: A Process-Driven Approach. United States of America: CRC Press. Ayers, M. L. 2012. Telecommunications

Embed Size (px)

Citation preview

DAFTAR PUSTAKA

Ahmed, Ashfaque. 2011. Software Project Management: A Process-Driven

Approach. United States of America: CRC Press.

Ayers, M. L. 2012. Telecommunications System Reliability Engineering, Theory,

and Practice. Canada: John Wiley & Sons, Inc.

Chaudhuri, Anil Bikas. 2005. The Art of Programming Through Flowcharts &

Algorithms. New Delhi: Firewall Media.

Enterprise, J. 2010. Panduan Memilih Koneksi Internet untuk Pemula. Jakarta: PT

Elex Media Komputindo.

H, N.S. 2012. Android Pemrograman Aplikasi Mobile Smartphone dan Tablet PC

Berbasis Android Edisi Revisi. Bandung: Informatika.

Hillebrand, Friedhelm. 2010. Short Message Service The Creation of Personal

Global Text. United Kingdom: John Wiley & Sons, Inc. 2010.

Huda, A.A. 2012. 24 Jam Pintar Pemrograman Android. Yogyakarta: Penerbit

Andi.

Hunter, D, et al. 2011. Beginning XML, 4th Edition. United Kingdom: Wrox.

Kasera, S. and Nishit Narang. 2008. 3G Networks Architecture, Protocols and

Procedures Based on 3GPP Specifications for UMTS WCDMA Networks.

New Delhi: Tata McGraw-Hill.

Mednieks, Z, dkk. 2011. Programming Android. United States of America:

O’Reilly Media,Inc.

Milette, G. and Adam Stroud. 2012. Professional AndroidTM Sensor Programming

Canada: John Wiley & Sons,Inc.

Sangeeta, S. 2008. Software Engineering. United Kingdom: New Age

International.

Shalahuddin, M dan Rosa A.S. 2009. Belajar Pemrograman dengan Bahasa C++

dan Java Dari Nol Menjadi Andal. Bandung: Informatika.

Shelly, Gary B., and Harry J. Rosenblatt. 2012. Systems Analysis and Design

Nineth Edition. United States of America: Course Technology.

Simarmata, Janner. 2010. Rekayasa Perangkat Lunak. Yogyakarta: Penerbit Andi.

http://www.mercubuana.ac.id 75

76

Talukder, A. K, Hasan Ahmed, dan Roopa R Yavagal. 2010. Second Edition

Mobile Computing Technology, Applications, and Service Creation. New Delhi:

Tata McGraw Hill Education Private Limited.

Wahana Komputer. 2012. Membuat Aplikasi Android untuk Tablet dan

Handphone. Semarang: PT. Elex Media Komputindo.

Westfall, Jon, Rocco Augusto, and Grant Allen. 2012. Beginning Android Web

Apps Development Develop for Android using HTML5,CSS3, and Javascript. New

York: Apress.

Trevisani, E., Vitaletti, A.: Cell-ID Location Technique, limits and Benefits: An

Experimental Study. In: Proceddings of the Sixth IEEE Workshop on Mobile

Computing Systems and Applications, WMCSA 2004 (2004).

Abusajid. ”CGI (Cell Global Identity)”.http://www.mobileindonesia.net/cgi-cell-

global-identity/ (diakses tanggal 25 Oktober 2012).

Android. ”Android 4.1, Jelly

Bean”.http://www.android.com/about/jelly-bean/(diakses tanggal 15 Oktober

2012).

Cedano, Franco, David Drew, and Wan Ling Yih. ”Implementing a SoC Design on

an FPGA”.http://people.ece.cornell.edu/land/courses/ece5760/FinalProjects/

f2008/djd36_fac24_wy47/djd36_fac24_wy47/index.html(diakses tanggal 9

Oktober 2012).

Wikipedia. ”Software Release Life Cycle”.http://en.wikipedia.org/wiki/ Software

release life cycle (diakses tanggal 08 Januari 2013).

http://www.mercubuana.ac.id

77 LAMPIRAN

Android Manifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.finding.hp" android:installLocation="internalOnly" android:versionCode="1" android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.WRITE_SMS" /> <uses-permission android:name="android.permission.READ_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.WAKE_LOCK"/>

<application android:allowBackup="true" android:allowClearUserData="false" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" android:persistent="true">

<uses-library android:name="com.google.android.maps" />

<receiver android:name=".SmsReceiver" android:exported="true" android:enabled="true"> <intent-filter android:priority="1000" > <action android:name="android.intent.action.QUICKBOOT_POWERON" /> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver>

<activity android:name="FindingHP" android:label="@string/app_name" android:launchMode="standard"> <intent-filter>

<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />

</intent-filter> </activity> <activity android:name="Login" android:label="@string/app_name" />

<service

http://www.mercubuana.ac.id

78

android:name="com.finding.hp.StarterService" android:enabled="true" android:icon="@drawable/ic_launcher"> </service> </application> </manifest>

Activity_finding_hp.xml <LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent" android:layout_height="fill_parent"

android:orientation="vertical"> <TextView android:layout_width="fill_parent"

android:layout_height="wrap_content" android:text="@string/hello_world" /> <ScrollView

android:layout_width="fill_parent" android:layout_height="wrap_content"> <TableLayout

android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchColumns="1">

<!-- Data GPS --> <TableRow android:id="@+id/tableRow8" android:layout_width="fill_parent"

android:layout_height="wrap_content" android:orientation="horizontal">

<TextView android:id="@+id/textView8" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="@string/latText" android:textStyle="bold" />

<TextView android:id="@+id/latitudeTxt" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="@string/unk" />

</TableRow>

<TableRow android:id="@+id/tableRow2" android:layout_width="fill_parent"

android:layout_height="wrap_content" android:orientation="horizontal">

<TextView android:id="@+id/textView2" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="@string/lonText" android:textStyle="bold" />

<TextView

http://www.mercubuana.ac.id

79

android:id="@+id/longitudeTxt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/unk" /> </TableRow>

<TableRow android:id="@+id/tableRow4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/Add" android:textStyle="bold" /> <TextView android:id="@+id/myaddress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/unk"/> </TableRow>

<TableRow > <TextView android:layout_width="fill_parent" android:layout_height="10dp"/> </TableRow>

<!-- Data CGI --> <TableRow android:id="@+id/tableRow5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/MccText" android:textStyle="bold"/> <TextView android:id="@+id/MCC_Text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/unk"/> </TableRow>

<TableRow android:id="@+id/tableRow3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/textView5" android:layout_width="wrap_content"

http://www.mercubuana.ac.id

80

android:layout_height="wrap_content" android:text="Jstring/MncText" android:textStyle="bold"/> <TextView

android:id="J+id/MNC_Text" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="Jstring/unk"/> </TableRow>

<TableRow android:id="J+id/tableRow11"

android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

<TextView android:id="J+id/textView6"

android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Jstring/LacText" android:textStyle="bold"/>

<TextView android:id="J+id/LAC_Text" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="Jstring/unk"/> </TableRow>

<TableRow android:id="J+id/tableRow9"

android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

<TextView android:id="J+id/textView7"

android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Jstring/CidText" android:textStyle="bold"/>

<TextView android:id="J+id/Cid_Text" android:layout_width="wrap_content"

android:layout_height="wrap_content" android:text="Jstring/unk"> </TextView>

</TableRow> <TableRow > <TextView android:layout_width="fill_parent" android:layout_height="10dp"/> </TableRow>

<TableRow android:id="J+id/tableRo1"

android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">

<TextView

http://www.mercubuana.ac.id

81

android:id="@+id/IMSI" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/IMSI" android:textStyle="bold"/> <TextView android:id="@+id/imsi_Text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/unk"/> </TableRow> </TableLayout> </ScrollView> </LinearLayout>

Login.xml <I-- login.xml --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools">

<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello_world" /> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="1"> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:text="@string/labelLogin" /> <TableRow android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:text="@string/insert_temp" /> <EditText android:id="@+id/insert_editText" android:hint="@string/insert_t" android:inputType="text" > </EditText> <requestFocus/> </TableRow> <TableRow> <TextView android:text="@string/insert_hp" /> <EditText android:id="@+id/insert_edithp" android:hint="@string/insert_hp" android:inputType="phone"> </EditText> <requestFocus/> </TableRow> <TableRow> <I-- Login button -->

http://www.mercubuana.ac.id

82

<Button android:id="@+id/btnLogin" android:text="@string/btnLogin"/ > </TableRow> </TableLayout>

<TextView android:text="@string/a" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content"/>

<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text="@string/a1" android:layout_width="match_parent" android:layout_height="wrap_content"/> </ScrollView> </LinearLayout>

<!-- Login Form Ends -->

String.xml

<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">FindingHP</string> <string name="hello_world">Tentang Ponselku</string> <string name="menu_settings">Settings</string> <string name="title_activity_conversion">Temukan Ponselku</string> <string name="labelLogin">Silahkan isi informasi di bawah ini:</string>

<!-- Petunjuk --> <string name="a">Petunjuk pengiriman SMS ke Aplikasi FindingHP:</string> <string name="a1"> Cari Lokasi &gt; ketik: "FindingHP lokasi: [pin SMS]" \n Contoh: FindingHP lokasi: 1234567890 \n\n Lupa Pin &gt; ketik: "FindingHP reg pin" \n SMS lupa pin hanya bisa dilakukan dari ponsel yang terdaftar.\n\n Ubah nomor Ponsel &gt; Ketik: "FindingHP ganti [pin SMS]: [nomor baru]" \n Contoh: FindingHP ganti 1234567890: 081123456789\n\n Lupa Petunjuk &gt; ketik: \n "FindingHP petunjuk lokasi" > format Lokasi \n "FindingHP petunjuk pin" > format pin \n "FindingHP petunjuk ponsel" > format ubah nomor ponsel \n "FindingHP petunjuk" > penulisan format petunjuk. </string>

<!-- Format SMS --> <string name="insert_temp">PIN SMS</string> <string name="insert_t">PIN SMS minimal 10 karakter</string>

<!-- No.Phone --> <string name="insert_hp">No. Ponsel</string> http://www.mercubuana.ac.id

83

<string name="btnLogin">Simpan</string>

<!-- GPS --> <string name="latText">Latitude </string> <string name="lonText">Longitude </string> <string name="Add">Alamat GPS :</string> <string name="myaddress"></string>

<!-- Cell ID --> <string name="MccText">MCC </string> <string name="MncText">MNC </string> <string name="LacText">LAC </string> <string name="CidText">CID </string> <string name="unk">Unknown</string>

<!-- IMSI -->

<string name="IMSI">IMSI Awal: </string> </resources>

FindingHP.java

http://www.mercubuana.ac.id

package com.finding.hp; import java.io.IOException;

import java.util.List; import java.util.Locale;

import android.content.Context; import android.content.Intent;

import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager;

import android.telephony.TelephonyManager; import android.telephony.gsm.GsmCellLocation;

import android.os.Bundle; import android.os.PowerManager; import android.app.Activity; import android.content.SharedPreferences; import android.view.WindowManager; import android.widget.TextView;

public class FindingHP extends Activity { private SharedPreferences spimsi; SharedPreferences.Editor speimsi; private LocationManager lm; private LocationListener locListener; private TextView latTxt, lonTxt, myaddress; private TextView textMCC, textMNC, textLAC, textCID, textIMSI;

84

http://www.mercubuana.ac.id

public static String add = "", code = "", nohp = "", imsiku = ""; public static String petcar = "", petpin = "", petno = "", pettuk = ""; public static double lati; int range; private PowerManager.WakeLock wl;

// Session Manager Class static SessionManagement session;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");

setContentView(R.layout.activity_finding_hp);

// Session class instance session = new SessionManagement(getApplicationContext()); session.checkLogin(); Intent mServiceIntent = new Intent(this, StarterService.class); startService(mServiceIntent);

// Data GPS latTxt = (TextView) -FindViewById(R.id.latitudeTxt); lonTxt = (TextView) -FindViewById(R.id.longitudeTxt); myaddress = (TextView) -FindViewById(R.id.myaddress);

// Data Cell ID textMCC = (TextView

) -FindViewById(R.id.MCC_Text);

textMNC = (TextView

) -FindViewById(R.id.MNC_Text);

textLAC = (TextView

) -FindViewById(R.id.LAC_Text);

textCID = (TextView

) -FindViewById(R.id.Cid_Text);

textIMSI = (TextView

) -FindViewById(R.id.imsi_Text); HashMap<String, String> user = session.getUserDetails(); imsiku = user.get(SessionManagement.KEY_IMSI); textIMSI.setText(imsiku); // Read Phone State TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

// my Location: lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); locListener = new MyLocationListener(); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, locListener);

// cell id i-F (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) { String networkOperator = telephonyManager.getNetworkOperator(); GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation(); String mcc = networkOperator.substring(0, 3);

85

http://www.mercubuana.ac.id

String mnc = networkOperator.substring(3); int cid = cellLocation.getCid() & 0xffff; int lac = cellLocation.getLac() & 0xffff;

textMCC.setText(mcc); textMNC.setText(mnc); textCID.setText(String.valueOf(cid)); textLAC.setText(String.valueOf(lac)); } }

private class MyLocationListener implements LocationListener { public void onLocationChanged(Location loc) { GsmCellLocation.requestLocationUpdate(); if (loc != null) { latTxt.setText(String.valueOf(loc.getLatitude())); lonTxt.setText(String.valueOf(loc.getLongitude()));

String lat = Double.toString(loc.getLatitude()); String lon = Double.toString(loc.getLongitude()); myaddress.setText(String.valueOf(GetAddress(lat, lon))); add = GetAddress(lat, lon) + "\n" + "http://www.google.co.id/search?q=" + loc.getLatitude() + ","

+ loc.getLongitude(); lati = loc.getLatitude(); } }

public void onProviderDisabled(String provider) {GsmCellLocation.requestLocationUpdate();}

public void onProviderEnabled(String provider) {} public void onStatusChanged(String provider, int status, Bundle extras) {GsmCellLocation.requestLocationUpdate();} }

// Get Address based on Latitude & Longitude public String GetAddress(String lat, String lon) { Geocoder geocoder = new Geocoder(this, Locale.ENGLISH); String ret = ""; try {

List<Address> addresses = geocoder.getFromLocation (Double.parseDouble(lat), Double.parseDouble(lon), 1); if (addresses != null) { Address returnedAddress = addresses.get(0); StringBuilder strReturnedAddress = new StringBuilder(); for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++) { strReturnedAddress.append(returnedAddress.getAddressLine(i)).

86

append("\n");

http://www.mercubuana.ac.id

} ret = strReturnedAddress.toString(); } else {ret = "No Address returned!";} } catch (IOException e) { e.printStackTrace(); ret = "Can't get Address!"; } return ret; }

@Override protected void onPause()

{ wl.release(); super.onPause(); }

@Override protected void onResume() { wl.acquire(); super.onResume(); } }

Login.java

package com.finding.hp;

import android.app.Activity; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import android.content.Intent; import android.os.Bundle; import android.view.View;

public class Login extends Activity { // hp, SMS PIN Edit text EditText txtpin, hp;

// login button Button btnLogin;

//IMSI string String imsi="";

// Session Manager Class SessionManagement session; @Override

87

http://www.mercubuana.ac.id

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login);

// Session Manager session = new SessionManagement(getApplicationContext());

// no hp, Pin input text txtpin = (EditText) findViewById(R.id.insert_editText); hp = (EditText) findViewById(R.id.insert_edithp);

// Login button btnLogin = (Button) findViewById(R.id.btnLogin);

// Read Phone State TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); imsi = telephonyManager.getSubscriberId().toString();

// Login button click event btnLogin.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // Get SMS Pin, No.HP from EditText String smspin = txtpin.getText().toString(); String nohp = hp.getText().toString();

// Check if username, password is filled if(smspin.trim().length() > 9 && nohp.trim().length()>6)

{ // Creating user login session session.createLoginSession(smspin, nohp,imsi); // Starting MainActivity

Intent i = new Intent (getApplicationContext(), FindingHP.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); finish(); } else { Toast.makeText(getBaseContext(),

"Login Gagal: Silahkan Periksa kembali", Toast.LENGTH_SHORT).show();

} } }); } }

88

SessionManagement.java

http://www.mercubuana.ac.id

package com.finding.hp;

import java.util.HashMap; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor;

public class SessionManagement { // Shared Preferences SharedPreferences pref;

// Editor for Shared preferences Editor editor;

// Context Context _context;

// Shared pref mode int PRIVATE_MODE = 0;

// Sharedpref file name private static final String PREF_NAME = "Android";

// All Shared Preferences Keys private static final String IS_LOGIN = "IsLoggedIn";

// SMS PIN (make variable public to access from outside) public static final String KEY_PIN = "pin";

// PhoneNumber (make variable public to access from outside) public static final String KEY_HP = "myPhone";

// IMSI (make variable public to access from outside) public static final String KEY_IMSI = "myimsi";

public SessionManagement(Context context) { this._context = context; pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE); editor = pref.edit(); }

// Create login session public void createLoginSession(String pinsms, String hpku) { // Storing login value as TRUE editor.putBoolean(IS_LOGIN, true);

// Storing SMS Pin in pref editor.putString(KEY_PIN, pinsms);

// Storing PhoneNumber in pref editor.putString(KEY_HP, hpku);

89

http://www.mercubuana.ac.id

//Storing IMSI in pref editor.putString(KEY_IMSI, imsiku);

// commit changes editor.commit(); }

// Change Phone Number public void changePhoneNumber(String telp) { // Storing PhoneNumber in pref editor.putString(KEY_HP, telp); editor.commit(); }

public void changeimsi (String ims) { editor.putString(KEY_IMSI, ims); editor.commit(); }

/**Check login method will check user login status If false it will redirect * user to login page Else won't do anything * */ public void checkLogin() { // Check login status if (!this.isLoggedIn()) { // user is not logged in redirect him to Login Activity Intent i = new Intent(_context, Login.class);

// Closing all the Activities i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

// Add new Flag to start new Activity i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

// Staring Login Activity _context.startActivity(i); } } // Get stored session data public HashMap<String, String> getUserDetails() { HashMap<String, String> user = new HashMap<String, String>(); // SMS PIN user.put(KEY_PIN, pref.getString(KEY_PIN, null)); // Phone Number user.put(KEY_HP, pref.getString(KEY_HP, null)); // IMSI user.put(KEY_IMSI, pref.getString(KEY_IMSI, null)); return user; } /**Quick check for login * **/ // Get Login State

9 0

http://www.mercubuana.ac.id

public boolean isLoggedIn() {return pref.getBoolean(IS_LOGIN, false); } }

SmsReceiver.java

package com.finding.hp;

import java.util.StringTokenizer; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.PhoneNumberUtils; import android.telephony.SmsManager; import android.telephony.SmsMessage; import android.util.Log; public class SmsReceiver extends BroadcastReceiver { public static String str = "", PhoneNo = "", pesan = "", addr = ""; public static double lati; String lat="", lon="",myaddress="",address=""; String kodeku = StarterService.code;

String a = StarterService.petcar; String b = StarterService.petpin; String c = StarterService.petno; String d = StarterService.pettuk;

String apa = ""; Static SessionManagement ses;

@Override public void onReceive(Context context, Intent intent) { // Listen for boot_completed, then executes the onReceive() method. Log.i("Autostart", "BOOT_COMPLETED"); Intent A = new Intent(context,

StarterService.class); context.startService(A);

// ---get the SMS message passed in---

Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; if (bundle != null) { // ---retrieve the SMS message received---

Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; for (int i = 0; i < msgs.length; i++) { msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); str += "SMS from " + msgs[i].getOriginatingAddress(); str += " :"; str += msgs[i].getMessageBody().toString(); str += "\n"; PhoneNo = msgs[0].getOriginatingAddress().toString(); pesan = msgs[0].getDisplayMessageBody().toString(); }

91

http://www.mercubuana.ac.id

StringTokenizer satu = new StringTokenizer (pesan," "); String satuan = satu.nextToken(); i-F (satuan.toLowerCase().equals("-Findinghp")) {abortBroadcast();}

StringTokenizer tokens = new StringTokenizer(pesan, ":"); String -First = tokens.nextToken(); i-F(-First.equals("FindingHP ganti "+kodeku)) { String second = tokens.nextToken().replace(" ",""); apa = PhoneNumberUtils.formatNumber(second); StarterService.change(apa); sendSMS(PhoneNo,"Nomor anda sekarang: "+apa); }

String hpku = StarterService.nohp;

// cek harus kirim GPS atau cell id? i-F ( StarterService.lati==ø) {addr = StarterService.add_cell;} else {addr = StarterService.address;}

// compare 2 string: (pesan = "FindingHP lokasi: kodeku" ?) i-F (pesan.equals("FindingHP lokasi: " + kodeku)) {sendSMS(PhoneNo, addr); }

i-F (pesan.equals("FindingHP reg pin")) { i-F (PhoneNumberUtils.compare(PhoneNo, hpku)) { sendSMS(PhoneNo, "Pin Anda: \n" + kodeku);} }

i-F(pesan.equals("FindingHP petunjuk lokasi")) { sendSMS(PhoneNo, a); }

i-F(pesan.equals("FindingHP petunjuk pin")) { sendSMS(PhoneNo, b); }

i-F(pesan.equals("FindingHP petunjuk ponsel")) { sendSMS(PhoneNo, c); }

i-F(pesan.equals("FindingHP petunjuk")) { sendSMS(PhoneNo, d); } } } private void sendSMS(String phoneNo, String pesanku) { SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(phoneNo, null, pesanku, null, null); } }

92

StarterService.java

http://www.mercubuana.ac.id

package com.finding.hp;

import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Locale;

import android.app.Service; import android.content.Context; import android.content.Intent; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.os.IBinder; import android.os.Looper; import android.telephony.SmsManager; import android.telephony.TelephonyManager; import android.telephony.gsm.GsmCellLocation; import android.util.Log; import android.widget.Toast;

public class StarterService extends Service { int cid=0,lac=0; public static String mcc="",mnc="",add_cell=""; private LocationManager lm; private LocationListener locListener; public static String address ="",code="",nohp="",imsisy="",add1=""; public static String petcar="",petpin="",petno="",pettuk=""; public static double lati,lati1; String url="",imsi="",pesanIm="",lat="", lon="",myaddress=""; int range;

// Session Manager Class static SessionManagement session; public static final String TAG = "MyService";

@Override public IBinder onBind(Intent intent) { return null;}

@Override public void onDestroy() { Intent in = new Intent(); in.setAction("SmsReceiver"); sendBroadcast(in); Log.d(TAG, "onDestroy"); lm.removeUpdates(locListener); }

@Override

93

http://www.mercubuana.ac.id

public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); onStart(intent, startId); addLocationListener(); return START_STICKY; }

@Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate"); }

@Override public void onStart(Intent intent, int startid) { Log.d(TAG, "onStart"); super.onStart(intent, startid); addLocationListener(); }

private void addLocationListener() { Thread triggerService = new Thread(new Runnable() { public void run() { try { Looper.prepare(); lm = (LocationManager) getSystemService (Context.LOCATION_SERVICE); locListener = new MyLocationListener(); lm.requestLocationUpdates (LocationManager.GPS_PROVIDER, 5000, 0, locListener); //Read Phone State TelephonyManager telephonyManager = (TelephonyManager) getSystemService (Context.TELEPHONY_SERVICE); //baca IMSI imsi = telephonyManager.getSubscriberId().toString();

session = new SessionManagement (getApplicationContext()); session.checkLogin();

// get user data from session HashMap<String, String> user = session.getUserDetails(); nohp = user.get(SessionManagement.KEY_HP); code = user.get(SessionManagement.KEY_PIN); imsisy = user.get(SessionManagement.KEY_IMSI); if(imsisy.contentEquals("")==false) {

9 4

http://www.mercubuana.ac.id

if (imsi.equals(imsisy)==false) { pesanIm = "Kartu SIM telah diganti." + "\n" + "IMSI Lama: " + imsisy +"\n" + "IMSI Baru: " + imsi + "\n" ; sendSMS(nohp,pesanIm); changeIMSI (imsi); } }

petcar= "Petunjuk FindingHP: \n" + "Cari Lokasi > ketik: 'FindingHP lokasi: <pin SMS>' \n" +"Contoh: FindingHP lokasi: 1234567890";

pettuk="Petunjuk FindingHP: \n" + "Lupa Petunjuk > ketik:

'FindingHP petunjuk lokasi' atau 'FindingHP petunjuk pin' atau 'FindingHP petunjuk ponsel' atau 'FindingHP petunjuk'";

petpin="Petunjuk FindingHP: \n" +"Lupa Pin > ketik: 'FindingHP reg pin' \n" +"SMS lupa pin hanya bisa dilakukan dari ponsel yang terdaftar.";

petno= "Petunjuk FindingHP: \n" + "Ubah nomor Ponsel > Ketik: 'FindingHP ganti [pin SMS]: [nomor baru]' \n" +"Contoh: FindingHP ganti 1234567890: 081123456789";

if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) { String networkOperator = telephonyManager.getNetworkOperator(); GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation(); mcc = networkOperator.substring (0,3); mnc = networkOperator.substring (3); cid = cellLocation.getCid() & 0xffff; lac = cellLocation.getLac()& 0xffff; }

if (cid != 0) { url=http://www.opencellid.org/cell/get?cellid=

+ cid + "&mcc="+ mcc + "&mnc="+ mnc + "&lac="+ lac +"&fmt=txt"; add_cell= "MCC: "+ mcc + "\n" + "MNC: "+ mnc + "\n" + "LAC: "+ lac +"\n" + "CID: "+ cid + "\n\n"

95

http://www.mercubuana.ac.id

+ url; } Log.d("LOC_SERVICE", "Service RUNNING!"); Looper.loop(); } catch(Exception ex) {ex.printStackTrace();} } }, "LocationThread"); triggerService.start(); }

public static void change (String phoneNo) {session.changePhoneNumber(phoneNo);}

private void changeIMSI(String imsi2) {session.changeimsi(imsi2);}

private class MyLocationListener implements LocationListener { public void onLocationChanged (Location loc) { GsmCellLocation.requestLocationUpdate(); if (loc != null) { lat = Double.toString(loc.getLatitude()); lon = Double.toString(loc.getLongitude()); myaddress = GetAddress(lat, lon); address = GetAddress(lat,lon) + "\n" +http://www.google.co.id/search?q= + loc.getLatitude() + ","+ loc.getLongitude(); lati = loc.getLatitude(); } } public void onProviderDisabled (String provider) { GsmCellLocation.requestLocationUpdate(); Log.e(TAG, "onProviderDisabled: " + provider); }

public void onProviderEnabled (String provider) {} public void onStatusChanged(String provider, int status, Bundle extras) {GsmCellLocation.requestLocationUpdate();} }

// Get Address based on Latitude & Longitude public String GetAddress(String lat, String lon) { Geocoder geocoder = new Geocoder(this, Locale.ENGLISH); String ret = ""; try { List<Address> addresses = geocoder.getFromLocation (Double.parseDouble(lat), Double.parseDouble(lon), 1); if (addresses != null) { Address returnedAddress = addresses.get(0);

9 6

http://www.mercubuana.ac.id

StringBuilder strReturnedAddress = new StringBuilder(); for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++) { strReturnedAddress.append(returnedAddress.getAddressLine(i)).

append("\n"); } ret = strReturnedAddress.toString(); } else {ret = "No Address returned!";} } catch (IOException e) { e.printStackTrace(); ret = "Can't get Address!"; } return ret; }

private void sendSMS(String phoneNo2, String pesanku2) { SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(phoneNo2, null, pesanku2, null, null); } }

http://www.mercubuana.ac.id