Merge "Adding "Install Other Apps" in App Info page"

This commit is contained in:
TreeHugger Robot
2017-03-04 00:39:22 +00:00
committed by Android (Google) Code Review
6 changed files with 173 additions and 7 deletions

View File

@@ -977,7 +977,9 @@ public class InstalledAppDetails extends AppInfoBase
PictureInPictureSettings.checkPackageHasPictureInPictureActivities(
packageInfoWithActivities.packageName,
packageInfoWithActivities.activities);
if (hasDrawOverOtherApps || hasWriteSettings || hasPictureInPictureActivities) {
boolean isPotentialAppSource = isPotentialAppSource();
if (hasDrawOverOtherApps || hasWriteSettings || hasPictureInPictureActivities ||
isPotentialAppSource) {
PreferenceCategory category = new PreferenceCategory(getPrefContext());
category.setTitle(R.string.advanced_apps);
screen.addPreference(category);
@@ -1027,11 +1029,32 @@ public class InstalledAppDetails extends AppInfoBase
});
category.addPreference(pref);
}
if (isPotentialAppSource) {
Preference pref = new Preference(getPrefContext());
pref.setTitle(R.string.install_other_apps);
pref.setKey("install_other_apps");
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startAppInfoFragment(ExternalSourcesDetails.class,
getString(R.string.install_other_apps));
return true;
}
});
category.addPreference(pref);
}
}
addAppInstallerInfoPref(screen);
}
private boolean isPotentialAppSource() {
AppStateInstallAppsBridge.InstallAppsState appState =
new AppStateInstallAppsBridge(getContext(), null, null)
.createInstallAppsStateFor(mPackageName, mPackageInfo.applicationInfo.uid);
return appState.isPotentialAppSource();
}
private void addAppInstallerInfoPref(PreferenceScreen screen) {
String installerPackageName = null;
try {
@@ -1117,6 +1140,10 @@ public class InstalledAppDetails extends AppInfoBase
if (pref != null) {
pref.setSummary(WriteSettingsDetails.getSummary(getContext(), mAppEntry));
}
pref = findPreference("install_other_apps");
if (pref != null) {
pref.setSummary(ExternalSourcesDetails.getPreferenceSummary(getContext(), mAppEntry));
}
}
public static void setupAppSnippet(View appSnippet, CharSequence label, Drawable icon,