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.TimeCapabilitiesAndConfig;
|
||||
import android.app.time.TimeConfiguration;
|
||||
import android.app.time.TimeManager;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -35,6 +36,8 @@ import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
public class AutoTimePreferenceController extends TogglePreferenceController {
|
||||
|
||||
private static final String TAG = "AutoTimePreferenceController";
|
||||
|
||||
private UpdateTimeAndDateCallback mCallback;
|
||||
private final TimeManager mTimeManager;
|
||||
|
||||
@@ -74,7 +77,8 @@ public class AutoTimePreferenceController extends TogglePreferenceController {
|
||||
// arbitrary.
|
||||
return AVAILABLE;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown capability=" + capability);
|
||||
Log.e(TAG, "Unknown capability=" + capability);
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,6 +25,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;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -138,7 +139,8 @@ public class LocationTimeZoneDetectionPreferenceController
|
||||
} else if (capability == CAPABILITY_NOT_APPLICABLE || capability == CAPABILITY_POSSESSED) {
|
||||
return isAutoTimeZoneEnabled() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
|
||||
} else {
|
||||
throw new IllegalStateException("Unknown capability=" + capability);
|
||||
Log.e(TAG, "Unknown capability=" + capability);
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user