Add emergency call buttons to the work challenge screens in the case of
managed subscription for work telephony Test: manually tested for now Bug: b/258631630 Change-Id: I700d0408e3ffa86a595072b1a4aad62bac33b01d
This commit is contained in:
22
res/drawable/work_challenge_emergency_button_background.xml
Normal file
22
res/drawable/work_challenge_emergency_button_background.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
<inset xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="25dp"/>
|
||||
<solid android:color="@android:color/system_accent3_100" />
|
||||
</shape>
|
||||
</inset>
|
@@ -89,6 +89,19 @@
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/emergencyCallButton"
|
||||
style="@style/WorkChallengeEmergencyButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
android:layout_marginEnd="?attr/sudMarginEnd"
|
||||
android:layout_marginTop="60dp"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/work_challenge_emergency_button_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
|
||||
|
@@ -70,6 +70,19 @@
|
||||
android:layout_marginBottom="80dp"
|
||||
android:text="@string/cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/emergencyCallButton"
|
||||
style="@style/WorkChallengeEmergencyButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
android:layout_marginEnd="?attr/sudMarginEnd"
|
||||
android:layout_marginTop="60dp"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/work_challenge_emergency_button_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
|
||||
|
@@ -91,5 +91,17 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/emergencyCallButton"
|
||||
style="@style/WorkChallengeEmergencyButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
android:layout_marginEnd="?attr/sudMarginEnd"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/work_challenge_emergency_button_text"/>
|
||||
|
||||
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
|
||||
</com.google.android.setupdesign.GlifLayout>
|
||||
|
@@ -84,5 +84,17 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/emergencyCallButton"
|
||||
style="@style/WorkChallengeEmergencyButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
android:layout_marginEnd="?attr/sudMarginEnd"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/work_challenge_emergency_button_text"/>
|
||||
|
||||
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
|
||||
</com.google.android.setupdesign.GlifLayout>
|
||||
|
@@ -89,6 +89,19 @@
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/emergencyCallButton"
|
||||
style="@style/WorkChallengeEmergencyButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
android:layout_marginEnd="?attr/sudMarginEnd"
|
||||
android:layout_marginTop="60dp"
|
||||
android:layout_marginBottom="14dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/work_challenge_emergency_button_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
|
||||
|
@@ -71,6 +71,18 @@
|
||||
android:layout_marginBottom="80dp"
|
||||
android:text="@string/cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/emergencyCallButton"
|
||||
style="@style/WorkChallengeEmergencyButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
android:layout_marginEnd="?attr/sudMarginEnd"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/work_challenge_emergency_button_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
|
||||
|
@@ -3256,6 +3256,8 @@
|
||||
<!-- Security & location settings screen, change unlock pattern screen instruction if user
|
||||
draws incorrect pattern [CHAR LIMIT=30] -->
|
||||
<string name="lockpattern_need_to_unlock_wrong">Wrong pattern</string>
|
||||
<!-- Work challenge screen, this string is the label for an emergency call button, which opens the personal safety app to allow the user to make an emergency call. [CHAR LIMIT=20] -->
|
||||
<string name="work_challenge_emergency_button_text">Emergency</string>
|
||||
|
||||
<!-- Lock Pattern settings -->
|
||||
<!-- Security & location settings screen, header -->
|
||||
|
@@ -406,6 +406,17 @@
|
||||
<item name="android:layout_gravity">start|top</item>
|
||||
</style>
|
||||
|
||||
<style name="WorkChallengeEmergencyButtonStyle">
|
||||
<item name="android:background">@drawable/work_challenge_emergency_button_background</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:outlineProvider">none</item>
|
||||
<item name="android:paddingTop">15dp</item>
|
||||
<item name="android:paddingBottom">15dp</item>
|
||||
<item name="android:paddingLeft">30dp</item>
|
||||
<item name="android:paddingRight">30dp</item>
|
||||
<item name="android:textSize">16dp</item>
|
||||
</style>
|
||||
|
||||
<style name="device_info_dialog_label">
|
||||
<item name="android:textAlignment">viewStart</item>
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
|
||||
|
@@ -25,6 +25,7 @@ import android.annotation.Nullable;
|
||||
import android.app.Dialog;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.ManagedSubscriptionsPolicy;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@@ -34,6 +35,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -139,6 +141,31 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
||||
getActivity().finish();
|
||||
});
|
||||
setupForgotButtonIfManagedProfile(view);
|
||||
setupEmergencyCallButtonIfManagedSubscription(view);
|
||||
}
|
||||
|
||||
private void setupEmergencyCallButtonIfManagedSubscription(View view) {
|
||||
int policyType = getContext().getSystemService(
|
||||
DevicePolicyManager.class).getManagedSubscriptionsPolicy().getPolicyType();
|
||||
|
||||
if (policyType == ManagedSubscriptionsPolicy.TYPE_ALL_MANAGED_SUBSCRIPTIONS) {
|
||||
Button emergencyCallButton = view.findViewById(R.id.emergencyCallButton);
|
||||
if (emergencyCallButton == null) {
|
||||
Log.wtf(TAG,
|
||||
"Emergency call button not found in managed profile credential dialog");
|
||||
return;
|
||||
}
|
||||
emergencyCallButton.setVisibility(View.VISIBLE);
|
||||
emergencyCallButton.setOnClickListener(v -> {
|
||||
final Intent intent = getActivity()
|
||||
.getSystemService(TelecomManager.class)
|
||||
.createLaunchEmergencyDialerIntent(null)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
getActivity().startActivity(intent);
|
||||
getActivity().finish();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setupForgotButtonIfManagedProfile(View view) {
|
||||
|
Reference in New Issue
Block a user