Fix unbundled accessibility features settings crash when launched

Root cause: The ag/19938064 introduces Settings Core change preference value changed metrics log format. It tries to lookupMetricsCategory() at Fragment#instantiate() stage. It has not onAttach() to activity by FragmentManager#add() or #replace(). The features were added by ag/15824482.
Solution: PutInt new MATRICS_CATEGORY extra in previous class to avoid giving context for FeatureFactory.getFactory to custom 1P accessibility services for SettingsGoogle overlay.

Bug: 259355675
Test: manual test
Change-Id: Ic37d41be6a54fe388f211c1c397d0b9b87b5fb56
This commit is contained in:
menghanli
2022-11-17 20:39:37 +08:00
committed by Menghan Li
parent 1436b66e14
commit f76e31fe48
5 changed files with 19 additions and 23 deletions

View File

@@ -42,7 +42,6 @@ import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.overlay.FeatureFactory;
import java.util.ArrayList;
import java.util.List;
@@ -58,15 +57,7 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
@Override
public int getMetricsCategory() {
// Retrieve from getArguments() directly because this function will be executed from
// onAttach(), but variable mComponentName only available after onProcessArguments()
// which comes from onCreateView().
final ComponentName componentName = getArguments().getParcelable(
AccessibilitySettings.EXTRA_COMPONENT_NAME);
return FeatureFactory.getFactory(getActivity().getApplicationContext())
.getAccessibilityMetricsFeatureProvider()
.getDownloadedFeatureMetricsCategory(componentName);
return getArguments().getInt(AccessibilitySettings.EXTRA_METRICS_CATEGORY);
}
@Override