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

Commit a05719a2 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge changes If7c3a55e,I68dcba41,Ib96a15da into nyc-mr1-dev

* changes:
  Fixed a bug where the dimmed background could be invisible
  Fixed an issue where the inline controls where not usable
  Added Emergency affordance feature
parents caa71ddd 3334a182
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.net.ConnectivityManager;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.BatteryManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.DropBoxManager;
import android.os.IBinder;
@@ -8334,6 +8333,13 @@ public final class Settings {
         */
        public static final String CALL_AUTO_RETRY = "call_auto_retry";

        /**
         * A setting that can be read whether the emergency affordance is currently needed.
         * The value is a boolean (1 or 0).
         * @hide
         */
        public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed";

        /**
         * See RIL_PreferredNetworkType in ril.h
         * @hide
+101 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.policy;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;

/**
 * A class that manages emergency affordances and enables immediate calling to emergency services
 */
public class EmergencyAffordanceManager {

    public static final boolean ENABLED = true;

    /**
     * Global setting override with the number to call with the emergency affordance.
     * @hide
     */
    private static final String EMERGENCY_CALL_NUMBER_SETTING = "emergency_affordance_number";

    /**
     * Global setting, whether the emergency affordance should be shown regardless of device state.
     * The value is a boolean (1 or 0).
     * @hide
     */
    private static final String FORCE_EMERGENCY_AFFORDANCE_SETTING = "force_emergency_affordance";

    private final Context mContext;

    public EmergencyAffordanceManager(Context context) {
        mContext = context;
    }

    /**
     * perform an emergency call.
     */
    public final void performEmergencyCall() {
        performEmergencyCall(mContext);
    }

    private static Uri getPhoneUri(Context context) {
        String number = context.getResources().getString(
                com.android.internal.R.string.config_emergency_call_number);
        if (Build.IS_DEBUGGABLE) {
            String override = Settings.Global.getString(
                    context.getContentResolver(), EMERGENCY_CALL_NUMBER_SETTING);
            if (override != null) {
                number = override;
            }
        }
        return Uri.fromParts("tel", number, null);
    }

    private static void performEmergencyCall(Context context) {
        Intent intent = new Intent(Intent.ACTION_CALL_EMERGENCY);
        intent.setData(getPhoneUri(context));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }

    /**
     * @return whether emergency affordance should be active.
     */
    public boolean needsEmergencyAffordance() {
        if (!ENABLED) {
            return false;
        }
        if (forceShowing()) {
            return true;
        }
        return isEmergencyAffordanceNeeded();
    }

    private boolean isEmergencyAffordanceNeeded() {
        return Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.EMERGENCY_AFFORDANCE_NEEDED, 0) != 0;
    }


    private boolean forceShowing() {
        return Settings.Global.getInt(mContext.getContentResolver(),
                FORCE_EMERGENCY_AFFORDANCE_SETTING, 0) != 0;
    }
}
+40 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2014 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24.0dp"
        android:height="24.0dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?attr/colorControlNormal">
    <path
        android:fillColor="#FF000000"
        android:pathData="M6.8,17.3C5.3,15.9 4.5,14.0 4.5,12.0c0.0,-2.0 0.8,-3.8 2.1,-5.2l1.4,1.4c-1.0,1.0 -1.6,2.4 -1.6,3.8c0.0,1.5 0.6,2.9 1.6,3.9L6.8,17.3z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M3.3,20.2C1.2,18.0 0.0,15.1 0.0,12.0c0.0,-3.1 1.2,-6.0 3.3,-8.2l1.4,1.4C3.0,7.0 2.0,9.4 2.0,12.0s1.0,5.0 2.7,6.9L3.3,20.2z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M17.2,17.3l-1.4,-1.4c1.1,-1.0 1.6,-2.4 1.6,-3.9c0.0,-1.4 -0.6,-2.8 -1.6,-3.8l1.4,-1.4c1.4,1.4 2.1,3.3 2.1,5.2C19.5,14.0 18.7,15.9 17.2,17.3z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M20.7,20.2l-1.4,-1.4C21.0,17.0 22.0,14.6 22.0,12.0c0.0,-2.6 -1.0,-5.0 -2.7,-6.9l1.4,-1.4C22.8,6.0 24.0,8.9 24.0,12.0C24.0,15.1 22.8,18.0 20.7,20.2z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M11.0,15.0l2.0,0.0l0.0,2.0l-2.0,0.0z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M11.0,7.0l2.0,0.0l0.0,6.0l-2.0,0.0z"/>
</vector>
+10 −0
Original line number Diff line number Diff line
@@ -2526,6 +2526,16 @@
    <!-- True if the device supports system navigation keys. -->
    <bool name="config_supportSystemNavigationKeys">false</bool>

    <!-- emergency call number for the emergency affordance -->
    <string name="config_emergency_call_number" translatable="false">112</string>

    <!-- Do not translate. Mcc codes whose existence trigger the presence of emergency
         affordances-->
    <integer-array name="config_emergency_mcc_codes" translatable="false">
        <item>404</item>
        <item>405</item>
    </integer-array>

    <!-- Package name for the device provisioning package. -->
    <string name="config_deviceProvisioningPackage"></string>

+3 −0
Original line number Diff line number Diff line
@@ -486,6 +486,9 @@
    <!-- TODO: promote to separate string-->
    <string name="global_action_restart" translatable="false">@string/sim_restart_button</string>

    <!-- label for item that starts emergency call -->
    <string name="global_action_emergency">Emergency</string>

    <!-- label for item that generates a bug report in the phone options dialog -->
    <string name="global_action_bug_report">Bug report</string>

Loading