diff options
author | Ram Periathiruvadi <ramperry@google.com> | 2018-06-13 12:28:12 -0700 |
---|---|---|
committer | Ram Periathiruvadi <ramperry@google.com> | 2018-06-18 16:14:03 -0700 |
commit | d937c3284106e5641fd7f53bc075b2bcb1d66e56 (patch) | |
tree | 9d363d9d090ccdce8d8d228077a2b4358383b772 /service/src/com/android | |
parent | a8be0b8cbcc0f222bbb17db4b6a8bfc84f478738 (diff) | |
download | Car-d937c3284106e5641fd7f53bc075b2bcb1d66e56.tar.gz |
Check app install source before checking for DO.
Check if the non system apps were installed from an allowed app store
before looking for the distraction optimized activities in their
manifest. This prevents unauthorized apps faking DO behavior.
Bug: 109941605
Test: Test if sideloaded apps with DO activities are not added to the
allowed to run in a restricted state list.
Change-Id: I20f1560d1f26910216dcacc0333d2ae3b6fd1f27
Diffstat (limited to 'service/src/com/android')
-rw-r--r-- | service/src/com/android/car/pm/CarPackageManagerService.java | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/service/src/com/android/car/pm/CarPackageManagerService.java b/service/src/com/android/car/pm/CarPackageManagerService.java index 930a9e4305..3f3f0516f4 100644 --- a/service/src/com/android/car/pm/CarPackageManagerService.java +++ b/service/src/com/android/car/pm/CarPackageManagerService.java @@ -40,6 +40,7 @@ import android.content.pm.ServiceInfo; import android.content.pm.Signature; import android.content.res.Resources; import android.os.Binder; +import android.os.Build; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; @@ -92,6 +93,8 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements // Store the white list and black list strings from the resource file. private String mConfiguredWhitelist; private String mConfiguredBlacklist; + private final List<String> mAllowedAppInstallSources; + /** * Hold policy set from policy service or client. * Key: packageName of policy service @@ -152,8 +155,11 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements mEnableActivityBlocking = res.getBoolean(R.bool.enableActivityBlockingForSafety); String blockingActivity = res.getString(R.string.activityBlockingActivity); mActivityBlockingActivity = ComponentName.unflattenFromString(blockingActivity); + mAllowedAppInstallSources = Arrays.asList( + res.getStringArray(R.array.allowedAppInstallSources)); } + @Override public void setAppBlockingPolicy(String packageName, CarAppBlockingPolicy policy, int flags) { if (DBG_POLICY_SET) { @@ -583,7 +589,31 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements } } else { /* 2. If app is not listed in the config.xml check their Manifest meta-data to - see if they have any Distraction Optimized(DO) activities */ + see if they have any Distraction Optimized(DO) activities. + For non system apps, we check if the app install source was a permittable + source. This prevents side-loaded apps to fake DO. Bypass the check + for debug builds for development convenience. */ + if (!isDebugBuild() + && !info.applicationInfo.isSystemApp() + && !info.applicationInfo.isUpdatedSystemApp()) { + try { + if (mAllowedAppInstallSources != null) { + String installerName = mPackageManager.getInstallerPackageName( + info.packageName); + if (installerName == null || (installerName != null + && !mAllowedAppInstallSources.contains(installerName))) { + Log.w(CarLog.TAG_PACKAGE, + info.packageName + " not installed from permitted sources " + + installerName == null ? "NULL" : installerName); + continue; + } + } + } catch (IllegalArgumentException e) { + Log.w(CarLog.TAG_PACKAGE, info.packageName + " not installed!"); + continue; + } + } + try { activities = CarAppMetadataReader.findDistractionOptimizedActivities( mContext, @@ -622,6 +652,10 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements } } + private boolean isDebugBuild() { + return Build.IS_USERDEBUG || Build.IS_ENG; + } + /** * Generate a map of blacklisted packages and activities of the form {pkgName, Blacklisted * activities}. The blacklist information comes from a configuration XML resource. |