Loading src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java +64 −56 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ import android.text.method.ScrollingMovementMethod; import android.util.EventLog; import android.util.Log; import android.view.Display; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; Loading Loading @@ -401,8 +403,8 @@ public class DeviceAdminAdd extends Activity { final View restrictedAction = findViewById(R.id.restricted_action); restrictedAction.setFilterTouchesWhenObscured(true); restrictedAction.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final View.OnClickListener restrictedActionClickListener = v -> { if (!mActionButton.isEnabled()) { showPolicyTransparencyDialogIfRequired(); return; Loading Loading @@ -445,14 +447,20 @@ public class DeviceAdminAdd extends Activity { } }, mHandler)); // Don't want to wait too long. getWindow().getDecorView().getHandler().postDelayed(new Runnable() { @Override public void run() { continueRemoveAction(null); } }, 2*1000); } getWindow().getDecorView().getHandler().postDelayed( () -> continueRemoveAction(null), 2 * 1000); } }; restrictedAction.setOnKeyListener((view, keyCode, keyEvent) -> { if ((keyEvent.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) == 0) { Log.e(TAG, "Can not activate device-admin with KeyEvent from non-system app."); // Consume event to suppress click. return true; } // Fallback to view click handler. return false; }); restrictedAction.setOnClickListener(restrictedActionClickListener); } /** Loading src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessDetails.java +3 −0 Original line number Diff line number Diff line Loading @@ -181,7 +181,10 @@ public class NotificationAccessDetails extends AppInfoBase { public void updatePreference(SwitchPreference preference) { final CharSequence label = mPackageInfo.applicationInfo.loadLabel(mPm); final boolean isAllowedCn = mComponentName.flattenToShortString().length() <= NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH; preference.setChecked(isServiceEnabled(mComponentName)); preference.setEnabled(preference.isChecked() || isAllowedCn); preference.setOnPreferenceChangeListener((p, newValue) -> { final boolean access = (Boolean) newValue; if (!access) { Loading src/com/android/settings/notification/NotificationAccessConfirmationActivity.java +3 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,9 @@ public class NotificationAccessConfirmationActivity extends Activity mUserId = getIntent().getIntExtra(EXTRA_USER_ID, UserHandle.USER_NULL); CharSequence mAppLabel; if (mComponentName == null || mComponentName.getPackageName() == null) { if (mComponentName == null || mComponentName.getPackageName() == null || mComponentName.flattenToString().length() > NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH) { finish(); return; } Loading src/com/android/settings/notification/NotificationAccessSettings.java +7 −9 Original line number Diff line number Diff line Loading @@ -58,8 +58,6 @@ import java.util.List; public class NotificationAccessSettings extends EmptyTextSettings { private static final String TAG = "NotifAccessSettings"; private static final int MAX_CN_LENGTH = 500; private static final ManagedServiceSettings.Config CONFIG = new ManagedServiceSettings.Config.Builder() .setTag(TAG) Loading Loading @@ -94,12 +92,6 @@ public class NotificationAccessSettings extends EmptyTextSettings { .setNoun(CONFIG.noun) .setSetting(CONFIG.setting) .setTag(CONFIG.tag) .setValidator(info -> { if (info.getComponentName().flattenToString().length() > MAX_CN_LENGTH) { return false; } return true; }) .build(); mServiceListing.addCallback(this::updateList); setPreferenceScreen(getPreferenceManager().createPreferenceScreen(mContext)); Loading Loading @@ -140,6 +132,12 @@ public class NotificationAccessSettings extends EmptyTextSettings { services.sort(new PackageItemInfo.DisplayNameComparator(mPm)); for (ServiceInfo service : services) { final ComponentName cn = new ComponentName(service.packageName, service.name); boolean isAllowed = mNm.isNotificationListenerAccessGranted(cn); if (!isAllowed && cn.flattenToString().length() > NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH) { continue; } CharSequence title = null; try { title = mPm.getApplicationInfoAsUser( Loading @@ -154,7 +152,7 @@ public class NotificationAccessSettings extends EmptyTextSettings { pref.setIcon(mIconDrawableFactory.getBadgedIcon(service, service.applicationInfo, UserHandle.getUserId(service.applicationInfo.uid))); pref.setKey(cn.flattenToString()); pref.setSummary(mNm.isNotificationListenerAccessGranted(cn) pref.setSummary(isAllowed ? R.string.app_permission_summary_allowed : R.string.app_permission_summary_not_allowed); if (managedProfileId != UserHandle.USER_NULL Loading Loading
src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java +64 −56 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ import android.text.method.ScrollingMovementMethod; import android.util.EventLog; import android.util.Log; import android.view.Display; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; Loading Loading @@ -401,8 +403,8 @@ public class DeviceAdminAdd extends Activity { final View restrictedAction = findViewById(R.id.restricted_action); restrictedAction.setFilterTouchesWhenObscured(true); restrictedAction.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final View.OnClickListener restrictedActionClickListener = v -> { if (!mActionButton.isEnabled()) { showPolicyTransparencyDialogIfRequired(); return; Loading Loading @@ -445,14 +447,20 @@ public class DeviceAdminAdd extends Activity { } }, mHandler)); // Don't want to wait too long. getWindow().getDecorView().getHandler().postDelayed(new Runnable() { @Override public void run() { continueRemoveAction(null); } }, 2*1000); } getWindow().getDecorView().getHandler().postDelayed( () -> continueRemoveAction(null), 2 * 1000); } }; restrictedAction.setOnKeyListener((view, keyCode, keyEvent) -> { if ((keyEvent.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) == 0) { Log.e(TAG, "Can not activate device-admin with KeyEvent from non-system app."); // Consume event to suppress click. return true; } // Fallback to view click handler. return false; }); restrictedAction.setOnClickListener(restrictedActionClickListener); } /** Loading
src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessDetails.java +3 −0 Original line number Diff line number Diff line Loading @@ -181,7 +181,10 @@ public class NotificationAccessDetails extends AppInfoBase { public void updatePreference(SwitchPreference preference) { final CharSequence label = mPackageInfo.applicationInfo.loadLabel(mPm); final boolean isAllowedCn = mComponentName.flattenToShortString().length() <= NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH; preference.setChecked(isServiceEnabled(mComponentName)); preference.setEnabled(preference.isChecked() || isAllowedCn); preference.setOnPreferenceChangeListener((p, newValue) -> { final boolean access = (Boolean) newValue; if (!access) { Loading
src/com/android/settings/notification/NotificationAccessConfirmationActivity.java +3 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,9 @@ public class NotificationAccessConfirmationActivity extends Activity mUserId = getIntent().getIntExtra(EXTRA_USER_ID, UserHandle.USER_NULL); CharSequence mAppLabel; if (mComponentName == null || mComponentName.getPackageName() == null) { if (mComponentName == null || mComponentName.getPackageName() == null || mComponentName.flattenToString().length() > NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH) { finish(); return; } Loading
src/com/android/settings/notification/NotificationAccessSettings.java +7 −9 Original line number Diff line number Diff line Loading @@ -58,8 +58,6 @@ import java.util.List; public class NotificationAccessSettings extends EmptyTextSettings { private static final String TAG = "NotifAccessSettings"; private static final int MAX_CN_LENGTH = 500; private static final ManagedServiceSettings.Config CONFIG = new ManagedServiceSettings.Config.Builder() .setTag(TAG) Loading Loading @@ -94,12 +92,6 @@ public class NotificationAccessSettings extends EmptyTextSettings { .setNoun(CONFIG.noun) .setSetting(CONFIG.setting) .setTag(CONFIG.tag) .setValidator(info -> { if (info.getComponentName().flattenToString().length() > MAX_CN_LENGTH) { return false; } return true; }) .build(); mServiceListing.addCallback(this::updateList); setPreferenceScreen(getPreferenceManager().createPreferenceScreen(mContext)); Loading Loading @@ -140,6 +132,12 @@ public class NotificationAccessSettings extends EmptyTextSettings { services.sort(new PackageItemInfo.DisplayNameComparator(mPm)); for (ServiceInfo service : services) { final ComponentName cn = new ComponentName(service.packageName, service.name); boolean isAllowed = mNm.isNotificationListenerAccessGranted(cn); if (!isAllowed && cn.flattenToString().length() > NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH) { continue; } CharSequence title = null; try { title = mPm.getApplicationInfoAsUser( Loading @@ -154,7 +152,7 @@ public class NotificationAccessSettings extends EmptyTextSettings { pref.setIcon(mIconDrawableFactory.getBadgedIcon(service, service.applicationInfo, UserHandle.getUserId(service.applicationInfo.uid))); pref.setKey(cn.flattenToString()); pref.setSummary(mNm.isNotificationListenerAccessGranted(cn) pref.setSummary(isAllowed ? R.string.app_permission_summary_allowed : R.string.app_permission_summary_not_allowed); if (managedProfileId != UserHandle.USER_NULL Loading