Search in sources :

Example 6 with AssistContent

use of android.app.assist.AssistContent in project android_frameworks_base by ResurrectionRemix.

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 AssistContent

use of android.app.assist.AssistContent 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 8 with AssistContent

use of android.app.assist.AssistContent 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 9 with AssistContent

use of android.app.assist.AssistContent 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

AssistContent (android.app.assist.AssistContent)9 AssistStructure (android.app.assist.AssistStructure)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