Generate consent dialog when device log access is requested in SystemUI

This change is to implement device log access dialog from SystemUI rather than
 system server.

Bug: 238434889, 244173014
Test: GtsVerifier
Ignore-AOSP-First: migration of device log access dialog
Change-Id: I17058c008084f91099cd45a51ec8d8fbab1d78bb
This commit is contained in:
Eun-Jeong Shin
2022-10-25 16:31:58 -07:00
parent 05d894c1b3
commit fc13cb1d68
19 changed files with 150 additions and 124 deletions

View File

@@ -6908,13 +6908,6 @@
android:exported="false">
</activity>
<activity android:name="com.android.internal.app.LogAccessDialogActivity"
android:theme="@style/Theme.Translucent.NoTitleBar"
android:process=":ui"
android:excludeFromRecents="true"
android:exported="false">
</activity>
<activity android:name="com.android.server.notification.NASLearnMoreActivity"
android:theme="@style/Theme.Dialog.Confirmation"
android:excludeFromRecents="true"

View File

@@ -1,21 +0,0 @@
<!--
~ 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>
<style name="PermissionGrantButtonTop"
parent="@style/Widget.Leanback.Button.ButtonBarGravityStart" />
<style name="PermissionGrantButtonBottom"
parent="@style/Widget.Leanback.Button.ButtonBarGravityStart" />
</resources>

View File

@@ -5759,32 +5759,6 @@
<!-- Title for the harmful app warning dialog. [CHAR LIMIT=40] -->
<string name="harmful_app_warning_title">Harmful app detected</string>
<!-- Title for the log access confirmation dialog. [CHAR LIMIT=NONE] -->
<string name="log_access_confirmation_title">Allow <xliff:g id="log_access_app_name" example="Example App">%s</xliff:g> to access all device logs?</string>
<!-- Label for the allow button on the log access confirmation dialog. [CHAR LIMIT=40] -->
<string name="log_access_confirmation_allow">Allow one-time access</string>
<!-- Label for the deny button on the log access confirmation dialog. [CHAR LIMIT=20] -->
<string name="log_access_confirmation_deny">Don\u2019t allow</string>
<!-- Content for the log access confirmation dialog. [CHAR LIMIT=NONE]-->
<string name="log_access_confirmation_body" product="default">Device logs record what happens on your device. Apps can use these logs to find and fix issues.\n\nSome logs may contain sensitive info, so only allow apps you trust to access all device logs.
\n\nIf you don’t allow this app to access all device logs, it can still access its own logs. Your device manufacturer may still be able to access some logs or info on your device.
</string>
<!-- Content for the log access confirmation dialog. [CHAR LIMIT=NONE]-->
<string name="log_access_confirmation_body" product="tv">Device logs record what happens on your device. Apps can use these logs to find and fix issues.\n\nSome logs may contain sensitive info, so only allow apps you trust to access all device logs.
\n\nIf you don’t allow this app to access all device logs, it can still access its own logs. Your device manufacturer may still be able to access some logs or info on your device.\n\nLearn more at g.co/android/devicelogs.
</string>
<!-- Learn more URL for the log access confirmation dialog. [DO NOT TRANSLATE]-->
<string name="log_access_confirmation_learn_more" product="default" translatable="false">&lt;a href="https://support.google.com/android?p=system_logs#topic=7313011"&gt;Learn more&lt;/a&gt;</string>
<!-- Learn more URL for the log access confirmation dialog. [DO NOT TRANSLATE]-->
<string name="log_access_confirmation_learn_more" product="tv" translatable="false"></string>
<!-- Privacy notice do not show [CHAR LIMIT=20] -->
<string name="log_access_do_not_show_again">Don\u2019t show again</string>
<!-- Text describing a permission request for one app to show another app's
slices [CHAR LIMIT=NONE] -->
<string name="slices_permission_request"><xliff:g id="app" example="Example App">%1$s</xliff:g> wants to show <xliff:g id="app_2" example="Other Example App">%2$s</xliff:g> slices</string>

View File

