Merge "Add config_wearServiceComponent to start the WearService from system server."

This commit is contained in:
Himanshi Jain
2023-02-04 07:26:34 +00:00
committed by Android (Google) Code Review
3 changed files with 26 additions and 0 deletions

View File

@@ -2193,6 +2193,9 @@
<!-- The name of the package that will hold the system financed device controller role. -->
<string name="config_systemFinancedDeviceController" translatable="false">com.android.devicelockcontroller</string>
<!-- The component name of the wear service class that will be started by the system server. -->
<string name="config_wearServiceComponent" translatable="false"></string>
<!-- The name of the package that will handle updating the device management role. -->
<string name="config_devicePolicyManagementUpdater" translatable="false"></string>

View File

@@ -4926,6 +4926,7 @@
<java-symbol type="array" name="config_displayShapeArray" />
<java-symbol type="bool" name="config_stopSystemPackagesByDefault"/>
<java-symbol type="string" name="config_wearServiceComponent" />
<!-- Whether to show weather on the lockscreen by default. -->
<java-symbol type="bool" name="config_lockscreenWeatherEnabledByDefault" />

View File

@@ -38,6 +38,7 @@ import android.app.INotificationManager;
import android.app.SystemServiceRegistry;
import android.app.admin.DevicePolicySafetyChecker;
import android.app.usage.UsageStatsManagerInternal;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -2894,6 +2895,27 @@ public final class SystemServer implements Dumpable {
t.traceEnd();
}
if (isWatch) {
t.traceBegin("StartWearService");
String wearServiceComponentNameString =
context.getString(R.string.config_wearServiceComponent);
if (!TextUtils.isEmpty(wearServiceComponentNameString)) {
ComponentName wearServiceComponentName = ComponentName.unflattenFromString(
wearServiceComponentNameString);
if (wearServiceComponentName != null) {
Intent intent = new Intent();
intent.setComponent(wearServiceComponentName);
intent.addFlags(Intent.FLAG_DIRECT_BOOT_AUTO);
context.startServiceAsUser(intent, UserHandle.SYSTEM);
} else {
Slog.d(TAG, "Null wear service component name.");
}
}
t.traceEnd();
}
// Enable airplane mode in safe mode. setAirplaneMode() cannot be called
// earlier as it sends broadcasts to other services.
// TODO: This may actually be too late if radio firmware already started leaking