OSDN Git Service

Merge tag 'android-8.1.0_r74' into oreo-x86
[android-x86/packages-apps-Settings.git] / src / com / android / settings / SettingsActivity.java
index 609120d..777df85 100644 (file)
@@ -254,6 +254,12 @@ public class SettingsActivity extends SettingsDrawerActivity
     @Override
     protected void onCreate(Bundle savedState) {
         super.onCreate(savedState);
+
+        if (isLockTaskModePinned() && !isSettingsRunOnTop()) {
+            Log.w(LOG_TAG, "Devices lock task mode pinned.");
+            finish();
+        }
+
         long startTime = System.currentTimeMillis();
 
         final FeatureFactory factory = FeatureFactory.getFactory(this);
@@ -322,7 +328,7 @@ public class SettingsActivity extends SettingsDrawerActivity
         }
 
         if (mIsShowingDashboard) {
-            findViewById(R.id.search_bar).setVisibility(View.VISIBLE);
+            setSearchBarVisibility();
             findViewById(R.id.action_bar).setVisibility(View.GONE);
             Toolbar toolbar = findViewById(R.id.search_action_bar);
             toolbar.setOnClickListener(this);
@@ -407,6 +413,12 @@ public class SettingsActivity extends SettingsDrawerActivity
     }
 
     @VisibleForTesting
+    void setSearchBarVisibility() {
+        findViewById(R.id.search_bar).setVisibility(
+                Utils.isDeviceProvisioned(this) ? View.VISIBLE : View.INVISIBLE);
+    }
+
+    @VisibleForTesting
     void launchSettingFragment(String initialFragmentName, boolean isSubSettings, Intent intent) {
         if (!mIsShowingDashboard && initialFragmentName != null) {
             // UP will be shown only if it is a sub settings
@@ -827,6 +839,11 @@ public class SettingsActivity extends SettingsDrawerActivity
                 pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin)
                 || somethingChanged;
 
+        somethingChanged = setTileEnabled(new ComponentName(packageName,
+                         Settings.SuperuserActivity.class.getName()),
+                DevelopmentSettings.isRootForAppsEnabled(), isAdmin)
+                || somethingChanged;
+
         final boolean showDev = mDevelopmentPreferences.getBoolean(
                 DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng"))
                 && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES);
@@ -951,4 +968,18 @@ public class SettingsActivity extends SettingsDrawerActivity
         Intent intent = new Intent(this, SearchActivity.class);
         startActivity(intent);
     }
+
+    private boolean isLockTaskModePinned() {
+        final ActivityManager activityManager =
+            getApplicationContext().getSystemService(ActivityManager.class);
+        return activityManager.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED;
+    }
+
+    private boolean isSettingsRunOnTop() {
+        final ActivityManager activityManager =
+            getApplicationContext().getSystemService(ActivityManager.class);
+        final String taskPkgName = activityManager.getRunningTasks(1 /* maxNum */)
+            .get(0 /* index */).baseActivity.getPackageName();
+        return TextUtils.equals(getPackageName(), taskPkgName);
+    }
 }