DO NOT MERGE - Merge RQ2A.210505.003.
Bug: 187544653 Merged-In: If9e34a0120121ed851b911c8a8bd2bbe0e0f9e34 Merged-In: Ia6bd5658b77a26ab15fea013ec875050457473e0 Change-Id: I2e22d2bdd2c54eb3489fe82f2601ded2af16bd5c
This commit is contained in:
@@ -632,6 +632,13 @@
|
||||
<!-- The default minimal size of a PiP task, in both dimensions. -->
|
||||
<dimen name="default_minimal_size_pip_resizable_task">108dp</dimen>
|
||||
|
||||
<!--
|
||||
The overridable minimal size of a PiP task, in both dimensions.
|
||||
Different from default_minimal_size_pip_resizable_task, this is to limit the dimension
|
||||
when the pinned stack size is overridden by app via minWidth/minHeight.
|
||||
-->
|
||||
<dimen name="overridable_minimal_size_pip_resizable_task">48dp</dimen>
|
||||
|
||||
<!-- Height of a task when in minimized mode from the top when launcher is resizable. -->
|
||||
<dimen name="task_height_of_minimized_mode">80dp</dimen>
|
||||
|
||||
|
||||
@@ -1941,6 +1941,7 @@
|
||||
<java-symbol type="fraction" name="config_dimBehindFadeDuration" />
|
||||
<java-symbol type="dimen" name="default_minimal_size_resizable_task" />
|
||||
<java-symbol type="dimen" name="default_minimal_size_pip_resizable_task" />
|
||||
<java-symbol type="dimen" name="overridable_minimal_size_pip_resizable_task" />
|
||||
<java-symbol type="dimen" name="task_height_of_minimized_mode" />
|
||||
<java-symbol type="fraction" name="config_screenAutoBrightnessDozeScaleFactor" />
|
||||
<java-symbol type="bool" name="config_allowPriorityVibrationsInLowPowerMode" />
|
||||
|
||||
@@ -45,6 +45,7 @@ import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.util.Size;
|
||||
import android.view.SurfaceControl;
|
||||
@@ -223,6 +224,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements
|
||||
private PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
|
||||
mSurfaceControlTransactionFactory;
|
||||
private PictureInPictureParams mPictureInPictureParams;
|
||||
private int mOverridableMinSize;
|
||||
|
||||
/**
|
||||
* If set to {@code true}, the entering animation will be skipped and we will wait for
|
||||
@@ -244,6 +246,8 @@ public class PipTaskOrganizer extends TaskOrganizer implements
|
||||
mPipBoundsHandler = boundsHandler;
|
||||
mEnterExitAnimationDuration = context.getResources()
|
||||
.getInteger(R.integer.config_pipResizeAnimationDuration);
|
||||
mOverridableMinSize = context.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.overridable_minimal_size_pip_resizable_task);
|
||||
mSurfaceTransactionHelper = surfaceTransactionHelper;
|
||||
mPipAnimationController = pipAnimationController;
|
||||
mPipUiEventLoggerLogger = pipUiEventLogger;
|
||||
@@ -949,7 +953,14 @@ public class PipTaskOrganizer extends TaskOrganizer implements
|
||||
// -1 will be populated if an activity specifies defaultWidth/defaultHeight in <layout>
|
||||
// without minWidth/minHeight
|
||||
if (windowLayout.minWidth > 0 && windowLayout.minHeight > 0) {
|
||||
return new Size(windowLayout.minWidth, windowLayout.minHeight);
|
||||
// If either dimension is smaller than the allowed minimum, adjust them
|
||||
// according to mOverridableMinSize and log to SafeNet
|
||||
if (windowLayout.minWidth < mOverridableMinSize
|
||||
|| windowLayout.minHeight < mOverridableMinSize) {
|
||||
EventLog.writeEvent(0x534e4554, "174302616", -1, "");
|
||||
}
|
||||
return new Size(Math.max(windowLayout.minWidth, mOverridableMinSize),
|
||||
Math.max(windowLayout.minHeight, mOverridableMinSize));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ public class ScreenshotNotificationsController {
|
||||
dpm.createAdminSupportIntent(DevicePolicyManager.POLICY_DISABLE_SCREEN_CAPTURE);
|
||||
if (intent != null) {
|
||||
final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(
|
||||
mContext, 0, intent, 0, null, UserHandle.CURRENT);
|
||||
mContext, 0, intent, PendingIntent.FLAG_IMMUTABLE, null, UserHandle.CURRENT);
|
||||
b.setContentIntent(pendingIntent);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.internal.util.XmlUtils;
|
||||
import com.android.server.pm.PackageManagerService;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
@@ -463,6 +464,7 @@ public class SnoozeHelper {
|
||||
return PendingIntent.getBroadcast(mContext,
|
||||
REQUEST_CODE_REPOST,
|
||||
new Intent(REPOST_ACTION)
|
||||
.setPackage(PackageManagerService.PLATFORM_PACKAGE_NAME)
|
||||
.setData(new Uri.Builder().scheme(REPOST_SCHEME).appendPath(key).build())
|
||||
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
|
||||
.putExtra(EXTRA_KEY, key)
|
||||
|
||||
@@ -12528,6 +12528,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
if (hasOldPkg) {
|
||||
mPermissionManager.revokeRuntimePermissionsIfGroupChanged(pkg, oldPkg,
|
||||
allPackageNames);
|
||||
mPermissionManager.revokeStoragePermissionsIfScopeExpanded(pkg, oldPkg);
|
||||
}
|
||||
if (hasPermissionDefinitionChanges) {
|
||||
mPermissionManager.revokeRuntimePermissionsIfPermissionDefinitionChanged(
|
||||
|
||||
@@ -206,6 +206,9 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
private static final int USER_PERMISSION_FLAGS = FLAG_PERMISSION_USER_SET
|
||||
| FLAG_PERMISSION_USER_FIXED;
|
||||
|
||||
/** All storage permissions */
|
||||
private static final List<String> STORAGE_PERMISSIONS = new ArrayList<>();
|
||||
|
||||
/** If the permission of the value is granted, so is the key */
|
||||
private static final Map<String, String> FULLER_PERMISSION_MAP = new HashMap<>();
|
||||
|
||||
@@ -214,6 +217,9 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
FULLER_PERMISSION_MAP.put(Manifest.permission.INTERACT_ACROSS_USERS,
|
||||
Manifest.permission.INTERACT_ACROSS_USERS_FULL);
|
||||
STORAGE_PERMISSIONS.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||
STORAGE_PERMISSIONS.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
STORAGE_PERMISSIONS.add(Manifest.permission.ACCESS_MEDIA_LOCATION);
|
||||
}
|
||||
|
||||
/** Lock to protect internal data access */
|
||||
@@ -2265,6 +2271,49 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
return protectionLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the app is updated, and has scoped storage permissions, then it is possible that the
|
||||
* app updated in an attempt to get unscoped storage. If so, revoke all storage permissions.
|
||||
* @param newPackage The new package that was installed
|
||||
* @param oldPackage The old package that was updated
|
||||
*/
|
||||
private void revokeStoragePermissionsIfScopeExpanded(
|
||||
@NonNull AndroidPackage newPackage,
|
||||
@NonNull AndroidPackage oldPackage,
|
||||
@NonNull PermissionCallback permissionCallback) {
|
||||
boolean downgradedSdk = oldPackage.getTargetSdkVersion() >= Build.VERSION_CODES.Q
|
||||
&& newPackage.getTargetSdkVersion() < Build.VERSION_CODES.Q;
|
||||
boolean upgradedSdk = oldPackage.getTargetSdkVersion() < Build.VERSION_CODES.Q
|
||||
&& newPackage.getTargetSdkVersion() >= Build.VERSION_CODES.Q;
|
||||
boolean newlyRequestsLegacy = !upgradedSdk && !oldPackage.isRequestLegacyExternalStorage()
|
||||
&& newPackage.isRequestLegacyExternalStorage();
|
||||
|
||||
if (!newlyRequestsLegacy && !downgradedSdk) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
final int userId = UserHandle.getUserId(newPackage.getUid());
|
||||
int numRequestedPermissions = newPackage.getRequestedPermissions().size();
|
||||
for (int i = 0; i < numRequestedPermissions; i++) {
|
||||
PermissionInfo permInfo = getPermissionInfo(newPackage.getRequestedPermissions().get(i),
|
||||
newPackage.getPackageName(), 0);
|
||||
if (permInfo == null || !STORAGE_PERMISSIONS.contains(permInfo.name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EventLog.writeEvent(0x534e4554, "171430330", newPackage.getUid(),
|
||||
"Revoking permission " + permInfo.name + " from package "
|
||||
+ newPackage.getPackageName() + " as either the sdk downgraded "
|
||||
+ downgradedSdk + " or newly requested legacy full storage "
|
||||
+ newlyRequestsLegacy);
|
||||
|
||||
revokeRuntimePermissionInternal(permInfo.name, newPackage.getPackageName(),
|
||||
false, callingUid, userId, null, permissionCallback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* We might auto-grant permissions if any permission of the group is already granted. Hence if
|
||||
* the group of a granted permission changes we need to revoke it to avoid having permissions of
|
||||
@@ -4734,6 +4783,19 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
@UserIdInt int userId) {
|
||||
return PermissionManagerService.this.isPermissionsReviewRequired(pkg, userId);
|
||||
}
|
||||
/**
|
||||
* If the app is updated, and has scoped storage permissions, then it is possible that the
|
||||
* app updated in an attempt to get unscoped storage. If so, revoke all storage permissions.
|
||||
* @param newPackage The new package that was installed
|
||||
* @param oldPackage The old package that was updated
|
||||
*/
|
||||
public void revokeStoragePermissionsIfScopeExpanded(
|
||||
@NonNull AndroidPackage newPackage,
|
||||
@NonNull AndroidPackage oldPackage
|
||||
) {
|
||||
PermissionManagerService.this.revokeStoragePermissionsIfScopeExpanded(newPackage,
|
||||
oldPackage, mDefaultPermissionCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revokeRuntimePermissionsIfGroupChanged(
|
||||
|
||||
@@ -265,6 +265,17 @@ public abstract class PermissionManagerServiceInternal extends PermissionManager
|
||||
@NonNull List<String> permissionsToRevoke,
|
||||
@NonNull ArrayList<String> allPackageNames);
|
||||
|
||||
/**
|
||||
* If the app is updated, and has scoped storage permissions, then it is possible that the
|
||||
* app updated in an attempt to get unscoped storage. If so, revoke all storage permissions.
|
||||
* @param newPackage The new package that was installed
|
||||
* @param oldPackage The old package that was updated
|
||||
*/
|
||||
public abstract void revokeStoragePermissionsIfScopeExpanded(
|
||||
@NonNull AndroidPackage newPackage,
|
||||
@NonNull AndroidPackage oldPackage
|
||||
);
|
||||
|
||||
/**
|
||||
* Add all permissions in the given package.
|
||||
* <p>
|
||||
|
||||
@@ -512,7 +512,7 @@ public class LockTaskController {
|
||||
setStatusBarState(mLockTaskModeState, userId);
|
||||
setKeyguardState(mLockTaskModeState, userId);
|
||||
if (oldLockTaskModeState == LOCK_TASK_MODE_PINNED) {
|
||||
lockKeyguardIfNeeded();
|
||||
lockKeyguardIfNeeded(userId);
|
||||
}
|
||||
if (getDevicePolicyManager() != null) {
|
||||
getDevicePolicyManager().notifyLockTaskModeChanged(false, null, userId);
|
||||
@@ -824,15 +824,15 @@ public class LockTaskController {
|
||||
* Helper method for locking the device immediately. This may be necessary when the device
|
||||
* leaves the pinned mode.
|
||||
*/
|
||||
private void lockKeyguardIfNeeded() {
|
||||
if (shouldLockKeyguard()) {
|
||||
private void lockKeyguardIfNeeded(int userId) {
|
||||
if (shouldLockKeyguard(userId)) {
|
||||
mWindowManager.lockNow(null);
|
||||
mWindowManager.dismissKeyguard(null /* callback */, null /* message */);
|
||||
getLockPatternUtils().requireCredentialEntry(USER_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldLockKeyguard() {
|
||||
private boolean shouldLockKeyguard(int userId) {
|
||||
// This functionality should be kept consistent with
|
||||
// com.android.settings.security.ScreenPinningSettings (see b/127605586)
|
||||
try {
|
||||
@@ -842,7 +842,7 @@ public class LockTaskController {
|
||||
} catch (Settings.SettingNotFoundException e) {
|
||||
// Log to SafetyNet for b/127605586
|
||||
android.util.EventLog.writeEvent(0x534e4554, "127605586", -1, "");
|
||||
return getLockPatternUtils().isSecure(USER_CURRENT);
|
||||
return getLockPatternUtils().isSecure(userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.util.FastXmlSerializer;
|
||||
import com.android.server.UiServiceTestCase;
|
||||
import com.android.server.pm.PackageManagerService;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -256,6 +257,17 @@ public class SnoozeHelperTest extends UiServiceTestCase {
|
||||
UserHandle.USER_SYSTEM, r.getSbn().getPackageName(), r.getKey()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSnoozeSentToAndroid() throws Exception {
|
||||
NotificationRecord r = getNotificationRecord("pkg", 1, "one", UserHandle.SYSTEM);
|
||||
mSnoozeHelper.snooze(r, 1000);
|
||||
ArgumentCaptor<PendingIntent> captor = ArgumentCaptor.forClass(PendingIntent.class);
|
||||
verify(mAm, times(1)).setExactAndAllowWhileIdle(
|
||||
anyInt(), anyLong(), captor.capture());
|
||||
assertEquals(PackageManagerService.PLATFORM_PACKAGE_NAME,
|
||||
captor.getValue().getIntent().getPackage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSnooze() throws Exception {
|
||||
NotificationRecord r = getNotificationRecord("pkg", 1, "one", UserHandle.SYSTEM);
|
||||
|
||||
@@ -450,7 +450,7 @@ public class LockTaskControllerTest {
|
||||
Settings.Secure.clearProviderForTest();
|
||||
|
||||
// AND a password is set
|
||||
when(mLockPatternUtils.isSecure(anyInt()))
|
||||
when(mLockPatternUtils.isSecure(TEST_USER_ID))
|
||||
.thenReturn(true);
|
||||
|
||||
// AND there is a task record
|
||||
|
||||
Reference in New Issue
Block a user