Add logging to private space settings

Bug: 317625931
Test: Manual
Change-Id: I01200b54c436d2a60ac07c9facbb5cf35a44d920
This commit is contained in:
josephpv
2024-01-09 17:55:10 +00:00
committed by Joseph Vincent
parent 87117b0183
commit 6f4dc73c53
9 changed files with 48 additions and 15 deletions

View File

@@ -29,6 +29,7 @@ import static com.android.settings.privatespace.PrivateSpaceSetupActivity.SET_LO
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import androidx.activity.result.ActivityResult; import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.ActivityResultLauncher;
@@ -42,16 +43,18 @@ import com.android.settings.overlay.FeatureFactory;
import com.google.android.setupdesign.util.ThemeHelper; 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 { public class PrivateProfileContextHelperActivity extends FragmentActivity {
private static final String TAG = "PrivateProfileHelper"; private static final String TAG = "PrivateSpaceHelperAct";
private final ActivityResultLauncher<Intent> mAddAccountToPrivateProfile = private final ActivityResultLauncher<Intent> mAddAccountToPrivateProfile =
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), registerForActivityResult(
this::onAccountAdded); new ActivityResultContracts.StartActivityForResult(), this::onAccountAdded);
private final ActivityResultLauncher<Intent> mVerifyDeviceLock = private final ActivityResultLauncher<Intent> mVerifyDeviceLock =
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), registerForActivityResult(
this::onSetDeviceNewLock); new ActivityResultContracts.StartActivityForResult(), this::onSetDeviceNewLock);
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@@ -66,8 +69,8 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
if (action == ACCOUNT_LOGIN_ACTION) { if (action == ACCOUNT_LOGIN_ACTION) {
PrivateSpaceLoginFeatureProvider privateSpaceLoginFeatureProvider = PrivateSpaceLoginFeatureProvider privateSpaceLoginFeatureProvider =
FeatureFactory.getFeatureFactory().getPrivateSpaceLoginFeatureProvider(); FeatureFactory.getFeatureFactory().getPrivateSpaceLoginFeatureProvider();
if (!privateSpaceLoginFeatureProvider.initiateAccountLogin(this, if (!privateSpaceLoginFeatureProvider.initiateAccountLogin(
mAddAccountToPrivateProfile)) { this, mAddAccountToPrivateProfile)) {
setResult(RESULT_OK); setResult(RESULT_OK);
finish(); finish();
} }
@@ -90,8 +93,10 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
private void onAccountAdded(@Nullable ActivityResult result) { private void onAccountAdded(@Nullable ActivityResult result) {
if (result != null && result.getResultCode() == RESULT_OK) { if (result != null && result.getResultCode() == RESULT_OK) {
Log.i(TAG, "private space account login success");
setResult(RESULT_OK); setResult(RESULT_OK);
} else { } else {
Log.i(TAG, "private space account login failed");
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
} }
finish(); finish();
@@ -101,8 +106,10 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
// TODO(b/307281644) : Verify this for biometrics and check result code after new // TODO(b/307281644) : Verify this for biometrics and check result code after new
// Authentication changes are merged. // Authentication changes are merged.
if (result != null && getSystemService(KeyguardManager.class).isDeviceSecure()) { if (result != null && getSystemService(KeyguardManager.class).isDeviceSecure()) {
Log.i(TAG, "separate private space lock setup success");
setResult(RESULT_OK); setResult(RESULT_OK);
} else { } else {
Log.i(TAG, "separate private space lock not setup");
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
} }
finish(); finish();

View File

@@ -19,6 +19,7 @@ package com.android.settings.privatespace;
import android.app.Activity; import android.app.Activity;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; 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. */ /** Fragment to display error screen if creation of private profile failed for any reason. */
public class PrivateProfileCreationError extends InstrumentedFragment { public class PrivateProfileCreationError extends InstrumentedFragment {
private static final String TAG = "PrivateSpaceCreationErr";
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, LayoutInflater inflater,
@@ -83,6 +86,7 @@ public class PrivateProfileCreationError extends InstrumentedFragment {
return v -> { return v -> {
mMetricsFeatureProvider.action( mMetricsFeatureProvider.action(
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_TRY_CREATE_SPACE_AGAIN); getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_TRY_CREATE_SPACE_AGAIN);
Log.i(TAG, "Retry private space creation");
NavHostFragment.findNavController(PrivateProfileCreationError.this) NavHostFragment.findNavController(PrivateProfileCreationError.this)
.navigate(R.id.action_retry_profile_creation); .navigate(R.id.action_retry_profile_creation);
}; };
@@ -94,6 +98,7 @@ public class PrivateProfileCreationError extends InstrumentedFragment {
if (activity != null) { if (activity != null) {
mMetricsFeatureProvider.action( mMetricsFeatureProvider.action(
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_CANCEL_CREATE_SPACE); getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_CANCEL_CREATE_SPACE);
Log.i(TAG, "private space setup cancelled");
activity.finish(); activity.finish();
} }
}; };

View File

@@ -24,6 +24,7 @@ import android.app.settings.SettingsEnums;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; 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. */ /** Fragment to display error screen if the profile is not signed in with a Google account. */
public class PrivateSpaceAccountLoginError extends InstrumentedFragment { public class PrivateSpaceAccountLoginError extends InstrumentedFragment {
private static final String TAG = "PrivateSpaceAccLoginErr";
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
GlifLayout rootView = GlifLayout rootView =
(GlifLayout) inflater (GlifLayout)
.inflate(R.layout.privatespace_account_login_error, container, false); inflater.inflate(
R.layout.privatespace_account_login_error, container, false);
final FooterBarMixin mixin = rootView.getMixin(FooterBarMixin.class); final FooterBarMixin mixin = rootView.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton( mixin.setPrimaryButton(
new FooterButton.Builder(getContext()) new FooterButton.Builder(getContext())
@@ -86,6 +90,7 @@ public class PrivateSpaceAccountLoginError extends InstrumentedFragment {
&& (userHandle = privateSpaceMaintainer.getPrivateProfileHandle()) != null) { && (userHandle = privateSpaceMaintainer.getPrivateProfileHandle()) != null) {
Intent intent = new Intent(getContext(), PrivateProfileContextHelperActivity.class); Intent intent = new Intent(getContext(), PrivateProfileContextHelperActivity.class);
intent.putExtra(EXTRA_ACTION_TYPE, ACCOUNT_LOGIN_ACTION); intent.putExtra(EXTRA_ACTION_TYPE, ACCOUNT_LOGIN_ACTION);
Log.d(TAG, "Start private space activity for account login");
getActivity() getActivity()
.startActivityForResultAsUser(intent, ACCOUNT_LOGIN_ACTION, userHandle); .startActivityForResultAsUser(intent, ACCOUNT_LOGIN_ACTION, userHandle);
} }

View File

@@ -111,12 +111,14 @@ public class PrivateSpaceAuthenticationActivity extends FragmentActivity {
} }
private void promptToSetDeviceLock() { private void promptToSetDeviceLock() {
Log.d(TAG, "Show prompt to set device lock before using private space feature");
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setTitle(R.string.no_device_lock_title) .setTitle(R.string.no_device_lock_title)
.setMessage(R.string.no_device_lock_summary) .setMessage(R.string.no_device_lock_summary)
.setPositiveButton( .setPositiveButton(
R.string.no_device_lock_action_label, R.string.no_device_lock_action_label,
(DialogInterface dialog, int which) -> { (DialogInterface dialog, int which) -> {
Log.d(TAG, "Start activity to set new device lock");
mSetDeviceLock.launch(new Intent(ACTION_SET_NEW_PASSWORD)); mSetDeviceLock.launch(new Intent(ACTION_SET_NEW_PASSWORD));
}) })
.setNegativeButton( .setNegativeButton(
@@ -176,6 +178,7 @@ public class PrivateSpaceAuthenticationActivity extends FragmentActivity {
options.toBundle()) options.toBundle())
.getIntentSender()); .getIntentSender());
} else { } else {
Log.i(TAG, "Launch private space settings");
privateSpaceSettings.launch(); privateSpaceSettings.launch();
} }
finish(); finish();

View File

@@ -19,6 +19,7 @@ package com.android.settings.privatespace;
import android.app.Activity; import android.app.Activity;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -35,6 +36,7 @@ import com.google.android.setupdesign.GlifLayout;
/** Fragment educating about the usage of Private Space. */ /** Fragment educating about the usage of Private Space. */
public class PrivateSpaceEducation extends InstrumentedFragment { public class PrivateSpaceEducation extends InstrumentedFragment {
private static final String TAG = "PrivateSpaceEducation";
@Override @Override
public View onCreateView( public View onCreateView(
@@ -77,6 +79,7 @@ public class PrivateSpaceEducation extends InstrumentedFragment {
return v -> { return v -> {
mMetricsFeatureProvider.action( mMetricsFeatureProvider.action(
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_START); getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_START);
Log.i(TAG, "Starting private space setup");
NavHostFragment.findNavController(PrivateSpaceEducation.this) NavHostFragment.findNavController(PrivateSpaceEducation.this)
.navigate(R.id.action_education_to_auto_advance); .navigate(R.id.action_education_to_auto_advance);
}; };
@@ -88,6 +91,7 @@ public class PrivateSpaceEducation extends InstrumentedFragment {
if (activity != null) { if (activity != null) {
mMetricsFeatureProvider.action( mMetricsFeatureProvider.action(
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_CANCEL); getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_CANCEL);
Log.i(TAG, "private space setup cancelled");
activity.finish(); activity.finish();
} }
}; };

View File

@@ -224,6 +224,7 @@ public class PrivateSpaceMaintainer {
/** Sets the setting to show PS entry point to the provided value. */ /** Sets the setting to show PS entry point to the provided value. */
public void setHidePrivateSpaceEntryPointSetting(int value) { public void setHidePrivateSpaceEntryPointSetting(int value) {
Log.d(TAG, "Setting HIDE_PRIVATE_SPACE_ENTRY_POINT = " + value);
Settings.Secure.putInt(mContext.getContentResolver(), HIDE_PRIVATESPACE_ENTRY_POINT, value); Settings.Secure.putInt(mContext.getContentResolver(), HIDE_PRIVATESPACE_ENTRY_POINT, value);
} }
@@ -261,6 +262,7 @@ public class PrivateSpaceMaintainer {
*/ */
public synchronized boolean lockPrivateSpace() { public synchronized boolean lockPrivateSpace() {
if (isPrivateProfileRunning()) { if (isPrivateProfileRunning()) {
Log.d(TAG, "Calling requestQuietModeEnabled to enableQuietMode");
return mUserManager.requestQuietModeEnabled(true, mUserHandle); return mUserManager.requestQuietModeEnabled(true, mUserHandle);
} }
return false; return false;
@@ -273,6 +275,7 @@ public class PrivateSpaceMaintainer {
*/ */
public synchronized void unlockPrivateSpace(IntentSender intentSender) { public synchronized void unlockPrivateSpace(IntentSender intentSender) {
if (mUserHandle != null) { if (mUserHandle != null) {
Log.d(TAG, "Calling requestQuietModeEnabled to disableQuietMode");
mUserManager.requestQuietModeEnabled(false, mUserHandle, intentSender); mUserManager.requestQuietModeEnabled(false, mUserHandle, intentSender);
} }
} }
@@ -297,6 +300,7 @@ public class PrivateSpaceMaintainer {
*/ */
@GuardedBy("this") @GuardedBy("this")
private void setUserSetupComplete() { private void setUserSetupComplete() {
Log.d(TAG, "setting USER_SETUP_COMPLETE = 1 for private profile");
Settings.Secure.putIntForUser(mContext.getContentResolver(), USER_SETUP_COMPLETE, Settings.Secure.putIntForUser(mContext.getContentResolver(), USER_SETUP_COMPLETE,
1, mUserHandle.getIdentifier()); 1, mUserHandle.getIdentifier());
} }

View File

@@ -55,8 +55,8 @@ public class PrivateSpaceSetLockFragment extends InstrumentedFragment {
return null; return null;
} }
GlifLayout rootView = GlifLayout rootView =
(GlifLayout) inflater.inflate( (GlifLayout)
R.layout.privatespace_setlock_screen, container, false); inflater.inflate(R.layout.privatespace_setlock_screen, container, false);
final FooterBarMixin mixin = rootView.getMixin(FooterBarMixin.class); final FooterBarMixin mixin = rootView.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton( mixin.setPrimaryButton(
new FooterButton.Builder(getContext()) new FooterButton.Builder(getContext())
@@ -99,6 +99,7 @@ public class PrivateSpaceSetLockFragment extends InstrumentedFragment {
// Simply Use default screen lock. No need to handle // Simply Use default screen lock. No need to handle
mMetricsFeatureProvider.action( mMetricsFeatureProvider.action(
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_ACCOUNT_LOGIN_START); getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_ACCOUNT_LOGIN_START);
Log.d(TAG, "Use device lock for private profile");
launchActivityForAction(ACCOUNT_LOGIN_ACTION); launchActivityForAction(ACCOUNT_LOGIN_ACTION);
}; };
} }
@@ -117,6 +118,7 @@ public class PrivateSpaceSetLockFragment extends InstrumentedFragment {
if (userHandle != null) { if (userHandle != null) {
Intent intent = new Intent(getContext(), PrivateProfileContextHelperActivity.class); Intent intent = new Intent(getContext(), PrivateProfileContextHelperActivity.class);
intent.putExtra(EXTRA_ACTION_TYPE, action); intent.putExtra(EXTRA_ACTION_TYPE, action);
Log.i(TAG, "Start separate lock setup for private profile");
getActivity().startActivityForResultAsUser(intent, action, userHandle); getActivity().startActivityForResultAsUser(intent, action, userHandle);
} else { } else {
Log.w(TAG, "Private profile user handle is null"); Log.w(TAG, "Private profile user handle is null");

View File

@@ -52,8 +52,9 @@ public class PrivateSpaceSetupActivity extends FragmentActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider(); mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
setContentView(R.layout.privatespace_setup_root); setContentView(R.layout.privatespace_setup_root);
mNavHostFragment = (NavHostFragment) getSupportFragmentManager() mNavHostFragment =
.findFragmentById(R.id.ps_nav_host_fragment); (NavHostFragment)
getSupportFragmentManager().findFragmentById(R.id.ps_nav_host_fragment);
mNavHostFragment.getNavController().setGraph(R.navigation.privatespace_main_context_nav); mNavHostFragment.getNavController().setGraph(R.navigation.privatespace_main_context_nav);
} }

View File

@@ -22,6 +22,7 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -100,6 +101,7 @@ public class SetupSuccessFragment extends InstrumentedFragment {
} }
accessPrivateSpaceToast(); accessPrivateSpaceToast();
startActivity(allAppsIntent); startActivity(allAppsIntent);
Log.i(TAG, "Private space setup complete");
activity.finish(); activity.finish();
} }
}; };