Search in sources :

Example 11 with AssistStructure

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());
}
Also used : RemoteViews(android.widget.RemoteViews) FillResponse(android.service.autofill.FillResponse) AssistStructure(android.app.assist.AssistStructure) IntentSender(android.content.IntentSender) AutofillId(android.view.autofill.AutofillId)

Example 12 with AssistStructure

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();
    }
}
Also used : AssistContent(android.app.assist.AssistContent) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) AssistStructure(android.app.assist.AssistStructure) ReferrerIntent(com.android.internal.content.ReferrerIntent) Intent(android.content.Intent) RemoteException(android.os.RemoteException) Uri(android.net.Uri)

Example 13 with AssistStructure

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();
    }
}
Also used : AssistContent(android.app.assist.AssistContent) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) AssistStructure(android.app.assist.AssistStructure) ReferrerIntent(com.android.internal.content.ReferrerIntent) Intent(android.content.Intent) RemoteException(android.os.RemoteException) Uri(android.net.Uri)

Example 14 with AssistStructure

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) {
    }
}
Also used : AssistContent(android.app.assist.AssistContent) Bundle(android.os.Bundle) AssistStructure(android.app.assist.AssistStructure) Intent(android.content.Intent) RemoteException(android.os.RemoteException) ClipData(android.content.ClipData)

Aggregations

AssistStructure (android.app.assist.AssistStructure)14 AssistContent (android.app.assist.AssistContent)9 Intent (android.content.Intent)9 Bundle (android.os.Bundle)9 RemoteException (android.os.RemoteException)9 Uri (android.net.Uri)5 PersistableBundle (android.os.PersistableBundle)5 ReferrerIntent (com.android.internal.content.ReferrerIntent)5 ClipData (android.content.ClipData)4 Matrix (android.graphics.Matrix)4 Paint (android.graphics.Paint)4 IntentSender (android.content.IntentSender)1 FillResponse (android.service.autofill.FillResponse)1 AutofillId (android.view.autofill.AutofillId)1 RemoteViews (android.widget.RemoteViews)1