Skip to content

Commit

Permalink
Merge pull request #60 from xLaMbChOpSx/master
Browse files Browse the repository at this point in the history
 Neighbouring Cell Info, Ciphering Indicator & Initial About Dialog
  • Loading branch information
xLaMbChOpSx committed May 6, 2014
2 parents 11ad922 + ddba361 commit 51f6f10
Show file tree
Hide file tree
Showing 17 changed files with 1,512 additions and 85 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

}

Expand Down
24 changes: 16 additions & 8 deletions app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,24 @@ public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem mTrackLocation = menu.findItem(R.id.track_location);
MenuItem mTrackFemtocell = menu.findItem(R.id.track_femtocell);

if (mAimsicdService.TrackingCell) {
if (mBound && mAimsicdService.isTrackingCell()) {
mTrackCell.setTitle(R.string.untrack_cell);
mTrackCell.setIcon(R.drawable.track_cell);
} else {
mTrackCell.setTitle(R.string.track_cell);
mTrackCell.setIcon(R.drawable.untrack_cell);
}

if (mAimsicdService.TrackingLocation) {
if (mBound && mAimsicdService.isTrackingLocation()) {
mTrackLocation.setTitle(R.string.untrack_location);
mTrackLocation.setIcon(R.drawable.ic_action_location_found);
} else {
mTrackLocation.setTitle(R.string.track_location);
mTrackLocation.setIcon(R.drawable.ic_action_location_off);
}

if (mAimsicdService.getPhoneID() == TelephonyManager.PHONE_TYPE_CDMA) {
if (mAimsicdService.TrackingFemtocell) {
if (mBound && mAimsicdService.getPhoneID() == TelephonyManager.PHONE_TYPE_CDMA) {
if (mBound && mAimsicdService.isTrackingFemtocell()) {
mTrackFemtocell.setTitle(R.string.untrack_femtocell);
mTrackFemtocell.setIcon(R.drawable.ic_action_network_cell);
} else {
Expand Down Expand Up @@ -265,7 +265,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
case R.id.update_opencelldata:
double[] loc = mAimsicdService.getLastLocation();
getOpenCellData(loc[0], loc[1]);
if (loc[0] != 0.0 && loc[1] != 0.0) {
getOpenCellData(loc[0], loc[1]);
} else {
Helpers.sendMsg(mContext, "Unable to determine your last location, enable Location Services (GPS) and try again.");
}
return true;
case R.id.app_exit:
finish();
Expand Down Expand Up @@ -304,7 +308,7 @@ private void showmap() {
* Cell Information Tracking - Enable/Disable
*/
private void trackcell() {
if (mAimsicdService.TrackingCell) {
if (mAimsicdService.isTrackingCell()) {
mAimsicdService.setCellTracking(false);
} else {
mAimsicdService.setCellTracking(true);
Expand All @@ -315,7 +319,7 @@ private void trackcell() {
* Location Information Tracking - Enable/Disable
*/
private void tracklocation() {
if (mAimsicdService.TrackingLocation) {
if (mAimsicdService.isTrackingLocation()) {
mAimsicdService.setLocationTracking(false);
} else {
mAimsicdService.setLocationTracking(true);
Expand All @@ -326,7 +330,7 @@ private void tracklocation() {
* FemtoCell Detection (CDMA Phones ONLY) - Enable/Disable
*/
private void trackFemtocell() {
if (mAimsicdService.TrackingFemtocell) {
if (mAimsicdService.isTrackingFemtocell()) {
mAimsicdService.stopTrackingFemto();
} else {
mAimsicdService.startTrackingFemto();
Expand Down Expand Up @@ -512,6 +516,10 @@ public MyFragmentPagerAdapter(FragmentManager fm) {
titles.add(getString(R.string.device_info));
fragments.add(new DbViewerFragment(mContext));
titles.add(getString(R.string.db_viewer));
fragments.add(new CellInfoFragment(mContext));
titles.add(getString(R.string.cell_info_title));
fragments.add(new AboutFragment(mContext));
titles.add(getString(R.string.about_aimsicd));
}
@Override
public Fragment getItem(int position) {
Expand Down
43 changes: 43 additions & 0 deletions app/src/main/java/com/SecUpwN/AIMSICD/AboutFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.SecUpwN.AIMSICD;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class AboutFragment extends Fragment {

private Context mContext;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.about_fragment, container, false);
String version;

PackageManager manager = mContext.getPackageManager();
try {
PackageInfo info = manager.getPackageInfo(mContext.getPackageName(), 0);
version = info.versionName;
} catch (PackageManager.NameNotFoundException nnfe) {
//Woops something went wrong??
version = "";
}

TextView versionNumber = (TextView) v.findViewById(R.id.aimsicd_version);
versionNumber.setText(version);

return v;
}

public AboutFragment (Context context) {
mContext = context;
}


}
209 changes: 209 additions & 0 deletions app/src/main/java/com/SecUpwN/AIMSICD/CellInfoFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
package com.SecUpwN.AIMSICD;

import com.SecUpwN.AIMSICD.rilexecutor.DetectResult;
import com.SecUpwN.AIMSICD.service.AimsicdService;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CellInfoFragment extends Fragment {
private AimsicdService mAimsicdService;
private View mView;
private TextView mNeighbouringCells;
private TextView mNeighbouringTotal;
private TextView mNeighbouringTotalLabel;
private TextView mCipheringIndicatorLabel;
private TextView mCipheringIndicator;

private boolean mBound;
private Context mContext;

private Map<Integer,Integer> mNeighborMapUMTS = new HashMap<Integer,Integer>();
private Map<String,Integer> mNeighborMapGSM = new HashMap<String,Integer>();

public CellInfoFragment (Context context) {
mContext = context;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mView= inflater.inflate(R.layout.cell_fragment,
container, false);
mNeighbouringCells = (TextView) mView.findViewById(R.id.neighbouring_cells);
mNeighbouringTotal = (TextView) mView.findViewById(R.id.neighbouring_number);
mNeighbouringTotalLabel = (TextView) mView.findViewById(R.id.neighbouring_number_label);
mCipheringIndicatorLabel = (TextView) mView.findViewById(R.id.ciphering_indicator_title);
mCipheringIndicator = (TextView) mView.findViewById(R.id.ciphering_indicator);
Button refresh = (Button) mView.findViewById(R.id.button_refresh);
refresh.setOnClickListener(new btnClick());

return mView;
}

@Override
public void onDestroy() {
super.onDestroy();
// Unbind from the service
if (mBound) {
mContext.unbindService(mConnection);
mBound = false;
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Bind to LocalService
Intent intent = new Intent(mContext, AimsicdService.class);
//Start Service before binding to keep it resident when activity is destroyed
mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}

/**
* Service Connection to bind the activity to the service
*/
private final ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
// We've bound to LocalService, cast the IBinder and get LocalService instance
mAimsicdService = ((AimsicdService.AimscidBinder) service).getService();
mBound = true;
updateUI();
}

@Override
public void onServiceDisconnected(ComponentName arg0) {
mBound = false;
}
};

private class btnClick implements View.OnClickListener {
@Override
public void onClick(View v) {
updateUI();
}
}

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
updateUI();
}
}

private void updateUI() {
if (mBound) {
mAimsicdService.updateNeighbouringCells();
mNeighborMapUMTS = mAimsicdService.getUMTSNeighbouringCells();
mNeighborMapGSM = mAimsicdService.getGSMNeighbouringCells();

mNeighbouringTotal
.setText(String.valueOf(mAimsicdService.getNeighbouringCellSize()) + "/"
+ String.valueOf(mNeighborMapUMTS.size() + mNeighborMapGSM.size()));

StringBuilder sb = new StringBuilder();
int i = 1;
if (!mNeighborMapUMTS.isEmpty())
for (Object key : mNeighborMapUMTS.keySet()) {
sb.append(i)
.append(") PSC: ")
.append(key)
.append(" RSCP: ")
.append(mNeighborMapUMTS.get(key)) //TS25.133 section 9.1.1.3
.append(" dBm");
if (i < mNeighborMapUMTS.size() + mNeighborMapGSM.size())
sb.append("\n");
i++;
}
if (!mNeighborMapGSM.isEmpty())
for (Object key : mNeighborMapGSM.keySet()) {
sb.append(i)
.append(") LAC-CID: ")
.append(key)
.append(" RSSI: ")
.append(mNeighborMapGSM.get(key)) //TS27.007 section 8.5
.append(" dBm");
if (i < mNeighborMapUMTS.size() + mNeighborMapGSM.size())
sb.append("\n");
i++;
}
mNeighbouringCells.setText(sb);

//Try SamSung MultiRil Implementation
if (mNeighborMapGSM.isEmpty() && mNeighborMapUMTS.isEmpty()) {
DetectResult rilStatus = mAimsicdService.getRilExecutorStatus();
if (rilStatus.available) {
//new RequestOemInfoTask().execute();
new RequestOemInfoTask().execute();
}
} else {
mNeighbouringTotal.setVisibility(View.VISIBLE);
mNeighbouringTotalLabel.setVisibility(View.VISIBLE);
}
}
}

void updateCipheringIndicator() {
final List<String> list = mAimsicdService.getCipheringInfo();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (list != null) {
mCipheringIndicatorLabel.setVisibility(View.VISIBLE);
mCipheringIndicator.setVisibility(View.VISIBLE);
mCipheringIndicator.setText(TextUtils.join("\n", list));

}
}
});
}

void updateNeighbouringCells() {
final List<String> list = mAimsicdService.getNeighbours();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (list != null) {
mNeighbouringCells.setText(TextUtils.join("\n", list));
mNeighbouringTotal.setVisibility(View.GONE);
mNeighbouringTotalLabel.setVisibility(View.GONE);
}
}
});
}

private class RequestOemInfoTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... string) {
if (!mBound) return null;
updateNeighbouringCells();
updateCipheringIndicator();

return null;
}

@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
}
}

}
Loading

0 comments on commit 51f6f10

Please sign in to comment.