Restore @hide Core 1.1.0 binary compatibility

Make androidx.core.app.ComponentActivity
implement LifecycleOwner to maintain binary
compatibility with Core 1.0.0.

This fixes compatibility issues where devs
could upgrade to Core 1.1.0 and not Fragment
1.1.0 and have their FragmentActivity /
AppCompatActivity no longer be considered
a LifecycleOwner.

This is essentially a revert to the changes to
androidx.core.app.ComponentActivity from
https://android-review.googlesource.com/743643

Test: Ran in a sample app, tested with Fragments 1.0 and 1.1.0
BUG: 126612680
Change-Id: I10493f8138120cfa76255c0830a795e415fb1316
(cherry picked from commit 0b3e8f07c683df017917b13c399aa8af20d45a90)
diff --git a/activity/api/1.0.0-beta01.txt b/activity/api/1.0.0-beta01.txt
index cd98da6..9e0f44a 100644
--- a/activity/api/1.0.0-beta01.txt
+++ b/activity/api/1.0.0-beta01.txt
@@ -5,7 +5,6 @@
     ctor public ComponentActivity();
     ctor @ContentView public ComponentActivity(@LayoutRes int);
     method @Deprecated public Object? getLastCustomNonConfigurationInstance();
-    method public androidx.lifecycle.Lifecycle getLifecycle();
     method public final androidx.activity.OnBackPressedDispatcher getOnBackPressedDispatcher();
     method public final androidx.savedstate.SavedStateRegistry getSavedStateRegistry();
     method public androidx.lifecycle.ViewModelStore getViewModelStore();
diff --git a/activity/api/current.txt b/activity/api/current.txt
index cd98da6..9e0f44a 100644
--- a/activity/api/current.txt
+++ b/activity/api/current.txt
@@ -5,7 +5,6 @@
     ctor public ComponentActivity();
     ctor @ContentView public ComponentActivity(@LayoutRes int);
     method @Deprecated public Object? getLastCustomNonConfigurationInstance();
-    method public androidx.lifecycle.Lifecycle getLifecycle();
     method public final androidx.activity.OnBackPressedDispatcher getOnBackPressedDispatcher();
     method public final androidx.savedstate.SavedStateRegistry getSavedStateRegistry();
     method public androidx.lifecycle.ViewModelStore getViewModelStore();
diff --git a/core/api/restricted_1.1.0-rc03.txt b/core/api/restricted_1.1.0-rc03.txt
index 62d67c7..40fb68b 100644
--- a/core/api/restricted_1.1.0-rc03.txt
+++ b/core/api/restricted_1.1.0-rc03.txt
@@ -22,9 +22,10 @@
     method public void validateRequestPermissionsRequestCode(int);
   }
 
-  @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public class ComponentActivity extends android.app.Activity implements androidx.core.view.KeyEventDispatcher.Component {
+  @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public class ComponentActivity extends android.app.Activity implements androidx.core.view.KeyEventDispatcher.Component androidx.lifecycle.LifecycleOwner {
     ctor public ComponentActivity();
     method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public <T extends androidx.core.app.ComponentActivity.ExtraData> T! getExtraData(Class<T!>!);
+    method public androidx.lifecycle.Lifecycle getLifecycle();
     method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void putExtraData(androidx.core.app.ComponentActivity.ExtraData!);
     method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public boolean superDispatchKeyEvent(android.view.KeyEvent!);
   }
diff --git a/core/api/restricted_current.txt b/core/api/restricted_current.txt
index 62d67c7..40fb68b 100644
--- a/core/api/restricted_current.txt
+++ b/core/api/restricted_current.txt
@@ -22,9 +22,10 @@
     method public void validateRequestPermissionsRequestCode(int);
   }
 
-  @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public class ComponentActivity extends android.app.Activity implements androidx.core.view.KeyEventDispatcher.Component {
+  @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public class ComponentActivity extends android.app.Activity implements androidx.core.view.KeyEventDispatcher.Component androidx.lifecycle.LifecycleOwner {
     ctor public ComponentActivity();
     method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public <T extends androidx.core.app.ComponentActivity.ExtraData> T! getExtraData(Class<T!>!);
+    method public androidx.lifecycle.Lifecycle getLifecycle();
     method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void putExtraData(androidx.core.app.ComponentActivity.ExtraData!);
     method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public boolean superDispatchKeyEvent(android.view.KeyEvent!);
   }
diff --git a/core/src/main/java/androidx/core/app/ComponentActivity.java b/core/src/main/java/androidx/core/app/ComponentActivity.java
index 864c4d8..a0ade1ac 100644
--- a/core/src/main/java/androidx/core/app/ComponentActivity.java
+++ b/core/src/main/java/androidx/core/app/ComponentActivity.java
@@ -18,13 +18,22 @@
 
 import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX;
 
+import android.annotation.SuppressLint;
 import android.app.Activity;
+import android.os.Bundle;
 import android.view.KeyEvent;
 import android.view.View;
 
+import androidx.annotation.CallSuper;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 import androidx.annotation.RestrictTo;
 import androidx.collection.SimpleArrayMap;
 import androidx.core.view.KeyEventDispatcher;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleOwner;
+import androidx.lifecycle.LifecycleRegistry;
+import androidx.lifecycle.ReportFragment;
 
 /**
  * Base class for activities that enables composition of higher level components.
@@ -36,8 +45,9 @@
  * @hide
  */
 @RestrictTo(LIBRARY_GROUP_PREFIX)
-public class ComponentActivity extends Activity
-        implements KeyEventDispatcher.Component {
+public class ComponentActivity extends Activity implements
+        LifecycleOwner,
+        KeyEventDispatcher.Component {
     /**
      * Storage for {@link ExtraData} instances.
      *
@@ -45,6 +55,11 @@
      */
     private SimpleArrayMap<Class<? extends ExtraData>, ExtraData> mExtraDataMap =
             new SimpleArrayMap<>();
+    /**
+     * This is only used for apps that have not switched to Fragments 1.1.0, where this
+     * behavior is provided by <code>androidx.activity.ComponentActivity</code>.
+     */
+    private LifecycleRegistry mLifecycleRegistry = new LifecycleRegistry(this);
 
     /**
      * Store an instance of {@link ExtraData} for later retrieval by class name
@@ -60,6 +75,20 @@
         mExtraDataMap.put(extraData.getClass(), extraData);
     }
 
+    @SuppressLint("RestrictedApi")
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        ReportFragment.injectIfNeededIn(this);
+    }
+
+    @CallSuper
+    @Override
+    protected void onSaveInstanceState(@NonNull Bundle outState) {
+        mLifecycleRegistry.markState(Lifecycle.State.CREATED);
+        super.onSaveInstanceState(outState);
+    }
+
     /**
      * Retrieves a previously set {@link ExtraData} by class name.
      *
@@ -71,6 +100,12 @@
         return (T) mExtraDataMap.get(extraDataClass);
     }
 
+    @NonNull
+    @Override
+    public Lifecycle getLifecycle() {
+        return mLifecycleRegistry;
+    }
+
     /**
      * @hide
      */