Merge "Fix can't turn off Google" into udc-dev
This commit is contained in:
@@ -25,6 +25,7 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.UserIdInt;
|
import android.annotation.UserIdInt;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
@@ -482,7 +483,7 @@ public final class CredentialManagerService
|
|||||||
callback,
|
callback,
|
||||||
request,
|
request,
|
||||||
constructCallingAppInfo(callingPackage, userId, request.getOrigin()),
|
constructCallingAppInfo(callingPackage, userId, request.getOrigin()),
|
||||||
getEnabledProviders(),
|
getEnabledProvidersForUser(userId),
|
||||||
CancellationSignal.fromTransport(cancelTransport),
|
CancellationSignal.fromTransport(cancelTransport),
|
||||||
timestampBegan);
|
timestampBegan);
|
||||||
addSessionLocked(userId, session);
|
addSessionLocked(userId, session);
|
||||||
@@ -537,7 +538,7 @@ public final class CredentialManagerService
|
|||||||
getCredentialCallback,
|
getCredentialCallback,
|
||||||
request,
|
request,
|
||||||
constructCallingAppInfo(callingPackage, userId, request.getOrigin()),
|
constructCallingAppInfo(callingPackage, userId, request.getOrigin()),
|
||||||
getEnabledProviders(),
|
getEnabledProvidersForUser(userId),
|
||||||
CancellationSignal.fromTransport(cancelTransport),
|
CancellationSignal.fromTransport(cancelTransport),
|
||||||
timestampBegan,
|
timestampBegan,
|
||||||
prepareGetCredentialCallback);
|
prepareGetCredentialCallback);
|
||||||
@@ -655,7 +656,7 @@ public final class CredentialManagerService
|
|||||||
request,
|
request,
|
||||||
callback,
|
callback,
|
||||||
constructCallingAppInfo(callingPackage, userId, request.getOrigin()),
|
constructCallingAppInfo(callingPackage, userId, request.getOrigin()),
|
||||||
getEnabledProviders(),
|
getEnabledProvidersForUser(userId),
|
||||||
getPrimaryProvidersForUserId(getContext(), userId),
|
getPrimaryProvidersForUserId(getContext(), userId),
|
||||||
CancellationSignal.fromTransport(cancelTransport),
|
CancellationSignal.fromTransport(cancelTransport),
|
||||||
timestampBegan);
|
timestampBegan);
|
||||||
@@ -804,7 +805,7 @@ public final class CredentialManagerService
|
|||||||
verifyGetProvidersPermission();
|
verifyGetProvidersPermission();
|
||||||
|
|
||||||
return CredentialProviderInfoFactory.getCredentialProviderServices(
|
return CredentialProviderInfoFactory.getCredentialProviderServices(
|
||||||
mContext, userId, providerFilter, getEnabledProviders(),
|
mContext, userId, providerFilter, getEnabledProvidersForUser(userId),
|
||||||
getPrimaryProvidersForUserId(mContext, userId));
|
getPrimaryProvidersForUserId(mContext, userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,7 +816,7 @@ public final class CredentialManagerService
|
|||||||
|
|
||||||
final int userId = UserHandle.getCallingUserId();
|
final int userId = UserHandle.getCallingUserId();
|
||||||
return CredentialProviderInfoFactory.getCredentialProviderServicesForTesting(
|
return CredentialProviderInfoFactory.getCredentialProviderServicesForTesting(
|
||||||
mContext, userId, providerFilter, getEnabledProviders(),
|
mContext, userId, providerFilter, getEnabledProvidersForUser(userId),
|
||||||
getPrimaryProvidersForUserId(mContext, userId));
|
getPrimaryProvidersForUserId(mContext, userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,24 +833,26 @@ public final class CredentialManagerService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("GuardedBy") // ErrorProne requires service.mLock which is the same
|
private Set<ComponentName> getEnabledProvidersForUser(int userId) {
|
||||||
// this.mLock
|
final int resolvedUserId = ActivityManager.handleIncomingUser(
|
||||||
private Set<ComponentName> getEnabledProviders() {
|
Binder.getCallingPid(), Binder.getCallingUid(),
|
||||||
|
userId, false, false,
|
||||||
|
"getEnabledProvidersForUser", null);
|
||||||
|
|
||||||
Set<ComponentName> enabledProviders = new HashSet<>();
|
Set<ComponentName> enabledProviders = new HashSet<>();
|
||||||
synchronized (mLock) {
|
String directValue = Settings.Secure.getStringForUser(
|
||||||
runForUser(
|
mContext.getContentResolver(), Settings.Secure.CREDENTIAL_SERVICE, resolvedUserId);
|
||||||
(service) -> {
|
|
||||||
try {
|
if (!TextUtils.isEmpty(directValue)) {
|
||||||
enabledProviders.add(
|
String[] components = directValue.split(":");
|
||||||
service.getCredentialProviderInfo()
|
for (String componentString : components) {
|
||||||
.getServiceInfo().getComponentName());
|
ComponentName component = ComponentName.unflattenFromString(componentString);
|
||||||
} catch (NullPointerException e) {
|
if (component != null) {
|
||||||
// Safe check
|
enabledProviders.add(component);
|
||||||
Slog.e(TAG, "Skipping provider as either the providerInfo"
|
}
|
||||||
+ " or serviceInfo is null - weird");
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return enabledProviders;
|
return enabledProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,7 +882,7 @@ public final class CredentialManagerService
|
|||||||
callback,
|
callback,
|
||||||
request,
|
request,
|
||||||
constructCallingAppInfo(callingPackage, userId, null),
|
constructCallingAppInfo(callingPackage, userId, null),
|
||||||
getEnabledProviders(),
|
getEnabledProvidersForUser(userId),
|
||||||
CancellationSignal.fromTransport(cancelTransport),
|
CancellationSignal.fromTransport(cancelTransport),
|
||||||
timestampBegan);
|
timestampBegan);
|
||||||
addSessionLocked(userId, session);
|
addSessionLocked(userId, session);
|
||||||
|
|||||||
Reference in New Issue
Block a user