How does Provision application launched ?

1,004 views
Skip to first unread message

Olexandr Tereshchuk

unread,
Feb 29, 2016, 8:38:24 PM2/29/16
to android-platform
Provision application has single activity which sets DEVICE_PROVISIONED and USER_SETUP_COMPLETE flags and disables itself.

The problem is that I can't find any references in framework code - who launches Provision application ?
The only theory I have is that application defines intent filter:

            <intent-filter android:priority="1">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

which acts as HOME activity with highest priority. After first launch it gets disabled and does not mess with regular Launcher app.

public class DefaultActivity extends Activity {

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

        DevicePolicyManager policyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
        policyManager.setDeviceOwner("com.keypr.czar", "Czar");

        // Add a persistent setting to allow other apps to know the device has been provisioned.
        Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);

        // remove this activity from the package manager.
        PackageManager pm = getPackageManager();
        ComponentName name = new ComponentName(this, DefaultActivity.class);
        pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);

        // terminate the activity.
        finish();
    }
}

Dave Smith

unread,
Feb 29, 2016, 10:11:13 PM2/29/16
to android-...@googlegroups.com, Olexandr Tereshchuk
The problem is that I can't find any references in framework code - who launches Provision application ?
The only theory I have is that application defines intent filter:

            <intent-filter android:priority="1">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

which acts as HOME activity with highest priority. After first launch it gets disabled and does not mess with regular Launcher app.

Your theory is correct. The setup wizard application take control of the HOME Intent until it’s provisioning process is complete (that way it will still launch if the device reboots before completing setup), then disables it’s manifest components. At that point, the primary Launcher is the only application left to accept the HOME intent.

Cheers,
-- 
Dave Smith, PE
@devunwired
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages