Merge "Migrate PlatformCompat App List to SPA" into udc-qpr-dev am: 879ff5f271
am: 78981afdc2
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23410196 Change-Id: I09189fc2dfe6789db9c7745dd43cf5168c2e9dfc Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -25,12 +25,4 @@ public interface DevelopmentOptionsActivityRequestCodes {
|
||||
int REQUEST_CODE_DEBUG_APP = 1;
|
||||
|
||||
int REQUEST_MOCK_LOCATION_APP = 2;
|
||||
|
||||
int REQUEST_CODE_ANGLE_ALL_USE_ANGLE = 3;
|
||||
|
||||
int REQUEST_CODE_ANGLE_DRIVER_PKGS = 4;
|
||||
|
||||
int REQUEST_CODE_ANGLE_DRIVER_VALUES = 5;
|
||||
|
||||
int REQUEST_COMPAT_CHANGE_APP = 6;
|
||||
}
|
||||
|
@@ -17,21 +17,16 @@
|
||||
package com.android.settings.development.compat;
|
||||
|
||||
import static com.android.internal.compat.OverrideAllowedState.ALLOWED;
|
||||
import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_COMPAT_CHANGE_APP;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.compat.Compatibility.ChangeConfig;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArraySet;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -40,35 +35,28 @@ import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.internal.compat.AndroidBuildClassifier;
|
||||
import com.android.internal.compat.CompatibilityChangeConfig;
|
||||
import com.android.internal.compat.CompatibilityChangeInfo;
|
||||
import com.android.internal.compat.IPlatformCompat;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.development.AppPicker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
||||
/**
|
||||
* Dashboard for Platform Compat preferences.
|
||||
*/
|
||||
public class PlatformCompatDashboard extends DashboardFragment {
|
||||
private static final String TAG = "PlatformCompatDashboard";
|
||||
private static final String COMPAT_APP = "compat_app";
|
||||
public static final String COMPAT_APP = "compat_app";
|
||||
|
||||
private IPlatformCompat mPlatformCompat;
|
||||
|
||||
private CompatibilityChangeInfo[] mChanges;
|
||||
|
||||
private AndroidBuildClassifier mAndroidBuildClassifier = new AndroidBuildClassifier();
|
||||
|
||||
private boolean mShouldStartAppPickerOnResume = true;
|
||||
|
||||
@VisibleForTesting
|
||||
String mSelectedApp;
|
||||
|
||||
@@ -108,32 +96,6 @@ public class PlatformCompatDashboard extends DashboardFragment {
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException("Could not list changes!", e);
|
||||
}
|
||||
if (icicle != null) {
|
||||
mShouldStartAppPickerOnResume = false;
|
||||
mSelectedApp = icicle.getString(COMPAT_APP);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_COMPAT_CHANGE_APP) {
|
||||
mShouldStartAppPickerOnResume = false;
|
||||
switch (resultCode) {
|
||||
case Activity.RESULT_OK:
|
||||
mSelectedApp = data.getAction();
|
||||
break;
|
||||
case Activity.RESULT_CANCELED:
|
||||
if (TextUtils.isEmpty(mSelectedApp)) {
|
||||
finish();
|
||||
}
|
||||
break;
|
||||
case AppPicker.RESULT_NO_MATCHING_APPS:
|
||||
mSelectedApp = null;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,33 +104,18 @@ public class PlatformCompatDashboard extends DashboardFragment {
|
||||
if (isFinishingOrDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if (!mShouldStartAppPickerOnResume) {
|
||||
if (TextUtils.isEmpty(mSelectedApp)) {
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setTitle(R.string.platform_compat_dialog_title_no_apps)
|
||||
.setMessage(R.string.platform_compat_dialog_text_no_apps)
|
||||
.setPositiveButton(R.string.okay, (dialog, which) -> finish())
|
||||
.setOnDismissListener(dialog -> finish())
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final ApplicationInfo applicationInfo = getApplicationInfo();
|
||||
addPreferences(applicationInfo);
|
||||
return;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
mShouldStartAppPickerOnResume = true;
|
||||
mSelectedApp = null;
|
||||
}
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
mSelectedApp = arguments.getString(COMPAT_APP);
|
||||
try {
|
||||
final ApplicationInfo applicationInfo = getApplicationInfo();
|
||||
addPreferences(applicationInfo);
|
||||
} catch (PackageManager.NameNotFoundException ignored) {
|
||||
finish();
|
||||
}
|
||||
startAppPicker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString(COMPAT_APP, mSelectedApp);
|
||||
}
|
||||
|
||||
private void addPreferences(ApplicationInfo applicationInfo) {
|
||||
@@ -266,12 +213,6 @@ public class PlatformCompatDashboard extends DashboardFragment {
|
||||
appPreference.setIcon(icon);
|
||||
appPreference.setSummary(getString(R.string.platform_compat_selected_app_summary,
|
||||
mSelectedApp, applicationInfo.targetSdkVersion));
|
||||
appPreference.setKey(mSelectedApp);
|
||||
appPreference.setOnPreferenceClickListener(
|
||||
preference -> {
|
||||
startAppPicker();
|
||||
return true;
|
||||
});
|
||||
return appPreference;
|
||||
}
|
||||
|
||||
@@ -294,17 +235,6 @@ public class PlatformCompatDashboard extends DashboardFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void startAppPicker() {
|
||||
final Intent intent = new Intent(getContext(), AppPicker.class)
|
||||
.putExtra(AppPicker.EXTRA_INCLUDE_NOTHING, false);
|
||||
// If build is neither userdebug nor eng, only include debuggable apps
|
||||
final boolean debuggableBuild = mAndroidBuildClassifier.isDebuggableBuild();
|
||||
if (!debuggableBuild) {
|
||||
intent.putExtra(AppPicker.EXTRA_DEBUGGABLE, true /* value */);
|
||||
}
|
||||
startActivityForResult(intent, REQUEST_COMPAT_CHANGE_APP);
|
||||
}
|
||||
|
||||
private class CompatChangePreferenceChangeListener implements OnPreferenceChangeListener {
|
||||
private final long changeId;
|
||||
|
||||
|
Reference in New Issue
Block a user