Permalink
Browse files

Remove LifecycleDispatcher & Rename LifecycleRuntimeTrojanProvider

LifecycleDispatcher were hacks to make LifecycleFragment and
LifecycleActivity work, they are no longer needed since we integrated
with support library

Test: ProcessOwnerTest
Change-Id: I525607eac0f2d1518b08e918bbad4840db5764d6
  • Loading branch information...
Sergey Vasilinets
Sergey Vasilinets committed Oct 13, 2017
1 parent 0f9eac1 commit 566dbfd4b16f43685d4bdc835b1b862883b94d96
@@ -20,6 +20,6 @@
<provider android:authorities="${applicationId}.lifecycle-trojan"
android:multiprocess="true"
android:exported="false"
android:name="android.arch.lifecycle.LifecycleRuntimeTrojanProvider"/>
android:name="android.arch.lifecycle.ProcessLifecycleOwnerInitializer"/>
</application>
</manifest>

This file was deleted.

Oops, something went wrong.
@@ -156,7 +156,8 @@ void attach(Context context) {
app.registerActivityLifecycleCallbacks(new EmptyActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
ReportFragment .get(activity).setProcessListener(mInitializationListener);
ReportFragment.injectIfNeededIn(activity);
ReportFragment.get(activity).setProcessListener(mInitializationListener);
}
@Override
@@ -29,10 +29,9 @@
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class LifecycleRuntimeTrojanProvider extends ContentProvider {
public class ProcessLifecycleOwnerInitializer extends ContentProvider {
@Override
public boolean onCreate() {
LifecycleDispatcher.init(getContext());
ProcessLifecycleOwner.init(getContext());
return true;
}

This file was deleted.

Oops, something went wrong.
@@ -31,6 +31,7 @@
import android.arch.lifecycle.testapp.NavigationDialogActivity;
import android.arch.lifecycle.testapp.NavigationTestActivityFirst;
import android.arch.lifecycle.testapp.NavigationTestActivitySecond;
import android.arch.lifecycle.testapp.NonSupportActivity;
import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
@@ -94,6 +95,22 @@ public void testNavigation() throws Throwable {
checkProcessObserverSilent(secondActivity);
}
@Test
public void testNavigationToNonSupport() throws Throwable {
FragmentActivity firstActivity = setupObserverOnResume();
Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor(
NonSupportActivity.class.getCanonicalName(), null, false);
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
instrumentation.addMonitor(monitor);
Intent intent = new Intent(firstActivity, NonSupportActivity.class);
firstActivity.finish();
firstActivity.startActivity(intent);
NonSupportActivity secondActivity = (NonSupportActivity) monitor.waitForActivity();
assertThat("Failed to navigate", secondActivity, notNullValue());
checkProcessObserverSilent(secondActivity);
}
@Test
public void testRecreation() throws Throwable {
FragmentActivity activity = setupObserverOnResume();
@@ -164,4 +181,11 @@ private void checkProcessObserverSilent(FragmentActivity activity) throws Throwa
activityTestRule.runOnUiThread(() ->
ProcessLifecycleOwner.get().getLifecycle().removeObserver(mObserver));
}
private void checkProcessObserverSilent(NonSupportActivity activity) throws Throwable {
assertThat(activity.awaitResumedState(), is(true));
assertThat(mObserver.mChangedState, is(false));
activityTestRule.runOnUiThread(() ->
ProcessLifecycleOwner.get().getLifecycle().removeObserver(mObserver));
}
}
@@ -71,5 +71,6 @@
<activity android:name=".NavigationDialogActivity"
android:launchMode="singleTask"
android:theme="@android:style/Theme.DeviceDefault.Dialog" />
<activity android:name=".NonSupportActivity"/>
</application>
</manifest>
Oops, something went wrong.

0 comments on commit 566dbfd

Please sign in to comment.