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

Commit df12089e authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6823548 from 11762798 to rvc-qpr1-release

Change-Id: I32b243d818c445f7e4e2947691f96c77e660f290
parents 511edc73 11762798
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.icu.util.ULocale;

import com.android.internal.annotations.GuardedBy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -151,18 +152,18 @@ public final class LocaleList implements Parcelable {
    /**
     * Creates a new {@link LocaleList}.
     *
     * If two or more same locales are passed, the repeated locales will be dropped.
     * <p>For empty lists of {@link Locale} items it is better to use {@link #getEmptyLocaleList()},
     * which returns a pre-constructed empty list.</p>
     *
     * @throws NullPointerException if any of the input locales is <code>null</code>.
     * @throws IllegalArgumentException if any of the input locales repeat.
     */
    public LocaleList(@NonNull Locale... list) {
        if (list.length == 0) {
            mList = sEmptyList;
            mStringRepresentation = "";
        } else {
            final Locale[] localeList = new Locale[list.length];
            final ArrayList<Locale> localeList = new ArrayList<>();
            final HashSet<Locale> seenLocales = new HashSet<Locale>();
            final StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.length; i++) {
@@ -170,10 +171,10 @@ public final class LocaleList implements Parcelable {
                if (l == null) {
                    throw new NullPointerException("list[" + i + "] is null");
                } else if (seenLocales.contains(l)) {
                    throw new IllegalArgumentException("list[" + i + "] is a repetition");
                    // Dropping duplicated locale entries.
                } else {
                    final Locale localeClone = (Locale) l.clone();
                    localeList[i] = localeClone;
                    localeList.add(localeClone);
                    sb.append(localeClone.toLanguageTag());
                    if (i < list.length - 1) {
                        sb.append(',');
@@ -181,7 +182,7 @@ public final class LocaleList implements Parcelable {
                    seenLocales.add(localeClone);
                }
            }
            mList = localeList;
            mList = localeList.toArray(new Locale[localeList.size()]);
            mStringRepresentation = sb.toString();
        }
    }
+2 −1
Original line number Diff line number Diff line
@@ -566,7 +566,8 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
    private void saveScreenshot(Bitmap screenshot, Consumer<Uri> finisher, Rect screenRect,
            Insets screenInsets, boolean showFlash) {
        if (mScreenshotLayout.isAttachedToWindow()) {
            if (!mDismissAnimation.isRunning()) { // if we didn't already dismiss for another reason
            // if we didn't already dismiss for another reason
            if (mDismissAnimation == null || !mDismissAnimation.isRunning()) {
                mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_REENTERED);
            }
            dismissScreenshot("new screenshot requested", true);
+30 −0
Original line number Diff line number Diff line
@@ -478,6 +478,21 @@ public final class CachedAppOptimizer {
     */
    private static native void enableFreezerInternal(boolean enable);

    /**
     * Informs binder that a process is about to be frozen. If freezer is enabled on a process via
     * this method, this method will synchronously dispatch all pending transactions to the
     * specified pid. This method will not add significant latencies when unfreezing.
     * After freezing binder calls, binder will block all transaction to the frozen pid, and return
     * an error to the sending process.
     *
     * @param pid the target pid for which binder transactions are to be frozen
     * @param freeze specifies whether to flush transactions and then freeze (true) or unfreeze
     * binder for the specificed pid.
     *
     * @throws RuntimeException in case a flush/freeze operation could not complete successfully.
     */
    private static native void freezeBinder(int pid, boolean freeze);

    /**
     * Determines whether the freezer is supported by this system
     */
@@ -727,6 +742,13 @@ public final class CachedAppOptimizer {
        }

        if (!app.frozen) {
            try {
                freezeBinder(app.pid, false);
            } catch (RuntimeException e) {
                // TODO: it might be preferable to kill the target pid in this case
                Slog.e(TAG_AM, "Unable to unfreeze binder for " + app.pid + " " + app.processName);
            }

            if (DEBUG_FREEZER) {
                Slog.d(TAG_AM, "sync unfroze " + app.pid + " " + app.processName);
            }
@@ -1039,6 +1061,14 @@ public final class CachedAppOptimizer {
                    return;
                }

                try {
                    freezeBinder(pid, true);
                } catch (RuntimeException e) {
                    // TODO: it might be preferable to kill the target pid in this case
                    Slog.e(TAG_AM, "Unable to freeze binder for " + pid + " " + name);
                    return;
                }

                if (pid == 0 || proc.frozen) {
                    // Already frozen or not a real process, either one being
                    // launched or one being killed
+63 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.
 */

package com.android.server.telecom;

import android.content.Context;
import android.os.Binder;
import android.os.Process;

import com.android.internal.telecom.IDeviceIdleControllerAdapter;
import com.android.internal.telecom.IInternalServiceRetriever;
import com.android.server.DeviceIdleInternal;

/**
 * The Telecom APK can not access services stored in LocalService directly and since it is in the
 * SYSTEM process, it also can not use the *Manager interfaces
 * (see {@link Context#enforceCallingPermission(String, String)}). Instead, we must wrap these local
 * services in binder interfaces to allow Telecom access.
 */
public class InternalServiceRepository extends IInternalServiceRetriever.Stub {

    private final IDeviceIdleControllerAdapter.Stub mDeviceIdleControllerAdapter =
            new IDeviceIdleControllerAdapter.Stub() {
        @Override
        public void exemptAppTemporarilyForEvent(String packageName, long duration, int userHandle,
                String reason) {
            mDeviceIdleController.addPowerSaveTempWhitelistApp(Process.myUid(), packageName,
                    duration, userHandle, true /*sync*/, reason);
        }
    };

    private final DeviceIdleInternal mDeviceIdleController;

    public InternalServiceRepository(DeviceIdleInternal deviceIdleController) {
        mDeviceIdleController = deviceIdleController;
    }

    @Override
    public IDeviceIdleControllerAdapter getDeviceIdleController() {
        ensureSystemProcess();
        return mDeviceIdleControllerAdapter;
    }

    private void ensureSystemProcess() {
        if (Binder.getCallingUid() != Process.SYSTEM_UID) {
            // Correctness check - this should never happen.
            throw new SecurityException("SYSTEM ONLY API.");
        }
    }
}
+17 −8
Original line number Diff line number Diff line
@@ -35,7 +35,10 @@ import android.util.IntArray;
import android.util.Slog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.telecom.ITelecomLoader;
import com.android.internal.telecom.ITelecomService;
import com.android.internal.telephony.SmsApplication;
import com.android.server.DeviceIdleInternal;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.pm.UserManagerService;
@@ -53,16 +56,13 @@ public class TelecomLoaderService extends SystemService {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            // Normally, we would listen for death here, but since telecom runs in the same process
            // as this loader (process="system") thats redundant here.
            // as this loader (process="system") that's redundant here.
            try {
                service.linkToDeath(new IBinder.DeathRecipient() {
                    @Override
                    public void binderDied() {
                        connectToTelecom();
                    }
                }, 0);
                ITelecomLoader telecomLoader = ITelecomLoader.Stub.asInterface(service);
                ITelecomService telecomService = telecomLoader.createTelecomService(mServiceRepo);

                SmsApplication.getDefaultMmsApplication(mContext, false);
                ServiceManager.addService(Context.TELECOM_SERVICE, service);
                ServiceManager.addService(Context.TELECOM_SERVICE, telecomService.asBinder());

                synchronized (mLock) {
                    final PermissionManagerServiceInternal permissionManager =
@@ -114,6 +114,8 @@ public class TelecomLoaderService extends SystemService {
    @GuardedBy("mLock")
    private TelecomServiceConnection mServiceConnection;

    private InternalServiceRepository mServiceRepo;

    public TelecomLoaderService(Context context) {
        super(context);
        mContext = context;
@@ -129,6 +131,8 @@ public class TelecomLoaderService extends SystemService {
        if (phase == PHASE_ACTIVITY_MANAGER_READY) {
            registerDefaultAppNotifier();
            registerCarrierConfigChangedReceiver();
            // core services will have already been loaded.
            setupServiceRepository();
            connectToTelecom();
        }
    }
@@ -154,6 +158,11 @@ public class TelecomLoaderService extends SystemService {
        }
    }

    private void setupServiceRepository() {
        DeviceIdleInternal deviceIdleInternal = getLocalService(DeviceIdleInternal.class);
        mServiceRepo = new InternalServiceRepository(deviceIdleInternal);
    }


    private void registerDefaultAppProviders() {
        final PermissionManagerServiceInternal permissionManager =
Loading