summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2016-01-15 00:25:55 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-01-15 00:25:55 +0000
commitc23d802958158d522e7350321ad9ac6d43013883 (patch)
tree0d6862234400099dd937e3f56eadd38fc793eec6 /src
parent816baf35660c3c46ffcb9be7ec72d343fb0e1400 (diff)
parent82e74ce4906cce41c730188b4b0298b37736d079 (diff)
downloadandroid_packages_apps_PackageInstaller-c23d802958158d522e7350321ad9ac6d43013883.tar.gz
android_packages_apps_PackageInstaller-c23d802958158d522e7350321ad9ac6d43013883.tar.bz2
android_packages_apps_PackageInstaller-c23d802958158d522e7350321ad9ac6d43013883.zip
Merge "Improve untrusted sources UX for app side-loading"
Diffstat (limited to 'src')
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index 3ea3959d..0d283e22 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -68,6 +68,8 @@ import java.util.List;
public class PackageInstallerActivity extends Activity implements OnCancelListener, OnClickListener {
private static final String TAG = "PackageInstaller";
+ private static final int REQUEST_ENABLE_UNKNOWN_SOURCES = 1;
+
private int mSessionId = -1;
private Uri mPackageURI;
private Uri mOriginatingURI;
@@ -245,7 +247,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
.setPositiveButton(R.string.settings, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.i(TAG, "Launching settings");
- launchSettingsAppAndFinish();
+ launchSecuritySettings();
}
})
.setOnCancelListener(this)
@@ -350,12 +352,21 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
return null;
}
- private void launchSettingsAppAndFinish() {
- // Create an intent to launch SettingsTwo activity
+ private void launchSecuritySettings() {
Intent launchSettingsIntent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
- launchSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(launchSettingsIntent);
- finish();
+ startActivityForResult(launchSettingsIntent, REQUEST_ENABLE_UNKNOWN_SOURCES);
+ }
+
+ @Override
+ public void onActivityResult(int request, int result, Intent data) {
+ // If the settings app approved the install we are good to go regardless
+ // whether the untrusted sources setting is on. This allows partners to
+ // implement a "allow untrusted source once" feature.
+ if (request == REQUEST_ENABLE_UNKNOWN_SOURCES && result == RESULT_OK) {
+ initiateInstall();
+ } else {
+ finish();
+ }
}
private boolean isInstallRequestFromUnknownSource(Intent intent) {