Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e4b93b4 authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] fix Settings crash due to null dataDir

BUG: 298206852
Test: presubmit
Change-Id: I33c106f3e65cf393bfea738b2e1bbfb507fbcec8
parent 31c0fb48
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -2916,11 +2916,7 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile

            StringBuilder sb = new StringBuilder();
            for (final PackageSetting ps : mPackages.values()) {
                // TODO(b/135203078): This doesn't handle multiple users
                final String dataPath = PackageInfoUtils.getDataDir(ps, UserHandle.USER_SYSTEM)
                        .getAbsolutePath();

                if (ps.getPkg() == null || dataPath == null) {
                if (ps.getPkg() == null) {
                    if (!"android".equals(ps.getPackageName())) {
                        Slog.w(TAG, "Skipping " + ps + " due to missing metadata");
                    }
@@ -2932,6 +2928,10 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
                    continue;
                }

                // TODO(b/135203078): This doesn't handle multiple users
                final File dataDir = PackageInfoUtils.getDataDir(ps, UserHandle.USER_SYSTEM);
                final String dataPath = dataDir == null ? "null" : dataDir.getAbsolutePath();

                final boolean isDebug = ps.getPkg().isDebuggable();
                final IntArray gids = new IntArray();
                for (final int userId : userIds) {
@@ -2973,7 +2973,7 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
                sb.append(ps.getSeInfo());
                sb.append(" ");
                final int gidsSize = gids.size();
                if (gids != null && gids.size() > 0) {
                if (gids.size() > 0) {
                    sb.append(gids.get(0));
                    for (int i = 1; i < gidsSize; i++) {
                        sb.append(",");