Search in sources :

Example 6 with AssistStructure

use of android.app.assist.AssistStructure in project android_frameworks_base by DirtyUnicorns.

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)

Example 7 with AssistStructure

use of android.app.assist.AssistStructure in project android_frameworks_base by DirtyUnicorns.

the class AssistVisualizer method setAssistStructure.

public void setAssistStructure(AssistStructure as) {
    mAssistStructure = as;
    mTextRects.clear();
    final int N = as.getWindowNodeCount();
    if (N > 0) {
        for (int i = 0; i < N; i++) {
            AssistStructure.WindowNode windowNode = as.getWindowNodeAt(i);
            mMatrixStack.clear();
            Matrix matrix = new Matrix();
            matrix.setTranslate(windowNode.getLeft(), windowNode.getTop());
            mMatrixStack.add(matrix);
            buildTextRects(windowNode.getRootViewNode(), 0, windowNode.getLeft(), windowNode.getTop());
        }
    }
    Log.d(TAG, "Building text rects in " + this + ": found " + mTextRects.size());
    invalidate();
}
Also used : Matrix(android.graphics.Matrix) AssistStructure(android.app.assist.AssistStructure) Paint(android.graphics.Paint)

Example 8 with AssistStructure

use of android.app.assist.AssistStructure in project android_frameworks_base by AOSPA.

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 9 with AssistStructure

use of android.app.assist.AssistStructure in project android_frameworks_base by crdroidandroid.

the class AssistVisualizer method setAssistStructure.

public void setAssistStructure(AssistStructure as) {
    mAssistStructure = as;
    mTextRects.clear();
    final int N = as.getWindowNodeCount();
    if (N > 0) {
        for (int i = 0; i < N; i++) {
            AssistStructure.WindowNode windowNode = as.getWindowNodeAt(i);
            mMatrixStack.clear();
            Matrix matrix = new Matrix();
            matrix.setTranslate(windowNode.getLeft(), windowNode.getTop());
            mMatrixStack.add(matrix);
            buildTextRects(windowNode.getRootViewNode(), 0, windowNode.getLeft(), windowNode.getTop());
        }
    }
    Log.d(TAG, "Building text rects in " + this + ": found " + mTextRects.size());
    invalidate();
}
Also used : Matrix(android.graphics.Matrix) AssistStructure(android.app.assist.AssistStructure) Paint(android.graphics.Paint)

Example 10 with AssistStructure

use of android.app.assist.AssistStructure in project android_frameworks_base by DirtyUnicorns.

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)

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