[pm] make sure to restore mAlways=true preferred activity filter

Test: manual and verified that if a action has more than one preferred
activity filters, at least the mAlways=true filter will be restored on reboot.

Test: Before reboot in dumpsys:
      android.media.action.STILL_IMAGE_CAMERA:
        59144b6 com.google.android.GoogleCamera/com.android.camera.CameraImageActivity
         mMatch=0x100000 mAlways=false
          Action: "android.media.action.STILL_IMAGE_CAMERA"
          Category: "android.intent.category.DEFAULT"
        7d0bd59 com.google.android.GoogleCamera/com.android.camera.CameraImageActivity
         mMatch=0x100000 mAlways=false
          Action: "android.media.action.STILL_IMAGE_CAMERA"
          Category: "android.intent.category.DEFAULT"
        fbb913d com.google.android.GoogleCamera/com.android.camera.CameraImageActivity
         mMatch=0x100000 mAlways=false
          Action: "android.media.action.STILL_IMAGE_CAMERA"
          Category: "android.intent.category.DEFAULT"
        c86d195 com.google.android.GoogleCamera/com.android.camera.CameraImageActivity
         mMatch=0x100000 mAlways=true
          Selected from:
            com.google.android.GoogleCamera/com.android.camera.CameraImageActivity
            photo.android.hd.camera/com.android.camera.activity.SplashActivity
            filter.camera.snap.photo.video.panorama/cn.kuxun.kxcamera.CameraActivity
            net.sourceforge.opencamera/.MainActivity
            com.snapchat.android/com.snap.mushroom.MainActivity
          Action: "android.media.action.STILL_IMAGE_CAMERA"
          Category: "android.intent.category.DEFAULT"

Test: After reboot in dumpsys:
      android.media.action.STILL_IMAGE_CAMERA:
        aaf8ce5 com.google.android.GoogleCamera/com.android.camera.CameraImageActivity
         mMatch=0x100000 mAlways=false
          Action: "android.media.action.STILL_IMAGE_CAMERA"
          Category: "android.intent.category.DEFAULT"
        c249186 com.google.android.GoogleCamera/com.android.camera.CameraImageActivity
         mMatch=0x100000 mAlways=true
          Selected from:
            com.google.android.GoogleCamera/com.android.camera.CameraImageActivity
            photo.android.hd.camera/com.android.camera.activity.SplashActivity
            filter.camera.snap.photo.video.panorama/cn.kuxun.kxcamera.CameraActivity
            net.sourceforge.opencamera/.MainActivity
            com.snapchat.android/com.snap.mushroom.MainActivity
          Action: "android.media.action.STILL_IMAGE_CAMERA"
          Category: "android.intent.category.DEFAULT"

BUG: 157548344
Change-Id: I4b6c23e25957138a0b38f4be074c24a4519df59f
This commit is contained in:
Songchun Fan
2020-07-14 21:22:11 -07:00
parent 9c9434b30f
commit 8a40728f6d

View File

@@ -1407,7 +1407,7 @@ public final class Settings {
if (pa.mPref.getParseError() == null) {
final PreferredIntentResolver resolver = editPreferredActivitiesLPw(userId);
ArrayList<PreferredActivity> pal = resolver.findFilters(pa);
if (pal == null || pal.size() == 0) {
if (pal == null || pal.size() == 0 || pa.mPref.mAlways) {
resolver.addFilter(pa);
}
} else {