DO NOT MERGE: Cherry-pick misc fixes to AOSP
Remove wrapper for LocationManager Remove LocationManagerWrapper from SettingsLib Bug: 76167422 Test: RunSettingsRoboTests Remove OverlayManagerWrapper class out from Settings Remove OverlayManagerWrapper and use IOverlayManager instead. Based on comment from reviewer to refactor ThemePreferenceController. Bug: 76167422 Test: RunSettingsRoboTests Change-Id: I13a7997b5e21a16ffb723971d267132fbf65e4a6
This commit is contained in:
@@ -19,18 +19,21 @@ package com.android.settings.development;
|
||||
import static android.os.UserHandle.USER_SYSTEM;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.om.IOverlayManager;
|
||||
import android.content.om.OverlayInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.DisplayCutout;
|
||||
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.text.TextUtils;
|
||||
import android.view.DisplayCutout;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.wrapper.OverlayManagerWrapper;
|
||||
import com.android.settings.wrapper.OverlayManagerWrapper.OverlayInfo;
|
||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -41,7 +44,7 @@ public class EmulateDisplayCutoutPreferenceController extends
|
||||
|
||||
private static final String KEY = "display_cutout_emulation";
|
||||
|
||||
private final OverlayManagerWrapper mOverlayManager;
|
||||
private final IOverlayManager mOverlayManager;
|
||||
private final boolean mAvailable;
|
||||
|
||||
private ListPreference mPreference;
|
||||
@@ -49,7 +52,7 @@ public class EmulateDisplayCutoutPreferenceController extends
|
||||
|
||||
@VisibleForTesting
|
||||
EmulateDisplayCutoutPreferenceController(Context context, PackageManager packageManager,
|
||||
OverlayManagerWrapper overlayManager) {
|
||||
IOverlayManager overlayManager) {
|
||||
super(context);
|
||||
mOverlayManager = overlayManager;
|
||||
mPackageManager = packageManager;
|
||||
@@ -57,7 +60,8 @@ public class EmulateDisplayCutoutPreferenceController extends
|
||||
}
|
||||
|
||||
public EmulateDisplayCutoutPreferenceController(Context context) {
|
||||
this(context, context.getPackageManager(), new OverlayManagerWrapper());
|
||||
this(context, context.getPackageManager(), IOverlayManager.Stub
|
||||
.asInterface(ServiceManager.getService(Context.OVERLAY_SERVICE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,10 +106,14 @@ public class EmulateDisplayCutoutPreferenceController extends
|
||||
}
|
||||
|
||||
final boolean result;
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
result = mOverlayManager.setEnabled(currentPackageName, false, USER_SYSTEM);
|
||||
} else {
|
||||
result = mOverlayManager.setEnabledExclusiveInCategory(packageName, USER_SYSTEM);
|
||||
try {
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
result = mOverlayManager.setEnabled(currentPackageName, false, USER_SYSTEM);
|
||||
} else {
|
||||
result = mOverlayManager.setEnabledExclusiveInCategory(packageName, USER_SYSTEM);
|
||||
}
|
||||
} catch (RemoteException re) {
|
||||
throw re.rethrowFromSystemServer();
|
||||
}
|
||||
updateState(mPreference);
|
||||
return result;
|
||||
@@ -145,13 +153,17 @@ public class EmulateDisplayCutoutPreferenceController extends
|
||||
}
|
||||
|
||||
private OverlayInfo[] getOverlayInfos() {
|
||||
@SuppressWarnings("unchecked") List<OverlayInfo> overlayInfos =
|
||||
mOverlayManager.getOverlayInfosForTarget("android", USER_SYSTEM);
|
||||
for (int i = overlayInfos.size() - 1; i >= 0; i--) {
|
||||
if (!DisplayCutout.EMULATION_OVERLAY_CATEGORY.equals(
|
||||
overlayInfos.get(i).category)) {
|
||||
overlayInfos.remove(i);
|
||||
List<OverlayInfo> overlayInfos;
|
||||
try {
|
||||
overlayInfos = mOverlayManager.getOverlayInfosForTarget("android", USER_SYSTEM);
|
||||
for (int i = overlayInfos.size() - 1; i >= 0; i--) {
|
||||
if (!DisplayCutout.EMULATION_OVERLAY_CATEGORY.equals(
|
||||
overlayInfos.get(i).category)) {
|
||||
overlayInfos.remove(i);
|
||||
}
|
||||
}
|
||||
} catch (RemoteException re) {
|
||||
throw re.rethrowFromSystemServer();
|
||||
}
|
||||
return overlayInfos.toArray(new OverlayInfo[overlayInfos.size()]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user