FallBackHome, directBootAware

The Android system records the information of all installed apps in the system

Package – restrictions. XML,

/data/system/users/0/package-restrictions.xml

  • /system/priv-app The privileged app directory is mainly the low-level app. The mk file sets the tag, such as setting, systemUI, and TelephonyProvider

  • /system/app App directory of the system, which is mainly three-party customized apps, such as Launcher, Email, and Calendar

  • /data/app For common applications,reboot device PM automatically scans and installs apps in this directory. Normal user installation also stores APK files in this directory

Under the framework of the PM Settings. Java writePackageRestrictionsLPr () will operate on it

frameworks/base/services/core/java/com/android/server/pm/Settings.java


DirectBoot mode features under Android7.0

DirectBoot mode Indicates that the device is unlocked after power-on

The storage space

1.Credential Encrypted Storage, the default place to store data, is only available after users unlock their phones.

2.Device Encrypted Storage mainly corresponds to the storage space used by Direct Boot. Storage space that is available both in Direct Boot mode and after the user unlocks the phone

Application to run

The app cannot run in Direct Boot mode

To run it you need to set Android :directBootAware=”true” in AndroidManinfest. XML

The system stores some system data and the data of Apps that have registered relevant permissions in the Device-Encrypted Store. Other data is stored in the Credential-Encrypted Store by default.

When the phone is powered on, it will first enter an Dierect Boot mode, in which only the data under the device-Encrypted store can be accessed, but not the data under the Credential-Encrypted Store. When the user is unlocked, they are all accessible.

Generally, applications cannot run in Direct Boot mode

To enable an app to run in Direct Boot mode, you need to register relevant app components. Apps that normally need to run in this mode:

  1. Schedule notification applications, such as Clock
  2. Important user notification applications, such as SMS
  3. Apps that provide accessibility services, such as Talkback
FallBackHome

Android 7.0 starts FallBackHome before launching the launcher. FallBackHome is an Activity in the Setting with the Home attribute configured. Settings android:directBootAware is true. Only FallbackHome can be started in direct boot mode.

<application android:label="@string/settings_label" android:icon="@mipmap/ic_launcher_settings" ............ android:directBootAware="true"> <! -- Triggered when user-selected home app isn't encryption aware --> <activity android:name=".FallbackHome" android:excludeFromRecents="true" android:theme="@style/FallbackHome"> <intent-filter android:priority="-1000"> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>Copy the code

In FallbackHome, listen to the ACTION_USER_UNLOCKED broadcast to check whether the account is unlocked. If it is unlocked, continue to search for the Home screen. If it is not found, send a delayed message and search again for 500ms. If it finds the Launcher, it will finish the FallbackHome.

public class FallbackHome extends Activity {
    private static final String TAG = "FallbackHome";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Set ourselves totally black before the device is provisioned so that
        // we don't flash the wallpaper before SUW
        if (Settings.Global.getInt(getContentResolver(),
                Settings.Global.DEVICE_PROVISIONED, 0) == 0) {
            setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        }

        registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
        maybeFinish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mReceiver);
    }

    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            maybeFinish();
        }
    };

    private void maybeFinish() {
        if (getSystemService(UserManager.class).isUserUnlocked()) {
            final Intent homeIntent = new Intent(Intent.ACTION_MAIN)
                    .addCategory(Intent.CATEGORY_HOME);
            final ResolveInfo homeInfo = getPackageManager().resolveActivity(homeIntent, 0);
            if (Objects.equals(getPackageName(), homeInfo.activityInfo.packageName)) {
                Log.d(TAG, "User unlocked but no home; let's hope someone enables one soon?");
                mHandler.sendEmptyMessageDelayed(0, 500);
            } else {
                Log.d(TAG, "User unlocked and real home found; let's go!");
                finish();
            }
        }
    }

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            maybeFinish();
        }
    };
}
Copy the code

Using the PM command:

PM enable [-user USER_ID] PACKAGE_OR_COMPONENT Restores to the active state

PM disable [-user USER_ID] PACKAGE_OR_COMPONENT Changed to disable

PM list packages -d View the list of disabled package names

Lookup package information (printed is manifest file information)

Dumpsys package package name


The following two values indicate whether the boot wizard is complete.

Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
Copy the code

Force skip the boot wizard

adb shell pm disable pkgName
adb shell settings put global device_provisioned 1
adb shell settings put secure user_setup_complete 1
Copy the code