Fix issue where SmartAutoRotateController tries to unregister an unregistered receiver
Controllers are automatically bound to a lifecycle if registered in the xml file. Manually binding a lifecycle can cause multiple receivers to be unregistered/registered. Removing the manual binding will prevent this case from causing a potential exception.
Bug: 227762968
Test: none
Change-Id: I9c8ddc6f82b19cd4a9c8a4aec3c9c744935cd542
diff --git a/src/com/android/settings/display/SmartAutoRotateController.java b/src/com/android/settings/display/SmartAutoRotateController.java
index d29a64e..093c845 100644
--- a/src/com/android/settings/display/SmartAutoRotateController.java
+++ b/src/com/android/settings/display/SmartAutoRotateController.java
@@ -35,7 +35,6 @@
import android.service.rotationresolver.RotationResolverService;
import android.text.TextUtils;
-import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.Preference;
@@ -82,10 +81,6 @@
context);
}
- public void init(Lifecycle lifecycle) {
- lifecycle.addObserver(this);
- }
-
@Override
public int getAvailabilityStatus() {
if (!isRotationResolverServiceAvailable(mContext)) {
diff --git a/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java b/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
index 1b4e998..36d3006 100644
--- a/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
+++ b/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
@@ -64,7 +64,6 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- use(SmartAutoRotateController.class).init(getLifecycle());
DeviceStateAutoRotationHelper.initControllers(
getLifecycle(),
useAll(DeviceStateAutoRotateSettingController.class)