CrackMe.apk
Download file
package androidx.savedstate;
import android.os.Bundle;
import androidx.arch.core.internal.SafeIterableMap;
import androidx.lifecycle.GenericLifecycleObserver;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.savedstate.Recreator;
import java.util.Map;
public final class SavedStateRegistry {
private static final String SAVED_COMPONENTS_KEY = "androidx.lifecycle.BundlableSavedStateRegistry.key";
boolean mAllowingSavingState = true;
private SafeIterableMap<String, SavedStateProvider> mComponents = new SafeIterableMap<>();
private Recreator.SavedStateProvider mRecreatorProvider;
private boolean mRestored;
private Bundle mRestoredState;
public interface AutoRecreated {
void onRecreated(SavedStateRegistryOwner savedStateRegistryOwner);
}
public interface SavedStateProvider {
Bundle saveState();
}
SavedStateRegistry() {
}
public Bundle consumeRestoredStateForKey(String str) {
if (this.mRestored) {
Bundle bundle = this.mRestoredState;
if (bundle == null) {
return null;
}
Bundle bundle2 = bundle.getBundle(str);
this.mRestoredState.remove(str);
if (this.mRestoredState.isEmpty()) {
this.mRestoredState = null;
}
return bundle2;
}
throw new IllegalStateException("You can consumeRestoredStateForKey only after super.onCreate of corresponding component");
}
public void registerSavedStateProvider(String str, SavedStateProvider savedStateProvider) {
if (this.mComponents.putIfAbsent(str, savedStateProvider) != null) {
throw new IllegalArgumentException("SavedStateProvider with the given key is already registered");
}
}
public void unregisterSavedStateProvider(String str) {
this.mComponents.remove(str);
}
public boolean isRestored() {
return this.mRestored;
}
public void runOnNextRecreation(Class<? extends AutoRecreated> cls) {
if (this.mAllowingSavingState) {
if (this.mRecreatorProvider == null) {
this.mRecreatorProvider = new Recreator.SavedStateProvider(this);
}
try {
cls.getDeclaredConstructor(new Class[0]);
this.mRecreatorProvider.add(cls.getName());
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("Class" + cls.getSimpleName() + " must have default constructor in order to be automatically recreated", e);
}
} else {
throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
}
}
/* access modifiers changed from: package-private */
public void performRestore(Lifecycle lifecycle, Bundle bundle) {
if (!this.mRestored) {
if (bundle != null) {
this.mRestoredState = bundle.getBundle(SAVED_COMPONENTS_KEY);
}
lifecycle.addObserver(new GenericLifecycleObserver() {
public void onStateChanged(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
if (event == Lifecycle.Event.ON_START) {
SavedStateRegistry.this.mAllowingSavingState = true;
} else if (event == Lifecycle.Event.ON_STOP) {
SavedStateRegistry.this.mAllowingSavingState = false;
}
}
});
this.mRestored = true;
return;
}
throw new IllegalStateException("SavedStateRegistry was already restored.");
}
/* access modifiers changed from: package-private */
public void performSave(Bundle bundle) {
Bundle bundle2 = new Bundle();
Bundle bundle3 = this.mRestoredState;
if (bundle3 != null) {
bundle2.putAll(bundle3);
}
SafeIterableMap<K, V>.IteratorWithAdditions iteratorWithAdditions = this.mComponents.iteratorWithAdditions();
while (iteratorWithAdditions.hasNext()) {
Map.Entry entry = (Map.Entry) iteratorWithAdditions.next();
bundle2.putBundle((String) entry.getKey(), ((SavedStateProvider) entry.getValue()).saveState());
}
bundle.putBundle(SAVED_COMPONENTS_KEY, bundle2);
}
}
Download file