|
39 | 39 | import android.os.RemoteException; |
40 | 40 | import android.os.ServiceManager; |
41 | 41 | import android.os.StrictMode; |
| 42 | +import android.os.UserId; |
42 | 43 | import android.text.TextUtils; |
43 | 44 | import android.util.Log; |
44 | 45 | import android.util.Singleton; |
@@ -135,6 +136,31 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags) |
135 | 136 | return true; |
136 | 137 | } |
137 | 138 |
|
| 139 | + case START_ACTIVITY_AS_USER_TRANSACTION: |
| 140 | + { |
| 141 | + data.enforceInterface(IActivityManager.descriptor); |
| 142 | + IBinder b = data.readStrongBinder(); |
| 143 | + IApplicationThread app = ApplicationThreadNative.asInterface(b); |
| 144 | + Intent intent = Intent.CREATOR.createFromParcel(data); |
| 145 | + String resolvedType = data.readString(); |
| 146 | + IBinder resultTo = data.readStrongBinder(); |
| 147 | + String resultWho = data.readString(); |
| 148 | + int requestCode = data.readInt(); |
| 149 | + int startFlags = data.readInt(); |
| 150 | + String profileFile = data.readString(); |
| 151 | + ParcelFileDescriptor profileFd = data.readInt() != 0 |
| 152 | + ? data.readFileDescriptor() : null; |
| 153 | + Bundle options = data.readInt() != 0 |
| 154 | + ? Bundle.CREATOR.createFromParcel(data) : null; |
| 155 | + int userId = data.readInt(); |
| 156 | + int result = startActivityAsUser(app, intent, resolvedType, |
| 157 | + resultTo, resultWho, requestCode, startFlags, |
| 158 | + profileFile, profileFd, options, userId); |
| 159 | + reply.writeNoException(); |
| 160 | + reply.writeInt(result); |
| 161 | + return true; |
| 162 | + } |
| 163 | + |
138 | 164 | case START_ACTIVITY_AND_WAIT_TRANSACTION: |
139 | 165 | { |
140 | 166 | data.enforceInterface(IActivityManager.descriptor); |
@@ -454,8 +480,9 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags) |
454 | 480 | data.enforceInterface(IActivityManager.descriptor); |
455 | 481 | int maxNum = data.readInt(); |
456 | 482 | int fl = data.readInt(); |
| 483 | + int userId = data.readInt(); |
457 | 484 | List<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum, |
458 | | - fl); |
| 485 | + fl, userId); |
459 | 486 | reply.writeNoException(); |
460 | 487 | reply.writeTypedList(list); |
461 | 488 | return true; |
@@ -1764,6 +1791,42 @@ public int startActivity(IApplicationThread caller, Intent intent, |
1764 | 1791 | data.recycle(); |
1765 | 1792 | return result; |
1766 | 1793 | } |
| 1794 | + |
| 1795 | + public int startActivityAsUser(IApplicationThread caller, Intent intent, |
| 1796 | + String resolvedType, IBinder resultTo, String resultWho, int requestCode, |
| 1797 | + int startFlags, String profileFile, |
| 1798 | + ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException { |
| 1799 | + Parcel data = Parcel.obtain(); |
| 1800 | + Parcel reply = Parcel.obtain(); |
| 1801 | + data.writeInterfaceToken(IActivityManager.descriptor); |
| 1802 | + data.writeStrongBinder(caller != null ? caller.asBinder() : null); |
| 1803 | + intent.writeToParcel(data, 0); |
| 1804 | + data.writeString(resolvedType); |
| 1805 | + data.writeStrongBinder(resultTo); |
| 1806 | + data.writeString(resultWho); |
| 1807 | + data.writeInt(requestCode); |
| 1808 | + data.writeInt(startFlags); |
| 1809 | + data.writeString(profileFile); |
| 1810 | + if (profileFd != null) { |
| 1811 | + data.writeInt(1); |
| 1812 | + profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); |
| 1813 | + } else { |
| 1814 | + data.writeInt(0); |
| 1815 | + } |
| 1816 | + if (options != null) { |
| 1817 | + data.writeInt(1); |
| 1818 | + options.writeToParcel(data, 0); |
| 1819 | + } else { |
| 1820 | + data.writeInt(0); |
| 1821 | + } |
| 1822 | + data.writeInt(userId); |
| 1823 | + mRemote.transact(START_ACTIVITY_AS_USER_TRANSACTION, data, reply, 0); |
| 1824 | + reply.readException(); |
| 1825 | + int result = reply.readInt(); |
| 1826 | + reply.recycle(); |
| 1827 | + data.recycle(); |
| 1828 | + return result; |
| 1829 | + } |
1767 | 1830 | public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent, |
1768 | 1831 | String resolvedType, IBinder resultTo, String resultWho, |
1769 | 1832 | int requestCode, int startFlags, String profileFile, |
@@ -2163,12 +2226,13 @@ public List getTasks(int maxNum, int flags, |
2163 | 2226 | return list; |
2164 | 2227 | } |
2165 | 2228 | public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, |
2166 | | - int flags) throws RemoteException { |
| 2229 | + int flags, int userId) throws RemoteException { |
2167 | 2230 | Parcel data = Parcel.obtain(); |
2168 | 2231 | Parcel reply = Parcel.obtain(); |
2169 | 2232 | data.writeInterfaceToken(IActivityManager.descriptor); |
2170 | 2233 | data.writeInt(maxNum); |
2171 | 2234 | data.writeInt(flags); |
| 2235 | + data.writeInt(userId); |
2172 | 2236 | mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0); |
2173 | 2237 | reply.readException(); |
2174 | 2238 | ArrayList<ActivityManager.RecentTaskInfo> list |
|
0 commit comments