Skip to main content

Use system PIN dialog in Android application


Background



I am trying to write an application which works like described below.



  • When user start application it check if user have registered PIN on his device.

  • If user have registered PIN, application must show button "Continue with PIN".

  • When user press on button "Continue with PIN" system standard PIN dialog must appears. enter image description here

  • User enter his PIN and press "Continue" button.

  • After System must check if entered PIN is correct or no and continue working.





Researches



I have made some researches and find some articles on stackoverflow and other internet sources which say " There is no way to develop a new custom unlock mechanism on a non-rooted phone. " or " I would be surprised if you could, because then you would be probably able to steal the pin code, and I don't think anyone would want that. ".



Also I have watched some video tutorials like Tutorial: Android Internals - Building a Custom ROM, Pt. 1 of 2 and Tutorial: Android Internals - Building a Custom ROM, Pt. 2 of 2 .



EDITED



I have made some researches today and found very interesting thing, I think I am on a right way to the solution, and I want to share my ideas with you. So looking in android sources I found an interesting files ChooseLockPassword.java ( packages\apps\Settings\src\com\android\settings ) and LockPatternUtils.java (*frameworks\base\core\java\com\android\internal\widget*) now I am interest in:



Question



How can I call LockPatternUtils class function from my code ? Or Why I cant see that function in Eclipse ?





Decision



So I think that the only way to get access to the Android system PIN dialog is to root the phone make some changes in the system files and use system PIN dialod





Question



  1. Can somebody provide me useful links about getting access to the system PIN dialog in the rooted phone.

  2. Am I on a right way and can I solve my problem in this way ?

  3. If anybody encountered such problem please help me to solve.



Any Solutions ?


Source: Tips4allCCNA FINAL EXAM

Comments

  1. Okay, I have solved this problem and now I want to share my solution with you.

    At first as I told I have android sources so I have made some changes in android sources to get access to the PIN and Pattern dialogs. And here they are:

    in ~\AndroidSources\pakages\apps\Settings\AndroidManifest.xml I have changed following lines of code

    <activity android:name="ConfirmLockPattern"
    android:exported="true"> // This line was added by me.
    </activity>

    <activity android:name="ConfirmLockPassword"
    android:exported="true" // This line was added by me.
    android:them="@android:style/Them.NoTitleBar">
    </activity>

    <activity android:name="ChooseLockPattern"
    android:exported="true" // This line was added by me.
    android:label="@string/lockpattern_change_lock_pattern_label">
    </activity>


    This modifications allow me to call "ConfirmLockPattern", "ConfirmLockPassword" and "ChooseLockPattern" activities from my own application. After I compile android Source codes and launch system.img on my emulator.

    In my application I have write following functions in order to call "ConfirmLockPattern" or "ChooseLockPattern" activities:

    /**
    * Show PIN/Password confirmation dialog.
    */
    void ShowConfirmLockPINActivity() {
    CustomLog.i(TAG, "Show Confirm Lock PIN Activity");
    Intent intent = new Intent(Intent.ACTION_RUN);
    intent.setComponent(new ComponentName("com.android.settings",
    "com.android.settings.ConfirmLockPassword"));
    startActivityForResult(intent, mRequestCode);
    } /* ShowConfirmLockPINActivity() */

    /**
    * Show set PIN/Password dialog.
    */
    void ShowSetLockPINActivity() {
    CustomLog.i(TAG, "Show Set Lock PIN Activity");
    Intent intent = new Intent(Intent.ACTION_RUN);
    intent.setComponent(new ComponentName("com.android.settings",
    "com.android.settings.ChooseLockPassword"));
    startActivityForResult(intent, mRequestCode);
    } /* ShowSetLockPINActivity() */

    /**
    * Show Pattern Confirmation dialog.
    */
    void ShowSetLockPatternActivity() {
    CustomLog.i(TAG, "Show Set Lock Pattern Activity");
    Intent intent = new Intent(Intent.ACTION_RUN);
    intent.setComponent(new ComponentName("com.android.settings",
    "com.android.settings.ConfirmLockPattern"));
    startActivityForResult(intent, mRequestCode);
    } /* ShowSetLockPatternActivity() */

    ReplyDelete
  2. Here are some considerations regarding your question.


    Diving deep into Android's code is not very good idea in this particular case, since verifying PIN code is an important security point and its mechanism must be hidden and well protected to avoid any malicious intentions.
    Thus, the actions you want to perform (ask for PIN and then check it against real PIN) are prohibited and would look like an intrusion. So, you shouldn't try to get an access to the storage of user passwords.
    It would be more correct to try launching standard PIN screen via some Intent and ask it to make all job for you. However, a brief investigation didn't give me any results in this direction; perhaps, you'll find something.
    Modifying the ROM is obviously dead-end - no one will flash the phone to install one app. Requiring rooted phone is a bit better, there are apps that cannot run on non-rooted phone, but still it forwards us back to the point #2 (intrusion).
    Users may disable PIN check and there are devices with no SIM.


    So, according to the all mentioned I'd suggest you think of different verification method for your app.

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex