Ensure um is ready when updating cache (#1737)
This commit is contained in:
parent
97ef900125
commit
4b9a4f8316
|
|
@ -25,7 +25,7 @@ buildscript {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
val navVersion by extra("2.5.0-alpha02")
|
val navVersion by extra("2.5.0-alpha02")
|
||||||
val agpVersion by extra("7.1.1")
|
val agpVersion by extra("7.1.2")
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("com.android.tools.build:gradle:$agpVersion")
|
classpath("com.android.tools.build:gradle:$agpVersion")
|
||||||
classpath("org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r")
|
classpath("org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r")
|
||||||
|
|
|
||||||
|
|
@ -279,8 +279,8 @@ public class ConfigManager {
|
||||||
needCached = instance.lastModuleCacheTime == 0 || instance.lastScopeCacheTime == 0;
|
needCached = instance.lastModuleCacheTime == 0 || instance.lastScopeCacheTime == 0;
|
||||||
}
|
}
|
||||||
if (needCached) {
|
if (needCached) {
|
||||||
if (PackageService.isAlive()) {
|
if (PackageService.isAlive() && UserService.isAlive()) {
|
||||||
Log.d(TAG, "pm is ready, updating cache");
|
Log.d(TAG, "pm & um are ready, updating cache");
|
||||||
// must ensure cache is valid for later usage
|
// must ensure cache is valid for later usage
|
||||||
instance.updateCaches(true);
|
instance.updateCaches(true);
|
||||||
instance.updateManager(false);
|
instance.updateManager(false);
|
||||||
|
|
@ -440,7 +440,7 @@ public class ConfigManager {
|
||||||
|
|
||||||
private synchronized void cacheModules() {
|
private synchronized void cacheModules() {
|
||||||
// skip caching when pm is not yet available
|
// skip caching when pm is not yet available
|
||||||
if (!PackageService.isAlive()) return;
|
if (!PackageService.isAlive() || !UserService.isAlive()) return;
|
||||||
synchronized (cacheHandler) {
|
synchronized (cacheHandler) {
|
||||||
if (lastModuleCacheTime >= requestModuleCacheTime) return;
|
if (lastModuleCacheTime >= requestModuleCacheTime) return;
|
||||||
else lastModuleCacheTime = SystemClock.elapsedRealtime();
|
else lastModuleCacheTime = SystemClock.elapsedRealtime();
|
||||||
|
|
@ -481,9 +481,10 @@ public class ConfigManager {
|
||||||
try {
|
try {
|
||||||
pkgInfo = PackageService.getPackageInfoFromAllUsers(m.packageName, MATCH_ALL_FLAGS).values().stream().findFirst().orElse(null);
|
pkgInfo = PackageService.getPackageInfoFromAllUsers(m.packageName, MATCH_ALL_FLAGS).values().stream().findFirst().orElse(null);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.w(TAG, "get package info of " + m.packageName, e);
|
Log.w(TAG, "Get package info of " + m.packageName, e);
|
||||||
}
|
}
|
||||||
if (pkgInfo == null || pkgInfo.applicationInfo == null) {
|
if (pkgInfo == null || pkgInfo.applicationInfo == null) {
|
||||||
|
Log.w(TAG, "Failed to find package info of " + m.packageName);
|
||||||
obsoleteModules.add(m.packageName);
|
obsoleteModules.add(m.packageName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -503,8 +504,13 @@ public class ConfigManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m.apkPath = getModuleApkPath(pkgInfo.applicationInfo);
|
m.apkPath = getModuleApkPath(pkgInfo.applicationInfo);
|
||||||
if (m.apkPath == null) obsoleteModules.add(m.packageName);
|
if (m.apkPath == null) {
|
||||||
else obsoletePaths.put(m.packageName, m.apkPath);
|
Log.w(TAG, "Failed to find path of " + m.packageName);
|
||||||
|
obsoleteModules.add(m.packageName);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
obsoletePaths.put(m.packageName, m.apkPath);
|
||||||
|
}
|
||||||
m.appId = pkgInfo.applicationInfo.uid;
|
m.appId = pkgInfo.applicationInfo.uid;
|
||||||
return true;
|
return true;
|
||||||
}).forEach(m -> {
|
}).forEach(m -> {
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,11 @@ public class UserService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static boolean isAlive() {
|
||||||
|
var um = getUserManager();
|
||||||
|
return um != null && um.asBinder().isBinderAlive();
|
||||||
|
}
|
||||||
|
|
||||||
public static IUserManager getUserManager() {
|
public static IUserManager getUserManager() {
|
||||||
if (binder == null && um == null) {
|
if (binder == null && um == null) {
|
||||||
binder = ServiceManager.getService("user");
|
binder = ServiceManager.getService("user");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue