Merge "[DO NO MERGE] Enforce INTERACT_ACROSS_USERS_FULL permission for NotificationAccessDetails" into rvc-dev am: 450cacbee4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/21296639 Change-Id: I388da4ab1fed92f8afa92469e628f1324921df45 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
e116e63a91
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.settings.applications.specialaccess.notificationaccess;
|
||||
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
@@ -30,6 +33,7 @@ import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.text.TextUtils;
|
||||
import android.util.IconDrawableFactory;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
@@ -42,6 +46,7 @@ import androidx.preference.SwitchPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppInfoBase;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.password.PasswordUtils;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
|
||||
@@ -139,6 +144,41 @@ public class NotificationAccessDetails extends AppInfoBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String retrieveAppEntry() {
|
||||
final Bundle args = getArguments();
|
||||
final Intent intent = (args == null) ?
|
||||
getIntent() : (Intent) args.getParcelable("intent");
|
||||
|
||||
if (intent != null && intent.hasExtra(Intent.EXTRA_USER_HANDLE)) {
|
||||
if (!hasInteractAcrossUsersPermission()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
return super.retrieveAppEntry();
|
||||
}
|
||||
|
||||
private boolean hasInteractAcrossUsersPermission() {
|
||||
final String callingPackageName = PasswordUtils.getCallingAppPackageName(
|
||||
getActivity().getActivityToken());
|
||||
|
||||
if (TextUtils.isEmpty(callingPackageName)) {
|
||||
Log.w(TAG, "Not able to get calling package name for permission check");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getContext().getPackageManager().checkPermission(
|
||||
Manifest.permission.INTERACT_ACROSS_USERS_FULL, callingPackageName)
|
||||
!= PERMISSION_GRANTED) {
|
||||
Log.w(TAG, "Package " + callingPackageName + " does not have required permission "
|
||||
+ Manifest.permission.INTERACT_ACROSS_USERS_FULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updatePreference(SwitchPreference preference) {
|
||||
final CharSequence label = mPackageInfo.applicationInfo.loadLabel(mPm);
|
||||
preference.setChecked(isServiceEnabled(mComponentName));
|
||||
|
Reference in New Issue
Block a user