Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Option to randomize subscriber ID (ICC)
Browse files Browse the repository at this point in the history
Fixes #690
  • Loading branch information
M66B committed Nov 13, 2013
1 parent 5f2d91b commit e14b5d9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ Changelog

* Fixed rare null pointer exception ([issue](https://github.com/M66B/XPrivacy/issues/739))
* Fixed flickering with black theme
* Fixed setting global and randomize on boot settings
* Require Android 4.0.3 (minimum for Xposed)
* Added settings for Advertisement ID (including randomization) ([issue](https://github.com/M66B/XPrivacy/issues/738))
* Option to randomize subscriber ID (IMSI) ([issue](https://github.com/M66B/XPrivacy/issues/690))
* Added traditional Chinese translation
* Updated German translation
* Updated Vietnamese translation
Expand Down
2 changes: 1 addition & 1 deletion res/layout/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
android:text="@string/settings_subscriber"
android:textIsSelectable="false" />

<View />
<CheckBox android:id="@+id/cbSubscriber" />

<EditText
android:id="@+id/etSubscriber"
Expand Down
2 changes: 2 additions & 0 deletions src/biz/bokhorst/xprivacy/BootReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ private void randomizeSettings(Context context, int uid) {
PrivacyManager.getRandomProp("AdvertisingId"));
PrivacyManager.setSetting(null, context, uid, PrivacyManager.cSettingCountry,
PrivacyManager.getRandomProp("ISO3166"));
PrivacyManager.setSetting(null, context, uid, PrivacyManager.cSettingSubscriber,
PrivacyManager.getRandomProp("SubscriberId"));
}
}
}
13 changes: 11 additions & 2 deletions src/biz/bokhorst/xprivacy/PrivacyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,10 @@ public static Object getDefacedProp(int uid, String name) {
if (name.equals("getSimSerialNumber"))
return getSetting(null, null, uid, cSettingIccId, null, true);

if (name.equals("getSubscriberId")) // IMSI for a GSM phone
return getSetting(null, null, uid, cSettingSubscriber, null, true);
if (name.equals("getSubscriberId")) { // IMSI for a GSM phone
String value = getSetting(null, null, uid, cSettingSubscriber, null, true);
return (cValueRandom.equals(value) ? getRandomProp("SubscriberId") : value);
}

if (name.equals("SSID"))
return ""; // Hidden network
Expand Down Expand Up @@ -961,6 +963,13 @@ public static String getRandomProp(String name) {
return Double.toString(d);
}

if (name.equals("SubscriberId")) {
String subscriber = "001";
while (subscriber.length() < 15)
subscriber += Character.forDigit(r.nextInt(10), 10);
return subscriber;
}

return "";
}

Expand Down
21 changes: 16 additions & 5 deletions src/biz/bokhorst/xprivacy/SettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static void edit(final Context context, ApplicationInfoEx appInfo) {
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);

Button btnOk = (Button) dlgSettings.findViewById(R.id.btnOk);
Button btnClear = (Button) dlgSettings.findViewById(R.id.btnClear);
Expand All @@ -91,6 +92,7 @@ public static void edit(final Context context, ApplicationInfoEx appInfo) {
String gsfid = PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingGsfId, "", false);
String adid = PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingAdId, "", false);
String country = PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingCountry, "", false);
String subscriber = PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingSubscriber, "", false);

cbSerial.setChecked(serial.equals(PrivacyManager.cValueRandom));
cbLat.setChecked(lat.equals(PrivacyManager.cValueRandom));
Expand All @@ -102,6 +104,7 @@ public static void edit(final Context context, ApplicationInfoEx appInfo) {
cbGsfId.setChecked(gsfid.equals(PrivacyManager.cValueRandom));
cbAdId.setChecked(adid.equals(PrivacyManager.cValueRandom));
cbCountry.setChecked(country.equals(PrivacyManager.cValueRandom));
cbSubscriber.setChecked(subscriber.equals(PrivacyManager.cValueRandom));

etSerial.setText(cbSerial.isChecked() ? "" : serial);
etLat.setText(cbLat.isChecked() ? "" : lat);
Expand All @@ -113,6 +116,7 @@ public static void edit(final Context context, ApplicationInfoEx appInfo) {
etGsfId.setText(cbGsfId.isChecked() ? "" : gsfid);
etAdId.setText(cbAdId.isChecked() ? "" : adid);
etCountry.setText(cbCountry.isChecked() ? "" : country);
etSubscriber.setText(cbSubscriber.isChecked() ? "" : subscriber);

etSerial.setEnabled(!cbSerial.isChecked());
etLat.setEnabled(!cbLat.isChecked());
Expand All @@ -124,6 +128,7 @@ public static void edit(final Context context, ApplicationInfoEx appInfo) {
etGsfId.setEnabled(!cbGsfId.isChecked());
etAdId.setEnabled(!cbAdId.isChecked());
etCountry.setEnabled(!cbCountry.isChecked());
etSubscriber.setEnabled(!cbSubscriber.isChecked());

cbSerial.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
Expand Down Expand Up @@ -185,14 +190,18 @@ 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);
}
});

etIP.setText(PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingIP, "", false));
etMcc.setText(PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingMcc, "", false));
etMnc.setText(PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingMnc, "", false));
etOperator.setText(PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingOperator, "", false));
etIccId.setText(PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingIccId, "", false));
etSubscriber.setText(PrivacyManager
.getSetting(null, context, uid, PrivacyManager.cSettingSubscriber, "", false));
etUa.setText(PrivacyManager.getSetting(null, context, uid, PrivacyManager.cSettingUa, "", false));

if (uid == 0) {
Expand Down Expand Up @@ -253,6 +262,7 @@ public void onClick(View view) {
etGsfId.setText(PrivacyManager.getRandomProp("GSF_ID"));
etAdId.setText(PrivacyManager.getRandomProp("AdvertisingId"));
etCountry.setText(PrivacyManager.getRandomProp("ISO3166"));
etSubscriber.setText(PrivacyManager.getRandomProp("SubscriberId"));
}
});

Expand All @@ -276,7 +286,7 @@ public void onClick(View view) {
!cbCountry.isChecked() && etCountry.getText().toString().equals("") &&
etOperator.getText().toString().equals("") &&
etIccId.getText().toString().equals("") &&
etSubscriber.getText().toString().equals("") &&
!cbSubscriber.isChecked() && etSubscriber.getText().toString().equals("") &&
etUa.getText().toString().equals("")) {
// @formatter:on

Expand Down Expand Up @@ -352,8 +362,8 @@ public void onClick(View view) {
.toString());
PrivacyManager.setSetting(null, context, uid, PrivacyManager.cSettingIccId, etIccId.getText()
.toString());
PrivacyManager.setSetting(null, context, uid, PrivacyManager.cSettingSubscriber, etSubscriber
.getText().toString());
PrivacyManager.setSetting(null, context, uid, PrivacyManager.cSettingSubscriber,
cbSubscriber.isChecked() ? PrivacyManager.cValueRandom : etSubscriber.getText().toString());
PrivacyManager.setSetting(null, context, uid, PrivacyManager.cSettingUa, etUa.getText().toString());
}

Expand Down Expand Up @@ -410,6 +420,7 @@ public void onClick(View view) {
cbGsfId.setChecked(false);
cbAdId.setChecked(false);
cbCountry.setChecked(false);
cbSubscriber.setChecked(false);
}
});

Expand Down

0 comments on commit e14b5d9

Please sign in to comment.