Add config_wearServiceComponent to start the WearService from system server.

Also Cp'ing changes in ag/19338309 together.

Test: tested locally, service starting as expected.
Bug: 267404564

Change-Id: Idf26fd9408290263f791b8eb23689368064459db
This commit is contained in:
repo sync -c -j48
2023-02-01 14:34:18 +00:00
committed by Himanshi Jain
parent 0e8ed85612
commit 71c8ea7da6
3 changed files with 26 additions and 0 deletions

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