Loading packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java +75 −20 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.content.res.Resources.NotFoundException; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.os.RemoteException; import android.os.UserHandle; Loading Loading @@ -231,6 +232,41 @@ public class ActivityManagerWrapper { return label; } /** * Starts the recents activity. */ public void startRecentsActivity(AssistDataReceiver assistDataReceiver, Bundle options, ActivityOptions opts, int userId, Consumer<Boolean> resultCallback, Handler resultCallbackHandler) { Bundle activityOptions = opts != null ? opts.toBundle() : null; mBackgroundExecutor.submit(new Runnable() { @Override public void run() { try { ActivityManager.getService().startRecentsActivity(assistDataReceiver, options, activityOptions, userId); if (resultCallback != null) { resultCallbackHandler.post(new Runnable() { @Override public void run() { resultCallback.accept(true); } }); } } catch (Exception e) { if (resultCallback != null) { resultCallbackHandler.post(new Runnable() { @Override public void run() { resultCallback.accept(false); } }); } } } }); } /** * Starts a task from Recents. * Loading Loading @@ -270,16 +306,29 @@ public class ActivityManagerWrapper { // Execute this from another thread such that we can do other things (like caching the // bitmap for the thumbnail) while AM is busy starting our activity. mBackgroundExecutor.submit(() -> { mBackgroundExecutor.submit(new Runnable() { @Override public void run() { try { ActivityManager.getService().startActivityFromRecents(taskKey.id, finalOptions == null ? null : finalOptions.toBundle()); if (resultCallback != null) { resultCallbackHandler.post(() -> resultCallback.accept(true)); resultCallbackHandler.post(new Runnable() { @Override public void run() { resultCallback.accept(true); } }); } } catch (Exception e) { if (resultCallback != null) { resultCallbackHandler.post(() -> resultCallback.accept(false)); resultCallbackHandler.post(new Runnable() { @Override public void run() { resultCallback.accept(false); } }); } } } }); Loading @@ -289,12 +338,15 @@ public class ActivityManagerWrapper { * Requests that the system close any open system windows (including other SystemUI). */ public void closeSystemWindows(String reason) { mBackgroundExecutor.submit(() -> { mBackgroundExecutor.submit(new Runnable() { @Override public void run() { try { ActivityManager.getService().closeSystemDialogs(reason); } catch (RemoteException e) { Log.w(TAG, "Failed to close system windows", e); } } }); } Loading @@ -302,12 +354,15 @@ public class ActivityManagerWrapper { * Removes a task by id. */ public void removeTask(int taskId) { mBackgroundExecutor.submit(() -> { mBackgroundExecutor.submit(new Runnable() { @Override public void run() { try { ActivityManager.getService().removeTask(taskId); } catch (RemoteException e) { Log.w(TAG, "Failed to remove task=" + taskId, e); } } }); } Loading packages/SystemUI/shared/src/com/android/systemui/shared/system/AssistDataReceiver.java 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.shared.system; import android.app.IAssistDataReceiver; import android.graphics.Bitmap; import android.os.Bundle; /** * Abstract class for assist data receivers. */ public abstract class AssistDataReceiver extends IAssistDataReceiver.Stub { public abstract void onHandleAssistData(Bundle resultData); public abstract void onHandleAssistScreenshot(Bitmap screenshot); } Loading
packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java +75 −20 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.content.res.Resources.NotFoundException; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.os.RemoteException; import android.os.UserHandle; Loading Loading @@ -231,6 +232,41 @@ public class ActivityManagerWrapper { return label; } /** * Starts the recents activity. */ public void startRecentsActivity(AssistDataReceiver assistDataReceiver, Bundle options, ActivityOptions opts, int userId, Consumer<Boolean> resultCallback, Handler resultCallbackHandler) { Bundle activityOptions = opts != null ? opts.toBundle() : null; mBackgroundExecutor.submit(new Runnable() { @Override public void run() { try { ActivityManager.getService().startRecentsActivity(assistDataReceiver, options, activityOptions, userId); if (resultCallback != null) { resultCallbackHandler.post(new Runnable() { @Override public void run() { resultCallback.accept(true); } }); } } catch (Exception e) { if (resultCallback != null) { resultCallbackHandler.post(new Runnable() { @Override public void run() { resultCallback.accept(false); } }); } } } }); } /** * Starts a task from Recents. * Loading Loading @@ -270,16 +306,29 @@ public class ActivityManagerWrapper { // Execute this from another thread such that we can do other things (like caching the // bitmap for the thumbnail) while AM is busy starting our activity. mBackgroundExecutor.submit(() -> { mBackgroundExecutor.submit(new Runnable() { @Override public void run() { try { ActivityManager.getService().startActivityFromRecents(taskKey.id, finalOptions == null ? null : finalOptions.toBundle()); if (resultCallback != null) { resultCallbackHandler.post(() -> resultCallback.accept(true)); resultCallbackHandler.post(new Runnable() { @Override public void run() { resultCallback.accept(true); } }); } } catch (Exception e) { if (resultCallback != null) { resultCallbackHandler.post(() -> resultCallback.accept(false)); resultCallbackHandler.post(new Runnable() { @Override public void run() { resultCallback.accept(false); } }); } } } }); Loading @@ -289,12 +338,15 @@ public class ActivityManagerWrapper { * Requests that the system close any open system windows (including other SystemUI). */ public void closeSystemWindows(String reason) { mBackgroundExecutor.submit(() -> { mBackgroundExecutor.submit(new Runnable() { @Override public void run() { try { ActivityManager.getService().closeSystemDialogs(reason); } catch (RemoteException e) { Log.w(TAG, "Failed to close system windows", e); } } }); } Loading @@ -302,12 +354,15 @@ public class ActivityManagerWrapper { * Removes a task by id. */ public void removeTask(int taskId) { mBackgroundExecutor.submit(() -> { mBackgroundExecutor.submit(new Runnable() { @Override public void run() { try { ActivityManager.getService().removeTask(taskId); } catch (RemoteException e) { Log.w(TAG, "Failed to remove task=" + taskId, e); } } }); } Loading
packages/SystemUI/shared/src/com/android/systemui/shared/system/AssistDataReceiver.java 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.shared.system; import android.app.IAssistDataReceiver; import android.graphics.Bitmap; import android.os.Bundle; /** * Abstract class for assist data receivers. */ public abstract class AssistDataReceiver extends IAssistDataReceiver.Stub { public abstract void onHandleAssistData(Bundle resultData); public abstract void onHandleAssistScreenshot(Bitmap screenshot); }