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

Commit 6f4dc73c authored by josephpv's avatar josephpv Committed by Joseph Vincent
Browse files

Add logging to private space settings

Bug: 317625931
Test: Manual
Change-Id: I01200b54c436d2a60ac07c9facbb5cf35a44d920
parent 87117b01
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.android.settings.privatespace.PrivateSpaceSetupActivity.SET_LO
import android.app.KeyguardManager;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultLauncher;
@@ -42,16 +43,18 @@ import com.android.settings.overlay.FeatureFactory;

import com.google.android.setupdesign.util.ThemeHelper;

/** Activity that is started as private profile user that helps to set private profile lock or
 * add an account on the private profile. */
/**
 * Activity that is started as private profile user that helps to set private profile lock or add an
 * account on the private profile.
 */
public class PrivateProfileContextHelperActivity extends FragmentActivity {
    private static final String TAG = "PrivateProfileHelper";
    private static final String TAG = "PrivateSpaceHelperAct";
    private final ActivityResultLauncher<Intent> mAddAccountToPrivateProfile =
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
                    this::onAccountAdded);
            registerForActivityResult(
                    new ActivityResultContracts.StartActivityForResult(), this::onAccountAdded);
    private final ActivityResultLauncher<Intent> mVerifyDeviceLock =
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
                    this::onSetDeviceNewLock);
            registerForActivityResult(
                    new ActivityResultContracts.StartActivityForResult(), this::onSetDeviceNewLock);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -66,8 +69,8 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
            if (action == ACCOUNT_LOGIN_ACTION) {
                PrivateSpaceLoginFeatureProvider privateSpaceLoginFeatureProvider =
                        FeatureFactory.getFeatureFactory().getPrivateSpaceLoginFeatureProvider();
                if (!privateSpaceLoginFeatureProvider.initiateAccountLogin(this,
                        mAddAccountToPrivateProfile)) {
                if (!privateSpaceLoginFeatureProvider.initiateAccountLogin(
                        this, mAddAccountToPrivateProfile)) {
                    setResult(RESULT_OK);
                    finish();
                }
@@ -90,8 +93,10 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {

    private void onAccountAdded(@Nullable ActivityResult result) {
        if (result != null && result.getResultCode() == RESULT_OK) {
            Log.i(TAG, "private space account login success");
            setResult(RESULT_OK);
        } else {
            Log.i(TAG, "private space account login failed");
            setResult(RESULT_CANCELED);
        }
        finish();
@@ -101,8 +106,10 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
        // TODO(b/307281644) : Verify this for biometrics and check result code after new
        //  Authentication changes are merged.
        if (result != null && getSystemService(KeyguardManager.class).isDeviceSecure()) {
            Log.i(TAG, "separate private space lock setup success");
            setResult(RESULT_OK);
        } else {
            Log.i(TAG, "separate private space lock not setup");
            setResult(RESULT_CANCELED);
        }
        finish();
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.privatespace;
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -36,6 +37,8 @@ import com.google.android.setupdesign.GlifLayout;

/** Fragment to display error screen if creation of private profile failed for any reason. */
public class PrivateProfileCreationError extends InstrumentedFragment {
    private static final String TAG = "PrivateSpaceCreationErr";

    @Override
    public View onCreateView(
            LayoutInflater inflater,
@@ -83,6 +86,7 @@ public class PrivateProfileCreationError extends InstrumentedFragment {
        return v -> {
            mMetricsFeatureProvider.action(
                    getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_TRY_CREATE_SPACE_AGAIN);
            Log.i(TAG, "Retry private space creation");
            NavHostFragment.findNavController(PrivateProfileCreationError.this)
                    .navigate(R.id.action_retry_profile_creation);
        };
@@ -94,6 +98,7 @@ public class PrivateProfileCreationError extends InstrumentedFragment {
            if (activity != null) {
                mMetricsFeatureProvider.action(
                        getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_CANCEL_CREATE_SPACE);
                Log.i(TAG, "private space setup cancelled");
                activity.finish();
            }
        };
+7 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -40,14 +41,17 @@ import com.google.android.setupdesign.GlifLayout;

/** Fragment to display error screen if the profile is not signed in with a Google account. */
public class PrivateSpaceAccountLoginError extends InstrumentedFragment {
    private static final String TAG = "PrivateSpaceAccLoginErr";

    @Override
    public View onCreateView(
            LayoutInflater inflater,
            @Nullable ViewGroup container,
            @Nullable Bundle savedInstanceState) {
        GlifLayout rootView =
                (GlifLayout) inflater
                        .inflate(R.layout.privatespace_account_login_error, container, false);
                (GlifLayout)
                        inflater.inflate(
                                R.layout.privatespace_account_login_error, container, false);
        final FooterBarMixin mixin = rootView.getMixin(FooterBarMixin.class);
        mixin.setPrimaryButton(
                new FooterButton.Builder(getContext())
@@ -86,6 +90,7 @@ public class PrivateSpaceAccountLoginError extends InstrumentedFragment {
                    && (userHandle = privateSpaceMaintainer.getPrivateProfileHandle()) != null) {
                Intent intent = new Intent(getContext(), PrivateProfileContextHelperActivity.class);
                intent.putExtra(EXTRA_ACTION_TYPE, ACCOUNT_LOGIN_ACTION);
                Log.d(TAG, "Start private space activity for account login");
                getActivity()
                        .startActivityForResultAsUser(intent, ACCOUNT_LOGIN_ACTION, userHandle);
            }
+3 −0
Original line number Diff line number Diff line
@@ -111,12 +111,14 @@ public class PrivateSpaceAuthenticationActivity extends FragmentActivity {
    }

    private void promptToSetDeviceLock() {
        Log.d(TAG, "Show prompt to set device lock before using private space feature");
        new AlertDialog.Builder(this)
                .setTitle(R.string.no_device_lock_title)
                .setMessage(R.string.no_device_lock_summary)
                .setPositiveButton(
                        R.string.no_device_lock_action_label,
                        (DialogInterface dialog, int which) -> {
                            Log.d(TAG, "Start activity to set new device lock");
                            mSetDeviceLock.launch(new Intent(ACTION_SET_NEW_PASSWORD));
                        })
                .setNegativeButton(
@@ -176,6 +178,7 @@ public class PrivateSpaceAuthenticationActivity extends FragmentActivity {
                                    options.toBundle())
                            .getIntentSender());
        } else {
            Log.i(TAG, "Launch private space settings");
            privateSpaceSettings.launch();
        }
        finish();
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.privatespace;
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -35,6 +36,7 @@ import com.google.android.setupdesign.GlifLayout;

/** Fragment educating about the usage of Private Space. */
public class PrivateSpaceEducation extends InstrumentedFragment {
    private static final String TAG = "PrivateSpaceEducation";

    @Override
    public View onCreateView(
@@ -77,6 +79,7 @@ public class PrivateSpaceEducation extends InstrumentedFragment {
        return v -> {
            mMetricsFeatureProvider.action(
                    getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_START);
            Log.i(TAG, "Starting private space setup");
            NavHostFragment.findNavController(PrivateSpaceEducation.this)
                    .navigate(R.id.action_education_to_auto_advance);
        };
@@ -88,6 +91,7 @@ public class PrivateSpaceEducation extends InstrumentedFragment {
            if (activity != null) {
                mMetricsFeatureProvider.action(
                        getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_CANCEL);
                Log.i(TAG, "private space setup cancelled");
                activity.finish();
            }
        };
Loading