Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 962f9a89 authored by cretin45's avatar cretin45
Browse files

SetupWizard: RIP Whisperpush

Change-Id: I20363cc80dbb1481bd66abb4bd4202212ff37028
parent 95246f20
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
    <uses-permission android:name="cyanogenmod.permission.HARDWARE_ABSTRACTION_ACCESS" />
    <uses-permission android:name="android.permission.BACKUP" />
    <uses-permission android:name="org.whispersystems.whisperpush.permissions.REGISTER" />
    <uses-permission android:name="cyanogenmod.permission.FINISH_SETUP" />
    <uses-permission android:name="cyanogenmod.permission.LEGALESE" />
    <uses-permission android:name="com.cyngn.stats.SEND_ANALYTICS" />
@@ -57,9 +56,6 @@
        android:protectionLevel="signatureOrSystem"
        androidprv:allowViaWhitelist="true" />

    <permission android:name="org.whispersystems.whisperpush.permissions.REGISTER"
                android:protectionLevel="signature" />

    <protected-broadcast android:name="com.cyanogenmod.setupwizard.SETUP_FINISHED"
                         android:permission="cyanogenmod.permission.FINISH_SETUP"/>

+0 −35
Original line number Diff line number Diff line
@@ -209,41 +209,6 @@
                        android:text="@string/services_os_nav_keys_label"/>

                </LinearLayout>

                <!-- Checkbox for enabling secure SMS -->
                <LinearLayout
                    android:id="@+id/secure_sms"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingLeft="@dimen/location_margin_left"
                    android:paddingRight="@dimen/content_margin_right"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true">

                    <CheckBox
                        android:id="@+id/secure_sms_checkbox"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="top"
                        android:layout_marginTop="5dp"
                        android:duplicateParentState="true"
                        android:clickable="false" />

                    <TextView
                        android:id="@+id/secure_sms_summary"
                        android:layout_width="0px"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textSize="15sp"
                        android:lineSpacingExtra="@dimen/setup_line_spacing"
                        android:gravity="top"
                        android:layout_marginLeft="@dimen/location_text_margin_left"
                        android:layout_marginRight="@dimen/location_text_margin_right"
                        android:paddingBottom="@dimen/content_margin_bottom"
                        android:text="@string/services_secure_sms_label"/>

                </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </FrameLayout>
+0 −76
Original line number Diff line number Diff line
@@ -65,15 +65,12 @@ public class CyanogenSettingsPage extends SetupPage {
    public static final String TAG = "CyanogenSettingsPage";

    public static final String KEY_SEND_METRICS = "send_metrics";
    public static final String KEY_REGISTER_WHISPERPUSH = "register";
    public static final String KEY_ENABLE_NAV_KEYS = "enable_nav_keys";
    public static final String KEY_APPLY_DEFAULT_THEME = "apply_default_theme";

    public static final String SETTING_METRICS = "settings.cyanogen.allow_metrics";
    public static final String PRIVACY_POLICY_URI = "https://cyngn.com/oobe-legal?hideHeader=1";

    private static final String WHISPERPUSH_PACKAGE = "org.whispersystems.whisperpush";

    public CyanogenSettingsPage(Context context, SetupDataCallbacks callbacks) {
        super(context, callbacks);
    }
@@ -147,25 +144,10 @@ public class CyanogenSettingsPage extends SetupPage {
                }
            }
        });
        handleWhisperPushRegistration();
        handleEnableMetrics();
        handleDefaultThemeSetup();
    }

    private void handleWhisperPushRegistration() {
        Bundle privacyData = getData();
        if (privacyData != null &&
                privacyData.containsKey(KEY_REGISTER_WHISPERPUSH) &&
                privacyData.getBoolean(KEY_REGISTER_WHISPERPUSH)) {
            SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
                    SetupStats.Action.USE_SECURE_SMS,
                    SetupStats.Label.CHECKED,
                    String.valueOf(privacyData.getBoolean(KEY_REGISTER_WHISPERPUSH)));
            Log.i(TAG, "Registering with WhisperPush");
            WhisperPushUtils.startRegistration(mContext);
        }
    }

    private void handleEnableMetrics() {
        Bundle privacyData = getData();
        if (privacyData != null
@@ -204,23 +186,6 @@ public class CyanogenSettingsPage extends SetupPage {
        return hardware.get(CMHardwareManager.FEATURE_KEY_DISABLE);
    }

    private static boolean hideWhisperPush(Context context) {
        final int playServicesAvailable = GooglePlayServicesUtil
                .isGooglePlayServicesAvailable(context);
        try {
            PackageInfo pi = context.getPackageManager().getPackageInfo(WHISPERPUSH_PACKAGE, 0);
            if (pi == null) {
                return true;
            }
        } catch (PackageManager.NameNotFoundException e) {
            return true;
        }
        return playServicesAvailable != ConnectionResult.SUCCESS
                || !SetupWizardUtils.hasTelephony(context)
                || (SetupWizardUtils.hasTelephony(context) &&
                SetupWizardUtils.isSimMissing(context));
    }

    private static boolean hideThemeSwitch(Context context) {
        return SetupWizardUtils.getDefaultThemePackageName(context)
                               .equals(ThemeConfig.SYSTEM_DEFAULT);
@@ -234,15 +199,12 @@ public class CyanogenSettingsPage extends SetupPage {
        private View mMetricsRow;
        private View mDefaultThemeRow;
        private View mNavKeysRow;
        private View mSecureSmsRow;
        private CheckBox mMetrics;
        private CheckBox mDefaultTheme;
        private CheckBox mNavKeys;
        private CheckBox mSecureSms;

        private boolean mHideNavKeysRow = false;
        private boolean mHideThemeRow = false;
        private boolean mHideSmsRow = false;


        private View.OnClickListener mMetricsClickListener = new View.OnClickListener() {
@@ -272,15 +234,6 @@ public class CyanogenSettingsPage extends SetupPage {
            }
        };

        private View.OnClickListener mSecureSmsClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean checked = !mSecureSms.isChecked();
                mSecureSms.setChecked(checked);
                mPage.getData().putBoolean(KEY_REGISTER_WHISPERPUSH, checked);
            }
        };

        @Override
        protected void initializePage() {
            String privacy_policy = getString(R.string.services_privacy_policy);
@@ -370,23 +323,6 @@ public class CyanogenSettingsPage extends SetupPage {
                        isKeyDisablerActive(getActivity());
                mNavKeys.setChecked(navKeysDisabled);
            }

            mSecureSmsRow = mRootView.findViewById(R.id.secure_sms);
            mSecureSmsRow.setOnClickListener(mSecureSmsClickListener);
            String useSecureSms = getString(R.string.services_use_secure_sms);
            String secureSmsSummary = getString(R.string.services_secure_sms_label,
                    useSecureSms, getString(R.string.os_name));
            final SpannableStringBuilder secureSmsSpan =
                    new SpannableStringBuilder(secureSmsSummary);
            secureSmsSpan.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD),
                    0, useSecureSms.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            TextView secureSms = (TextView) mRootView.findViewById(R.id.secure_sms_summary);
            secureSms.setText(secureSmsSpan);
            mHideSmsRow = hideWhisperPush(getActivity());
            if (mHideSmsRow) {
                mSecureSmsRow.setVisibility(View.GONE);
            }
            mSecureSms = (CheckBox) mRootView.findViewById(R.id.secure_sms_checkbox);
        }

        @Override
@@ -400,7 +336,6 @@ public class CyanogenSettingsPage extends SetupPage {
            /*updateDisableNavkeysOption();*/
            updateMetricsOption();
            updateThemeOption();
            updateSmsOption();
        }

        private void updateMetricsOption() {
@@ -427,17 +362,6 @@ public class CyanogenSettingsPage extends SetupPage {
            }
        }

        private void updateSmsOption() {
            if (!mHideSmsRow) {
                final Bundle myPageBundle = mPage.getData();
                boolean smsChecked = myPageBundle.containsKey(KEY_REGISTER_WHISPERPUSH) ?
                        myPageBundle.getBoolean(KEY_REGISTER_WHISPERPUSH) :
                        false;
                mSecureSms.setChecked(smsChecked);
                myPageBundle.putBoolean(KEY_REGISTER_WHISPERPUSH, smsChecked);
            }
        }

        /*private void updateDisableNavkeysOption() {
            if (!mHideNavKeysRow) {
                final Bundle myPageBundle = mPage.getData();