Replaced exception with more elegant option in Time Settings
Currently, some controllers in the Date and Time settings page throw exceptions if a capability is not known. This would cause the Settings app to crash, so we are moving away from exception and replacing it with the deactivation of the controller. Test: manual Flag: EXEMPT refactor Bug: 296835792 Change-Id: I56b01ec6d9eebf721deeb4f67aa177742482dd53
This commit is contained in:
@@ -26,6 +26,7 @@ import android.app.time.TimeZoneCapabilities;
|
||||
import android.app.time.TimeZoneCapabilitiesAndConfig;
|
||||
import android.app.time.TimeZoneConfiguration;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -35,6 +36,8 @@ import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
public class AutoTimeZonePreferenceController extends TogglePreferenceController {
|
||||
|
||||
private static final String TAG = "AutoTimeZonePreferenceController";
|
||||
|
||||
private boolean mIsFromSUW;
|
||||
private UpdateTimeAndDateCallback mCallback;
|
||||
private final TimeManager mTimeManager;
|
||||
@@ -92,7 +95,8 @@ public class AutoTimeZonePreferenceController extends TogglePreferenceController
|
||||
// arbitrary.
|
||||
return AVAILABLE;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown capability=" + capability);
|
||||
Log.e(TAG, "Unknown capability=" + capability);
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user