Remove temp GAIA education screen from PS setup code
With this change the temp GAIA education screen is removed from private space setup code and adds a new loading screen with "Just a sec" title in the activity while the gms intent in launched to fix blank screen issue. Screenrecording link: b/336822960#comment7 Bug: 336822960 Test: Manual Change-Id: I9ee41835b39c194fefb970321b7a9d5a30f87306
This commit is contained in:
@@ -16,8 +16,14 @@
|
||||
|
||||
package com.android.settings.privatespace;
|
||||
|
||||
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.ACCOUNT_LOGIN_ACTION;
|
||||
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.EXTRA_ACTION_TYPE;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
@@ -42,12 +48,31 @@ import com.google.android.setupdesign.GlifLayout;
|
||||
public class PrivateSpaceCreationFragment extends InstrumentedFragment {
|
||||
private static final String TAG = "PrivateSpaceCreateFrag";
|
||||
private static final int PRIVATE_SPACE_CREATE_POST_DELAY_MS = 1000;
|
||||
private static final int PRIVATE_SPACE_ACCOUNT_LOGIN_POST_DELAY_MS = 5000;
|
||||
private static final Handler sHandler = new Handler(Looper.getMainLooper());
|
||||
private Runnable mRunnable =
|
||||
() -> {
|
||||
createPrivateSpace();
|
||||
};
|
||||
|
||||
private Runnable mAccountLoginRunnable =
|
||||
() -> {
|
||||
unRegisterReceiver();
|
||||
startAccountLogin();
|
||||
};
|
||||
|
||||
final BroadcastReceiver mProfileAccessReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
if (action.equals(Intent.ACTION_PROFILE_ACCESSIBLE)) {
|
||||
Log.i(TAG, "onReceive " + action);
|
||||
sHandler.removeCallbacks(mAccountLoginRunnable);
|
||||
sHandler.post(mAccountLoginRunnable);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
if (android.os.Flags.allowPrivateProfile()
|
||||
@@ -82,6 +107,7 @@ public class PrivateSpaceCreationFragment extends InstrumentedFragment {
|
||||
super.onResume();
|
||||
// Ensures screen visibility to user by introducing a 1-second delay before creating private
|
||||
// space.
|
||||
sHandler.removeCallbacks(mRunnable);
|
||||
sHandler.postDelayed(mRunnable, PRIVATE_SPACE_CREATE_POST_DELAY_MS);
|
||||
}
|
||||
|
||||
@@ -97,8 +123,9 @@ public class PrivateSpaceCreationFragment extends InstrumentedFragment {
|
||||
mMetricsFeatureProvider.action(
|
||||
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_SPACE_CREATED, true);
|
||||
if (isConnectedToInternet()) {
|
||||
NavHostFragment.findNavController(PrivateSpaceCreationFragment.this)
|
||||
.navigate(R.id.action_account_intro_fragment);
|
||||
registerReceiver();
|
||||
sHandler.postDelayed(
|
||||
mAccountLoginRunnable, PRIVATE_SPACE_ACCOUNT_LOGIN_POST_DELAY_MS);
|
||||
} else {
|
||||
NavHostFragment.findNavController(PrivateSpaceCreationFragment.this)
|
||||
.navigate(R.id.action_set_lock_fragment);
|
||||
@@ -127,4 +154,25 @@ public class PrivateSpaceCreationFragment extends InstrumentedFragment {
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
/** Start new activity in private profile to add an account to private profile */
|
||||
private void startAccountLogin() {
|
||||
Intent intent = new Intent(getContext(), PrivateProfileContextHelperActivity.class);
|
||||
intent.putExtra(EXTRA_ACTION_TYPE, ACCOUNT_LOGIN_ACTION);
|
||||
mMetricsFeatureProvider.action(
|
||||
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_ACCOUNT_LOGIN_START);
|
||||
getActivity().startActivityForResult(intent, ACCOUNT_LOGIN_ACTION);
|
||||
}
|
||||
|
||||
private void registerReceiver() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_PROFILE_ACCESSIBLE);
|
||||
getActivity().registerReceiver(mProfileAccessReceiver, filter);
|
||||
}
|
||||
|
||||
private void unRegisterReceiver() {
|
||||
if (mProfileAccessReceiver != null) {
|
||||
getActivity().unregisterReceiver(mProfileAccessReceiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user