Skip to content

Commit

Permalink
Disable "silence call recording alerts" mod if Dialer > 94.x
Browse files Browse the repository at this point in the history
Fixes #50
  • Loading branch information
jacopotediosi committed Mar 22, 2023
1 parent da21002 commit 7694c87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.IOException;
import java.io.InputStream;

@SuppressWarnings("FieldCanBeLocal")
public class SuggestedModsFragment extends Fragment {
private View mView;
private SwitchCompat mForceEnableCallRecordingSwitch;
Expand Down Expand Up @@ -71,6 +72,8 @@ public class SuggestedModsFragment extends Fragment {
};
private final String CALLRECORDINGPROMPT_STARTING_VOICE_US = "starting_voice-en_US.wav";
private final String CALLRECORDINGPROMPT_ENDING_VOICE_US = "ending_voice-en_US.wav";
// Dialer versionCode 10681248 (94.x) is the last version in which we can silence call recording alerts. In newer versions Google patched our hack.
private final int SILENCE_CALL_RECORDING_ALERTS_MAX_VERSION = 10681248;

// The following boolean flags enable or disable Call Screen / Revelio features
private final String[] ENABLE_CALL_SCREEN_FLAGS = {
Expand Down Expand Up @@ -131,8 +134,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mForceEnableCallRecordingSwitchOnCheckedChangeListener = (buttonView, isChecked) -> forceEnableCallRecording(isChecked);
mForceEnableCallRecordingSwitch.setOnCheckedChangeListener(mForceEnableCallRecordingSwitchOnCheckedChangeListener);

mSilenceCallRecordingAlertsSwitchOnCheckedChangeListener = (buttonView, isChecked) -> silenceCallRecordingAlerts(isChecked);
mSilenceCallRecordingAlertsSwitch.setOnCheckedChangeListener(mSilenceCallRecordingAlertsSwitchOnCheckedChangeListener);
try {
if(requireContext().getPackageManager().getPackageInfo(DIALER_PACKAGE_NAME, 0).versionCode <= SILENCE_CALL_RECORDING_ALERTS_MAX_VERSION) {
mSilenceCallRecordingAlertsSwitchOnCheckedChangeListener = (buttonView, isChecked) -> silenceCallRecordingAlerts(isChecked);
mSilenceCallRecordingAlertsSwitch.setOnCheckedChangeListener(mSilenceCallRecordingAlertsSwitchOnCheckedChangeListener);
mSilenceCallRecordingAlertsSwitch.setEnabled(true);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}

mForceEnableCallScreenSwitchOnCheckedChangeListener = (buttonView, isChecked) -> forceEnableCallScreen(isChecked);
mForceEnableCallScreenSwitch.setOnCheckedChangeListener(mForceEnableCallScreenSwitchOnCheckedChangeListener);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/suggested_mods_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:enabled="false"
android:minHeight="0dp"
tools:ignore="RtlHardcoded,TouchTargetSizeCheck" />
</RelativeLayout>
Expand Down

0 comments on commit 7694c87

Please sign in to comment.