Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99c50335 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge branch '2805os-t-fwbase_rebase' into 'v1-t'

base: Rebase v1-t-tablet onto v1-t

See merge request e/os/android_frameworks_base!242
parents c5bc5805 630fcd8c
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright (c) 2022, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
-->
<resources>
    <dimen name="small_clock_text_size">150dp</dimen>
</resources>
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright (c) 2022, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
-->
<resources>
    <dimen name="small_clock_text_size">150dp</dimen>
</resources>
+7 −1
Original line number Diff line number Diff line
@@ -79,7 +79,13 @@ constructor(
    }

    private fun updateResources() {
        useSplitShade = LargeScreenUtils.shouldUseSplitNotificationShade(context.resources)
        // Set this to false, we want to make only media controller think that we aren't
        // using split shade. Other components still will use split. This forces media to
        // place the tile under notifications in split mode
        // No checks here are necessary since split only applies to landscape keyguard which
        // is only available to tablets.
        // This change thus does not affect smartphones.
        useSplitShade = false
    }

    @VisibleForTesting
+0 −7
Original line number Diff line number Diff line
@@ -1593,13 +1593,6 @@ public final class NotificationPanelViewController implements Dumpable {

    @ClockSize
    private int computeDesiredClockSizeForSplitShade() {
        // Media is not visible to the user on AOD.
        boolean isMediaVisibleToUser =
                mMediaDataManager.hasActiveMediaOrRecommendation() && !isOnAod();
        if (isMediaVisibleToUser) {
            // When media is visible, it overlaps with the large clock. Use small clock instead.
            return SMALL;
        }
        return LARGE;
    }

+80 −2
Original line number Diff line number Diff line
@@ -18,12 +18,25 @@ package com.android.systemui.statusbar.phone;


import android.annotation.Nullable;
import android.app.ActivityTaskManager.RootTaskInfo;
import android.app.ActivityTaskManager;
import android.app.IActivityTaskManager;
import android.app.TaskStackListener;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.Rect;
import android.inputmethodservice.InputMethodService;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Pair;
@@ -61,6 +74,7 @@ import java.util.Objects;

public class PhoneStatusBarView extends FrameLayout implements Callbacks {
    private static final String TAG = "PhoneStatusBarView";
    private static final String BLISS_LAUNCHER_DOCK_WIDTH = "bliss_launcher_dock_width";
    private final CommandQueue mCommandQueue;
    private final StatusBarContentInsetsProvider mContentInsetsProvider;

@@ -83,6 +97,29 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
     */
    private int mCutoutSideNudge = 0;

    private String mPreviousApp = "";
    private IActivityTaskManager mActivityTaskManager;
    private Handler mHandler = new Handler(Looper.getMainLooper());
    private final TaskStackListener mTaskListener = new TaskStackListener() {
        @Override
        public void onTaskStackChanged() {
            try {
                String foregroundApp = getForegroundApp();
                if (foregroundApp != null && !mPreviousApp.equals(foregroundApp)) {
                    mPreviousApp = foregroundApp;
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            updateStatusBarHeight();
                        }
                    });
                }
            } catch (Exception e) {
                // Do nothing
            }
        }
    };

    public PhoneStatusBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mCommandQueue = Dependency.get(CommandQueue.class);
@@ -116,6 +153,23 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
                    () -> getDisplay().getRotation());
            mRotationButtonController.setRotationButton(floatingRotationButton, null);
        }
        ContentObserver observer = new ContentObserver(new Handler()) {
            @Override
            public void onChange(boolean selfChange, Uri uri) {
                if (uri.equals(Settings.Secure.getUriFor(BLISS_LAUNCHER_DOCK_WIDTH))) {
                    updateStatusBarHeight();
                }
            }
        };
        context.getContentResolver().registerContentObserver(
                        Settings.Secure.getUriFor(BLISS_LAUNCHER_DOCK_WIDTH), false, observer, UserHandle.USER_ALL);

        try {
            mActivityTaskManager = ActivityTaskManager.getService();
            mActivityTaskManager.registerTaskStackListener(mTaskListener);
        } catch (RemoteException e) {
            // Do nothing
        }
    }

    @Override
@@ -293,11 +347,22 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
        int statusBarPaddingEnd = getResources().getDimensionPixelSize(
                R.dimen.status_bar_padding_end);

        boolean isHomePackage = false;

        // Get the home launcher package name
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        ResolveInfo resolveInfo = getContext().getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
        if (resolveInfo != null) {
            String homePackageName = resolveInfo.activityInfo.packageName;
            isHomePackage = homePackageName != null && homePackageName.equals(getForegroundApp());
        }
        int dockWidth = !isHomePackage ? 0 : Settings.Secure.getInt(getContext().getContentResolver(), BLISS_LAUNCHER_DOCK_WIDTH, 0);
        View sbContents = findViewById(R.id.status_bar_contents);
        sbContents.setPaddingRelative(
                statusBarPaddingStart,
                statusBarPaddingStart + (mRotationOrientation == RotationUtils.ROTATION_SEASCAPE ? dockWidth : 0),
                statusBarPaddingTop,
                statusBarPaddingEnd,
                statusBarPaddingEnd + (mRotationOrientation == RotationUtils.ROTATION_LANDSCAPE ? dockWidth : 0),
                0);

        findViewById(R.id.notification_lights_out)
@@ -306,6 +371,19 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
        setLayoutParams(layoutParams);
    }

    private String getForegroundApp() {
        RootTaskInfo info = null;
        try {
            info = mActivityTaskManager.getFocusedRootTaskInfo();
            if (info != null && info.topActivity != null) {
                return info.topActivity.getPackageName();
            }
        } catch (RemoteException e) {
            // Do nothing
        }
        return null;
    }

    private void updateLayoutForCutout() {
        updateStatusBarHeight();
        updateCutoutLocation();