Merge "Final cleanups to permission slices" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-05-25 22:10:20 +00:00
committed by Android (Google) Code Review
6 changed files with 77 additions and 1 deletions

View File

@@ -15,6 +15,8 @@
*/
package android.app.slice;
import static android.app.slice.Slice.SUBTYPE_COLOR;
import android.annotation.NonNull;
import android.app.PendingIntent;
import android.content.ComponentName;
@@ -29,6 +31,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ProviderInfo;
import android.database.ContentObserver;
import android.database.Cursor;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -39,6 +42,8 @@ import android.os.StrictMode;
import android.os.StrictMode.ThreadPolicy;
import android.util.ArraySet;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import java.util.ArrayList;
import java.util.Arrays;
@@ -472,12 +477,25 @@ public abstract class SliceProvider extends ContentProvider {
}
Slice.Builder parent = new Slice.Builder(sliceUri);
Slice.Builder childAction = new Slice.Builder(parent)
.addIcon(Icon.createWithResource(context,
com.android.internal.R.drawable.ic_permission), null,
Collections.emptyList())
.addHints(Arrays.asList(Slice.HINT_TITLE, Slice.HINT_SHORTCUT))
.addAction(action, new Slice.Builder(parent).build(), null);
TypedValue tv = new TypedValue();
new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault_Light)
.getTheme().resolveAttribute(android.R.attr.colorAccent, tv, true);
int deviceDefaultAccent = tv.data;
parent.addSubSlice(new Slice.Builder(sliceUri.buildUpon().appendPath("permission").build())
.addIcon(Icon.createWithResource(context,
com.android.internal.R.drawable.ic_arrow_forward), null,
Collections.emptyList())
.addText(getPermissionString(context, callingPackage), null,
Collections.emptyList())
.addInt(deviceDefaultAccent, SUBTYPE_COLOR,
Collections.emptyList())
.addSubSlice(childAction.build(), null)
.build(), null);
return parent.addHints(Arrays.asList(Slice.HINT_PERMISSION_REQUEST)).build();

View File

@@ -0,0 +1,24 @@
<!--
Copyright (C) 2018 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">
<path
android:fillColor="#FF000000"
android:pathData="M12.0,4.0l-1.41,1.41L16.17,11.0L4.0,11.0l0.0,2.0l12.17,0.0l-5.58,5.59L12.0,20.0l8.0,-8.0z"/>
</vector>

View File

@@ -0,0 +1,26 @@
<!--
Copyright (C) 2018 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="16.0"
android:viewportHeight="16.0">
<path
android:fillColor="#FF000000"
android:pathData="
M9.0,12l-2.0,0.0l0.0,-2.0l2.0,0.0l0.0,2.0z
m0.0,-4.0l-2.0,0.0l0.0,-4.0l2.0,0.0l0.0,4.0z"/>
</vector>

View File

@@ -3383,4 +3383,6 @@
<java-symbol type="string" name="battery_saver_description_with_learn_more" />
<java-symbol type="drawable" name="ic_lock_lockdown" />
<java-symbol type="drawable" name="ic_arrow_forward" />
<java-symbol type="drawable" name="ic_permission" />
</resources>

View File

@@ -211,6 +211,8 @@
<!-- Permission necessary to change car audio volume through CarAudioManager -->
<uses-permission android:name="android.car.permission.CAR_CONTROL_AUDIO_VOLUME" />
<uses-permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS" />
<application
android:name=".SystemUIApplication"
android:persistent="true"

View File

@@ -14,6 +14,8 @@
package com.android.systemui;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.slice.SliceManager;
@@ -61,7 +63,9 @@ public class SlicePermissionActivity extends Activity implements OnClickListener
.setNegativeButton(R.string.slice_permission_deny, this)
.setPositiveButton(R.string.slice_permission_allow, this)
.setOnDismissListener(this)
.show();
.create();
dialog.getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
dialog.show();
TextView t1 = dialog.getWindow().getDecorView().findViewById(R.id.text1);
t1.setText(getString(R.string.slice_permission_text_1, app2));
TextView t2 = dialog.getWindow().getDecorView().findViewById(R.id.text2);