TrustInterfaceService: Do the needful at a later stage
According to the lifecycle of a SystemService, onStart() is called to get
the service running and the service should publish its binder interface
at that point. First of all, ensure to do that and then do the real work
once boot is completed.
This was actually the root cause of the issue that commit c06e32d
addressed (not entirely correctly). Although the crash was no longer
observed after that commit, the proper fix is actually this one.
Change-Id: I42dc7182ba3d0db5413709de229ab9c0c4926df6
This commit is contained in:
@@ -69,13 +69,6 @@ public class TrustInterfaceService extends LineageSystemService {
|
||||
public TrustInterfaceService(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mNotificationManager = context.getSystemService(NotificationManager.class);
|
||||
if (context.getPackageManager().hasSystemFeature(LineageContextConstants.Features.TRUST)) {
|
||||
publishBinderService(LineageContextConstants.LINEAGE_TRUST_INTERFACE, mService);
|
||||
} else {
|
||||
Log.wtf(TAG, "Lineage Trust service started by system server but feature xml not" +
|
||||
" declared. Not publishing binder service!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,20 +78,34 @@ public class TrustInterfaceService extends LineageSystemService {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
try {
|
||||
mUsbRestrictor = IUsbRestrict.getService();
|
||||
} catch (NoSuchElementException | RemoteException e) {
|
||||
// ignore, the hal is not available
|
||||
if (mContext.getPackageManager().hasSystemFeature(LineageContextConstants.Features.TRUST)) {
|
||||
publishBinderService(LineageContextConstants.LINEAGE_TRUST_INTERFACE, mService);
|
||||
} else {
|
||||
Log.wtf(TAG, "Lineage Trust service started by system server but feature xml not" +
|
||||
" declared. Not publishing binder service!");
|
||||
}
|
||||
}
|
||||
|
||||
// Onboard
|
||||
if (!hasOnboardedUser()) {
|
||||
postOnBoardingNotification();
|
||||
registerLocaleChangedReceiver();
|
||||
return;
|
||||
@Override
|
||||
public void onBootPhase(int phase) {
|
||||
if (phase == PHASE_BOOT_COMPLETED) {
|
||||
mNotificationManager = mContext.getSystemService(NotificationManager.class);
|
||||
|
||||
try {
|
||||
mUsbRestrictor = IUsbRestrict.getService();
|
||||
} catch (NoSuchElementException | RemoteException e) {
|
||||
// ignore, the hal is not available
|
||||
}
|
||||
|
||||
// Onboard
|
||||
if (!hasOnboardedUser()) {
|
||||
postOnBoardingNotification();
|
||||
registerLocaleChangedReceiver();
|
||||
return;
|
||||
}
|
||||
|
||||
runTestInternal();
|
||||
}
|
||||
|
||||
runTestInternal();
|
||||
}
|
||||
|
||||
/* Public methods implementation */
|
||||
|
||||
Reference in New Issue
Block a user