diff options
author | Fyodor Kupolov <fkupolov@google.com> | 2015-01-29 18:02:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-29 18:02:40 +0000 |
commit | 57641a8b5080b5122fcdd98c56fffaef90b3992d (patch) | |
tree | f35b735dd512429bc410bcf86767bb2b1c73981e | |
parent | db591467f6ae0e082c0ce627874a851f1926d63a (diff) | |
parent | d7e93570d35cfec4e5de0f3edc5d326ecdb8a442 (diff) | |
download | Settings-57641a8b5080b5122fcdd98c56fffaef90b3992d.tar.gz |
am d7e93570: am f11f9f47: Added a check if a custom activity can be started
* commit 'd7e93570d35cfec4e5de0f3edc5d326ecdb8a442':
Added a check if a custom activity can be started
-rw-r--r-- | src/com/android/settings/users/AppRestrictionsFragment.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/settings/users/AppRestrictionsFragment.java b/src/com/android/settings/users/AppRestrictionsFragment.java index f1022b9a2eb..fcaf18f4f4f 100644 --- a/src/com/android/settings/users/AppRestrictionsFragment.java +++ b/src/com/android/settings/users/AppRestrictionsFragment.java @@ -24,6 +24,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.RestrictionEntry; +import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageInfo; @@ -924,6 +925,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen } else if (restrictionsIntent != null) { preference.setRestrictions(restrictions); if (invokeIfCustom && AppRestrictionsFragment.this.isResumed()) { + assertSafeToStartCustomActivity(restrictionsIntent); int requestCode = generateCustomActivityRequestCode( RestrictionsResultReceiver.this.preference); AppRestrictionsFragment.this.startActivityForResult( @@ -931,6 +933,25 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen } } } + + private void assertSafeToStartCustomActivity(Intent intent) { + // Activity can be started if it belongs to the same app + if (intent.getPackage() != null && intent.getPackage().equals(packageName)) { + return; + } + // Activity can be started if intent resolves to multiple activities + List<ResolveInfo> resolveInfos = AppRestrictionsFragment.this.mPackageManager + .queryIntentActivities(intent, 0 /* no flags */); + if (resolveInfos.size() != 1) { + return; + } + // Prevent potential privilege escalation + ActivityInfo activityInfo = resolveInfos.get(0).activityInfo; + if (!packageName.equals(activityInfo.packageName)) { + throw new SecurityException("Application " + packageName + + " is not allowed to start activity " + intent); + }; + } } private void onRestrictionsReceived(AppRestrictionsPreference preference, String packageName, |