Loading services/core/java/com/android/server/pm/PackageManagerService.java +7 −7 Original line number Diff line number Diff line Loading @@ -1449,21 +1449,21 @@ public class PackageManagerService extends IPackageManager.Stub /** Token for keys in mPendingEnableRollback. */ private int mPendingEnableRollbackToken = 0; @Watched @Watched(manual = true) volatile boolean mSystemReady; @Watched @Watched(manual = true) private volatile boolean mSafeMode; volatile boolean mHasSystemUidErrors; @Watched private final WatchedSparseBooleanArray mWebInstantAppsDisabled = new WatchedSparseBooleanArray(); @Watched @Watched(manual = true) private ApplicationInfo mAndroidApplication; @Watched @Watched(manual = true) final ActivityInfo mResolveActivity = new ActivityInfo(); final ResolveInfo mResolveInfo = new ResolveInfo(); @Watched @Watched(manual = true) private ComponentName mResolveComponentName; AndroidPackage mPlatformPackage; ComponentName mCustomResolverComponentName; Loading @@ -1479,9 +1479,9 @@ public class PackageManagerService extends IPackageManager.Stub final ComponentName mInstantAppResolverSettingsComponent; /** Activity used to install instant applications */ @Watched @Watched(manual = true) private ActivityInfo mInstantAppInstallerActivity; @Watched @Watched(manual = true) private final ResolveInfo mInstantAppInstallerInfo = new ResolveInfo(); private final Map<String, Pair<PackageInstalledInfo, IPackageInstallObserver2>> services/core/java/com/android/server/utils/Watchable.java +15 −12 Original line number Diff line number Diff line Loading @@ -73,7 +73,8 @@ public interface Watchable { return; } for (Field f : base.getClass().getDeclaredFields()) { if (f.getAnnotation(Watched.class) != null) { final Watched annotation = f.getAnnotation(Watched.class); if (annotation != null) { final String fn = base.getClass().getName() + "." + f.getName(); try { f.setAccessible(true); Loading @@ -81,25 +82,27 @@ public interface Watchable { if (o instanceof Watchable) { Watchable attr = (Watchable) (o); if (attr != null && !attr.isRegisteredObserver(observer)) { if (logOnly) { Log.e("Watchable", fn + " missing an observer"); } else { throw new RuntimeException("Watchable " + fn + " missing an observer"); } handleVerifyError("Watchable " + fn + " missing an observer", logOnly); } } else if (!annotation.manual()) { handleVerifyError("@Watched annotated field " + fn + " is not a watchable" + " type and is not flagged for manual watching.", logOnly); } } catch (IllegalAccessException e) { // The field is protected; ignore it. Other exceptions that may be thrown by // Field.get() are allowed to roll up. if (logOnly) { Log.e("Watchable", fn + " not visible"); } else { throw new RuntimeException("Watchable " + fn + " not visible"); handleVerifyError("Watchable " + fn + " not visible", logOnly); } } } } static void handleVerifyError(String errorMessage, boolean logOnly) { if (logOnly) { Log.e("Watchable", errorMessage); } else { throw new RuntimeException(errorMessage); } } /** Loading services/core/java/com/android/server/utils/Watched.java +2 −0 Original line number Diff line number Diff line Loading @@ -29,4 +29,6 @@ import java.lang.annotation.Target; @Target({ ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) public @interface Watched { /** true if the annotated field is manually tracked */ boolean manual() default false; } Loading
services/core/java/com/android/server/pm/PackageManagerService.java +7 −7 Original line number Diff line number Diff line Loading @@ -1449,21 +1449,21 @@ public class PackageManagerService extends IPackageManager.Stub /** Token for keys in mPendingEnableRollback. */ private int mPendingEnableRollbackToken = 0; @Watched @Watched(manual = true) volatile boolean mSystemReady; @Watched @Watched(manual = true) private volatile boolean mSafeMode; volatile boolean mHasSystemUidErrors; @Watched private final WatchedSparseBooleanArray mWebInstantAppsDisabled = new WatchedSparseBooleanArray(); @Watched @Watched(manual = true) private ApplicationInfo mAndroidApplication; @Watched @Watched(manual = true) final ActivityInfo mResolveActivity = new ActivityInfo(); final ResolveInfo mResolveInfo = new ResolveInfo(); @Watched @Watched(manual = true) private ComponentName mResolveComponentName; AndroidPackage mPlatformPackage; ComponentName mCustomResolverComponentName; Loading @@ -1479,9 +1479,9 @@ public class PackageManagerService extends IPackageManager.Stub final ComponentName mInstantAppResolverSettingsComponent; /** Activity used to install instant applications */ @Watched @Watched(manual = true) private ActivityInfo mInstantAppInstallerActivity; @Watched @Watched(manual = true) private final ResolveInfo mInstantAppInstallerInfo = new ResolveInfo(); private final Map<String, Pair<PackageInstalledInfo, IPackageInstallObserver2>>
services/core/java/com/android/server/utils/Watchable.java +15 −12 Original line number Diff line number Diff line Loading @@ -73,7 +73,8 @@ public interface Watchable { return; } for (Field f : base.getClass().getDeclaredFields()) { if (f.getAnnotation(Watched.class) != null) { final Watched annotation = f.getAnnotation(Watched.class); if (annotation != null) { final String fn = base.getClass().getName() + "." + f.getName(); try { f.setAccessible(true); Loading @@ -81,25 +82,27 @@ public interface Watchable { if (o instanceof Watchable) { Watchable attr = (Watchable) (o); if (attr != null && !attr.isRegisteredObserver(observer)) { if (logOnly) { Log.e("Watchable", fn + " missing an observer"); } else { throw new RuntimeException("Watchable " + fn + " missing an observer"); } handleVerifyError("Watchable " + fn + " missing an observer", logOnly); } } else if (!annotation.manual()) { handleVerifyError("@Watched annotated field " + fn + " is not a watchable" + " type and is not flagged for manual watching.", logOnly); } } catch (IllegalAccessException e) { // The field is protected; ignore it. Other exceptions that may be thrown by // Field.get() are allowed to roll up. if (logOnly) { Log.e("Watchable", fn + " not visible"); } else { throw new RuntimeException("Watchable " + fn + " not visible"); handleVerifyError("Watchable " + fn + " not visible", logOnly); } } } } static void handleVerifyError(String errorMessage, boolean logOnly) { if (logOnly) { Log.e("Watchable", errorMessage); } else { throw new RuntimeException(errorMessage); } } /** Loading
services/core/java/com/android/server/utils/Watched.java +2 −0 Original line number Diff line number Diff line Loading @@ -29,4 +29,6 @@ import java.lang.annotation.Target; @Target({ ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) public @interface Watched { /** true if the annotated field is manually tracked */ boolean manual() default false; }