summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2016-01-15 01:27:22 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-01-15 01:27:22 +0000
commit8e9c4fef04a6964e74a39ab2808d2771b9fe2fa8 (patch)
tree807841daef6d0ec9c659d02fe437cd8128f53bd0 /src
parentf72df377f62b6c49a0395cc3f8eed2e9f52cb584 (diff)
parente3ebb33a49099621c08edf07f40a06a4d0429cf3 (diff)
downloadandroid_packages_apps_PackageInstaller-8e9c4fef04a6964e74a39ab2808d2771b9fe2fa8.tar.gz
android_packages_apps_PackageInstaller-8e9c4fef04a6964e74a39ab2808d2771b9fe2fa8.tar.bz2
android_packages_apps_PackageInstaller-8e9c4fef04a6964e74a39ab2808d2771b9fe2fa8.zip
Merge "Improve untrusted sources UX for app side-loading" am: c23d802958
am: e3ebb33a49 * commit 'e3ebb33a49099621c08edf07f40a06a4d0429cf3': 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 0385ecdf..e3ad4f34 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -64,6 +64,8 @@ import java.io.File;
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;
@@ -222,7 +224,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)
@@ -327,12 +329,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) {