Better handling of backup/restore operations.

When the caller is a backup/restore app (as determined by the BACKUP
permission), then let them set the OWNER_PACKAGE_NAME column to
restore media ownership information.

Also update idle maintenance logic to examine pending install
sessions when deciding if media should be orphaned.  (Consider the
case where a backup/restore app has restored media ownership, but
the actual apps are still waiting to be installed.)

Bug: 141870626, 129848296
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I66a0dd6668f3cf236eba5ab939aaeb55b235a91a
3 files changed