@@ -1541,40 +1541,4 @@ please see styles_device_defaults.xml.
<style name="NotificationTombstoneAction" parent="NotificationAction">
<item name="textColor">#555555</item>
</style>
<!-- The style for log access consent text -->
<style name="AllowLogAccess">
<item name="android:textSize">24sp</item>
<item name="android:fontFamily">google-sans</item>
</style>
<style name="PrimaryAllowLogAccess">
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">google-sans-text</item>
</style>
<style name="PermissionGrantButtonTextAppearance">
<item name="android:fontFamily">google-sans-medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@android:color/system_neutral1_900</item>
</style>
<style name="PermissionGrantButtonTop"
parent="@android:style/Widget.DeviceDefault.Button.Borderless.Colored">
<item name="android:layout_width">332dp</item>
<item name="android:layout_height">56dp</item>
<item name="android:layout_marginTop">2dp</item>
<item name="android:layout_marginBottom">2dp</item>
<item name="android:background">@drawable/grant_permissions_buttons_top</item>
</style>
<style name="PermissionGrantButtonBottom"
parent="@android:style/Widget.DeviceDefault.Button.Borderless.Colored">
<item name="android:layout_width">332dp</item>
<item name="android:layout_height">56dp</item>
<item name="android:layout_marginTop">2dp</item>
<item name="android:layout_marginBottom">2dp</item>
<item name="android:background">@drawable/grant_permissions_buttons_bottom</item>
</style>
</resources>

View File

@@ -3938,17 +3938,6 @@
<java-symbol type="string" name="harmful_app_warning_title" />
<java-symbol type="layout" name="harmful_app_warning_dialog" />
<java-symbol type="string" name="log_access_confirmation_allow" />
<java-symbol type="string" name="log_access_confirmation_deny" />
<java-symbol type="string" name="log_access_confirmation_title" />
<java-symbol type="string" name="log_access_confirmation_body" />
<java-symbol type="string" name="log_access_confirmation_learn_more" />
<java-symbol type="layout" name="log_access_user_consent_dialog_permission" />
<java-symbol type="id" name="log_access_dialog_title" />
<java-symbol type="id" name="log_access_dialog_body" />
<java-symbol type="id" name="log_access_dialog_allow_button" />
<java-symbol type="id" name="log_access_dialog_deny_button" />
<java-symbol type="string" name="config_defaultAssistantAccessComponent" />
<java-symbol type="string" name="slices_permission_request" />

View File

@@ -986,5 +986,11 @@
<action android:name="com.android.systemui.action.DISMISS_VOLUME_PANEL_DIALOG" />
</intent-filter>
</receiver>
<activity android:name=".logcat.LogAccessDialogActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:excludeFromRecents="true"
android:exported="false">
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,24 @@
<!--
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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF4883F3"
android:pathData="M19 3H5c-1.1 0,-2 .9,-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2,-.9 2,-2V5c0,-1.1,-.9,-2,-2,-2zm-1.99 6H7V7h10.01v2zm0 4H7v-2h10.01v2zm-3 4H7v-2h7.01v2z"/>
</vector>

View File

@@ -75,7 +75,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/log_access_confirmation_allow"
style="@style/PermissionGrantButtonTop"
style="?permissionGrantButtonTopStyle"
android:textAppearance="@style/PermissionGrantButtonTextAppearance"
android:layout_marginBottom="5dp"
android:layout_centerHorizontal="true"
@@ -89,7 +89,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/log_access_confirmation_deny"
style="@style/PermissionGrantButtonBottom"
style="?permissionGrantButtonBottomStyle"
android:textAppearance="@style/PermissionGrantButtonTextAppearance"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"

View File

@@ -0,0 +1,27 @@
<?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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Content for the log access confirmation dialog. [CHAR LIMIT=NONE]-->
<string name="log_access_confirmation_body">Device logs record what happens on your device. Apps can use these logs to find and fix issues.\n\nSome logs may contain sensitive info, so only allow apps you trust to access all device logs.
\n\nIf you don’t allow this app to access all device logs, it can still access its own logs. Your device manufacturer may still be able to access some logs or info on your device.\n\nLearn more at g.co/android/devicelogs.
</string>
<!-- Learn more URL for the log access confirmation dialog. [DO NOT TRANSLATE]-->
<string name="log_access_confirmation_learn_more" translatable="false"></string>
</resources>

View File

