Adding app specific screen for "External Sources"
Adding app specific screen so that third party apps and package installer can directly intent there to direct users to change the setting. Also added automater tests. Test: adb shell am instrument -w -e class \ 'com.android.settings.applications.ExternalSourcesSettingsTest' \ 'com.android.settings.tests/android.support.test.runner.AndroidJUnitRunner' Bug: 33792674 Bug: 35487166 Change-Id: I5a481ee7032979df94a9e267ea74aa90da6a0906
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.android.settings.applications;
|
||||
|
||||
import static android.app.Activity.RESULT_CANCELED;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
@@ -26,6 +29,7 @@ import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
|
||||
@@ -67,6 +71,10 @@ public class ExternalSourcesDetails extends AppInfoWithHeader
|
||||
final boolean checked = (Boolean) newValue;
|
||||
if (preference == mSwitchPref) {
|
||||
if (mInstallAppsState != null && checked != mInstallAppsState.canInstallApps()) {
|
||||
if (Settings.ManageAppExternalSourcesActivity.class.getName().equals(
|
||||
getIntent().getComponent().getClassName())) {
|
||||
setResult(checked ? RESULT_OK : RESULT_CANCELED);
|
||||
}
|
||||
setCanInstallApps(checked);
|
||||
refreshUi();
|
||||
}
|
||||
@@ -97,9 +105,13 @@ public class ExternalSourcesDetails extends AppInfoWithHeader
|
||||
protected boolean refreshUi() {
|
||||
mInstallAppsState = mAppBridge.createInstallAppsStateFor(mPackageName,
|
||||
mPackageInfo.applicationInfo.uid);
|
||||
|
||||
final boolean canWrite = mInstallAppsState.canInstallApps();
|
||||
mSwitchPref.setChecked(canWrite);
|
||||
if (!mInstallAppsState.isPotentialAppSource()) {
|
||||
// Invalid app entry. Should not allow changing permission
|
||||
mSwitchPref.setEnabled(false);
|
||||
return true;
|
||||
}
|
||||
final boolean canInstallApps = mInstallAppsState.canInstallApps();
|
||||
mSwitchPref.setChecked(canInstallApps);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user