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

Commit 81092777 authored by cretin45's avatar cretin45
Browse files

SetupWizard: Ensure compliance with GMS TOS

* Launches GMS TOS per documentation
* Filters out redundant location page if GMS present
* Uses setupwizardlib for some helper functions
* Hide notification icons

Issue-id: CYNGNOS-2599

Change-Id: I4b59592f0b84d0eb0eafe365eab3bad77c1f76ff
parent 941aa1e1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -28,4 +28,6 @@ LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dir))
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages com.google.android.gms

include frameworks/opt/setupwizard/library/common.mk

include $(BUILD_PACKAGE)
+0 −36
Original line number Diff line number Diff line
@@ -45,42 +45,6 @@
                    android:paddingRight="@dimen/content_margin_right"
                    style="@style/PageSummaryText" />

                <LinearLayout
                    android:id="@+id/backup"
                    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/backup_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/backup_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/backup_data_summary"
                        android:maxLines="5" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/location"
                    android:orientation="horizontal"
+8 −3
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class SetupWizardApp extends Application {
    public static final int REQUEST_CODE_SETUP_BLUETOOTH= 5;
    public static final int REQUEST_CODE_UNLOCK = 6;
    public static final int REQUEST_CODE_SETUP_FINGERPRINT = 7;
    public static final int REQUEST_CODE_VENDOR_SETUP_GMS = 8;

    public static final int RADIO_READY_TIMEOUT = 10 * 1000;

@@ -150,9 +151,13 @@ public class SetupWizardApp extends Application {
    }

    public void disableStatusBar() {
        mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND | StatusBarManager.DISABLE_NOTIFICATION_ALERTS
                | StatusBarManager.DISABLE_NOTIFICATION_TICKER | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME
                | StatusBarManager.DISABLE_SEARCH);
        mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND |
                StatusBarManager.DISABLE_NOTIFICATION_ALERTS |
                StatusBarManager.DISABLE_NOTIFICATION_ICONS |
                StatusBarManager.DISABLE_NOTIFICATION_TICKER |
                StatusBarManager.DISABLE_RECENT |
                StatusBarManager.DISABLE_HOME |
                StatusBarManager.DISABLE_SEARCH);
    }

    public void enableStatusBar() {
+6 −1
Original line number Diff line number Diff line
@@ -113,8 +113,13 @@ public class CMSetupWizardData extends AbstractSetupData {
        boolean isConnected = SetupWizardUtils.isNetworkConnected(mContext);
        GmsAccountPage gmsAccountPage =
                (GmsAccountPage) getPage(GmsAccountPage.TAG);
        OtherSettingsPage otherSettingsPage = (OtherSettingsPage) getPage(OtherSettingsPage.TAG);
        if (gmsAccountPage != null) {
            gmsAccountPage.setHidden(!isConnected && gmsAccountPage.canSkip());
            boolean hidden = !isConnected && gmsAccountPage.canSkip();
            gmsAccountPage.setHidden(hidden);
            if (otherSettingsPage != null) {
                otherSettingsPage.setHidden(!hidden);
            }
        }
        CyanogenServicesPage cyanogenServicesPage =
                (CyanogenServicesPage) getPage(CyanogenServicesPage.TAG);
+31 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.Bundle;
import android.service.persistentdata.PersistentDataBlockManager;
import android.util.Log;

import com.android.setupwizardlib.util.ResultCodes;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
@@ -46,6 +47,7 @@ public class GmsAccountPage extends SetupPage {

    public static final String ACTION_RESTORE = "com.google.android.setupwizard.RESTORE";
    public static final String ACTION_PROGRESS = "com.google.android.setupwizard.PROGRESS";
    public static final String ACTION_VENDOR_SETUP = "com.google.android.setupwizard.VENDOR_SETUP";
    public static final String RESTORE_ACTION_ID = "mfm_restore_start";
    public static final String RESTORE_CHECK_ID = "restore_check";
    public static final String FRAGMENT_START_RESTORE =
@@ -128,7 +130,10 @@ public class GmsAccountPage extends SetupPage {
                }
            }
        }
        if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS && data != null) {
        if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS &&
                resultCode == ResultCodes.RESULT_SKIP) {
            launchGmsVendorSetup();
        } else if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS && data != null) {
            if (SetupWizardUtils.isOwner() && resultCode == Activity.RESULT_OK) {

                // If we don't have a restore token and a restore account, then we need to
@@ -242,6 +247,31 @@ public class GmsAccountPage extends SetupPage {
        }
    }

    private void launchGmsVendorSetup() {
        if (SetupWizardApp.DEBUG) {
            Log.d(TAG, "Launching gms vendor setup page");
        }
        try {
            Intent intent = new Intent(ACTION_VENDOR_SETUP);
            intent.setPackage(SetupWizardUtils.GOOGLE_SETUPWIZARD_PACKAGE);
            intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
            intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
            intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
            intent.putExtra(SetupWizardApp.EXTRA_THEME, SetupWizardApp.EXTRA_MATERIAL_LIGHT);
            ActivityOptions options =
                    ActivityOptions.makeCustomAnimation(mContext,
                            android.R.anim.fade_in,
                            android.R.anim.fade_out);
            mFragment.startActivityForResult(
                    intent,
                    SetupWizardApp.REQUEST_CODE_VENDOR_SETUP_GMS, options.toBundle());
            return;
        } catch (Exception e) {
            // Move on if the vendor setup activity is not found.
            getCallbacks().onNextPage();
        }
    }

    public boolean canSkip() {
        final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
                mContext.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
Loading