@@ -63,4 +63,10 @@
<item name="android:paddingVertical">@dimen/bottom_sheet_button_padding_vertical</item>
<item name="android:stateListAnimator">@anim/tv_bottom_sheet_button_state_list_animator</item>
</style>
<!-- The style for log access consent button -->
<style name="LogAccessDialogTheme" parent="@android:style/Theme.DeviceDefault.Dialog.Alert">
<item name="permissionGrantButtonTopStyle">?android:buttonBarButtonStyle</item>
<item name="permissionGrantButtonBottomStyle">?android:buttonBarButtonStyle</item>
</style>
</resources>

View File

@@ -204,5 +204,10 @@
<attr name="passwordTextAppearance" format="reference" />
<attr name="errorTextAppearance" format="reference"/>
</declare-styleable>
<declare-styleable name="LogAccessPermissionGrantDialog">
<attr name="permissionGrantButtonTopStyle" format="reference"/>
<attr name="permissionGrantButtonBottomStyle" format="reference"/>
</declare-styleable>
</resources>

View File

@@ -195,5 +195,7 @@
<item type="id" name="pm_lite"/>
<item type="id" name="settings_button_container"/>
<item type="id" name="log_access_dialog_allow_button" />
<item type="id" name="log_access_dialog_deny_button" />
</resources>

View File

@@ -2770,4 +2770,19 @@
<!-- Time format for the Dream Time Complication for 24-hour time format [CHAR LIMIT=NONE] -->
<string name="dream_time_complication_24_hr_time_format">kk:mm</string>
<!-- Title for the log access confirmation dialog. [CHAR LIMIT=NONE] -->
<string name="log_access_confirmation_title">Allow <xliff:g id="log_access_app_name" example="Example App">%s</xliff:g> to access all device logs?</string>
<!-- Label for the allow button on the log access confirmation dialog. [CHAR LIMIT=40] -->
<string name="log_access_confirmation_allow">Allow one-time access</string>
<!-- Label for the deny button on the log access confirmation dialog. [CHAR LIMIT=20] -->
<string name="log_access_confirmation_deny">Don\u2019t allow</string>
<!-- Content for the log access confirmation dialog. [CHAR LIMIT=NONE]-->
<string name="log_access_confirmation_body">Device logs record what happens on your device. Apps can use these logs to find and fix issues.\n\nSome logs may contain sensitive info, so only allow apps you trust to access all device logs.
\n\nIf you don’t allow this app to access all device logs, it can still access its own logs. Your device manufacturer may still be able to access some logs or info on your device.
</string>
<!-- Learn more URL for the log access confirmation dialog. [DO NOT TRANSLATE]-->
<string name="log_access_confirmation_learn_more" translatable="false">&lt;a href="https://support.google.com/android?p=system_logs#topic=7313011"&gt;Learn more&lt;/a&gt;</string>
</resources>

View File

