Do not attempt to account for settings window in PiP
Bug: 161289758 Test: manually Change-Id: Icd251e4865201f99bdb0712293c6d0d32ca1e69f
This commit is contained in:
@@ -17,23 +17,6 @@
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<!-- List of package names or class names which are considered as Settings,
|
||||
so PIP location should be adjusted to the left of the side panel.
|
||||
If it should be applied for all activities in a package, add the package name.
|
||||
If it should be applied for an activity in a package, add its class name with package name.
|
||||
The class name must follow format 'package_name/.class_name' ('/.' in between).
|
||||
This can be overriden in an overlay.
|
||||
-->
|
||||
<string-array name="tv_pip_settings_class_name" translatable="false">
|
||||
<item>com.android.tv.settings</item>
|
||||
<item>com.google.android.leanbacklauncher/.settings.HomeScreenSettingsActivity</item>
|
||||
<item>com.google.android.apps.mediashell/.settings.CastSettingsActivity</item>
|
||||
<item>com.google.android.katniss.setting/.SpeechSettingsActivity</item>
|
||||
<item>com.google.android.katniss.setting/.SearchSettingsActivity</item>
|
||||
<item>com.google.android.tungsten.setupwraith/.settings.usage.UsageDiagnosticsSettingActivity</item>
|
||||
<item>com.google.android.tvlauncher/.notifications.NotificationsSidePanelActivity</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="audio_recording_disclosure_exempt_apps" translatable="false">
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows,
|
||||
when the PIP menu is shown with settings. -->
|
||||
<string translatable="false" name="pip_settings_bounds">"662 756 1142 1026"</string>
|
||||
|
||||
<!-- Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows,
|
||||
when the PIP menu is shown in center. -->
|
||||
<string translatable="false" name="pip_menu_bounds">"596 280 1324 690"</string>
|
||||
|
||||
@@ -43,7 +43,6 @@ import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.DisplayInfo;
|
||||
|
||||
import com.android.systemui.Dependency;
|
||||
@@ -74,10 +73,6 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
private static final String TAG = "PipManager";
|
||||
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
private static final String SETTINGS_PACKAGE_AND_CLASS_DELIMITER = "/";
|
||||
|
||||
private static List<Pair<String, String>> sSettingsPackageAndClassNamePairList;
|
||||
|
||||
/**
|
||||
* State when there's no PIP.
|
||||
*/
|
||||
@@ -123,10 +118,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
private final Handler mHandler = new Handler();
|
||||
private List<Listener> mListeners = new ArrayList<>();
|
||||
private List<MediaListener> mMediaListeners = new ArrayList<>();
|
||||
private Rect mCurrentPipBounds;
|
||||
private Rect mPipBounds;
|
||||
private Rect mDefaultPipBounds = new Rect();
|
||||
private Rect mSettingsPipBounds;
|
||||
private Rect mMenuModePipBounds;
|
||||
private int mLastOrientation = Configuration.ORIENTATION_UNDEFINED;
|
||||
private boolean mInitialized;
|
||||
@@ -261,37 +254,6 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
broadcastDispatcher.registerReceiver(mBroadcastReceiver, intentFilter,
|
||||
null /* handler */, UserHandle.ALL);
|
||||
|
||||
if (sSettingsPackageAndClassNamePairList == null) {
|
||||
String[] settings = mContext.getResources().getStringArray(
|
||||
R.array.tv_pip_settings_class_name);
|
||||
sSettingsPackageAndClassNamePairList = new ArrayList<>();
|
||||
if (settings != null) {
|
||||
for (int i = 0; i < settings.length; i++) {
|
||||
Pair<String, String> entry = null;
|
||||
String[] packageAndClassName =
|
||||
settings[i].split(SETTINGS_PACKAGE_AND_CLASS_DELIMITER);
|
||||
switch (packageAndClassName.length) {
|
||||
case 1:
|
||||
entry = Pair.<String, String>create(packageAndClassName[0], null);
|
||||
break;
|
||||
case 2:
|
||||
if (packageAndClassName[1] != null) {
|
||||
entry = Pair.<String, String>create(packageAndClassName[0],
|
||||
packageAndClassName[1].startsWith(".")
|
||||
? packageAndClassName[0] + packageAndClassName[1]
|
||||
: packageAndClassName[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (entry != null) {
|
||||
sSettingsPackageAndClassNamePairList.add(entry);
|
||||
} else {
|
||||
Log.w(TAG, "Ignoring malformed settings name " + settings[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the last orientation and apply the current configuration
|
||||
Configuration initialConfig = mContext.getResources().getConfiguration();
|
||||
mLastOrientation = initialConfig.orientation;
|
||||
@@ -319,15 +281,13 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
}
|
||||
|
||||
Resources res = mContext.getResources();
|
||||
mSettingsPipBounds = Rect.unflattenFromString(res.getString(
|
||||
R.string.pip_settings_bounds));
|
||||
mMenuModePipBounds = Rect.unflattenFromString(res.getString(
|
||||
R.string.pip_menu_bounds));
|
||||
|
||||
// Reset the PIP bounds and apply. PIP bounds can be changed by two reasons.
|
||||
// 1. Configuration changed due to the language change (RTL <-> RTL)
|
||||
// 2. SystemUI restarts after the crash
|
||||
mPipBounds = isSettingsShown() ? mSettingsPipBounds : mDefaultPipBounds;
|
||||
mPipBounds = mDefaultPipBounds;
|
||||
resizePinnedStack(getPinnedStackInfo() == null ? STATE_NO_PIP : STATE_PIP);
|
||||
}
|
||||
|
||||
@@ -448,9 +408,10 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
return;
|
||||
}
|
||||
mState = state;
|
||||
final Rect newBounds;
|
||||
switch (mState) {
|
||||
case STATE_NO_PIP:
|
||||
mCurrentPipBounds = null;
|
||||
newBounds = null;
|
||||
// If the state was already STATE_NO_PIP, then do not resize the stack below as it
|
||||
// will not exist
|
||||
if (wasStateNoPip) {
|
||||
@@ -458,16 +419,15 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
}
|
||||
break;
|
||||
case STATE_PIP_MENU:
|
||||
mCurrentPipBounds = mMenuModePipBounds;
|
||||
newBounds = mMenuModePipBounds;
|
||||
break;
|
||||
case STATE_PIP: // fallthrough
|
||||
default:
|
||||
mCurrentPipBounds = mPipBounds;
|
||||
newBounds = mPipBounds;
|
||||
break;
|
||||
}
|
||||
if (mCurrentPipBounds != null) {
|
||||
mPipTaskOrganizer.scheduleAnimateResizePip(mCurrentPipBounds, mResizeAnimationDuration,
|
||||
null);
|
||||
if (newBounds != null) {
|
||||
mPipTaskOrganizer.scheduleAnimateResizePip(newBounds, mResizeAnimationDuration, null);
|
||||
} else {
|
||||
mPipTaskOrganizer.exitPip(mResizeAnimationDuration);
|
||||
}
|
||||
@@ -628,30 +588,6 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
return PLAYBACK_STATE_UNAVAILABLE;
|
||||
}
|
||||
|
||||
private boolean isSettingsShown() {
|
||||
List<RunningTaskInfo> runningTasks;
|
||||
try {
|
||||
runningTasks = mActivityTaskManager.getTasks(1);
|
||||
if (runningTasks.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.d(TAG, "Failed to detect top activity", e);
|
||||
return false;
|
||||
}
|
||||
ComponentName topActivity = runningTasks.get(0).topActivity;
|
||||
for (Pair<String, String> componentName : sSettingsPackageAndClassNamePairList) {
|
||||
String packageName = componentName.first;
|
||||
if (topActivity.getPackageName().equals(packageName)) {
|
||||
String className = componentName.second;
|
||||
if (className == null || topActivity.getClassName().equals(className)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private TaskStackChangeListener mTaskStackListener = new TaskStackChangeListener() {
|
||||
@Override
|
||||
public void onTaskStackChanged() {
|
||||
@@ -680,9 +616,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
}
|
||||
}
|
||||
if (getState() == STATE_PIP) {
|
||||
Rect bounds = isSettingsShown() ? mSettingsPipBounds : mDefaultPipBounds;
|
||||
if (mPipBounds != bounds) {
|
||||
mPipBounds = bounds;
|
||||
if (mPipBounds != mDefaultPipBounds) {
|
||||
mPipBounds = mDefaultPipBounds;
|
||||
resizePinnedStack(STATE_PIP);
|
||||
}
|
||||
}
|
||||
@@ -704,7 +639,6 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
stackInfo.taskNames[stackInfo.taskNames.length - 1]);
|
||||
// Set state to STATE_PIP so we show it when the pinned stack animation ends.
|
||||
mState = STATE_PIP;
|
||||
mCurrentPipBounds = mPipBounds;
|
||||
mMediaSessionManager.addOnActiveSessionsChangedListener(
|
||||
mActiveMediaSessionListener, null);
|
||||
updateMediaController(mMediaSessionManager.getActiveSessions(null));
|
||||
|
||||
Reference in New Issue
Block a user