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

Commit d213c271 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge branch 'epic42-t-bringup' into 'v1-t'

Port changes from Android S

See merge request e/os/android_frameworks_base!139
parents 52e8e6c9 ec36ab6e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ package android {
    field public static final String DUMP = "android.permission.DUMP";
    field public static final String EXPAND_STATUS_BAR = "android.permission.EXPAND_STATUS_BAR";
    field public static final String FACTORY_TEST = "android.permission.FACTORY_TEST";
    field public static final String FAKE_PACKAGE_SIGNATURE = "android.permission.FAKE_PACKAGE_SIGNATURE";
    field public static final String FOREGROUND_SERVICE = "android.permission.FOREGROUND_SERVICE";
    field public static final String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
    field public static final String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
@@ -222,6 +223,7 @@ package android {
    field public static final String CALL_LOG = "android.permission-group.CALL_LOG";
    field public static final String CAMERA = "android.permission-group.CAMERA";
    field public static final String CONTACTS = "android.permission-group.CONTACTS";
    field public static final String FAKE_PACKAGE = "android.permission-group.FAKE_PACKAGE";
    field public static final String LOCATION = "android.permission-group.LOCATION";
    field public static final String MICROPHONE = "android.permission-group.MICROPHONE";
    field public static final String NEARBY_DEVICES = "android.permission-group.NEARBY_DEVICES";
+4 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeoutException;

import com.android.internal.safetynet.SafetyNetHooks;

/**
 * Base class for implementing application instrumentation code.  When running
 * with instrumentation turned on, this class will be instantiated for you
@@ -1242,6 +1244,7 @@ public class Instrumentation {
        Application app = getFactory(context.getPackageName())
                .instantiateApplication(cl, className);
        app.attach(context);
        SafetyNetHooks.init(app);
        return app;
    }
    
@@ -1259,6 +1262,7 @@ public class Instrumentation {
            ClassNotFoundException {
        Application app = (Application)clazz.newInstance();
        app.attach(context);
        SafetyNetHooks.init(app);
        return app;
    }

+1 −1
Original line number Diff line number Diff line
@@ -1034,7 +1034,7 @@ public class Switch extends CompoundButton {
        }

        final int switchWidth = Math.max(mSwitchMinWidth,
                2 * mThumbWidth + paddingLeft + paddingRight);
                (int) (1.8 * mThumbWidth) + paddingLeft + paddingRight);
        final int switchHeight = Math.max(trackHeight, thumbHeight);
        mSwitchWidth = switchWidth;
        mSwitchHeight = switchHeight;
+62 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

package com.android.internal.safetynet;

import java.lang.reflect.Field;
import java.util.Arrays;

import android.app.Application;
import android.os.Build;
import android.util.Log;

public final class SafetyNetHooks {

    private static final String TAG = "SafetyNetHooks";
    private static final String GMS_PACKAGE_NAME = "com.google.android.gms";

    private static volatile boolean sIsGms = false;

    private static void setBuildField(String key, String value) {
        try {
            Field field = Build.class.getDeclaredField(key);
            field.setAccessible(true);
            field.set(null, value);
            field.setAccessible(false);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            Log.e(TAG, "Failed to fake Build." + key, e);
        }
    }

    public static void init(Application app) {
        if (GMS_PACKAGE_NAME.equals(app.getPackageName())) {
            sIsGms = true;
            setBuildField("MODEL", Build.MODEL + " ");
        }
    }

    private static boolean isCallerSafetyNet() {
        return Arrays.stream(Thread.currentThread().getStackTrace())
                .anyMatch(elem -> elem.getClassName().contains("DroidGuard"));
    }

    public static void onEngineGetCertificateChain() {
        // Check stack for SafetyNet
        if (sIsGms && isCallerSafetyNet()) {
            throw new UnsupportedOperationException();
        }
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -3572,6 +3572,21 @@
        android:description="@string/permdesc_getPackageSize"
        android:protectionLevel="normal" />

    <!-- Dummy user-facing group for faking package signature -->
    <permission-group android:name="android.permission-group.FAKE_PACKAGE"
        android:label="@string/permgrouplab_fake_package_signature"
        android:description="@string/permgroupdesc_fake_package_signature"
        android:request="@string/permgrouprequest_fake_package_signature"
        android:priority="100" />

    <!-- Allows an application to change the package signature as
         seen by applications -->
    <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
        android:permissionGroup="android.permission-group.UNDEFINED"
        android:protectionLevel="dangerous"
        android:label="@string/permlab_fakePackageSignature"
        android:description="@string/permdesc_fakePackageSignature" />

    <!-- @deprecated No longer useful, see
         {@link android.content.pm.PackageManager#addPackageToPreferred}
         for details. -->
Loading