Merge "Unbind autofill service when the service package is updated." into pi-dev
This commit is contained in:
@@ -219,6 +219,8 @@ public final class AutofillManagerService extends SystemService {
|
||||
final String activePackageName = getActiveAutofillServicePackageName();
|
||||
if (packageName.equals(activePackageName)) {
|
||||
removeCachedServiceLocked(getChangingUserId());
|
||||
} else {
|
||||
handlePackageUpdateLocked(packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,6 +252,8 @@ public final class AutofillManagerService extends SystemService {
|
||||
return true;
|
||||
}
|
||||
removeCachedServiceLocked(getChangingUserId());
|
||||
} else {
|
||||
handlePackageUpdateLocked(pkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,6 +278,14 @@ public final class AutofillManagerService extends SystemService {
|
||||
}
|
||||
return serviceComponent.getPackageName();
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private void handlePackageUpdateLocked(String packageName) {
|
||||
final int size = mServicesCache.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
mServicesCache.valueAt(i).handlePackageUpdateLocked(packageName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// package changes
|
||||
|
||||
@@ -625,10 +625,26 @@ final class AutofillManagerServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
void handlePackageUpdateLocked(String packageName) {
|
||||
final ServiceInfo serviceInfo = mFieldClassificationStrategy.getServiceInfo();
|
||||
if (serviceInfo != null && serviceInfo.packageName.equals(packageName)) {
|
||||
resetExtServiceLocked();
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
void resetExtServiceLocked() {
|
||||
if (sVerbose) Slog.v(TAG, "reset autofill service.");
|
||||
mFieldClassificationStrategy.reset();
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
void destroyLocked() {
|
||||
if (sVerbose) Slog.v(TAG, "destroyLocked()");
|
||||
|
||||
resetExtServiceLocked();
|
||||
|
||||
final int numSessions = mSessions.size();
|
||||
final ArraySet<RemoteFillService> remoteFillServices = new ArraySet<>(numSessions);
|
||||
for (int i = 0; i < numSessions; i++) {
|
||||
|
||||
@@ -83,7 +83,7 @@ final class FieldClassificationStrategy {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ServiceInfo getServiceInfo() {
|
||||
ServiceInfo getServiceInfo() {
|
||||
final String packageName =
|
||||
mContext.getPackageManager().getServicesSystemSharedLibraryPackageName();
|
||||
if (packageName == null) {
|
||||
@@ -119,6 +119,18 @@ final class FieldClassificationStrategy {
|
||||
return name;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
synchronized (mLock) {
|
||||
if (mServiceConnection != null) {
|
||||
if (sDebug) Slog.d(TAG, "reset(): unbinding service.");
|
||||
mContext.unbindService(mServiceConnection);
|
||||
mServiceConnection = null;
|
||||
} else {
|
||||
if (sDebug) Slog.d(TAG, "reset(): service is not bound. Do nothing.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a command, starting the service connection if necessary.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user