Java Code Examples for android.content.Intent#ACTION_APPLICATION_RESTRICTIONS_CHANGED

The following examples show how to use android.content.Intent#ACTION_APPLICATION_RESTRICTIONS_CHANGED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void setApplicationRestrictions(String packageName, Bundle restrictions,
        int userId) {
    checkSystemOrRoot("set application restrictions");
    if (restrictions != null) {
        restrictions.setDefusable(true);
    }
    synchronized (mAppRestrictionsLock) {
        if (restrictions == null || restrictions.isEmpty()) {
            cleanAppRestrictionsForPackageLAr(packageName, userId);
        } else {
            // Write the restrictions to XML
            writeApplicationRestrictionsLAr(packageName, restrictions, userId);
        }
    }

    // Notify package of changes via an intent - only sent to explicitly registered receivers.
    Intent changeIntent = new Intent(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
    changeIntent.setPackage(packageName);
    changeIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    mContext.sendBroadcastAsUser(changeIntent, UserHandle.of(userId));
}
 
Example 2
Source File: MainActivity.java    From appauth-android-codelab with Apache License 2.0 5 votes vote down vote up
private void registerRestrictionsReceiver(){
  IntentFilter restrictionsFilter =
          new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);

  mRestrictionsReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
      getAppRestrictions();
    }
  };

  registerReceiver(mRestrictionsReceiver, restrictionsFilter);
}
 
Example 3
Source File: SupervisedUserContentProvider.java    From delion with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void createEnabledBroadcastReceiver() {
    IntentFilter restrictionsFilter = new IntentFilter(
            Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
    BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            updateEnabledState();
        }
    };
    getContext().registerReceiver(restrictionsReceiver, restrictionsFilter);
}
 
Example 4
Source File: SupervisedUserContentProvider.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void createEnabledBroadcastReceiver() {
    IntentFilter restrictionsFilter = new IntentFilter(
            Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
    BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            updateEnabledState();
        }
    };
    getContext().registerReceiver(restrictionsReceiver, restrictionsFilter);
}
 
Example 5
Source File: AppRestrictionsProvider.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected String getRestrictionChangeIntentAction() {
    // Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED was introduced in LOLLIPOP.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return null;
    return Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED;
}
 
Example 6
Source File: SupervisedUserContentProvider.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void createEnabledBroadcastReceiver() {
    IntentFilter restrictionsFilter = new IntentFilter(
            Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
    BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            updateEnabledState();
        }
    };
    getContext().registerReceiver(restrictionsReceiver, restrictionsFilter);
}