diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index af8a61800..bc72ecab8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -121,6 +121,22 @@
+
+
+
+
+
+
+
+
+
-
-
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_marginLeft="30dip"
+ android:gravity="center_vertical"
+ android:orientation="horizontal" >
+
+
+ android:hint="35"
+ android:inputType="numberDecimal"
+ android:maxLength="2"
+ tools:ignore="HardcodedText" />
+
-
+
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:text="@string/settings_quirks"
+ android:textIsSelectable="false" />
-
-
-
+ android:hint="freeze,resolve,test"
+ android:inputType="text"
+ tools:ignore="HardcodedText" />
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
+
-
+
-
+
+
-
-
-
-
-
-
+
-
+
-
+
-
-
-
-
-
+
+
-
+
-
+
-
+
+
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/res/menu/settings.xml b/res/menu/settings.xml
new file mode 100644
index 000000000..1ec268e87
--- /dev/null
+++ b/res/menu/settings.xml
@@ -0,0 +1,15 @@
+
+
\ No newline at end of file
diff --git a/src/biz/bokhorst/xprivacy/ActivityApp.java b/src/biz/bokhorst/xprivacy/ActivityApp.java
index 3eea74021..2cc59b982 100644
--- a/src/biz/bokhorst/xprivacy/ActivityApp.java
+++ b/src/biz/bokhorst/xprivacy/ActivityApp.java
@@ -679,7 +679,10 @@ private void optionFetch() {
}
private void optionSettings() {
- SettingsDialog.edit(ActivityApp.this, mAppInfo);
+ Intent intent = new Intent(ActivityApp.this, ActivitySettings.class);
+ intent.putExtra(ActivitySettings.cAppUid, mAppInfo.getUid());
+ intent.putStringArrayListExtra(ActivitySettings.cAppName, mAppInfo.getApplicationName());
+ startActivity(intent);
}
private void optionDump() {
diff --git a/src/biz/bokhorst/xprivacy/ActivityMain.java b/src/biz/bokhorst/xprivacy/ActivityMain.java
index 992dbb3de..561b1cce5 100644
--- a/src/biz/bokhorst/xprivacy/ActivityMain.java
+++ b/src/biz/bokhorst/xprivacy/ActivityMain.java
@@ -101,6 +101,7 @@ public class ActivityMain extends ActivityBase implements OnItemSelectedListener
private static final int ERROR_NON_MATCHING_UID = 0x103;
public static final Uri cProUri = Uri.parse("http://www.xprivacy.eu/");
+ public static final String cRefreshUI = "RefreshUI";
private static ExecutorService mExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
new PriorityThreadFactory());
@@ -360,6 +361,12 @@ protected void onNewIntent(Intent intent) {
if (Intent.ACTION_VIEW.equals(intent.getAction()))
Util.importProLicense(new File(intent.getData().getPath()));
+
+ // Handle clear XPrivacy data (needs UI refresh)
+ if (intent.hasExtra(cRefreshUI)) {
+ ((EditText) findViewById(R.id.etFilter)).setText("");
+ recreate();
+ }
}
@Override
@@ -597,7 +604,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
optionSwitchTheme();
return true;
case R.id.menu_settings:
- SettingsDialog.edit(ActivityMain.this, null);
+ optionSettings();
return true;
case R.id.menu_dump:
optionDump();
@@ -989,6 +996,11 @@ private void optionSwitchTheme() {
this.recreate();
}
+ private void optionSettings() {
+ Intent intent = new Intent(this, ActivitySettings.class);
+ startActivity(intent);
+ }
+
private void optionDump() {
try {
PrivacyService.getClient().dump(0);
diff --git a/src/biz/bokhorst/xprivacy/ActivitySettings.java b/src/biz/bokhorst/xprivacy/ActivitySettings.java
new file mode 100644
index 000000000..2a04a7a15
--- /dev/null
+++ b/src/biz/bokhorst/xprivacy/ActivitySettings.java
@@ -0,0 +1,758 @@
+package biz.bokhorst.xprivacy;
+
+import java.io.File;
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Address;
+import android.location.Geocoder;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Process;
+import android.text.TextUtils;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.Toast;
+
+public class ActivitySettings extends ActivityBase implements OnCheckedChangeListener, OnClickListener {
+ private int userId;
+ private int uid;
+ private boolean isApp;
+ private boolean odSystem;
+ private CheckBox cbNotify;
+ private CheckBox cbOnDemand;
+ private CheckBox cbBlacklist;
+ private CheckBox cbUsage;
+ private CheckBox cbParameters;
+ private CheckBox cbLog;
+ private CheckBox cbSystem;
+ private CheckBox cbExperimental;
+ private CheckBox cbHttps;
+ private CheckBox cbAOSP;
+ private EditText etConfidence;
+ private EditText etQuirks;
+ private Button btnClearDb;
+ private CheckBox cbRandom;
+ private EditText etSerial;
+ private EditText etLat;
+ private EditText etLon;
+ private EditText etAlt;
+ private EditText etSearch;
+ private EditText etMac;
+ private EditText etIP;
+ private EditText etImei;
+ private EditText etPhone;
+ private EditText etId;
+ private EditText etGsfId;
+ private EditText etAdId;
+ private EditText etMcc;
+ private EditText etMnc;
+ private EditText etCountry;
+ private EditText etOperator;
+ private EditText etIccId;
+ private EditText etCid;
+ private EditText etLac;
+ private EditText etSubscriber;
+ private EditText etSSID;
+ private EditText etUa;
+ private CheckBox cbSerial;
+ private CheckBox cbLat;
+ private CheckBox cbLon;
+ private CheckBox cbAlt;
+ private CheckBox cbMac;
+ private CheckBox cbImei;
+ private CheckBox cbPhone;
+ private CheckBox cbId;
+ private CheckBox cbGsfId;
+ private CheckBox cbAdId;
+ private CheckBox cbCountry;
+ private CheckBox cbSubscriber;
+ private CheckBox cbSSID;
+
+ public static final String ACTION_SETTINGS = "biz.bokhorst.xprivacy.action.SETTINGS";
+ public static final String cAppUid = "AppUid";
+ public static final String cAppName = "AppName";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.settings);
+ setTitle(R.string.menu_settings);
+
+ final Bundle extras = getIntent().getExtras();
+ userId = Util.getUserId(Process.myUid());
+
+ if (extras != null && extras.containsKey(cAppUid))
+ uid = extras.getInt(cAppUid);
+ else
+ uid = userId;
+
+ // Reference controls
+ cbNotify = (CheckBox) findViewById(R.id.cbNotify);
+ cbOnDemand = (CheckBox) findViewById(R.id.cbOnDemand);
+ cbBlacklist = (CheckBox) findViewById(R.id.cbBlacklist);
+ cbUsage = (CheckBox) findViewById(R.id.cbUsage);
+ cbParameters = (CheckBox) findViewById(R.id.cbParameters);
+ cbLog = (CheckBox) findViewById(R.id.cbLog);
+
+ final CheckBox cbExpert = (CheckBox) findViewById(R.id.cbExpert);
+ cbSystem = (CheckBox) findViewById(R.id.cbSystem);
+ cbExperimental = (CheckBox) findViewById(R.id.cbExperimental);
+ cbHttps = (CheckBox) findViewById(R.id.cbHttps);
+ cbAOSP = (CheckBox) findViewById(R.id.cbAOSP);
+ final LinearLayout llConfidence = (LinearLayout) findViewById(R.id.llConfidence);
+ etConfidence = (EditText) findViewById(R.id.etConfidence);
+ etQuirks = (EditText) findViewById(R.id.etQuirks);
+ btnClearDb = (Button) findViewById(R.id.btnClearDb);
+
+ cbRandom = (CheckBox) findViewById(R.id.cbRandom);
+ final Button btnRandom = (Button) findViewById(R.id.btnRandom);
+ final Button btnClear = (Button) findViewById(R.id.btnClear);
+ final Button btnFlush = (Button) findViewById(R.id.btnFlush);
+
+ etSerial = (EditText) findViewById(R.id.etSerial);
+ etLat = (EditText) findViewById(R.id.etLat);
+ etLon = (EditText) findViewById(R.id.etLon);
+ etAlt = (EditText) findViewById(R.id.etAlt);
+ etSearch = (EditText) findViewById(R.id.etSearch);
+ final Button btnSearch = (Button) findViewById(R.id.btnSearch);
+ etMac = (EditText) findViewById(R.id.etMac);
+ etIP = (EditText) findViewById(R.id.etIP);
+ etImei = (EditText) findViewById(R.id.etImei);
+ etPhone = (EditText) findViewById(R.id.etPhone);
+ etId = (EditText) findViewById(R.id.etId);
+ etGsfId = (EditText) findViewById(R.id.etGsfId);
+ etAdId = (EditText) findViewById(R.id.etAdId);
+ etMcc = (EditText) findViewById(R.id.etMcc);
+ etMnc = (EditText) findViewById(R.id.etMnc);
+ etCountry = (EditText) findViewById(R.id.etCountry);
+ etOperator = (EditText) findViewById(R.id.etOperator);
+ etIccId = (EditText) findViewById(R.id.etIccId);
+ etCid = (EditText) findViewById(R.id.etCid);
+ etLac = (EditText) findViewById(R.id.etLac);
+ etSubscriber = (EditText) findViewById(R.id.etSubscriber);
+ etSSID = (EditText) findViewById(R.id.etSSID);
+ etUa = (EditText) findViewById(R.id.etUa);
+
+ cbSerial = (CheckBox) findViewById(R.id.cbSerial);
+ cbLat = (CheckBox) findViewById(R.id.cbLat);
+ cbLon = (CheckBox) findViewById(R.id.cbLon);
+ cbAlt = (CheckBox) findViewById(R.id.cbAlt);
+ cbMac = (CheckBox) findViewById(R.id.cbMac);
+ cbImei = (CheckBox) findViewById(R.id.cbImei);
+ cbPhone = (CheckBox) findViewById(R.id.cbPhone);
+ cbId = (CheckBox) findViewById(R.id.cbId);
+ cbGsfId = (CheckBox) findViewById(R.id.cbGsfId);
+ cbAdId = (CheckBox) findViewById(R.id.cbAdId);
+ cbCountry = (CheckBox) findViewById(R.id.cbCountry);
+ cbSubscriber = (CheckBox) findViewById(R.id.cbSubscriber);
+ cbSSID = (CheckBox) findViewById(R.id.cbSSID);
+
+ // Listen for changes
+ cbExpert.setOnCheckedChangeListener(this);
+ cbSerial.setOnCheckedChangeListener(this);
+ cbLat.setOnCheckedChangeListener(this);
+ cbLon.setOnCheckedChangeListener(this);
+ cbAlt.setOnCheckedChangeListener(this);
+ cbMac.setOnCheckedChangeListener(this);
+ cbImei.setOnCheckedChangeListener(this);
+ cbPhone.setOnCheckedChangeListener(this);
+ cbId.setOnCheckedChangeListener(this);
+ cbGsfId.setOnCheckedChangeListener(this);
+ cbAdId.setOnCheckedChangeListener(this);
+ cbCountry.setOnCheckedChangeListener(this);
+ cbSubscriber.setOnCheckedChangeListener(this);
+ cbSSID.setOnCheckedChangeListener(this);
+
+ // Display app name
+ if (extras != null) {
+ String subtitle;
+ if (extras.containsKey(cAppName))
+ subtitle = TextUtils.join(", ", extras.getIntegerArrayList(cAppName));
+ else // Should never happen
+ subtitle = "-";
+ getActionBar().setSubtitle(subtitle);
+ }
+
+ // Get current values
+ boolean usage = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingUsage, true);
+ boolean parameters = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingParameters, false);
+ boolean log = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingLog, false);
+
+ boolean components = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingSystem, false);
+ boolean experimental = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingExperimental, false);
+ boolean https = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingHttps, true);
+ boolean aosp = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingAOSPMode, false);
+ String confidence = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingConfidence, "");
+
+ // Get quirks
+ boolean freeze = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingFreeze, false);
+ boolean resolve = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingResolve, false);
+ boolean noresolve = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingNoResolve, false);
+ boolean permman = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingPermMan, false);
+ boolean iwall = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingIntentWall, false);
+ boolean safemode = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingSafeMode, false);
+ boolean test = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingTestVersions, false);
+ boolean odsystem = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingOnDemandSystem, false);
+ List listQuirks = new ArrayList();
+ if (freeze)
+ listQuirks.add("freeze");
+ if (resolve)
+ listQuirks.add("resolve");
+ if (noresolve)
+ listQuirks.add("noresolve");
+ if (permman)
+ listQuirks.add("permman");
+ if (iwall)
+ listQuirks.add("iwall");
+ if (safemode)
+ listQuirks.add("safemode");
+ if (test)
+ listQuirks.add("test");
+ if (odsystem)
+ listQuirks.add("odsystem");
+ Collections.sort(listQuirks);
+ String quirks = TextUtils.join(",", listQuirks.toArray());
+
+ final boolean expert = (components || experimental || !https || aosp || !"".equals(confidence) || listQuirks
+ .size() > 0);
+
+ // Application specific
+ boolean notify = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingNotify, true);
+ boolean ondemand = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingOnDemand, uid == userId);
+ boolean blacklist = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingBlacklist, false);
+ boolean enabled = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingRestricted, true);
+
+ // Common
+ boolean random = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingRandom, false);
+
+ String serial = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSerial, "");
+ String lat = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLatitude, "");
+ String lon = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLongitude, "");
+ String alt = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingAltitude, "");
+ String mac = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMac, "");
+ String imei = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingImei, "");
+ String phone = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingPhone, "");
+ String id = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingId, "");
+ String gsfid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingGsfId, "");
+ String adid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingAdId, "");
+ String country = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingCountry, "");
+ String subscriber = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSubscriber, "");
+ String ssid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSSID, "");
+
+ // Set current values
+ if (uid == userId) {
+ // Global settings
+ cbUsage.setChecked(usage);
+ cbParameters.setChecked(parameters);
+ cbParameters.setEnabled(Util.hasProLicense(this) != null);
+ if (userId == 0)
+ cbLog.setChecked(log);
+ else {
+ cbLog.setVisibility(View.GONE);
+ btnClearDb.setVisibility(View.GONE);
+ }
+ cbExpert.setChecked(expert);
+
+ if (PrivacyManager.cVersion3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
+ cbAOSP.setVisibility(View.VISIBLE);
+
+ if (expert) {
+ cbSystem.setChecked(components);
+ cbExperimental.setChecked(experimental);
+ cbHttps.setChecked(https);
+ cbAOSP.setChecked(aosp);
+ etConfidence.setText(confidence);
+ etQuirks.setText(quirks);
+ } else {
+ cbSystem.setEnabled(false);
+ cbExperimental.setEnabled(false);
+ cbHttps.setEnabled(false);
+ cbHttps.setChecked(true);
+ cbAOSP.setEnabled(false);
+ cbAOSP.setChecked(false);
+ etConfidence.setEnabled(false);
+ etQuirks.setEnabled(false);
+ btnClearDb.setEnabled(false);
+ }
+ } else {
+ // Disable global settings
+ cbUsage.setVisibility(View.GONE);
+ cbParameters.setVisibility(View.GONE);
+ cbLog.setVisibility(View.GONE);
+ cbSystem.setVisibility(View.GONE);
+ cbExperimental.setVisibility(View.GONE);
+ cbHttps.setVisibility(View.GONE);
+ cbAOSP.setVisibility(View.GONE);
+ llConfidence.setVisibility(View.GONE);
+ btnClearDb.setVisibility(View.GONE);
+
+ cbExpert.setChecked(expert);
+ if (expert)
+ etQuirks.setText(quirks);
+ else
+ etQuirks.setEnabled(false);
+ }
+
+ boolean gnotify = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingNotify, true);
+ if (uid == userId || gnotify)
+ cbNotify.setChecked(notify);
+ else
+ cbNotify.setVisibility(View.GONE);
+
+ isApp = PrivacyManager.isApplication(uid);
+ odSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemandSystem, false);
+ boolean gondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
+ if (uid == userId || ((isApp || odSystem) && gondemand)) {
+ cbOnDemand.setChecked(ondemand);
+ cbOnDemand.setEnabled(enabled);
+ } else
+ cbOnDemand.setVisibility(View.GONE);
+
+ String blFileName = Environment.getExternalStorageDirectory().getPath() + "/.xprivacy/blacklist";
+ if (uid == userId || !new File(blFileName).exists())
+ cbBlacklist.setVisibility(View.GONE);
+ else
+ cbBlacklist.setChecked(blacklist);
+
+ // Common
+ cbRandom.setChecked(random);
+
+ // Set randomize on access check boxes
+ cbSerial.setChecked(serial.equals(PrivacyManager.cValueRandom));
+ cbLat.setChecked(lat.equals(PrivacyManager.cValueRandom));
+ cbLon.setChecked(lon.equals(PrivacyManager.cValueRandom));
+ cbAlt.setChecked(alt.equals(PrivacyManager.cValueRandom));
+ cbMac.setChecked(mac.equals(PrivacyManager.cValueRandom));
+ cbImei.setChecked(imei.equals(PrivacyManager.cValueRandom));
+ cbPhone.setChecked(phone.equals(PrivacyManager.cValueRandom));
+ cbId.setChecked(id.equals(PrivacyManager.cValueRandom));
+ cbGsfId.setChecked(gsfid.equals(PrivacyManager.cValueRandom));
+ cbAdId.setChecked(adid.equals(PrivacyManager.cValueRandom));
+ cbCountry.setChecked(country.equals(PrivacyManager.cValueRandom));
+ cbSubscriber.setChecked(subscriber.equals(PrivacyManager.cValueRandom));
+ cbSSID.setChecked(ssid.equals(PrivacyManager.cValueRandom));
+
+ // Set fake values
+ etSerial.setText(cbSerial.isChecked() ? "" : serial);
+ etLat.setText(cbLat.isChecked() ? "" : lat);
+ etLon.setText(cbLon.isChecked() ? "" : lon);
+ etAlt.setText(cbAlt.isChecked() ? "" : alt);
+ etMac.setText(cbMac.isChecked() ? "" : mac);
+ etImei.setText(cbImei.isChecked() ? "" : imei);
+ etPhone.setText(cbPhone.isChecked() ? "" : phone);
+ etId.setText(cbId.isChecked() ? "" : id);
+ etGsfId.setText(cbGsfId.isChecked() ? "" : gsfid);
+ etAdId.setText(cbAdId.isChecked() ? "" : adid);
+ etCountry.setText(cbCountry.isChecked() ? "" : country);
+ etSubscriber.setText(cbSubscriber.isChecked() ? "" : subscriber);
+ etSSID.setText(cbSSID.isChecked() ? "" : ssid);
+
+ etSerial.setEnabled(!cbSerial.isChecked());
+ etLat.setEnabled(!cbLat.isChecked());
+ etLon.setEnabled(!cbLon.isChecked());
+ etAlt.setEnabled(!cbAlt.isChecked());
+
+ etSearch.setEnabled(Geocoder.isPresent());
+ btnSearch.setEnabled(Geocoder.isPresent());
+
+ etMac.setEnabled(!cbMac.isChecked());
+ etImei.setEnabled(!cbImei.isChecked());
+ etPhone.setEnabled(!cbPhone.isChecked());
+ etId.setEnabled(!cbId.isChecked());
+ etGsfId.setEnabled(!cbGsfId.isChecked());
+ etAdId.setEnabled(!cbAdId.isChecked());
+ etCountry.setEnabled(!cbCountry.isChecked());
+ etSubscriber.setEnabled(!cbSubscriber.isChecked());
+ etSSID.setEnabled(!cbSSID.isChecked());
+
+ etIP.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingIP, ""));
+ etMcc.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMcc, ""));
+ etMnc.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMnc, ""));
+ etOperator.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingOperator, ""));
+ etIccId.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingIccId, ""));
+ etCid.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingCid, ""));
+ etLac.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLac, ""));
+ etUa.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingUa, ""));
+
+ btnClearDb.setOnClickListener(this);
+ btnRandom.setOnClickListener(this);
+ btnClear.setOnClickListener(this);
+ btnSearch.setOnClickListener(this);
+
+ // Handle flush
+ if (uid == 0)
+ btnFlush.setOnClickListener(this);
+ else
+ btnFlush.setVisibility(View.GONE);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ if (inflater != null && PrivacyService.checkClient()) {
+ inflater.inflate(R.menu.settings, menu);
+ return true;
+ } else
+ return false;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.menu_cancel:
+ finish();
+ return true;
+ case R.id.menu_save:
+ optionSave();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ switch (buttonView.getId()) {
+ case R.id.cbSerial:
+ etSerial.setEnabled(!isChecked);
+ break;
+ case R.id.cbLat:
+ etLat.setEnabled(!isChecked);
+ break;
+ case R.id.cbLon:
+ etLon.setEnabled(!isChecked);
+ break;
+ case R.id.cbAlt:
+ etAlt.setEnabled(!isChecked);
+ break;
+ case R.id.cbMac:
+ etMac.setEnabled(!isChecked);
+ break;
+ case R.id.cbImei:
+ etImei.setEnabled(!isChecked);
+ break;
+ case R.id.cbPhone:
+ etPhone.setEnabled(!isChecked);
+ break;
+ case R.id.cbId:
+ etId.setEnabled(!isChecked);
+ break;
+ case R.id.cbGsfId:
+ etGsfId.setEnabled(!isChecked);
+ break;
+ case R.id.cbAdId:
+ etAdId.setEnabled(!isChecked);
+ break;
+ case R.id.cbCountry:
+ etCountry.setEnabled(!isChecked);
+ break;
+ case R.id.cbSubscriber:
+ etSubscriber.setEnabled(!isChecked);
+ break;
+ case R.id.cbSSID:
+ etSSID.setEnabled(!isChecked);
+ break;
+ case R.id.cbExpert:
+ cbSystem.setEnabled(isChecked);
+ cbExperimental.setEnabled(isChecked);
+ cbHttps.setEnabled(isChecked);
+ cbAOSP.setEnabled(isChecked);
+ etConfidence.setEnabled(isChecked);
+ etQuirks.setEnabled(isChecked);
+ btnClearDb.setEnabled(isChecked);
+ if (!isChecked) {
+ cbSystem.setChecked(false);
+ cbExperimental.setChecked(false);
+ cbHttps.setChecked(true);
+ cbAOSP.setChecked(false);
+ etConfidence.setText("");
+ etQuirks.setText("");
+ }
+ break;
+ }
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.btnClearDb:
+ clearDB();
+ break;
+ case R.id.btnRandom:
+ randomize();
+ break;
+ case R.id.btnClear:
+ clear();
+ break;
+ case R.id.btnSearch:
+ search();
+ break;
+ case R.id.btnFlush:
+ flush();
+ break;
+ }
+ }
+
+ private void clearDB() {
+ AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivitySettings.this);
+ alertDialogBuilder.setTitle(R.string.menu_clear_db);
+ alertDialogBuilder.setMessage(R.string.msg_sure);
+ alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
+ alertDialogBuilder.setPositiveButton(getString(android.R.string.ok),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ PrivacyManager.clear();
+ Toast.makeText(ActivitySettings.this, getString(R.string.msg_reboot), Toast.LENGTH_LONG)
+ .show();
+ finish();
+
+ // Refresh main UI
+ Intent intent = new Intent(ActivitySettings.this, ActivityMain.class);
+ intent.putExtra(ActivityMain.cRefreshUI, true);
+ startActivity(intent);
+ }
+ });
+ alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ });
+ AlertDialog alertDialog = alertDialogBuilder.create();
+ alertDialog.show();
+ }
+
+ private void randomize() {
+ etSerial.setText(PrivacyManager.getRandomProp("SERIAL"));
+ etLat.setText(PrivacyManager.getRandomProp("LAT"));
+ etLon.setText(PrivacyManager.getRandomProp("LON"));
+ etAlt.setText(PrivacyManager.getRandomProp("ALT"));
+ etMac.setText(PrivacyManager.getRandomProp("MAC"));
+ etImei.setText(PrivacyManager.getRandomProp("IMEI"));
+ etPhone.setText(PrivacyManager.getRandomProp("PHONE"));
+ etId.setText(PrivacyManager.getRandomProp("ANDROID_ID"));
+ etGsfId.setText(PrivacyManager.getRandomProp("GSF_ID"));
+ etAdId.setText(PrivacyManager.getRandomProp("AdvertisingId"));
+ etCountry.setText(PrivacyManager.getRandomProp("ISO3166"));
+ etSubscriber.setText(PrivacyManager.getRandomProp("SubscriberId"));
+ etSSID.setText(PrivacyManager.getRandomProp("SSID"));
+ }
+
+ private void clear() {
+ final EditText[] edits = new EditText[] { etSerial, etLat, etLon, etAlt, etMac, etIP, etImei, etPhone, etId,
+ etGsfId, etAdId, etMcc, etMnc, etCountry, etOperator, etIccId, etCid, etLac, etSubscriber, etSSID, etUa };
+ final CheckBox[] boxes = new CheckBox[] { cbSerial, cbLat, cbLon, cbAlt, cbMac, cbImei, cbPhone, cbId, cbGsfId,
+ cbAdId, cbCountry, cbSubscriber, cbSSID };
+
+ for (EditText edit : edits)
+ edit.setText("");
+ etSearch.setText("");
+
+ for (CheckBox box : boxes)
+ box.setChecked(false);
+ }
+
+ private void search() {
+ try {
+ String search = etSearch.getText().toString();
+ final List listAddress = new Geocoder(ActivitySettings.this).getFromLocationName(search, 1);
+ if (listAddress.size() > 0) {
+ Address address = listAddress.get(0);
+
+ // Get coordinates
+ if (address.hasLatitude()) {
+ cbLat.setChecked(false);
+ etLat.setText(Double.toString(address.getLatitude()));
+ }
+ if (address.hasLongitude()) {
+ cbLon.setChecked(false);
+ etLon.setText(Double.toString(address.getLongitude()));
+ }
+
+ // Get address
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i <= address.getMaxAddressLineIndex(); i++) {
+ if (i != 0)
+ sb.append(", ");
+ sb.append(address.getAddressLine(i));
+ }
+ etSearch.setText(sb.toString());
+ }
+ } catch (Throwable ex) {
+ Toast.makeText(ActivitySettings.this, ex.getMessage(), Toast.LENGTH_LONG).show();
+ }
+ }
+
+ private void flush() {
+ Intent flushIntent = new Intent(UpdateService.cFlush);
+ startService(flushIntent);
+ Toast.makeText(ActivitySettings.this, getString(R.string.msg_done), Toast.LENGTH_LONG).show();
+ }
+
+ @SuppressLint("DefaultLocale")
+ private void optionSave() {
+ if (uid == userId) {
+ // Global settings
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingUsage, Boolean.toString(cbUsage.isChecked()));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingParameters,
+ Boolean.toString(cbParameters.isChecked()));
+ if (userId == 0)
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingLog, Boolean.toString(cbLog.isChecked()));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingSystem,
+ Boolean.toString(cbSystem.isChecked()));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingExperimental,
+ Boolean.toString(cbExperimental.isChecked()));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingHttps, Boolean.toString(cbHttps.isChecked()));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingAOSPMode,
+ Boolean.toString(cbAOSP.isChecked()));
+ PrivacyManager
+ .setSetting(uid, PrivacyManager.cSettingConfidence, etConfidence.getText().toString());
+ }
+
+ // Quirks
+ List listQuirks = Arrays.asList(etQuirks.getText().toString().toLowerCase().replace(" ", "")
+ .split(","));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingFreeze,
+ Boolean.toString(listQuirks.contains("freeze")));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingResolve,
+ Boolean.toString(listQuirks.contains("resolve")));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingNoResolve,
+ Boolean.toString(listQuirks.contains("noresolve")));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingPermMan,
+ Boolean.toString(listQuirks.contains("permman")));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingIntentWall,
+ Boolean.toString(listQuirks.contains("iwall")));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingSafeMode,
+ Boolean.toString(listQuirks.contains("safemode")));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingTestVersions,
+ Boolean.toString(listQuirks.contains("test")));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemandSystem,
+ Boolean.toString(listQuirks.contains("odsystem")));
+
+ // Notifications
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingNotify, Boolean.toString(cbNotify.isChecked()));
+
+ // On demand restricting
+ if (uid == userId || (isApp || odSystem))
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemand,
+ Boolean.toString(cbOnDemand.isChecked()));
+
+ if (uid != userId)
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingBlacklist,
+ Boolean.toString(cbBlacklist.isChecked()));
+
+ // Random at boot
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingRandom,
+ cbRandom.isChecked() ? Boolean.toString(true) : null);
+
+ // Serial#
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingSerial, getValue(cbSerial, etSerial));
+
+ // Set latitude
+ if (cbLat.isChecked())
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, PrivacyManager.cValueRandom);
+ else
+ try {
+ float lat = Float.parseFloat(etLat.getText().toString().replace(',', '.'));
+ if (lat < -90 || lat > 90)
+ throw new InvalidParameterException();
+
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, Float.toString(lat));
+ } catch (Throwable ignored) {
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, null);
+ }
+
+ // Set longitude
+ if (cbLon.isChecked())
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, PrivacyManager.cValueRandom);
+ else
+ try {
+ float lon = Float.parseFloat(etLon.getText().toString().replace(',', '.'));
+ if (lon < -180 || lon > 180)
+ throw new InvalidParameterException();
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, Float.toString(lon));
+ } catch (Throwable ignored) {
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, null);
+ }
+
+ // Set altitude
+ if (cbAlt.isChecked())
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, PrivacyManager.cValueRandom);
+ else
+ try {
+ float alt = Float.parseFloat(etAlt.getText().toString().replace(',', '.'));
+ if (alt < -10000 || alt > 10000)
+ throw new InvalidParameterException();
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, Float.toString(alt));
+ } catch (Throwable ignored) {
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, null);
+ }
+
+ // Check Gsf ID
+ try {
+ String value = etGsfId.getText().toString();
+ if (!"".equals(value))
+ Long.parseLong(value.toLowerCase(), 16);
+ } catch (NumberFormatException ignored) {
+ etGsfId.setText("");
+ }
+
+ // Other settings
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingMac, getValue(cbMac, etMac));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingIP, getValue(null, etIP));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingImei, getValue(cbImei, etImei));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingPhone, getValue(cbPhone, etPhone));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingId, getValue(cbId, etId));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingGsfId, getValue(cbGsfId, etGsfId));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingAdId, getValue(cbAdId, etAdId));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingMcc, getValue(null, etMcc));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingMnc, getValue(null, etMnc));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingCountry, getValue(cbCountry, etCountry));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingOperator, getValue(null, etOperator));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingIccId, getValue(null, etIccId));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingCid, getValue(null, etCid));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingLac, getValue(null, etLac));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingSubscriber, getValue(cbSubscriber, etSubscriber));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingSSID, getValue(cbSSID, etSSID));
+ PrivacyManager.setSetting(uid, PrivacyManager.cSettingUa, getValue(null, etUa));
+
+ finish();
+
+ // Refresh view
+ if (uid == userId) {
+ Intent intent = new Intent(ActivitySettings.this, ActivityMain.class);
+ startActivity(intent);
+ } else {
+ Intent intent = new Intent(ActivitySettings.this, ActivityApp.class);
+ intent.putExtra(ActivityApp.cUid, uid);
+ intent.putExtra(ActivityApp.cAction, ActivityApp.cActionRefresh);
+ startActivity(intent);
+ }
+ }
+
+ private static String getValue(CheckBox check, EditText edit) {
+ if (check != null && check.isChecked())
+ return PrivacyManager.cValueRandom;
+ String value = edit.getText().toString().trim();
+ return ("".equals(value) ? null : value);
+ }
+}
diff --git a/src/biz/bokhorst/xprivacy/ApplicationInfoEx.java b/src/biz/bokhorst/xprivacy/ApplicationInfoEx.java
index f02fc3bef..7e3174ed4 100644
--- a/src/biz/bokhorst/xprivacy/ApplicationInfoEx.java
+++ b/src/biz/bokhorst/xprivacy/ApplicationInfoEx.java
@@ -84,7 +84,7 @@ public static List getXApplicationList(Context context, Progr
return listApp;
}
- public List getApplicationName() {
+ public ArrayList getApplicationName() {
return new ArrayList(mMapAppInfo.navigableKeySet());
}
diff --git a/src/biz/bokhorst/xprivacy/SettingsDialog.java b/src/biz/bokhorst/xprivacy/SettingsDialog.java
deleted file mode 100644
index 24067f6fa..000000000
--- a/src/biz/bokhorst/xprivacy/SettingsDialog.java
+++ /dev/null
@@ -1,715 +0,0 @@
-package biz.bokhorst.xprivacy;
-
-import java.io.File;
-import java.security.InvalidParameterException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import android.annotation.SuppressLint;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.location.Address;
-import android.location.Geocoder;
-import android.os.Build;
-import android.os.Environment;
-import android.os.Process;
-import android.text.TextUtils;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-public class SettingsDialog {
-
- public static void edit(final ActivityBase context, ApplicationInfoEx appInfo) {
- final int userId = Util.getUserId(Process.myUid());
- final int uid = (appInfo == null ? userId : appInfo.getUid());
-
- // Build dialog
- String themeName = PrivacyManager.getSetting(userId, PrivacyManager.cSettingTheme, "");
- int themeId = (themeName.equals("Dark") ? R.style.CustomTheme_Dialog : R.style.CustomTheme_Light_Dialog);
- final Dialog dlgSettings = new Dialog(context, themeId);
- dlgSettings.requestWindowFeature(Window.FEATURE_LEFT_ICON);
- dlgSettings.setTitle(R.string.menu_settings);
- dlgSettings.setContentView(R.layout.settings);
- dlgSettings.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, context.getThemed(R.attr.icon_launcher));
-
- // Reference controls
- TextView tvAppName = (TextView) dlgSettings.findViewById(R.id.tvAppName);
- View vwAppNameBorder = (View) dlgSettings.findViewById(R.id.vwAppNameBorder);
-
- final CheckBox cbNotify = (CheckBox) dlgSettings.findViewById(R.id.cbNotify);
- final CheckBox cbOnDemand = (CheckBox) dlgSettings.findViewById(R.id.cbOnDemand);
- final CheckBox cbBlacklist = (CheckBox) dlgSettings.findViewById(R.id.cbBlacklist);
- final CheckBox cbUsage = (CheckBox) dlgSettings.findViewById(R.id.cbUsage);
- final CheckBox cbParameters = (CheckBox) dlgSettings.findViewById(R.id.cbParameters);
- final CheckBox cbLog = (CheckBox) dlgSettings.findViewById(R.id.cbLog);
-
- final CheckBox cbExpert = (CheckBox) dlgSettings.findViewById(R.id.cbExpert);
- final CheckBox cbSystem = (CheckBox) dlgSettings.findViewById(R.id.cbSystem);
- final CheckBox cbExperimental = (CheckBox) dlgSettings.findViewById(R.id.cbExperimental);
- final CheckBox cbHttps = (CheckBox) dlgSettings.findViewById(R.id.cbHttps);
- final CheckBox cbAOSP = (CheckBox) dlgSettings.findViewById(R.id.cbAOSP);
- final LinearLayout llConfidence = (LinearLayout) dlgSettings.findViewById(R.id.llConfidence);
- final EditText etConfidence = (EditText) dlgSettings.findViewById(R.id.etConfidence);
- final EditText etQuirks = (EditText) dlgSettings.findViewById(R.id.etQuirks);
- final Button btnClearDb = (Button) dlgSettings.findViewById(R.id.btnClearDb);
-
- final CheckBox cbRandom = (CheckBox) dlgSettings.findViewById(R.id.cbRandom);
- final Button btnRandom = (Button) dlgSettings.findViewById(R.id.btnRandom);
- final Button btnClear = (Button) dlgSettings.findViewById(R.id.btnClear);
- final Button btnFlush = (Button) dlgSettings.findViewById(R.id.btnFlush);
-
- final EditText etSerial = (EditText) dlgSettings.findViewById(R.id.etSerial);
- final EditText etLat = (EditText) dlgSettings.findViewById(R.id.etLat);
- final EditText etLon = (EditText) dlgSettings.findViewById(R.id.etLon);
- final EditText etAlt = (EditText) dlgSettings.findViewById(R.id.etAlt);
- final EditText etSearch = (EditText) dlgSettings.findViewById(R.id.etSearch);
- final Button btnSearch = (Button) dlgSettings.findViewById(R.id.btnSearch);
- final EditText etMac = (EditText) dlgSettings.findViewById(R.id.etMac);
- final EditText etIP = (EditText) dlgSettings.findViewById(R.id.etIP);
- final EditText etImei = (EditText) dlgSettings.findViewById(R.id.etImei);
- final EditText etPhone = (EditText) dlgSettings.findViewById(R.id.etPhone);
- final EditText etId = (EditText) dlgSettings.findViewById(R.id.etId);
- final EditText etGsfId = (EditText) dlgSettings.findViewById(R.id.etGsfId);
- final EditText etAdId = (EditText) dlgSettings.findViewById(R.id.etAdId);
- final EditText etMcc = (EditText) dlgSettings.findViewById(R.id.etMcc);
- final EditText etMnc = (EditText) dlgSettings.findViewById(R.id.etMnc);
- final EditText etCountry = (EditText) dlgSettings.findViewById(R.id.etCountry);
- final EditText etOperator = (EditText) dlgSettings.findViewById(R.id.etOperator);
- final EditText etIccId = (EditText) dlgSettings.findViewById(R.id.etIccId);
- final EditText etCid = (EditText) dlgSettings.findViewById(R.id.etCid);
- final EditText etLac = (EditText) dlgSettings.findViewById(R.id.etLac);
- final EditText etSubscriber = (EditText) dlgSettings.findViewById(R.id.etSubscriber);
- final EditText etSSID = (EditText) dlgSettings.findViewById(R.id.etSSID);
- final EditText etUa = (EditText) dlgSettings.findViewById(R.id.etUa);
-
- final CheckBox cbSerial = (CheckBox) dlgSettings.findViewById(R.id.cbSerial);
- final CheckBox cbLat = (CheckBox) dlgSettings.findViewById(R.id.cbLat);
- final CheckBox cbLon = (CheckBox) dlgSettings.findViewById(R.id.cbLon);
- final CheckBox cbAlt = (CheckBox) dlgSettings.findViewById(R.id.cbAlt);
- final CheckBox cbMac = (CheckBox) dlgSettings.findViewById(R.id.cbMac);
- final CheckBox cbImei = (CheckBox) dlgSettings.findViewById(R.id.cbImei);
- final CheckBox cbPhone = (CheckBox) dlgSettings.findViewById(R.id.cbPhone);
- final CheckBox cbId = (CheckBox) dlgSettings.findViewById(R.id.cbId);
- final CheckBox cbGsfId = (CheckBox) dlgSettings.findViewById(R.id.cbGsfId);
- final CheckBox cbAdId = (CheckBox) dlgSettings.findViewById(R.id.cbAdId);
- final CheckBox cbCountry = (CheckBox) dlgSettings.findViewById(R.id.cbCountry);
- final CheckBox cbSubscriber = (CheckBox) dlgSettings.findViewById(R.id.cbSubscriber);
- final CheckBox cbSSID = (CheckBox) dlgSettings.findViewById(R.id.cbSSID);
-
- Button btnOk = (Button) dlgSettings.findViewById(R.id.btnOk);
- Button btnCancel = (Button) dlgSettings.findViewById(R.id.btnCancel);
-
- final EditText[] edits = new EditText[] { etSerial, etLat, etLon, etAlt, etMac, etIP, etImei, etPhone, etId,
- etGsfId, etAdId, etMcc, etMnc, etCountry, etOperator, etIccId, etCid, etLac, etSubscriber, etSSID, etUa };
-
- final CheckBox[] boxes = new CheckBox[] { cbSerial, cbLat, cbLon, cbAlt, cbMac, cbImei, cbPhone, cbId, cbGsfId,
- cbAdId, cbCountry, cbSubscriber, cbSSID };
-
- // Listen for changes
- cbExpert.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- cbSystem.setEnabled(isChecked);
- cbExperimental.setEnabled(isChecked);
- cbHttps.setEnabled(isChecked);
- cbAOSP.setEnabled(isChecked);
- etConfidence.setEnabled(isChecked);
- etQuirks.setEnabled(isChecked);
- btnClearDb.setEnabled(isChecked);
- if (!isChecked) {
- cbSystem.setChecked(false);
- cbExperimental.setChecked(false);
- cbHttps.setChecked(true);
- cbAOSP.setChecked(false);
- etConfidence.setText("");
- etQuirks.setText("");
- }
- }
- });
-
- cbSerial.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etSerial.setEnabled(!isChecked);
- }
- });
-
- cbLat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etLat.setEnabled(!isChecked);
- }
- });
-
- cbLon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etLon.setEnabled(!isChecked);
- }
- });
-
- cbAlt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etAlt.setEnabled(!isChecked);
- }
- });
-
- cbMac.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etMac.setEnabled(!isChecked);
- }
- });
-
- cbImei.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etImei.setEnabled(!isChecked);
- }
- });
-
- cbPhone.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etPhone.setEnabled(!isChecked);
- }
- });
-
- cbId.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etId.setEnabled(!isChecked);
- }
- });
-
- cbGsfId.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etGsfId.setEnabled(!isChecked);
- }
- });
-
- cbAdId.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etAdId.setEnabled(!isChecked);
- }
- });
-
- cbCountry.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etCountry.setEnabled(!isChecked);
- }
- });
-
- cbSubscriber.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etSubscriber.setEnabled(!isChecked);
- }
- });
-
- cbSSID.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- etSSID.setEnabled(!isChecked);
- }
- });
-
- // Display app name
- if (appInfo == null) {
- tvAppName.setVisibility(View.GONE);
- vwAppNameBorder.setVisibility(View.GONE);
- } else
- tvAppName.setText(TextUtils.join(", ", appInfo.getApplicationName()));
-
- // Get current values
- boolean usage = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingUsage, true);
- boolean parameters = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingParameters, false);
- boolean log = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingLog, false);
-
- boolean components = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingSystem, false);
- boolean experimental = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingExperimental, false);
- boolean https = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingHttps, true);
- boolean aosp = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingAOSPMode, false);
- String confidence = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingConfidence, "");
-
- // Get quirks
- boolean freeze = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingFreeze, false);
- boolean resolve = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingResolve, false);
- boolean noresolve = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingNoResolve, false);
- boolean permman = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingPermMan, false);
- boolean iwall = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingIntentWall, false);
- boolean safemode = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingSafeMode, false);
- boolean test = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingTestVersions, false);
- boolean odsystem = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingOnDemandSystem, false);
- List listQuirks = new ArrayList();
- if (freeze)
- listQuirks.add("freeze");
- if (resolve)
- listQuirks.add("resolve");
- if (noresolve)
- listQuirks.add("noresolve");
- if (permman)
- listQuirks.add("permman");
- if (iwall)
- listQuirks.add("iwall");
- if (safemode)
- listQuirks.add("safemode");
- if (test)
- listQuirks.add("test");
- if (odsystem)
- listQuirks.add("odsystem");
- Collections.sort(listQuirks);
- String quirks = TextUtils.join(",", listQuirks.toArray());
-
- final boolean expert = (components || experimental || !https || aosp || !"".equals(confidence) || listQuirks
- .size() > 0);
-
- // Application specific
- boolean notify = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingNotify, true);
- boolean ondemand = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingOnDemand, uid == userId);
- boolean blacklist = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingBlacklist, false);
- boolean enabled = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingRestricted, true);
-
- // Common
- boolean random = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingRandom, false);
-
- String serial = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSerial, "");
- String lat = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLatitude, "");
- String lon = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLongitude, "");
- String alt = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingAltitude, "");
- String mac = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMac, "");
- String imei = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingImei, "");
- String phone = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingPhone, "");
- String id = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingId, "");
- String gsfid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingGsfId, "");
- String adid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingAdId, "");
- String country = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingCountry, "");
- String subscriber = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSubscriber, "");
- String ssid = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingSSID, "");
-
- // Set current values
- if (uid == userId) {
- // Global settings
- cbUsage.setChecked(usage);
- cbParameters.setChecked(parameters);
- cbParameters.setEnabled(Util.hasProLicense(context) != null);
- if (userId == 0)
- cbLog.setChecked(log);
- else {
- cbLog.setVisibility(View.GONE);
- btnClearDb.setVisibility(View.GONE);
- }
- cbExpert.setChecked(expert);
-
- if (PrivacyManager.cVersion3 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
- cbAOSP.setVisibility(View.VISIBLE);
-
- if (expert) {
- cbSystem.setChecked(components);
- cbExperimental.setChecked(experimental);
- cbHttps.setChecked(https);
- cbAOSP.setChecked(aosp);
- etConfidence.setText(confidence);
- etQuirks.setText(quirks);
- } else {
- cbSystem.setEnabled(false);
- cbExperimental.setEnabled(false);
- cbHttps.setEnabled(false);
- cbHttps.setChecked(true);
- cbAOSP.setEnabled(false);
- cbAOSP.setChecked(false);
- etConfidence.setEnabled(false);
- etQuirks.setEnabled(false);
- btnClearDb.setEnabled(false);
- }
- } else {
- // Disable global settings
- cbUsage.setVisibility(View.GONE);
- cbParameters.setVisibility(View.GONE);
- cbLog.setVisibility(View.GONE);
- cbSystem.setVisibility(View.GONE);
- cbExperimental.setVisibility(View.GONE);
- cbHttps.setVisibility(View.GONE);
- cbAOSP.setVisibility(View.GONE);
- llConfidence.setVisibility(View.GONE);
- btnClearDb.setVisibility(View.GONE);
-
- cbExpert.setChecked(expert);
- if (expert)
- etQuirks.setText(quirks);
- else
- etQuirks.setEnabled(false);
- }
-
- boolean gnotify = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingNotify, true);
- if (uid == userId || gnotify)
- cbNotify.setChecked(notify);
- else
- cbNotify.setVisibility(View.GONE);
-
- final boolean isApp = PrivacyManager.isApplication(uid);
- final boolean odSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemandSystem, false);
- boolean gondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
- if (uid == userId || ((isApp || odSystem) && gondemand)) {
- cbOnDemand.setChecked(ondemand);
- cbOnDemand.setEnabled(enabled);
- } else
- cbOnDemand.setVisibility(View.GONE);
-
- String blFileName = Environment.getExternalStorageDirectory().getPath() + "/.xprivacy/blacklist";
- if (uid == userId || !new File(blFileName).exists())
- cbBlacklist.setVisibility(View.GONE);
- else
- cbBlacklist.setChecked(blacklist);
-
- // Common
- cbRandom.setChecked(random);
-
- // Set randomize on access check boxes
- cbSerial.setChecked(serial.equals(PrivacyManager.cValueRandom));
- cbLat.setChecked(lat.equals(PrivacyManager.cValueRandom));
- cbLon.setChecked(lon.equals(PrivacyManager.cValueRandom));
- cbAlt.setChecked(alt.equals(PrivacyManager.cValueRandom));
- cbMac.setChecked(mac.equals(PrivacyManager.cValueRandom));
- cbImei.setChecked(imei.equals(PrivacyManager.cValueRandom));
- cbPhone.setChecked(phone.equals(PrivacyManager.cValueRandom));
- cbId.setChecked(id.equals(PrivacyManager.cValueRandom));
- cbGsfId.setChecked(gsfid.equals(PrivacyManager.cValueRandom));
- cbAdId.setChecked(adid.equals(PrivacyManager.cValueRandom));
- cbCountry.setChecked(country.equals(PrivacyManager.cValueRandom));
- cbSubscriber.setChecked(subscriber.equals(PrivacyManager.cValueRandom));
- cbSSID.setChecked(ssid.equals(PrivacyManager.cValueRandom));
-
- // Set fake values
- etSerial.setText(cbSerial.isChecked() ? "" : serial);
- etLat.setText(cbLat.isChecked() ? "" : lat);
- etLon.setText(cbLon.isChecked() ? "" : lon);
- etAlt.setText(cbAlt.isChecked() ? "" : alt);
- etMac.setText(cbMac.isChecked() ? "" : mac);
- etImei.setText(cbImei.isChecked() ? "" : imei);
- etPhone.setText(cbPhone.isChecked() ? "" : phone);
- etId.setText(cbId.isChecked() ? "" : id);
- etGsfId.setText(cbGsfId.isChecked() ? "" : gsfid);
- etAdId.setText(cbAdId.isChecked() ? "" : adid);
- etCountry.setText(cbCountry.isChecked() ? "" : country);
- etSubscriber.setText(cbSubscriber.isChecked() ? "" : subscriber);
- etSSID.setText(cbSSID.isChecked() ? "" : ssid);
-
- etSerial.setEnabled(!cbSerial.isChecked());
- etLat.setEnabled(!cbLat.isChecked());
- etLon.setEnabled(!cbLon.isChecked());
- etAlt.setEnabled(!cbAlt.isChecked());
-
- etSearch.setEnabled(Geocoder.isPresent());
- btnSearch.setEnabled(Geocoder.isPresent());
-
- etMac.setEnabled(!cbMac.isChecked());
- etImei.setEnabled(!cbImei.isChecked());
- etPhone.setEnabled(!cbPhone.isChecked());
- etId.setEnabled(!cbId.isChecked());
- etGsfId.setEnabled(!cbGsfId.isChecked());
- etAdId.setEnabled(!cbAdId.isChecked());
- etCountry.setEnabled(!cbCountry.isChecked());
- etSubscriber.setEnabled(!cbSubscriber.isChecked());
- etSSID.setEnabled(!cbSSID.isChecked());
-
- etIP.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingIP, ""));
- etMcc.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMcc, ""));
- etMnc.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingMnc, ""));
- etOperator.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingOperator, ""));
- etIccId.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingIccId, ""));
- etCid.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingCid, ""));
- etLac.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingLac, ""));
- etUa.setText(PrivacyManager.getSetting(-uid, PrivacyManager.cSettingUa, ""));
-
- btnClearDb.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
- alertDialogBuilder.setTitle(R.string.menu_clear_db);
- alertDialogBuilder.setMessage(R.string.msg_sure);
- alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher));
- alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- PrivacyManager.clear();
- ((EditText) context.findViewById(R.id.etFilter)).setText("");
- context.recreate();
- Toast.makeText(context, context.getString(R.string.msg_reboot), Toast.LENGTH_LONG)
- .show();
- dlgSettings.dismiss();
- }
- });
- alertDialogBuilder.setNegativeButton(context.getString(android.R.string.cancel),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- AlertDialog alertDialog = alertDialogBuilder.create();
- alertDialog.show();
- }
- });
-
- // Handle manual randomize
- btnRandom.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- etSerial.setText(PrivacyManager.getRandomProp("SERIAL"));
- etLat.setText(PrivacyManager.getRandomProp("LAT"));
- etLon.setText(PrivacyManager.getRandomProp("LON"));
- etAlt.setText(PrivacyManager.getRandomProp("ALT"));
- etMac.setText(PrivacyManager.getRandomProp("MAC"));
- etImei.setText(PrivacyManager.getRandomProp("IMEI"));
- etPhone.setText(PrivacyManager.getRandomProp("PHONE"));
- etId.setText(PrivacyManager.getRandomProp("ANDROID_ID"));
- etGsfId.setText(PrivacyManager.getRandomProp("GSF_ID"));
- etAdId.setText(PrivacyManager.getRandomProp("AdvertisingId"));
- etCountry.setText(PrivacyManager.getRandomProp("ISO3166"));
- etSubscriber.setText(PrivacyManager.getRandomProp("SubscriberId"));
- etSSID.setText(PrivacyManager.getRandomProp("SSID"));
- }
- });
-
- // Handle clear
- btnClear.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- for (EditText edit : edits)
- edit.setText("");
- etSearch.setText("");
-
- for (CheckBox box : boxes)
- box.setChecked(false);
- }
- });
-
- // Handle flush
- if (uid == 0)
- btnFlush.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent flushIntent = new Intent(UpdateService.cFlush);
- context.startService(flushIntent);
- Toast.makeText(context, context.getString(R.string.msg_done), Toast.LENGTH_LONG).show();
- }
- });
- else
- btnFlush.setVisibility(View.GONE);
-
- // Handle search
- btnSearch.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- try {
- String search = etSearch.getText().toString();
- final List listAddress = new Geocoder(context).getFromLocationName(search, 1);
- if (listAddress.size() > 0) {
- Address address = listAddress.get(0);
-
- // Get coordinates
- if (address.hasLatitude()) {
- cbLat.setChecked(false);
- etLat.setText(Double.toString(address.getLatitude()));
- }
- if (address.hasLongitude()) {
- cbLon.setChecked(false);
- etLon.setText(Double.toString(address.getLongitude()));
- }
-
- // Get address
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i <= address.getMaxAddressLineIndex(); i++) {
- if (i != 0)
- sb.append(", ");
- sb.append(address.getAddressLine(i));
- }
- etSearch.setText(sb.toString());
- }
- } catch (Throwable ex) {
- Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
- }
- }
- });
-
- // Handle OK
- btnOk.setOnClickListener(new View.OnClickListener() {
- @Override
- @SuppressLint("DefaultLocale")
- public void onClick(View view) {
- if (uid == userId) {
- // Global settings
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingUsage, Boolean.toString(cbUsage.isChecked()));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingParameters,
- Boolean.toString(cbParameters.isChecked()));
- if (userId == 0)
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingLog, Boolean.toString(cbLog.isChecked()));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingSystem,
- Boolean.toString(cbSystem.isChecked()));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingExperimental,
- Boolean.toString(cbExperimental.isChecked()));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingHttps, Boolean.toString(cbHttps.isChecked()));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingAOSPMode,
- Boolean.toString(cbAOSP.isChecked()));
- PrivacyManager
- .setSetting(uid, PrivacyManager.cSettingConfidence, etConfidence.getText().toString());
- }
-
- // Quirks
- List listQuirks = Arrays.asList(etQuirks.getText().toString().toLowerCase().replace(" ", "")
- .split(","));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingFreeze,
- Boolean.toString(listQuirks.contains("freeze")));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingResolve,
- Boolean.toString(listQuirks.contains("resolve")));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingNoResolve,
- Boolean.toString(listQuirks.contains("noresolve")));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingPermMan,
- Boolean.toString(listQuirks.contains("permman")));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingIntentWall,
- Boolean.toString(listQuirks.contains("iwall")));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingSafeMode,
- Boolean.toString(listQuirks.contains("safemode")));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingTestVersions,
- Boolean.toString(listQuirks.contains("test")));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemandSystem,
- Boolean.toString(listQuirks.contains("odsystem")));
-
- // Notifications
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingNotify, Boolean.toString(cbNotify.isChecked()));
-
- // On demand restricting
- if (uid == userId || (isApp || odSystem))
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemand,
- Boolean.toString(cbOnDemand.isChecked()));
-
- if (uid != userId)
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingBlacklist,
- Boolean.toString(cbBlacklist.isChecked()));
-
- // Random at boot
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingRandom,
- cbRandom.isChecked() ? Boolean.toString(true) : null);
-
- // Serial#
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingSerial, getValue(cbSerial, etSerial));
-
- // Set latitude
- if (cbLat.isChecked())
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, PrivacyManager.cValueRandom);
- else
- try {
- float lat = Float.parseFloat(etLat.getText().toString().replace(',', '.'));
- if (lat < -90 || lat > 90)
- throw new InvalidParameterException();
-
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, Float.toString(lat));
- } catch (Throwable ignored) {
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, null);
- }
-
- // Set longitude
- if (cbLon.isChecked())
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, PrivacyManager.cValueRandom);
- else
- try {
- float lon = Float.parseFloat(etLon.getText().toString().replace(',', '.'));
- if (lon < -180 || lon > 180)
- throw new InvalidParameterException();
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, Float.toString(lon));
- } catch (Throwable ignored) {
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, null);
- }
-
- // Set altitude
- if (cbAlt.isChecked())
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, PrivacyManager.cValueRandom);
- else
- try {
- float alt = Float.parseFloat(etAlt.getText().toString().replace(',', '.'));
- if (alt < -10000 || alt > 10000)
- throw new InvalidParameterException();
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, Float.toString(alt));
- } catch (Throwable ignored) {
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, null);
- }
-
- // Check Gsf ID
- try {
- String value = etGsfId.getText().toString();
- if (!"".equals(value))
- Long.parseLong(value.toLowerCase(), 16);
- } catch (NumberFormatException ignored) {
- etGsfId.setText("");
- }
-
- // Other settings
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingMac, getValue(cbMac, etMac));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingIP, getValue(null, etIP));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingImei, getValue(cbImei, etImei));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingPhone, getValue(cbPhone, etPhone));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingId, getValue(cbId, etId));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingGsfId, getValue(cbGsfId, etGsfId));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingAdId, getValue(cbAdId, etAdId));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingMcc, getValue(null, etMcc));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingMnc, getValue(null, etMnc));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingCountry, getValue(cbCountry, etCountry));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingOperator, getValue(null, etOperator));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingIccId, getValue(null, etIccId));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingCid, getValue(null, etCid));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingLac, getValue(null, etLac));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingSubscriber, getValue(cbSubscriber, etSubscriber));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingSSID, getValue(cbSSID, etSSID));
- PrivacyManager.setSetting(uid, PrivacyManager.cSettingUa, getValue(null, etUa));
-
- dlgSettings.dismiss();
-
- // Refresh view
- if (uid == userId) {
- Intent intent = new Intent(context, ActivityMain.class);
- context.startActivity(intent);
- } else {
- Intent intent = new Intent(context, ActivityApp.class);
- intent.putExtra(ActivityApp.cUid, uid);
- intent.putExtra(ActivityApp.cAction, ActivityApp.cActionRefresh);
- context.startActivity(intent);
- }
- }
- });
-
- // Handle Cancel
- btnCancel.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dlgSettings.dismiss();
- }
- });
-
- // Show dialog
- dlgSettings.setCancelable(true);
- dlgSettings.show();
- }
-
- private static String getValue(CheckBox check, EditText edit) {
- if (check != null && check.isChecked())
- return PrivacyManager.cValueRandom;
- String value = edit.getText().toString().trim();
- return ("".equals(value) ? null : value);
- }
-}