frameworks/base
Revision | a3a788cac4b38d0d2fd44839cc4872fe21492dc1 (tree) |
---|---|
Zeit | 2019-10-24 13:31:17 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Merge tag 'android-8.1.0_r69' into oreo-x86
Android 8.1.0 Release 69 (5794017)
@@ -706,6 +706,8 @@ public class Binder implements IBinder { | ||
706 | 706 | Log.w(TAG, "Caught a RuntimeException from the binder stub implementation.", e); |
707 | 707 | } |
708 | 708 | } else { |
709 | + // Clear the parcel before writing the exception | |
710 | + reply.setDataSize(0); | |
709 | 711 | reply.setDataPosition(0); |
710 | 712 | reply.writeException(e); |
711 | 713 | } |
@@ -1070,6 +1070,9 @@ public abstract class Layout { | ||
1070 | 1070 | if (limit > lineEnd) { |
1071 | 1071 | limit = lineEnd; |
1072 | 1072 | } |
1073 | + if (limit == start) { | |
1074 | + continue; | |
1075 | + } | |
1073 | 1076 | level[limit - lineStart - 1] = |
1074 | 1077 | (byte) ((runs[i + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK); |
1075 | 1078 | } |
@@ -1165,8 +1168,8 @@ public abstract class Layout { | ||
1165 | 1168 | } |
1166 | 1169 | |
1167 | 1170 | /** |
1168 | - * Computes in linear time the results of calling | |
1169 | - * #getHorizontal for all offsets on a line. | |
1171 | + * Computes in linear time the results of calling #getHorizontal for all offsets on a line. | |
1172 | + * | |
1170 | 1173 | * @param line The line giving the offsets we compute information for |
1171 | 1174 | * @param clamped Whether to clamp the results to the width of the layout |
1172 | 1175 | * @param primary Whether the results should be the primary or the secondary horizontal |
@@ -1201,7 +1204,7 @@ public abstract class Layout { | ||
1201 | 1204 | TextLine.recycle(tl); |
1202 | 1205 | |
1203 | 1206 | if (clamped) { |
1204 | - for (int offset = 0; offset <= wid.length; ++offset) { | |
1207 | + for (int offset = 0; offset < wid.length; ++offset) { | |
1205 | 1208 | if (wid[offset] > mWidth) { |
1206 | 1209 | wid[offset] = mWidth; |
1207 | 1210 | } |
@@ -84,7 +84,7 @@ JHwBlob::JHwBlob(JNIEnv *env, jobject thiz, size_t size) | ||
84 | 84 | mOwnsBuffer(true), |
85 | 85 | mHandle(0) { |
86 | 86 | if (size > 0) { |
87 | - mBuffer = malloc(size); | |
87 | + mBuffer = calloc(size, 1); | |
88 | 88 | } |
89 | 89 | } |
90 | 90 |
@@ -121,7 +121,7 @@ public class HidProfile implements LocalBluetoothProfile { | ||
121 | 121 | |
122 | 122 | public boolean isPreferred(BluetoothDevice device) { |
123 | 123 | if (mService == null) return false; |
124 | - return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; | |
124 | + return mService.getPriority(device) != BluetoothProfile.PRIORITY_OFF; | |
125 | 125 | } |
126 | 126 | |
127 | 127 | public int getPreferred(BluetoothDevice device) { |
@@ -21,6 +21,7 @@ | ||
21 | 21 | |
22 | 22 | <uses-permission android:name="android.permission.CONTROL_VPN" /> |
23 | 23 | <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" /> |
24 | + <uses-permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"/> | |
24 | 25 | |
25 | 26 | <application android:label="VpnDialogs" |
26 | 27 | android:allowBackup="false" > |
@@ -16,6 +16,8 @@ | ||
16 | 16 | |
17 | 17 | package com.android.vpndialogs; |
18 | 18 | |
19 | +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; | |
20 | + | |
19 | 21 | import android.content.Context; |
20 | 22 | import android.content.DialogInterface; |
21 | 23 | import android.content.pm.PackageManager; |
@@ -78,6 +80,7 @@ public class ConfirmDialog extends AlertActivity | ||
78 | 80 | setupAlert(); |
79 | 81 | |
80 | 82 | getWindow().setCloseOnTouchOutside(false); |
83 | + getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); | |
81 | 84 | Button button = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); |
82 | 85 | button.setFilterTouchesWhenObscured(true); |
83 | 86 | } |
@@ -4925,9 +4925,9 @@ public class ActivityManagerService extends IActivityManager.Stub | ||
4925 | 4925 | userId, false, ALLOW_FULL_ONLY, "startActivityInPackage", null); |
4926 | 4926 | |
4927 | 4927 | // TODO: Switch to user app stacks here. |
4928 | - return mActivityStarter.startActivityMayWait(null, uid, callingPackage, intent, | |
4929 | - resolvedType, null, null, resultTo, resultWho, requestCode, startFlags, | |
4930 | - null, null, null, bOptions, false, userId, inTask, reason); | |
4928 | + return mActivityStarter.startActivityMayWait(null, uid, ActivityStarter.PID_NULL, uid, | |
4929 | + callingPackage, intent, resolvedType, null, null, resultTo, resultWho, requestCode, | |
4930 | + startFlags, null, null, null, bOptions, false, userId, inTask, reason); | |
4931 | 4931 | } |
4932 | 4932 | |
4933 | 4933 | @Override |
@@ -4947,13 +4947,20 @@ public class ActivityManagerService extends IActivityManager.Stub | ||
4947 | 4947 | final int startActivitiesInPackage(int uid, String callingPackage, |
4948 | 4948 | Intent[] intents, String[] resolvedTypes, IBinder resultTo, |
4949 | 4949 | Bundle bOptions, int userId) { |
4950 | + return startActivitiesInPackage(uid, ActivityStarter.PID_NULL, UserHandle.USER_NULL, | |
4951 | + callingPackage, intents, resolvedTypes, resultTo, bOptions, userId); | |
4952 | + } | |
4953 | + | |
4954 | + final int startActivitiesInPackage(int uid, int realCallingPid, int realCallingUid, | |
4955 | + String callingPackage, Intent[] intents, String[] resolvedTypes, | |
4956 | + IBinder resultTo, Bundle bOptions, int userId) { | |
4950 | 4957 | |
4951 | 4958 | final String reason = "startActivityInPackage"; |
4952 | 4959 | userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), |
4953 | 4960 | userId, false, ALLOW_FULL_ONLY, reason, null); |
4954 | 4961 | // TODO: Switch to user app stacks here. |
4955 | - int ret = mActivityStarter.startActivities(null, uid, callingPackage, intents, resolvedTypes, | |
4956 | - resultTo, bOptions, userId, reason); | |
4962 | + int ret = mActivityStarter.startActivities(null, uid, realCallingPid, realCallingUid, | |
4963 | + callingPackage, intents, resolvedTypes, resultTo, bOptions, userId, reason); | |
4957 | 4964 | return ret; |
4958 | 4965 | } |
4959 | 4966 |
@@ -4596,19 +4596,11 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D | ||
4596 | 4596 | mLockTaskNotify = new LockTaskNotify(mService.mContext); |
4597 | 4597 | } |
4598 | 4598 | mLockTaskNotify.show(false); |
4599 | - try { | |
4600 | - boolean shouldLockKeyguard = Settings.Secure.getIntForUser( | |
4601 | - mService.mContext.getContentResolver(), | |
4602 | - Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, | |
4603 | - UserHandle.USER_CURRENT) != 0; | |
4604 | - if (mLockTaskModeState == LOCK_TASK_MODE_PINNED && shouldLockKeyguard) { | |
4605 | - mWindowManager.lockNow(null); | |
4606 | - mWindowManager.dismissKeyguard(null /* callback */); | |
4607 | - new LockPatternUtils(mService.mContext) | |
4608 | - .requireCredentialEntry(UserHandle.USER_ALL); | |
4609 | - } | |
4610 | - } catch (SettingNotFoundException e) { | |
4611 | - // No setting, don't lock. | |
4599 | + if (mLockTaskModeState == LOCK_TASK_MODE_PINNED && shouldLockKeyguard()) { | |
4600 | + mWindowManager.lockNow(null); | |
4601 | + mWindowManager.dismissKeyguard(null /* callback */); | |
4602 | + new LockPatternUtils(mService.mContext) | |
4603 | + .requireCredentialEntry(UserHandle.USER_ALL); | |
4612 | 4604 | } |
4613 | 4605 | } catch (RemoteException ex) { |
4614 | 4606 | throw new RuntimeException(ex); |
@@ -4635,6 +4627,22 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D | ||
4635 | 4627 | } |
4636 | 4628 | } |
4637 | 4629 | |
4630 | + private boolean shouldLockKeyguard() { | |
4631 | + // This functionality should be kept consistent with | |
4632 | + // com.android.settings.security.ScreenPinningSettings (see b/127605586) | |
4633 | + try { | |
4634 | + return Settings.Secure.getIntForUser( | |
4635 | + mService.mContext.getContentResolver(), | |
4636 | + Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, | |
4637 | + UserHandle.USER_CURRENT) != 0; | |
4638 | + } catch (Settings.SettingNotFoundException e) { | |
4639 | + // Log to SafetyNet for b/127605586 | |
4640 | + android.util.EventLog.writeEvent(0x534e4554, "127605586", -1, ""); | |
4641 | + LockPatternUtils lockPatternUtils = new LockPatternUtils(mService.mContext); | |
4642 | + return lockPatternUtils.isSecure(mCurrentUser); | |
4643 | + } | |
4644 | + } | |
4645 | + | |
4638 | 4646 | // TODO: Move to its own file. |
4639 | 4647 | /** Exactly one of these classes per Display in the system. Capable of holding zero or more |
4640 | 4648 | * attached {@link ActivityStack}s */ |
@@ -136,6 +136,8 @@ import java.util.Date; | ||
136 | 136 | * an activity and associated task and stack. |
137 | 137 | */ |
138 | 138 | class ActivityStarter { |
139 | + public static final int PID_NULL = 0; | |
140 | + | |
139 | 141 | private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityStarter" : TAG_AM; |
140 | 142 | private static final String TAG_RESULTS = TAG + POSTFIX_RESULTS; |
141 | 143 | private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS; |
@@ -677,6 +679,20 @@ class ActivityStarter { | ||
677 | 679 | ProfilerInfo profilerInfo, WaitResult outResult, |
678 | 680 | Configuration globalConfig, Bundle bOptions, boolean ignoreTargetSecurity, int userId, |
679 | 681 | TaskRecord inTask, String reason) { |
682 | + return startActivityMayWait(caller, callingUid, PID_NULL, UserHandle.USER_NULL, | |
683 | + callingPackage, intent, resolvedType, voiceSession, voiceInteractor, resultTo, | |
684 | + resultWho, requestCode, startFlags, profilerInfo, outResult, globalConfig, bOptions, | |
685 | + ignoreTargetSecurity, userId, inTask, reason); | |
686 | + } | |
687 | + | |
688 | + final int startActivityMayWait(IApplicationThread caller, int callingUid, | |
689 | + int requestRealCallingPid, int requestRealCallingUid, | |
690 | + String callingPackage, Intent intent, String resolvedType, | |
691 | + IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor, | |
692 | + IBinder resultTo, String resultWho, int requestCode, int startFlags, | |
693 | + ProfilerInfo profilerInfo, WaitResult outResult, | |
694 | + Configuration globalConfig, Bundle bOptions, boolean ignoreTargetSecurity, int userId, | |
695 | + TaskRecord inTask, String reason) { | |
680 | 696 | // Refuse possible leaked file descriptors |
681 | 697 | if (intent != null && intent.hasFileDescriptors()) { |
682 | 698 | throw new IllegalArgumentException("File descriptors passed in Intent"); |
@@ -730,8 +746,14 @@ class ActivityStarter { | ||
730 | 746 | |
731 | 747 | ActivityOptions options = ActivityOptions.fromBundle(bOptions); |
732 | 748 | synchronized (mService) { |
733 | - final int realCallingPid = Binder.getCallingPid(); | |
734 | - final int realCallingUid = Binder.getCallingUid(); | |
749 | + | |
750 | + final int realCallingPid = requestRealCallingPid != PID_NULL | |
751 | + ? requestRealCallingPid | |
752 | + : Binder.getCallingPid(); | |
753 | + final int realCallingUid = requestRealCallingUid != UserHandle.USER_NULL | |
754 | + ? requestRealCallingUid | |
755 | + : Binder.getCallingUid(); | |
756 | + | |
735 | 757 | int callingPid; |
736 | 758 | if (callingUid >= 0) { |
737 | 759 | callingPid = -1; |
@@ -883,6 +905,14 @@ class ActivityStarter { | ||
883 | 905 | final int startActivities(IApplicationThread caller, int callingUid, String callingPackage, |
884 | 906 | Intent[] intents, String[] resolvedTypes, IBinder resultTo, |
885 | 907 | Bundle bOptions, int userId, String reason) { |
908 | + return startActivities(caller, callingUid, PID_NULL, UserHandle.USER_NULL, callingPackage, | |
909 | + intents, resolvedTypes, resultTo, bOptions, userId, reason); | |
910 | + } | |
911 | + | |
912 | + final int startActivities(IApplicationThread caller, int callingUid, | |
913 | + int incomingRealCallingPid, int incomingRealCallingUid, String callingPackage, | |
914 | + Intent[] intents, String[] resolvedTypes, IBinder resultTo, | |
915 | + Bundle bOptions, int userId, String reason) { | |
886 | 916 | if (intents == null) { |
887 | 917 | throw new NullPointerException("intents is null"); |
888 | 918 | } |
@@ -893,8 +923,13 @@ class ActivityStarter { | ||
893 | 923 | throw new IllegalArgumentException("intents are length different than resolvedTypes"); |
894 | 924 | } |
895 | 925 | |
896 | - final int realCallingPid = Binder.getCallingPid(); | |
897 | - final int realCallingUid = Binder.getCallingUid(); | |
926 | + final int realCallingPid = incomingRealCallingPid != PID_NULL | |
927 | + ? incomingRealCallingPid | |
928 | + : Binder.getCallingPid(); | |
929 | + | |
930 | + final int realCallingUid = incomingRealCallingUid != UserHandle.USER_NULL | |
931 | + ? incomingRealCallingUid | |
932 | + : Binder.getCallingUid(); | |
898 | 933 | |
899 | 934 | int callingPid; |
900 | 935 | if (callingUid >= 0) { |
@@ -332,8 +332,9 @@ final class PendingIntentRecord extends IIntentSender.Stub { | ||
332 | 332 | } |
333 | 333 | allIntents[allIntents.length-1] = finalIntent; |
334 | 334 | allResolvedTypes[allResolvedTypes.length-1] = resolvedType; |
335 | - owner.startActivitiesInPackage(uid, key.packageName, allIntents, | |
336 | - allResolvedTypes, resultTo, options, userId); | |
335 | + owner.startActivitiesInPackage(uid, callingPid, callingUid, | |
336 | + key.packageName, allIntents, allResolvedTypes, resultTo, | |
337 | + options, userId); | |
337 | 338 | } else { |
338 | 339 | owner.startActivityInPackage(uid, key.packageName, finalIntent, |
339 | 340 | resolvedType, resultTo, resultWho, requestCode, 0, |
@@ -19445,6 +19445,12 @@ public class PackageManagerService extends IPackageManager.Stub | ||
19445 | 19445 | @Override |
19446 | 19446 | public boolean isPackageDeviceAdminOnAnyUser(String packageName) { |
19447 | 19447 | final int callingUid = Binder.getCallingUid(); |
19448 | + if (checkUidPermission(android.Manifest.permission.MANAGE_USERS, callingUid) | |
19449 | + != PERMISSION_GRANTED) { | |
19450 | + EventLog.writeEvent(0x534e4554, "128599183", -1, ""); | |
19451 | + throw new SecurityException(android.Manifest.permission.MANAGE_USERS | |
19452 | + + " permission is required to call this API"); | |
19453 | + } | |
19448 | 19454 | if (getInstantAppPackageName(callingUid) != null |
19449 | 19455 | && !isCallerSameApp(packageName, callingUid)) { |
19450 | 19456 | return false; |
@@ -25846,11 +25852,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); | ||
25846 | 25852 | } |
25847 | 25853 | if (mExternalSourcesPolicy != null) { |
25848 | 25854 | int isTrusted = mExternalSourcesPolicy.getPackageTrustedToInstallApps(packageName, uid); |
25849 | - if (isTrusted != PackageManagerInternal.ExternalSourcesPolicy.USER_DEFAULT) { | |
25850 | - return isTrusted == PackageManagerInternal.ExternalSourcesPolicy.USER_TRUSTED; | |
25851 | - } | |
25855 | + return isTrusted == PackageManagerInternal.ExternalSourcesPolicy.USER_TRUSTED; | |
25852 | 25856 | } |
25853 | - return checkUidPermission(appOpPermission, uid) == PERMISSION_GRANTED; | |
25857 | + return false; | |
25854 | 25858 | } |
25855 | 25859 | |
25856 | 25860 | @Override |
@@ -3428,6 +3428,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { | ||
3428 | 3428 | |
3429 | 3429 | @Override |
3430 | 3430 | public boolean isSeparateProfileChallengeAllowed(int userHandle) { |
3431 | + if (!isCallerWithSystemUid()) { | |
3432 | + throw new SecurityException("Caller must be system"); | |
3433 | + } | |
3431 | 3434 | ComponentName profileOwner = getProfileOwner(userHandle); |
3432 | 3435 | // Profile challenge is supported on N or newer release. |
3433 | 3436 | return profileOwner != null && |