Loading services/core/java/com/android/server/attention/AttentionManagerService.java +10 −3 Original line number Diff line number Diff line Loading @@ -113,6 +113,11 @@ public class AttentionManagerService extends SystemService { cancelAndUnbindLocked(peekUserStateLocked(userId)); } /** Returns {@code true} if attention service is configured on this device. */ public static boolean isServiceConfigured(Context context) { return !TextUtils.isEmpty(getServiceConfig(context)); } /** Resolves and sets up the attention service if it had not been done yet. */ private boolean isServiceAvailable() { if (mComponentName == null) { Loading Loading @@ -285,6 +290,10 @@ public class AttentionManagerService extends SystemService { return mUserStates.get(userId); } private static String getServiceConfig(Context context) { return context.getString(R.string.config_defaultAttentionService); } /** * Provides attention service component name at runtime, making sure it's provided by the * system. Loading @@ -293,9 +302,7 @@ public class AttentionManagerService extends SystemService { final String flag = DeviceConfig.getProperty(NAMESPACE_ATTENTION_MANAGER_SERVICE, COMPONENT_NAME); final String componentNameString = flag != null ? flag : context.getString( R.string.config_defaultAttentionService); final String componentNameString = flag != null ? flag : getServiceConfig(context); if (TextUtils.isEmpty(componentNameString)) { return null; } Loading services/core/java/com/android/server/power/AttentionDetector.java +1 −1 Original line number Diff line number Diff line Loading @@ -269,7 +269,7 @@ public class AttentionDetector { */ @VisibleForTesting boolean isAttentionServiceSupported() { return mAttentionManager.isAttentionServiceSupported(); return mAttentionManager != null && mAttentionManager.isAttentionServiceSupported(); } public void dump(PrintWriter pw) { Loading services/java/com/android/server/SystemServer.java +12 −4 Original line number Diff line number Diff line Loading @@ -1230,6 +1230,7 @@ public final class SystemServer { } startContentCaptureService(context); startAttentionService(context); // App prediction manager service traceBeginAndSlog("StartAppPredictionService"); Loading Loading @@ -1284,10 +1285,6 @@ public final class SystemServer { traceEnd(); } traceBeginAndSlog("StartAttentionManagerService"); mSystemServiceManager.startService(AttentionManagerService.class); traceEnd(); traceBeginAndSlog("StartNetworkScoreService"); mSystemServiceManager.startService(NetworkScoreService.Lifecycle.class); traceEnd(); Loading Loading @@ -2260,6 +2257,17 @@ public final class SystemServer { traceEnd(); } private void startAttentionService(@NonNull Context context) { if (!AttentionManagerService.isServiceConfigured(context)) { Slog.d(TAG, "AttentionService is not configured on this device"); return; } traceBeginAndSlog("StartAttentionManagerService"); mSystemServiceManager.startService(AttentionManagerService.class); traceEnd(); } static final void startSystemUi(Context context, WindowManagerService windowManager) { Intent intent = new Intent(); intent.setComponent(new ComponentName("com.android.systemui", Loading services/tests/servicestests/src/com/android/server/power/AttentionDetectorTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,13 @@ public class AttentionDetectorTest extends AndroidTestCase { assertThat(mNextDimming).isEqualTo(when); } @Test public void testOnUserActivity_doesntCrashIfNoAttentionService() { mAttentionManagerInternal = null; registerAttention(); // Does not crash. } @Test public void onUserActivity_ignoresWhiteListedActivityTypes() { for (int i = 0; i < NUM_USER_ACTIVITY_TYPES; i++) { Loading Loading
services/core/java/com/android/server/attention/AttentionManagerService.java +10 −3 Original line number Diff line number Diff line Loading @@ -113,6 +113,11 @@ public class AttentionManagerService extends SystemService { cancelAndUnbindLocked(peekUserStateLocked(userId)); } /** Returns {@code true} if attention service is configured on this device. */ public static boolean isServiceConfigured(Context context) { return !TextUtils.isEmpty(getServiceConfig(context)); } /** Resolves and sets up the attention service if it had not been done yet. */ private boolean isServiceAvailable() { if (mComponentName == null) { Loading Loading @@ -285,6 +290,10 @@ public class AttentionManagerService extends SystemService { return mUserStates.get(userId); } private static String getServiceConfig(Context context) { return context.getString(R.string.config_defaultAttentionService); } /** * Provides attention service component name at runtime, making sure it's provided by the * system. Loading @@ -293,9 +302,7 @@ public class AttentionManagerService extends SystemService { final String flag = DeviceConfig.getProperty(NAMESPACE_ATTENTION_MANAGER_SERVICE, COMPONENT_NAME); final String componentNameString = flag != null ? flag : context.getString( R.string.config_defaultAttentionService); final String componentNameString = flag != null ? flag : getServiceConfig(context); if (TextUtils.isEmpty(componentNameString)) { return null; } Loading
services/core/java/com/android/server/power/AttentionDetector.java +1 −1 Original line number Diff line number Diff line Loading @@ -269,7 +269,7 @@ public class AttentionDetector { */ @VisibleForTesting boolean isAttentionServiceSupported() { return mAttentionManager.isAttentionServiceSupported(); return mAttentionManager != null && mAttentionManager.isAttentionServiceSupported(); } public void dump(PrintWriter pw) { Loading
services/java/com/android/server/SystemServer.java +12 −4 Original line number Diff line number Diff line Loading @@ -1230,6 +1230,7 @@ public final class SystemServer { } startContentCaptureService(context); startAttentionService(context); // App prediction manager service traceBeginAndSlog("StartAppPredictionService"); Loading Loading @@ -1284,10 +1285,6 @@ public final class SystemServer { traceEnd(); } traceBeginAndSlog("StartAttentionManagerService"); mSystemServiceManager.startService(AttentionManagerService.class); traceEnd(); traceBeginAndSlog("StartNetworkScoreService"); mSystemServiceManager.startService(NetworkScoreService.Lifecycle.class); traceEnd(); Loading Loading @@ -2260,6 +2257,17 @@ public final class SystemServer { traceEnd(); } private void startAttentionService(@NonNull Context context) { if (!AttentionManagerService.isServiceConfigured(context)) { Slog.d(TAG, "AttentionService is not configured on this device"); return; } traceBeginAndSlog("StartAttentionManagerService"); mSystemServiceManager.startService(AttentionManagerService.class); traceEnd(); } static final void startSystemUi(Context context, WindowManagerService windowManager) { Intent intent = new Intent(); intent.setComponent(new ComponentName("com.android.systemui", Loading
services/tests/servicestests/src/com/android/server/power/AttentionDetectorTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,13 @@ public class AttentionDetectorTest extends AndroidTestCase { assertThat(mNextDimming).isEqualTo(when); } @Test public void testOnUserActivity_doesntCrashIfNoAttentionService() { mAttentionManagerInternal = null; registerAttention(); // Does not crash. } @Test public void onUserActivity_ignoresWhiteListedActivityTypes() { for (int i = 0; i < NUM_USER_ACTIVITY_TYPES; i++) { Loading