Search in sources :

Example 11 with AppStateInstallAppsBridge

use of com.android.settings.applications.AppStateInstallAppsBridge in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ExternalSourcesDetails method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Context context = getActivity();
    mAppBridge = new AppStateInstallAppsBridge(context, mState, null);
    mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
    mActivityManager = context.getSystemService(ActivityManager.class);
    mUserManager = UserManager.get(context);
    addPreferencesFromResource(R.xml.external_sources_details);
    mSwitchPref = (RestrictedSwitchPreference) findPreference(KEY_EXTERNAL_SOURCE_SWITCH);
    mSwitchPref.setOnPreferenceChangeListener(this);
}
Also used : Context(android.content.Context) AppStateInstallAppsBridge(com.android.settings.applications.AppStateInstallAppsBridge) ActivityManager(android.app.ActivityManager)

Example 12 with AppStateInstallAppsBridge

use of com.android.settings.applications.AppStateInstallAppsBridge in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ExternalSourcesDetails method getPreferenceSummary.

public static CharSequence getPreferenceSummary(Context context, AppEntry entry) {
    final UserHandle userHandle = UserHandle.getUserHandleForUid(entry.info.uid);
    final UserManager um = UserManager.get(context);
    final int userRestrictionSource = um.getUserRestrictionSource(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, userHandle) | um.getUserRestrictionSource(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY, userHandle);
    if ((userRestrictionSource & UserManager.RESTRICTION_SOURCE_SYSTEM) != 0) {
        return context.getString(R.string.disabled_by_admin);
    } else if (userRestrictionSource != 0) {
        return context.getString(R.string.disabled);
    }
    final InstallAppsState appsState = new AppStateInstallAppsBridge(context, null, null).createInstallAppsStateFor(entry.info.packageName, entry.info.uid);
    return context.getString(appsState.canInstallApps() ? R.string.app_permission_summary_allowed : R.string.app_permission_summary_not_allowed);
}
Also used : AppStateInstallAppsBridge(com.android.settings.applications.AppStateInstallAppsBridge) UserManager(android.os.UserManager) UserHandle(android.os.UserHandle) InstallAppsState(com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState)

Example 13 with AppStateInstallAppsBridge

use of com.android.settings.applications.AppStateInstallAppsBridge in project android_packages_apps_Settings by omnirom.

the class ExternalSourcesDetails method getPreferenceSummary.

public static CharSequence getPreferenceSummary(Context context, AppEntry entry) {
    final UserHandle userHandle = UserHandle.getUserHandleForUid(entry.info.uid);
    final UserManager um = UserManager.get(context);
    final int userRestrictionSource = um.getUserRestrictionSource(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, userHandle) | um.getUserRestrictionSource(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY, userHandle);
    if ((userRestrictionSource & UserManager.RESTRICTION_SOURCE_SYSTEM) != 0) {
        return context.getString(R.string.disabled_by_admin);
    } else if (userRestrictionSource != 0) {
        return context.getString(R.string.disabled);
    }
    final InstallAppsState appsState = new AppStateInstallAppsBridge(context, null, null).createInstallAppsStateFor(entry.info.packageName, entry.info.uid);
    return context.getString(appsState.canInstallApps() ? R.string.app_permission_summary_allowed : R.string.app_permission_summary_not_allowed);
}
Also used : AppStateInstallAppsBridge(com.android.settings.applications.AppStateInstallAppsBridge) UserManager(android.os.UserManager) UserHandle(android.os.UserHandle) InstallAppsState(com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState)

Example 14 with AppStateInstallAppsBridge

use of com.android.settings.applications.AppStateInstallAppsBridge in project android_packages_apps_Settings by omnirom.

the class ExternalSourcesDetails method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Context context = getActivity();
    mAppBridge = new AppStateInstallAppsBridge(context, mState, null);
    mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
    mUserManager = UserManager.get(context);
    addPreferencesFromResource(R.xml.external_sources_details);
    mSwitchPref = (RestrictedSwitchPreference) findPreference(KEY_EXTERNAL_SOURCE_SWITCH);
    mSwitchPref.setOnPreferenceChangeListener(this);
}
Also used : Context(android.content.Context) AppStateInstallAppsBridge(com.android.settings.applications.AppStateInstallAppsBridge)

Aggregations

AppStateInstallAppsBridge (com.android.settings.applications.AppStateInstallAppsBridge)14 InstallAppsState (com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState)10 ApplicationInfo (android.content.pm.ApplicationInfo)8 UserManager (android.os.UserManager)8 Test (org.junit.Test)8 ContextWrapper (android.content.ContextWrapper)6 ShadowUserManager (com.android.settings.testutils.shadow.ShadowUserManager)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Context (android.content.Context)2 PackageInfo (android.content.pm.PackageInfo)2 UserHandle (android.os.UserHandle)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 ActivityManager (android.app.ActivityManager)1