use of android.app.assist.AssistStructure in project TinyKeePass by sorz.
the class TinyAutofillService method onFillRequest.
@Override
public void onFillRequest(@NonNull FillRequest request, @NonNull CancellationSignal cancellationSignal, @NonNull FillCallback callback) {
cancellationSignal.setOnCancelListener(() -> Log.d(TAG, "autofill canceled."));
if (!hasDatabaseConfigured(this)) {
callback.onSuccess(null);
return;
}
AssistStructure structure = request.getFillContexts().get(request.getFillContexts().size() - 1).getStructure();
StructureParser.Result parseResult = new StructureParser(structure).parse();
if (parseResult.password.isEmpty()) {
Log.d(TAG, "no password field found");
callback.onSuccess(null);
return;
}
FillResponse.Builder responseBuilder = new FillResponse.Builder();
RemoteViews presentation = AutofillUtils.getRemoteViews(this, getString(R.string.autofill_unlock_db), android.R.drawable.ic_lock_lock);
IntentSender sender = AuthActivity.getAuthIntentSenderForResponse(this);
AutofillId[] autofillIds = parseResult.allAutofillIds().toArray(AutofillId[]::new);
responseBuilder.setAuthentication(autofillIds, sender, presentation);
callback.onSuccess(responseBuilder.build());
}
use of android.app.assist.AssistStructure in project platform_frameworks_base by android.
the class ActivityThread method handleRequestAssistContextExtras.
public void handleRequestAssistContextExtras(RequestAssistContextExtras cmd) {
if (mLastSessionId != cmd.sessionId) {
// Clear the existing structures
mLastSessionId = cmd.sessionId;
for (int i = mLastAssistStructures.size() - 1; i >= 0; i--) {
AssistStructure structure = mLastAssistStructures.get(i).get();
if (structure != null) {
structure.clearSendChannel();
}
mLastAssistStructures.remove(i);
}
}
Bundle data = new Bundle();
AssistStructure structure = null;
AssistContent content = new AssistContent();
ActivityClientRecord r = mActivities.get(cmd.activityToken);
Uri referrer = null;
if (r != null) {
r.activity.getApplication().dispatchOnProvideAssistData(r.activity, data);
r.activity.onProvideAssistData(data);
referrer = r.activity.onProvideReferrer();
if (cmd.requestType == ActivityManager.ASSIST_CONTEXT_FULL) {
structure = new AssistStructure(r.activity);
Intent activityIntent = r.activity.getIntent();
if (activityIntent != null && (r.window == null || (r.window.getAttributes().flags & WindowManager.LayoutParams.FLAG_SECURE) == 0)) {
Intent intent = new Intent(activityIntent);
intent.setFlags(intent.getFlags() & ~(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION));
intent.removeUnsafeExtras();
content.setDefaultIntent(intent);
} else {
content.setDefaultIntent(new Intent());
}
r.activity.onProvideAssistContent(content);
}
}
if (structure == null) {
structure = new AssistStructure();
}
mLastAssistStructures.add(new WeakReference<>(structure));
IActivityManager mgr = ActivityManagerNative.getDefault();
try {
mgr.reportAssistContextExtras(cmd.requestToken, data, structure, content, referrer);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
use of android.app.assist.AssistStructure in project android_frameworks_base by crdroidandroid.
the class ActivityThread method handleRequestAssistContextExtras.
public void handleRequestAssistContextExtras(RequestAssistContextExtras cmd) {
if (mLastSessionId != cmd.sessionId) {
// Clear the existing structures
mLastSessionId = cmd.sessionId;
for (int i = mLastAssistStructures.size() - 1; i >= 0; i--) {
AssistStructure structure = mLastAssistStructures.get(i).get();
if (structure != null) {
structure.clearSendChannel();
}
mLastAssistStructures.remove(i);
}
}
Bundle data = new Bundle();
AssistStructure structure = null;
AssistContent content = new AssistContent();
ActivityClientRecord r = mActivities.get(cmd.activityToken);
Uri referrer = null;
if (r != null) {
r.activity.getApplication().dispatchOnProvideAssistData(r.activity, data);
r.activity.onProvideAssistData(data);
referrer = r.activity.onProvideReferrer();
if (cmd.requestType == ActivityManager.ASSIST_CONTEXT_FULL) {
structure = new AssistStructure(r.activity);
Intent activityIntent = r.activity.getIntent();
if (activityIntent != null && (r.window == null || (r.window.getAttributes().flags & WindowManager.LayoutParams.FLAG_SECURE) == 0)) {
Intent intent = new Intent(activityIntent);
intent.setFlags(intent.getFlags() & ~(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION));
intent.removeUnsafeExtras();
content.setDefaultIntent(intent);
} else {
content.setDefaultIntent(new Intent());
}
r.activity.onProvideAssistContent(content);
}
}
if (structure == null) {
structure = new AssistStructure();
}
mLastAssistStructures.add(new WeakReference<>(structure));
IActivityManager mgr = ActivityManagerNative.getDefault();
try {
mgr.reportAssistContextExtras(cmd.requestToken, data, structure, content, referrer);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
use of android.app.assist.AssistStructure in project android_frameworks_base by crdroidandroid.
the class VoiceInteractionSessionConnection method deliverSessionDataLocked.
private void deliverSessionDataLocked(AssistDataForActivity assistDataForActivity) {
Bundle assistData = assistDataForActivity.data.getBundle(VoiceInteractionSession.KEY_DATA);
AssistStructure structure = assistDataForActivity.data.getParcelable(VoiceInteractionSession.KEY_STRUCTURE);
AssistContent content = assistDataForActivity.data.getParcelable(VoiceInteractionSession.KEY_CONTENT);
int uid = assistDataForActivity.data.getInt(Intent.EXTRA_ASSIST_UID, -1);
if (uid >= 0 && content != null) {
Intent intent = content.getIntent();
if (intent != null) {
ClipData data = intent.getClipData();
if (data != null && Intent.isAccessUriMode(intent.getFlags())) {
grantClipDataPermissions(data, intent.getFlags(), uid, mCallingUid, mSessionComponentName.getPackageName());
}
}
ClipData data = content.getClipData();
if (data != null) {
grantClipDataPermissions(data, Intent.FLAG_GRANT_READ_URI_PERMISSION, uid, mCallingUid, mSessionComponentName.getPackageName());
}
}
try {
mSession.handleAssist(assistData, structure, content, assistDataForActivity.activityIndex, assistDataForActivity.activityCount);
} catch (RemoteException e) {
}
}
Aggregations