Last active
January 7, 2020 13:03
-
-
Save ganadist/af8541d36aaf36c5e94f6a7596ea02eb to your computer and use it in GitHub Desktop.
MissingSplitsManagerFactory source codes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Source code recreated from a .class file by IntelliJ IDEA | |
// (powered by Fernflower decompiler) | |
// | |
package com.google.android.play.core.missingsplits; | |
import android.content.ComponentName; | |
import android.content.Context; | |
import android.content.pm.ComponentInfo; | |
import android.content.pm.PackageInfo; | |
import android.content.pm.PackageManager; | |
import android.content.pm.PackageManager.NameNotFoundException; | |
import com.google.android.play.core.internal.ae; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.Iterator; | |
import java.util.List; | |
final class a { | |
private static final ae a = new ae("MissingSplitsAppComponentsHelper"); | |
private final Context b; | |
private final PackageManager c; | |
a(Context var1, PackageManager var2) { | |
this.b = var1; | |
this.c = var2; | |
} | |
// areAllNonActivityComponentsDisabled | |
final boolean a() { | |
Iterator var1 = this.d().iterator(); | |
ComponentInfo var2; | |
do { | |
if (!var1.hasNext()) { | |
a.b("All non-activity components are disabled", new Object[0]); | |
return true; | |
} | |
var2 = (ComponentInfo)var1.next(); | |
} while(this.c.getComponentEnabledSetting(new ComponentName(var2.packageName, var2.name)) == 2); | |
a.b("Not all non-activity components are disabled", new Object[0]); | |
return false; | |
} | |
// disableAllNonActivityComponents | |
final void b() { | |
a.a("Disabling all non-activity components", new Object[0]); | |
this.a(this.d(), 2); | |
} | |
// restoreAllNonActivityComponents | |
final void c() { | |
a.a("Resetting enabled state of all non-activity components", new Object[0]); | |
this.a(this.d(), 0); | |
} | |
private final void a(List<ComponentInfo> var1, int var2) { | |
Iterator var3 = var1.iterator(); | |
while(var3.hasNext()) { | |
ComponentInfo var4 = (ComponentInfo)var3.next(); | |
this.c.setComponentEnabledSetting(new ComponentName(var4.packageName, var4.name), var2, 1); | |
} | |
} | |
// getAllNonActivityComponents | |
private final List<ComponentInfo> d() { | |
try { | |
ArrayList var1 = new ArrayList(); | |
PackageInfo var2; | |
if ((var2 = this.c.getPackageInfo(this.b.getPackageName(), 526)).providers != null) { | |
Collections.addAll(var1, var2.providers); | |
} | |
if (var2.receivers != null) { | |
Collections.addAll(var1, var2.receivers); | |
} | |
if (var2.services != null) { | |
Collections.addAll(var1, var2.services); | |
} | |
return var1; | |
} catch (NameNotFoundException var3) { | |
a.c("Failed to resolve own package", new Object[]{var3}); | |
return Collections.emptyList(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Source code recreated from a .class file by IntelliJ IDEA | |
// (powered by Fernflower decompiler) | |
// | |
package com.google.android.play.core.missingsplits; | |
import android.app.Activity; | |
import android.app.ActivityManager; | |
import android.app.ActivityManager.AppTask; | |
import android.app.ActivityManager.RecentTaskInfo; | |
import android.content.ComponentName; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.pm.ApplicationInfo; | |
import android.content.pm.PackageInfo; | |
import android.content.pm.PackageManager; | |
import android.content.pm.PackageManager.NameNotFoundException; | |
import android.os.Build.VERSION; | |
import com.google.android.play.core.internal.ae; | |
import java.util.Collections; | |
import java.util.HashSet; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Set; | |
import java.util.concurrent.atomic.AtomicReference; | |
final class b implements MissingSplitsManager { | |
private static final ae a = new ae("MissingSplitsManagerImpl"); | |
private final Context b; | |
private final Runtime c; | |
private final a d; | |
private final AtomicReference<Boolean> e; | |
b(Context var1, Runtime var2, a var3, AtomicReference<Boolean> var4) { | |
this.b = var1; | |
this.c = var2; | |
this.d = var3; | |
this.e = var4; | |
} | |
public final boolean disableAppIfMissingRequiredSplits() { | |
if (VERSION.SDK_INT < 21) { | |
return false; | |
} else if (!this.isMissingRequiredSplits()) { | |
if (this.d.a()) { | |
this.d.c(); | |
this.c.exit(0); | |
} | |
return false; | |
} else { | |
Iterator var4 = this.c().iterator(); | |
boolean var10000; | |
while(true) { | |
if (var4.hasNext()) { | |
AppTask var5; | |
if ((var5 = (AppTask)var4.next()).getTaskInfo() == null || var5.getTaskInfo().baseIntent == null || var5.getTaskInfo().baseIntent.getComponent() == null) { | |
continue; | |
} | |
String var6 = var5.getTaskInfo().baseIntent.getComponent().getClassName(); | |
if (!PlayCoreMissingSplitsActivity.class.getName().equals(var6)) { | |
continue; | |
} | |
var10000 = true; | |
break; | |
} | |
var10000 = false; | |
break; | |
} | |
if (!var10000) { | |
b var2 = this; | |
Iterator var3 = this.c().iterator(); | |
while(true) { | |
if (!var3.hasNext()) { | |
var10000 = false; | |
break; | |
} | |
RecentTaskInfo var8; | |
if ((var8 = ((AppTask)var3.next()).getTaskInfo()) != null && var8.baseIntent != null && var8.baseIntent.getComponent() != null && var2.a(var8.baseIntent.getComponent())) { | |
var10000 = true; | |
break; | |
} | |
} | |
boolean var1 = var10000; | |
this.d.b(); | |
var3 = this.c().iterator(); | |
// exitGracefully | |
while(var3.hasNext()) { | |
((AppTask)var3.next()).finishAndRemoveTask(); | |
} | |
if (var1) { | |
this.b.getPackageManager().setComponentEnabledSetting(new ComponentName(this.b, PlayCoreMissingSplitsActivity.class), 1, 1); | |
Intent var7 = (new Intent(this.b, PlayCoreMissingSplitsActivity.class)).addFlags(884998144); | |
this.b.startActivity(var7); | |
} | |
this.c.exit(0); | |
} | |
return true; | |
} | |
} | |
public final boolean isMissingRequiredSplits() { | |
synchronized(this.e) { | |
if ((Boolean)this.e.get() == null) { | |
Set var5; | |
this.e.set(VERSION.SDK_INT >= 21 && | |
this.a() && | |
((var5 = this.b()).isEmpty() || var5.size() == 1 && var5.contains(""))); | |
} | |
return (Boolean)this.e.get(); | |
} | |
} | |
// isSplitApks | |
private final boolean a() { | |
PackageManager var1 = this.b.getPackageManager(); | |
try { | |
ApplicationInfo var2; | |
return (var2 = var1.getApplicationInfo(this.b.getPackageName(), 128)).metaData != null && Boolean.TRUE.equals(var2.metaData.get("com.android.vending.splits.required")); | |
} catch (NameNotFoundException var3) { | |
a.c("App '%s' is not found in the PackageManager", new Object[]{this.b.getPackageName()}); | |
return false; | |
} | |
} | |
private final Set<String> b() { | |
if (VERSION.SDK_INT < 21) { | |
return Collections.emptySet(); | |
} else { | |
try { | |
PackageInfo var1 = this.b.getPackageManager().getPackageInfo(this.b.getPackageName(), 0); | |
HashSet var2 = new HashSet(); | |
if (var1.splitNames != null) { | |
Collections.addAll(var2, var1.splitNames); | |
} | |
return var2; | |
} catch (NameNotFoundException var3) { | |
a.c("App '%s' is not found in PackageManager", new Object[]{this.b.getPackageName()}); | |
return Collections.emptySet(); | |
} | |
} | |
} | |
private final boolean a(ComponentName var1) { | |
String var2 = var1.getClassName(); | |
Class var3; | |
try { | |
var3 = Class.forName(var2); | |
} catch (ClassNotFoundException var6) { | |
a.c("ClassNotFoundException when scanning class hierarchy of '%s'", new Object[]{var2}); | |
try { | |
if (this.b.getPackageManager().getActivityInfo(var1, 0) != null) { | |
return true; | |
} | |
return false; | |
} catch (NameNotFoundException var5) { | |
return false; | |
} | |
} | |
while(var3 != null) { | |
if (var3.equals(Activity.class)) { | |
return true; | |
} | |
Class var4; | |
var3 = (var4 = var3.getSuperclass()) != var3 ? var4 : null; | |
} | |
return false; | |
} | |
private final List<AppTask> c() { | |
List var2; | |
return (var2 = ((ActivityManager)this.b.getSystemService("activity")).getAppTasks()) != null ? var2 : Collections.emptyList(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Source code recreated from a .class file by IntelliJ IDEA | |
// (powered by Fernflower decompiler) | |
// | |
package com.google.android.play.core.missingsplits; | |
import android.content.Context; | |
import java.util.concurrent.atomic.AtomicReference; | |
public class MissingSplitsManagerFactory { | |
private static final AtomicReference<Boolean> a = new AtomicReference((Object)null); | |
public MissingSplitsManagerFactory() { | |
} | |
public static MissingSplitsManager create(Context var0) { | |
return new b(var0, Runtime.getRuntime(), new a(var0, var0.getPackageManager()), a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment