Disables the Gesture nav option if 3P launcher is default
Disables the Gesture navigation radio button if 3P launcher is set as default for current user. Also shows an info icon on the right side that opens a dialog explaining why it is disables. Bug: 129532605 Test: Manual test with 3P launcher Test: make RunSettingsRoboTests ROBOTEST_FILTER=RadioButtonPreferenceWithExtraWidgetTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=SystemNavigationGestureSettingsTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=SystemNavigationPreferenceControllerTest Change-Id: I90000c74246699fa9391ac042c87d7f0ece03637
This commit is contained in:
@@ -22,11 +22,14 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SystemNavigationPreferenceController extends BasePreferenceController {
|
||||
|
||||
static final String PREF_KEY_SYSTEM_NAVIGATION = "gesture_system_navigation";
|
||||
@@ -98,4 +101,31 @@ public class SystemNavigationPreferenceController extends BasePreferenceControll
|
||||
return NAV_BAR_MODE_GESTURAL == context.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_navBarInteractionMode);
|
||||
}
|
||||
|
||||
static boolean isGestureNavSupportedByDefaultLauncher(Context context) {
|
||||
final ComponentName cn = context.getPackageManager().getHomeActivities(new ArrayList<>());
|
||||
if (cn == null) {
|
||||
// There is no default home app set for the current user, don't make any changes yet.
|
||||
return true;
|
||||
}
|
||||
ComponentName recentsComponentName = ComponentName.unflattenFromString(context.getString(
|
||||
com.android.internal.R.string.config_recentsComponentName));
|
||||
return recentsComponentName.getPackageName().equals(cn.getPackageName());
|
||||
}
|
||||
|
||||
static String getDefaultHomeAppName(Context context) {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
final ComponentName cn = pm.getHomeActivities(new ArrayList<>());
|
||||
if (cn != null) {
|
||||
try {
|
||||
ApplicationInfo ai = pm.getApplicationInfo(cn.getPackageName(), 0);
|
||||
if (ai != null) {
|
||||
return pm.getApplicationLabel(ai).toString();
|
||||
}
|
||||
} catch (final PackageManager.NameNotFoundException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user