Changed how the Smart Suggestions service is defined.

Initially it was defined as secure Settings, but the proper way is to let the
OEMs set it by overlaying a framework resources, which an option to temporarily
override that setting using a Shell cmd (so it can be changed on CTS tests).

This CL also changes how the service can be explicitly enabled / disabled at
the time the system starts, so it can be disabled by a server-push in case of
emergencies (and also manually enable by developers when running the CTS tests
on AOSP builds).

Bug: 119776618
Bug: 111276913
Bug: 117779333

Test: adb shell settings put global \
   smart_suggestions_service_explicitly_enabled true && \
   sleep 10s && \ adb shell stop && adb shell start \
   atest CtsContentCaptureServiceTestCases
Test: atest FrameworksCoreTests:SettingsBackupTest
Test: atest CtsAutoFillServiceTestCases # to make sure it didn't break
Test: m -j SettingsProvider

Change-Id: Ibd1bba0c0d534b4b6344516d8ff893142785a57a
This commit is contained in:
Felipe Leme
2018-11-30 12:49:45 -08:00
parent a06d12e6bd
commit 658c8e423f
13 changed files with 311 additions and 30 deletions

View File

@@ -22,6 +22,7 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import static android.os.IServiceManager.DUMP_FLAG_PROTO;
import static android.view.Display.DEFAULT_DISPLAY;
import android.annotation.NonNull;
import android.app.ActivityThread;
import android.app.INotificationManager;
import android.app.usage.UsageStatsManagerInternal;
@@ -55,7 +56,9 @@ import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.os.storage.IStorageManager;
import android.provider.Settings;
import android.sysprop.VoldProperties;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Slog;
@@ -797,10 +800,6 @@ public final class SystemServer {
boolean disableSystemTextClassifier = SystemProperties.getBoolean(
"config.disable_systemtextclassifier", false);
//TODO(b/111276913): temporarily disabled until the manager is properly implemented to
// ignore events when disabled and buffer when enabled
boolean disableIntelligence = SystemProperties.getBoolean(
"config.disable_intelligence", true);
boolean disableNetworkTime = SystemProperties.getBoolean("config.disable_networktime",
false);
boolean disableCameraService = SystemProperties.getBoolean("config.disable_cameraservice",
@@ -1131,13 +1130,7 @@ public final class SystemServer {
traceEnd();
}
if (!disableIntelligence) {
traceBeginAndSlog("StartIntelligenceService");
mSystemServiceManager.startService(INTELLIGENCE_MANAGER_SERVICE_CLASS);
traceEnd();
} else {
Slog.d(TAG, "IntelligenceService disabled");
}
startIntelligenceService(context);
// NOTE: ClipboardService indirectly depends on IntelligenceService
traceBeginAndSlog("StartClipboardService");
@@ -2101,6 +2094,37 @@ public final class SystemServer {
}, BOOT_TIMINGS_TRACE_LOG);
}
private void startIntelligenceService(@NonNull Context context) {
// First check if it was explicitly enabled by Settings
boolean explicitlySupported = false;
final String settings = Settings.Global.getString(context.getContentResolver(),
Settings.Global.SMART_SUGGESTIONS_SERVICE_EXPLICITLY_ENABLED);
if (settings != null) {
explicitlySupported = Boolean.parseBoolean(settings);
if (explicitlySupported) {
Slog.d(TAG, "IntelligenceService explicitly enabled by Settings");
} else {
Slog.d(TAG, "IntelligenceService explicitly disabled by Settings");
return;
}
}
// Then check if OEM overlaid the resource that defines the service.
if (!explicitlySupported) {
final String serviceName = context
.getString(com.android.internal.R.string.config_defaultSmartSuggestionsService);
if (TextUtils.isEmpty(serviceName)) {
Slog.d(TAG, "IntelligenceService disabled because config resource is not overlaid");
return;
}
}
traceBeginAndSlog("StartIntelligenceService");
mSystemServiceManager.startService(INTELLIGENCE_MANAGER_SERVICE_CLASS);
traceEnd();
}
static final void startSystemUi(Context context, WindowManagerService windowManager) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.systemui",