Fix IllegalStateException to get tile content after device rotate
Root cause: Race condition to get content after the onDetach() Solution: Add protection to prevent this IllegalStateException Bug: 239578655 Test: make RunSettingsRoboTests ROBOTEST_FILTER=OneHandedSettings Test: Manual testing by rotating 100 times quickly Change-Id: I0a03cf1c01cd34c8ae0b0e70c4ffc41168b18ab8
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.accessibility.AccessibilityShortcutController;
|
||||
import com.android.settings.R;
|
||||
@@ -39,6 +40,7 @@ import com.android.settingslib.widget.MainSwitchPreference;
|
||||
*/
|
||||
public class OneHandedSettings extends AccessibilityShortcutPreferenceFragment {
|
||||
|
||||
private static final String TAG = "OneHandedSettings";
|
||||
private static final String ONE_HANDED_SHORTCUT_KEY = "one_handed_shortcuts_preference";
|
||||
private static final String ONE_HANDED_ILLUSTRATION_KEY = "one_handed_header";
|
||||
protected static final String ONE_HANDED_MAIN_SWITCH_KEY =
|
||||
@@ -131,9 +133,15 @@ public class OneHandedSettings extends AccessibilityShortcutPreferenceFragment {
|
||||
|
||||
@Override
|
||||
protected CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
final Context context = getContext();
|
||||
if (context == null) {
|
||||
Log.w(TAG, "OneHandedSettings not attached to a context.");
|
||||
return null;
|
||||
}
|
||||
return type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? getText(R.string.accessibility_one_handed_mode_qs_tooltip_content)
|
||||
: getText(R.string.accessibility_one_handed_mode_auto_added_qs_tooltip_content);
|
||||
? context.getText(R.string.accessibility_one_handed_mode_qs_tooltip_content)
|
||||
: context.getText(
|
||||
R.string.accessibility_one_handed_mode_auto_added_qs_tooltip_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,7 +151,7 @@ public class OneHandedSettings extends AccessibilityShortcutPreferenceFragment {
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return null;
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user