@@ -1274,4 +1274,45 @@
<item name="android:textColor">?androidprv:attr/textColorOnAccent</item>
<item name="android:textSize">@dimen/broadcast_dialog_btn_text_size</item>
</style>
<!-- The style for log access consent dialog -->
<style name="LogAccessDialogTheme" parent="@style/Theme.SystemUI.Dialog.Alert">
<item name="permissionGrantButtonTopStyle">@style/PermissionGrantButtonTop</item>
<item name="permissionGrantButtonBottomStyle">@style/PermissionGrantButtonBottom</item>
</style>
<style name="AllowLogAccess">
<item name="android:textSize">24sp</item>
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
</style>
<style name="PrimaryAllowLogAccess">
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
</style>
<style name="PermissionGrantButtonTextAppearance">
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@android:color/system_neutral1_900</item>
</style>
<style name="PermissionGrantButtonTop"
parent="@android:style/Widget.DeviceDefault.Button.Borderless.Colored">
<item name="android:layout_width">332dp</item>
<item name="android:layout_height">56dp</item>
<item name="android:layout_marginTop">2dp</item>
<item name="android:layout_marginBottom">2dp</item>
<item name="android:background">@drawable/grant_permissions_buttons_top</item>
</style>
<style name="PermissionGrantButtonBottom"
parent="@android:style/Widget.DeviceDefault.Button.Borderless.Colored">
<item name="android:layout_width">332dp</item>
<item name="android:layout_height">56dp</item>
<item name="android:layout_marginTop">2dp</item>
<item name="android:layout_marginBottom">2dp</item>
<item name="android:background">@drawable/grant_permissions_buttons_bottom</item>
</style>
</resources>

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.internal.app;
package com.android.systemui.logcat;
import android.annotation.StyleRes;
import android.app.Activity;
@@ -23,7 +23,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -43,7 +42,9 @@ import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.android.internal.R;
import com.android.internal.app.ILogAccessDialogCallback;
import com.android.systemui.R;
/**
* Dialog responsible for obtaining user consent per-use log access
@@ -93,10 +94,7 @@ public class LogAccessDialogActivity extends Activity implements
mAlertLearnMore = getResources().getString(R.string.log_access_confirmation_learn_more);
// create View
boolean isDarkTheme = (getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
int themeId = isDarkTheme ? android.R.style.Theme_DeviceDefault_Dialog_Alert :
android.R.style.Theme_DeviceDefault_Light_Dialog_Alert;
int themeId = R.style.LogAccessDialogTheme;
mAlertView = createView(themeId);
// create AlertDialog
@@ -177,8 +175,7 @@ public class LogAccessDialogActivity extends Activity implements
PackageManager.MATCH_DIRECT_BOOT_AUTO,
UserHandle.getUserId(uid)).loadLabel(pm);
String titleString = context.getString(
com.android.internal.R.string.log_access_confirmation_title, appLabel);
String titleString = context.getString(R.string.log_access_confirmation_title, appLabel);
return titleString;
}
@@ -235,15 +232,12 @@ public class LogAccessDialogActivity extends Activity implements
@Override
public void onClick(View view) {
try {
switch (view.getId()) {
case R.id.log_access_dialog_allow_button:
mCallback.approveAccessForClient(mUid, mPackageName);
finish();
break;
case R.id.log_access_dialog_deny_button:
declineLogAccess();
finish();
break;
if (view.getId() == R.id.log_access_dialog_allow_button) {
mCallback.approveAccessForClient(mUid, mPackageName);
finish();
} else if (view.getId() == R.id.log_access_dialog_allow_button) {
declineLogAccess();
finish();
}
} catch (RemoteException e) {
finish();

View File

@@ -0,0 +1,2 @@
# Bug component: 1218649
file:platform/frameworks/base:/services/core/java/com/android/server/logcat/OWNERS

View File

@@ -23,6 +23,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -41,7 +42,6 @@ import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ILogAccessDialogCallback;
import com.android.internal.app.LogAccessDialogActivity;
import com.android.internal.util.ArrayUtils;
import com.android.server.LocalServices;
import com.android.server.SystemService;
@@ -62,6 +62,10 @@ import java.util.function.Supplier;
public final class LogcatManagerService extends SystemService {
private static final String TAG = "LogcatManagerService";
private static final boolean DEBUG = false;
private static final String TARGET_PACKAGE_NAME = "com.android.systemui";
private static final String TARGET_ACTIVITY_NAME =
"com.android.systemui.logcat.LogAccessDialogActivity";
public static final String EXTRA_CALLBACK = "EXTRA_CALLBACK";
/** How long to wait for the user to approve/decline before declining automatically */
@VisibleForTesting
@@ -442,6 +446,7 @@ public final class LogcatManagerService extends SystemService {
mClock.get() + PENDING_CONFIRMATION_TIMEOUT_MILLIS);
final Intent mIntent = createIntent(client);
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mIntent.setComponent(new ComponentName(TARGET_PACKAGE_NAME, TARGET_ACTIVITY_NAME));
mContext.startActivityAsUser(mIntent, UserHandle.SYSTEM);
}
@@ -536,13 +541,13 @@ public final class LogcatManagerService extends SystemService {
* Create the Intent for LogAccessDialogActivity.
*/
public Intent createIntent(LogAccessClient client) {
final Intent intent = new Intent(mContext, LogAccessDialogActivity.class);
final Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, client.mPackageName);
intent.putExtra(Intent.EXTRA_UID, client.mUid);
intent.putExtra(LogAccessDialogActivity.EXTRA_CALLBACK, mDialogCallback.asBinder());
intent.putExtra(EXTRA_CALLBACK, mDialogCallback.asBinder());
return intent;
}