ShelterService: stop being foreground when unbound

This commit is contained in:
Peter Cai 2021-04-02 10:11:16 +08:00
parent 4e2f498c6c
commit ffba2c0d20
1 changed files with 10 additions and 0 deletions

View File

@ -291,6 +291,16 @@ public class ShelterService extends Service {
return mBinder;
}
@Override
public boolean onUnbind(Intent intent) {
// Stop our foreground notification (if it was created at all) when
// all clients have disconnected.
// This helps to ensure no notification is left when the Shelter activity
// is closed.
stopForeground(true);
return false;
}
private boolean isHidden(String packageName) {
return mIsProfileOwner && mPolicyManager.isApplicationHidden(mAdminComponent, packageName);
}